{"version":3,"file":"events_controller-DIe9-wR6.js","sources":["../../../app/javascript/controllers/notification/events_controller.js"],"sourcesContent":["import ApplicationController from \"../application_controller\"\n\nexport default class extends ApplicationController {\n static values = {\n subscribedToAll: Boolean,\n chooseAll: Boolean,\n disable: { type: Boolean, default: true }\n }\n\n static targets = [\"event\", \"checkbox\", \"submit\", \"skip\"]\n\n initialize() {\n if(this.subscribedToAllValue || this.chooseAllValue) {\n this.checkAndDisableAll()\n }\n\n if(this.disableValue) {\n this.syncSubmitButton()\n }\n }\n\n syncAllOptions({ target }) {\n if (target.checked) {\n this.checkAndDisableAll()\n this.enable(this.submitTarget)\n } else {\n this.uncheckAndEnableAll()\n }\n }\n\n checkAndDisableAll() {\n this.eventTargets.forEach((element) => {\n this.addClass(element, \"bg-night-10\", \"cursor-not-allowed\")\n\n const checkbox= element.querySelector(\"input\")\n\n if(checkbox.checked) {\n checkbox.setAttribute(\"data-was-checked\", \"\")\n }\n\n checkbox.checked = true\n checkbox.dispatchEvent(new Event(\"change\"))\n\n this.disable(checkbox)\n this.addClass(checkbox, \"!hidden\")\n })\n }\n\n syncSubmitButton() {\n if(this.hasSubmitTarget) {\n this.submitTarget.disabled = this.checkboxTargets.every(checkbox => !checkbox.checked)\n }\n }\n\n uncheckAndEnableAll() {\n this.eventTargets.forEach((element) => {\n this.removeClass(element, \"bg-night-10\", \"cursor-not-allowed\")\n\n const checkbox = element.querySelector(\"input\")\n checkbox.checked = checkbox.hasAttribute(\"data-was-checked\")\n\n checkbox.dispatchEvent(new Event(\"change\"))\n checkbox.removeAttribute(\"data-was-checked\")\n\n this.enable(element.querySelector(\"input\"))\n this.removeClass(element.querySelector(\"input\"), \"!hidden\")\n })\n\n this.syncSubmitButton()\n }\n\n updateSubmitButtonLabel() {\n if(!this.hasSkipTarget) return\n\n if(this.checkboxTargets.some(checkbox => checkbox.checked)) {\n this.show(this.submitTarget)\n this.hide(this.skipTarget)\n } else {\n this.hide(this.submitTarget)\n this.show(this.skipTarget)\n }\n }\n}\n"],"names":["NotificationEventsController","ApplicationController","target","element","checkbox","__publicField"],"mappings":"uNAEe,MAAKA,UAASC,CAAsB,CASjD,YAAa,EACR,KAAK,sBAAwB,KAAK,iBACnC,KAAK,mBAAkB,EAGtB,KAAK,cACN,KAAK,iBAAgB,CAE3B,CAEE,eAAe,CAAE,OAAAC,GAAU,CACrBA,EAAO,SACT,KAAK,mBAAkB,EACvB,KAAK,OAAO,KAAK,YAAY,GAE7B,KAAK,oBAAmB,CAE9B,CAEE,oBAAqB,CACnB,KAAK,aAAa,QAASC,GAAY,CACrC,KAAK,SAASA,EAAS,cAAe,oBAAoB,EAE1D,MAAMC,EAAUD,EAAQ,cAAc,OAAO,EAE1CC,EAAS,SACVA,EAAS,aAAa,mBAAoB,EAAE,EAG9CA,EAAS,QAAU,GACnBA,EAAS,cAAc,IAAI,MAAM,QAAQ,CAAC,EAE1C,KAAK,QAAQA,CAAQ,EACrB,KAAK,SAASA,EAAU,SAAS,CAClC,CAAA,CACL,CAEE,kBAAmB,CACd,KAAK,kBACN,KAAK,aAAa,SAAW,KAAK,gBAAgB,MAAMA,GAAY,CAACA,EAAS,OAAO,EAE3F,CAEE,qBAAsB,CACpB,KAAK,aAAa,QAASD,GAAY,CACrC,KAAK,YAAYA,EAAS,cAAe,oBAAoB,EAE7D,MAAMC,EAAWD,EAAQ,cAAc,OAAO,EAC9CC,EAAS,QAAUA,EAAS,aAAa,kBAAkB,EAE3DA,EAAS,cAAc,IAAI,MAAM,QAAQ,CAAC,EAC1CA,EAAS,gBAAgB,kBAAkB,EAE3C,KAAK,OAAOD,EAAQ,cAAc,OAAO,CAAC,EAC1C,KAAK,YAAYA,EAAQ,cAAc,OAAO,EAAG,SAAS,CAC3D,CAAA,EAED,KAAK,iBAAgB,CACzB,CAEE,yBAA0B,CACpB,KAAK,gBAEN,KAAK,gBAAgB,KAAKC,GAAYA,EAAS,OAAO,GACvD,KAAK,KAAK,KAAK,YAAY,EAC3B,KAAK,KAAK,KAAK,UAAU,IAEzB,KAAK,KAAK,KAAK,YAAY,EAC3B,KAAK,KAAK,KAAK,UAAU,GAE/B,CACA,CA/EEC,EADkBL,EACX,SAAS,CACd,gBAAiB,QACjB,UAAW,QACX,QAAS,CAAE,KAAM,QAAS,QAAS,EAAI,CAC3C,GAEEK,EAPkBL,EAOX,UAAU,CAAC,QAAS,WAAY,SAAU,MAAM"}