{"version":3,"file":"property_controller-LCHaCFYl.js","sources":["../../../app/javascript/controllers/property_controller.js"],"sourcesContent":["import ApplicationController from './application_controller'\n\nimport { useLineNotifiers } from './mixins/useLineNotifiers'\n\nexport default class extends ApplicationController {\n static values = {\n persisted: { type: Boolean, default: false },\n focus: { type: Boolean, default: false },\n error: { type: Boolean, default: false },\n originalName: String,\n profileScoped: { type: Boolean, default: false },\n }\n\n static targets = [\n \"main\",\n \"inputContainer\",\n \"input\",\n \"form\",\n \"tooltip\",\n \"toggleUniquenessButton\",\n \"uniquenessLabel\",\n \"focus\",\n ]\n\n connect() {\n super.connect();\n\n if(this.hasInputTarget) {\n this.nameValue = this.inputTarget.value\n }\n\n this.parentElement = this.element.parentElement\n\n if(this.focusValue) {\n this.focus()\n }\n\n useLineNotifiers(this, {\n element: this.element.closest('li')\n })\n }\n\n disconnect() {\n if(document.getElementById('property--modal')) {\n this.dispatch('hide', {\n target: document.getElementById('property--modal')\n })\n }\n\n super.disconnect()\n }\n\n focus() {\n this.mainTarget.classList.add(\"hidden\")\n this.inputContainerTarget.classList.remove(\"hidden\")\n\n if(this.hasInputTarget) {\n super.focus(this.inputTarget, { moveCursorToEnd: true })\n }\n\n this.nextTick(() => this.moveLineToThisElement())\n }\n\n saveChanges(e) {\n if(\n this.inputContainerTarget.classList.contains(\"hidden\")\n || this.inputContainerTarget.contains(e.target)\n || this.mainTarget.contains(e.target)\n || this.inputContainerTarget.contains(e.target)\n || this.togglingUniqueness\n ) return\n\n if(this.hasInputTarget && this.nameValue !== this.inputTarget.value) {\n this.element.requestSubmit()\n }\n\n this.blur()\n this.element.closest('li').removeAttribute('data-line-active')\n }\n\n blur() {\n this.element.removeAttribute('data-line-active')\n\n this.mainTarget.classList.remove(\"hidden\")\n this.inputContainerTarget.classList.add(\"hidden\")\n\n if(this.errorValue) {\n this.inputTarget.value = this.originalNameValue\n this.inputContainerTarget.classList.remove(\"error\")\n this.errorValue = false\n\n setTimeout(() => {\n this.element.dataset.controller = this.element.dataset.controller.replace(\"tooltip\", \"\")\n this.element.dataset.action = this.element.dataset.action.replace(this.element.dataset.tooltipActions, \"\")\n this.tooltipTarget.classList.add(\"hidden\")\n }, 300)\n }\n }\n\n blurField() {\n if(this.hasInputTarget) {\n this.inputContainerTarget.blur()\n }\n }\n\n requestDeletion() {\n this.dispatch('show', {\n target: document.getElementById('property--modal'),\n detail: {\n url: this.element.action,\n element: this.element,\n profileScoped: this.profileScopedValue,\n },\n })\n\n setTimeout(() => {\n this.focus()\n\n if(this.hasInputTarget) {\n this.inputTarget.blur()\n }\n })\n }\n\n onModalClosed() {\n setTimeout(() => {\n this.mainTarget.click()\n })\n }\n\n save() {\n this.element.requestSubmit()\n }\n\n restore() {\n if(this.hasInputTarget) {\n this.inputTarget.value = this.originalNameValue\n }\n\n this.blur()\n this.blurLine()\n }\n\n toggleUniqueness() {\n this.togglingUniqueness = true\n this.toggleUniquenessButtonTarget.click()\n }\n\n onSubmitEnd({ detail }) {\n if(detail.success && this.togglingUniqueness) {\n this.focus()\n\n this.togglingUniqueness = false\n this.uniquenessLabelTarget.classList.toggle('hidden')\n }\n }\n}\n"],"names":["PropertyController","ApplicationController","useLineNotifiers","e","detail","__publicField"],"mappings":"0QAIe,MAAKA,UAASC,CAAsB,CAoBjD,SAAU,CACR,MAAM,QAAS,EAEZ,KAAK,iBACN,KAAK,UAAY,KAAK,YAAY,OAGpC,KAAK,cAAgB,KAAK,QAAQ,cAE/B,KAAK,YACN,KAAK,MAAK,EAGZC,EAAiB,KAAM,CACrB,QAAS,KAAK,QAAQ,QAAQ,IAAI,CACnC,CAAA,CACL,CAEE,YAAa,CACR,SAAS,eAAe,iBAAiB,GAC1C,KAAK,SAAS,OAAQ,CACpB,OAAQ,SAAS,eAAe,iBAAiB,CAClD,CAAA,EAGH,MAAM,WAAU,CACpB,CAEE,OAAQ,CACN,KAAK,WAAW,UAAU,IAAI,QAAQ,EACtC,KAAK,qBAAqB,UAAU,OAAO,QAAQ,EAEhD,KAAK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