{"version":3,"file":"action_controller-CjOyJYcN.js","sources":["../../../app/javascript/controllers/search/action_controller.js"],"sourcesContent":["import { get } from '@rails/request.js'\n\nimport ApplicationController from '../application_controller'\n\nexport default class extends ApplicationController {\n static values = {\n url: String,\n groupUrl: String,\n id: String,\n name: String,\n }\n\n static targets = [\n 'placeholderButton',\n 'inputSection',\n 'popover',\n 'subgroup',\n 'main',\n 'actionTemplate',\n 'groupAction',\n 'subgroupActionsContainer',\n 'idInput',\n 'input',\n 'search',\n 'item',\n ]\n\n initialize() {\n this.search = this.search.bind(this)\n super.initialize()\n }\n\n edit() {\n this.hide(this.placeholderButtonTarget)\n this.show(this.inputSectionTarget)\n\n this.popoverTarget.showPopover()\n\n this.focus(this.inputTarget, { moveCursorToEnd: true })\n }\n\n debounceSearch() {\n this.clearDebounce()\n this.debounce(this.search)\n }\n\n search() {\n this.subgroupActionsContainerTarget.innerHTML = ''\n this.forward()\n\n get(this.urlValue, {\n responseKind: 'turbo-stream',\n query: {\n append: this.popoverTarget.id,\n q: this.inputTarget.value,\n },\n })\n }\n\n back() {\n this.hide(this.subgroupTarget)\n this.show(this.mainTarget)\n }\n\n forward() {\n this.hide(this.mainTarget)\n this.show(this.subgroupTarget)\n }\n\n viewGroup({ params }) {\n if(params.group === this.groupValue) {\n return this.forward()\n }\n\n this.groupValue = params.group\n this.groupCountValue = params.count\n\n this.subgroupActionsContainerTarget.innerHTML = ''\n\n for(let i = 0; i < this.groupCountValue; i++) {\n const skeleton = this.actionTemplateTarget.cloneNode(true)\n skeleton.classList.remove('hidden')\n\n this.subgroupActionsContainerTarget.appendChild(skeleton)\n }\n\n this.forward()\n\n get(this.groupUrlValue, {\n responseKind: 'turbo-stream',\n query: {\n group: this.groupValue\n }\n })\n }\n\n selectAction({ currentTarget, params }) {\n this.idValue = params.id\n this.nameValue = params.name\n\n this.idInputTarget.value = params.id\n\n this.placeholderButtonTarget.textContent = params.name\n this.inputTarget.value = params.name\n\n this.addClass(this.placeholderButtonTarget, 'font-medium')\n this.removeClass(this.placeholderButtonTarget, 'text-night-60')\n\n this.hide(this.inputSectionTarget)\n this.show(this.placeholderButtonTarget)\n\n this.popoverTarget.hidePopover()\n\n this.dispatch('set', {\n detail: params\n })\n\n this.itemTargets.forEach(item => {\n if(currentTarget === item) {\n this.addClass(item, 'bg-lavender-light')\n } else {\n this.removeClass(item, 'bg-lavender-light')\n }\n })\n }\n\n itemTargetConnected(item) {\n this.itemTargets.forEach(item => {\n if(item.dataset.id === this.idValue) {\n this.addClass(item, 'bg-lavender-light')\n } else {\n this.removeClass(item, 'bg-lavender-light')\n }\n })\n }\n\n restore() {\n this.show(this.placeholderButtonTarget)\n this.hide(this.inputSectionTarget)\n\n if(!this.idValue) {\n this.removeClass(this.placeholderButtonTarget, 'font-medium')\n this.addClass(this.placeholderButtonTarget, 'text-night-60')\n\n this.inputTarget.value = ''\n this.back()\n }\n\n this.popoverTarget.hidePopover()\n }\n\n onClickOutside({ target }) {\n if(this.element.contains(target) || this.isInvisible(this.inputSectionTarget)) return\n\n this.clearDebounce()\n this.restore()\n }\n\n idValueChanged() {\n if(this.idValue) {\n this.element.setAttribute('data-valid', true)\n } else {\n this.element.removeAttribute('data-valid')\n }\n\n this.dispatch('validation', {\n prefix: 'property',\n })\n }\n}\n"],"names":["action_controller","ApplicationController","get","params","i","skeleton","currentTarget","item","target","__publicField"],"mappings":"+PAIe,MAAKA,UAASC,CAAsB,CAuBjD,YAAa,CACX,KAAK,OAAS,KAAK,OAAO,KAAK,IAAI,EACnC,MAAM,WAAU,CACpB,CAEE,MAAO,CACL,KAAK,KAAK,KAAK,uBAAuB,EACtC,KAAK,KAAK,KAAK,kBAAkB,EAEjC,KAAK,cAAc,YAAW,EAE9B,KAAK,MAAM,KAAK,YAAa,CAAE,gBAAiB,EAAM,CAAA,CAC1D,CAEE,gBAAiB,CACf,KAAK,cAAa,EAClB,KAAK,SAAS,KAAK,MAAM,CAC7B,CAEE,QAAS,CACP,KAAK,+BAA+B,UAAY,G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