{"version":3,"file":"property_controller-GyhoFfg2.js","sources":["../../../app/javascript/controllers/automation/property_controller.js"],"sourcesContent":["import MessageController from \"../step/message_controller\"\n\nimport { commaSeperatedListWithAndConjunction } from '../models/sentence'\n\nexport default class extends MessageController {\n static values = {\n name: String,\n value: String,\n id: String,\n kind: String,\n stepName: String,\n }\n\n static targets = [\n \"title\",\n \"description\",\n \"submit\",\n \"openModal\",\n \"propertyInput\",\n \"valuesInput\",\n ]\n\n initialize() {\n this.name = this.nameValue\n this.value = this.valueValue\n this.display = this.descriptionTarget.innerText\n\n this.paneSnapshot = this.paneTarget.cloneNode(true)\n super.initialize()\n }\n\n connect() {\n if((this.withinAnswer || this.afterMessage) && this.persistedValue && !['date', 'birthday'].includes(this.kindValue)) {\n this.dispatch('reply:show', {\n target: this.paneTarget,\n })\n }\n\n super.connect()\n }\n\n togglePane() {\n if (window.paneId) {\n return window.dispatchEvent(\n new CustomEvent(\"pane:alert\", {detail: this.element.id})\n )\n }\n\n this.paneTarget.classList.toggle(\"-right-full\")\n this.paneTarget.classList.toggle(\"right-0\")\n\n this.triggerTarget.classList.toggle(\"halo--active\")\n\n if(this.paneIsInvisible) return\n\n this.dispatch('focus', {\n target: this.paneTarget,\n })\n\n if(!this.persistedValue) {\n this.delayed(() => {\n this.dispatch('show', {\n target: this.paneTarget.querySelector('[data-automation--property-value-target=\"propertiesPopover\"]'),\n })\n }, 300)\n }\n }\n\n saveValue({ detail }) {\n this.name = detail.name\n this.value = detail.value\n this.id = detail.id\n this.display = detail.display || detail.value\n\n if(!this.withinAnswer && !this.afterMessage) return\n\n if(detail.text || detail.number) {\n this.dispatch('reply:show', {\n target: this.paneTarget,\n })\n\n if(!detail.value) {\n this.dispatch('reply', {\n target: this.paneTarget,\n })\n\n this.value = '{reply}'\n }\n } else {\n this.dispatch('reply:hide', {\n target: this.paneTarget,\n })\n }\n }\n\n save({ detail }) {\n window.paneId = null\n\n this.paneTarget.classList.replace(\"right-0\", \"-right-full\")\n this.triggerTarget.classList.remove(\"halo--active\")\n\n this.paneSnapshot = this.paneTarget.cloneNode(true)\n\n this.persistedValue = true\n\n this.nameValue = this.name\n this.valueValue = this.value\n this.idValue = this.id\n\n this.propertyInputTarget.value = this.idValue\n this.valuesInputTarget.value = this.valueValue\n\n this.stepNameValue = detail.name\n\n if(this.stepNameValue) {\n this.titleTarget.textContent = this.stepNameValue\n } else {\n this.titleTarget.textContent = t.automation.properties.property.title.set.replace('%{property}', this.name)\n this.descriptionTarget.textContent = commaSeperatedListWithAndConjunction(this.display.split(','))\n }\n }\n\n onClickOutside({ target }) {\n if(!this.persistedValue) {\n return this.remove()\n }\n\n this.paneTarget.classList.replace(\"right-0\", \"-right-full\")\n this.triggerTarget.classList.remove(\"halo--active\")\n }\n\n abortChanges() {\n if(!this.persistedValue) {\n return this.remove()\n }\n\n this.paneTarget.classList.replace(\"right-0\", \"-right-full\")\n this.triggerTarget.classList.remove(\"halo--active\")\n\n this.name = this.nameValue\n this.value = this.valueValue\n\n this.delayed(() => {\n this.paneTarget.replaceWith(this.paneSnapshot.cloneNode(true))\n\n this.paneTarget.querySelector('input.form-control').remove()\n }, 300)\n }\n\n remove() {\n this.dropzone.remove()\n\n if (this.hasRemovedInputTarget) {\n this.removedInputTarget.disabled = false\n\n document\n .getElementById(\"drawing_container\")\n .appendChild(this.removedInputTarget)\n }\n\n this.paneTarget.classList.replace(\"right-0\", \"-right-full\")\n this.triggerTarget.classList.remove(\"halo--active\")\n\n this.nextTick(() => {\n this.paneTarget.remove()\n this.element.remove()\n }, 300)\n }\n\n get paneIsInvisible() {\n return this.paneTarget.classList.contains(\"-right-full\")\n }\n\n get paneIsVisible() {\n return this.paneTarget.classList.contains(\"right-0\")\n }\n\n get afterMessage() {\n return document.getElementById(this.parentTarget.value)?.dataset?.kind === 'message'\n }\n\n get paneTarget() {\n return document.getElementById(`${this.element.id}_pane`)\n }\n}\n"],"names":["PropertyController","MessageController","detail","commaSeperatedListWithAndConjunction","target","_b","_a","__publicField"],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