{"version":3,"file":"trackable_search_controller-CZQ-gGET.js","sources":["../../../app/javascript/controllers/track/trackable_search_controller.js"],"sourcesContent":["import { get } from '@rails/request.js'\n\nimport ItemController from '@/controllers/artifact/entity/item_controller'\n\n\nexport default class extends ItemController {\n static values = {\n actionId: String,\n type: String,\n }\n\n static targets = [\n 'typeInput',\n ]\n\n static classes = ['disabled']\n\n async onActionChange({ detail: actionId }) {\n this.actionIdValue = actionId\n\n this.element.classList.remove(...this.disabledClasses)\n this.element.removeAttribute('title')\n\n this.enable(this.placeholderButtonTarget)\n\n await get(this.searchUrlValue, {\n responseKind: this.formatValue,\n query: {\n append: this.popoverTarget.id,\n q: this.inputTarget.value,\n action_id: this.actionIdValue,\n },\n })\n\n this.showPopover()\n }\n\n async search() {\n const response = await get(this.searchUrlValue, {\n responseKind: this.formatValue,\n query: {\n append: this.popoverTarget.id,\n q: this.inputTarget.value,\n action_id: this.actionIdValue,\n },\n })\n\n this.showPopover()\n }\n\n focusInput() {\n this.hide(this.placeholderButtonTarget)\n this.show(this.inputSectionTarget)\n\n this.focus(this.inputTarget, { moveCursorToEnd: true })\n }\n\n enableSearch() {\n this.removeClass(...this.disabledClasses)\n this.element.removeAttribute('title')\n }\n\n markAsRequired() {\n this.show(this.starTarget)\n\n this.element.setAttribute('data-required', 'true')\n this.element.setAttribute('data-artifact--entity--form-target', 'requiredProperty')\n }\n\n markAsOptional() {\n this.hide(this.starTarget)\n\n this.element.removeAttribute('data-required')\n this.element.removeAttribute('data-artifact--entity--form-target')\n }\n\n selectEntity(event) {\n this.typeInputTarget.value = event.currentTarget.dataset.type\n this.setProduct(event)\n }\n\n onClickOutside({ target }) {\n if(this.element.contains(target) || this.isInvisible(this.inputSectionTarget)) return\n\n this.hidePopover()\n this.clearDebounce()\n\n this.restore()\n }\n\n setTypeFromNewEntity({ detail: type }) {\n this.typeInputTarget.value = type\n this.typeValue = type\n }\n\n save() {\n this.typeValue = this.typeInputTarget.value\n super.save()\n }\n\n restore() {\n this.typeInputTarget.value = this.typeValue\n super.restore()\n }\n}\n"],"names":["trackable_search_controller","ItemController","actionId","get","event","target","type","__publicField"],"mappings":"8PAKe,MAAKA,UAASC,CAAe,CAY1C,MAAM,eAAe,CAAE,OAAQC,GAAY,CACzC,KAAK,cAAgBA,EAErB,KAAK,QAAQ,UAAU,OAAO,GAAG,KAAK,eAAe,EACrD,KAAK,QAAQ,gBAAgB,OAAO,EAEpC,KAAK,OAAO,KAAK,uBAAuB,EAExC,MAAMC,EAAI,KAAK,eAAgB,CAC7B,aAAc,KAAK,YACnB,MAAO,CACL,OAAQ,KAAK,cAAc,GAC3B,EAAG,KAAK,YAAY,MACpB,UAAW,KAAK,aACjB,CACF,CAAA,EAED,KAAK,YAAW,CACpB,CAEE,MAAM,QAAS,CACI,MAAMA,EAAI,KAAK,eAAgB,CAC9C,aAAc,KAAK,YACnB,MAAO,CACL,OAAQ,KAAK,cAAc,GAC3B,EAAG,KAAK,YAAY,MACpB,UAAW,KAAK,aACjB,CACF,CAAA,EAED,KAAK,YAAW,CACpB,CAEE,YAAa,CACX,KAAK,KAAK,KAAK,uBAAuB,EACtC,KAAK,KAAK,KAAK,kBAAkB,EAEjC,KAAK,MAAM,KAAK,YAAa,CAAE,gBAAiB,EAAM,CAAA,CAC1D,CAEE,cAAe,CACb,KAAK,YAAY,GAAG,KAAK,eAAe,EACxC,KAAK,QAAQ,gBAAgB,OAAO,CACxC,CAEE,gBAAiB,CACf,KAAK,KAAK,KAAK,UAAU,EAEzB,KAAK,QAAQ,aAAa,gBAAiB,MAAM,EACjD,KAAK,QAAQ,aAAa,qCAAsC,kBAAkB,CACtF,CAEE,gBAAiB,CACf,KAAK,KAAK,KAAK,UAAU,EAEzB,KAAK,QAAQ,gBAAgB,eAAe,EAC5C,KAAK,QAAQ,gBAAgB,oCAAoC,CACrE,CAEE,aAAaC,EAAO,CAClB,KAAK,gBAAgB,MAAQA,EAAM,cAAc,QAAQ,KACzD,KAAK,WAAWA,CAAK,CACzB,CAE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