{"version":3,"file":"modal_controller-BLneZfuE.js","sources":["../../../app/javascript/controllers/contact/modal_controller.js"],"sourcesContent":["import ApplicationController from '../application_controller'\n\nexport default class extends ApplicationController {\n static values = {\n subscriptionUrl: String,\n deleteUrl: String,\n }\n\n static targets = [\n 'unsubscription',\n 'delete',\n ]\n\n showSubscriptionModal({ detail: { id } }) {\n this.titleElement.innerText = this.translations.contact.subscriptions.modal.do_you_have_consent\n this.subtitleElement.innerText = ''\n\n this.form.action = this.subscriptionUrlValue.replace(':contact', id)\n const submitButton = this.form.querySelector('button[type=\"submit\"]')\n\n submitButton.setAttribute('value', 'subscribe')\n submitButton.innerText = this.translations.contact.subscriptions.button.subscribe\n\n this.dispatch('open', {\n target: this.unsubscriptionTarget\n })\n }\n\n showUnsubscriptionModal({ detail: { id, name } }) {\n this.titleElement.innerText = this.translations.contact.subscriptions.modal.are_you_sure.replace('%{contactable}', name)\n this.subtitleElement.innerText = this.translations.contact.subscriptions.modal.this_will_cause_the_contactable_to_unsubscribe_from_every_channel\n\n this.form.action = this.subscriptionUrlValue.replace(':contact', id)\n const submitButton = this.form.querySelector('button[type=\"submit\"]')\n\n submitButton.setAttribute('value', 'unsubscribe')\n submitButton.innerText = this.translations.contact.subscriptions.button.unsubscribe\n\n this.open(this.unsubscriptionTarget)\n }\n\n showDeleteModal({ detail: { id }}) {\n const form = this.deleteTarget.querySelector('[data-contact--modal-target=\"form\"]')\n form.action = this.deleteUrlValue.replace(':contact', id)\n\n this.open(this.deleteTarget)\n }\n\n // private\n\n open(modal) {\n this.dispatch('open', {\n target: modal\n })\n }\n\n get titleElement() {\n return this.unsubscriptionTarget.querySelector('[data-modal-target=\"title\"]')\n }\n\n get subtitleElement() {\n return this.unsubscriptionTarget.querySelector('[data-modal-target=\"subtitle\"]')\n }\n\n get form() {\n return this.unsubscriptionTarget.querySelector('[data-contact--modal-target=\"form\"]')\n }\n}\n"],"names":["modal_controller","ApplicationController","id","submitButton","name","form","modal","__publicField"],"mappings":"uNA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