{"version":3,"file":"filters_controller-oP72J_yF.js","sources":["../../../app/javascript/controllers/inbox/filters_controller.js"],"sourcesContent":["import ApplicationController from '../application_controller'\n\nexport default class extends ApplicationController {\n static values = {\n inactiveActions: String\n }\n\n static targets = [\"activeList\", \"inactiveList\", \"filter\", \"hint\"]\n static classes = [\"active\", \"inactive\"]\n\n connect() {\n super.connect()\n\n if(this.noMoreInactiveFilters) {\n this.show(this.hintTarget)\n }\n }\n\n apply({ currentTarget }) {\n const clonedNode = currentTarget.cloneNode(true)\n clonedNode.removeAttribute(\"data-inbox--filters-target\")\n\n currentTarget.classList.add(\"hidden\")\n\n this.activeListTarget.appendChild(clonedNode)\n this.applyActiveStateOn(clonedNode)\n\n if(this.noMoreInactiveFilters) {\n this.show(this.hintTarget)\n }\n }\n\n remove(e) {\n e.stopImmediatePropagation()\n e.preventDefault()\n\n const { currentTarget } = e\n\n const filterToRemove = this.activeListTarget.querySelector(`[data-id=\"${currentTarget.dataset.id}\"]`)\n const actualHiddenFilter = this.inactiveListTarget.querySelector(`[data-id=\"${currentTarget.dataset.id}\"]`)\n\n filterToRemove.remove()\n actualHiddenFilter.classList.remove(\"hidden\")\n\n this.hide(this.hintTarget)\n }\n\n // private\n\n applyActiveStateOn(element) {\n element.removeAttribute(\"data-action\")\n element.classList.remove(...this.inactiveClasses)\n element.classList.add(...this.activeClasses)\n element.querySelector(\"[data-remove-button]\").classList.remove(\"hidden\")\n }\n\n applyInactiveStateOn(element) {\n element.setAttribute(\"data-action\", this.inactiveActionsValue)\n element.classList.remove(...this.activeClasses)\n element.classList.add(...this.inactiveClasses)\n element.querySelector(\"[data-remove-button]\").classList.add(\"hidden\")\n }\n\n get noMoreInactiveFilters() {\n return this.filterTargets.filter(element => !element.classList.contains('hidden')).length === 0\n }\n}\n"],"names":["filters_controller","ApplicationController","currentTarget","clonedNode","e","filterToRemove","actualHiddenFilter","element","__publicField"],"mappings":"uNAEe,MAAKA,UAASC,CAAsB,CAQjD,SAAU,CACR,MAA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