{"version":3,"file":"map_form_controller-D0RolJXq.js","sources":["../../../app/javascript/controllers/import/map_form_controller.js"],"sourcesContent":["import ApplicationController from '../application_controller'\n\nexport default class extends ApplicationController {\n static targets = [\n 'submit',\n 'item',\n ]\n\n handleMapItemChange(event) {\n this.disableButton()\n\n let atLeastOneChecked = false\n\n const enable = this.itemTargets.every(element => {\n const isChecked = element.dataset['import-MapItemChecked'] === 'true'\n const isSelected = element.dataset['import-MapItemSelected'] === 'true'\n\n atLeastOneChecked = atLeastOneChecked || isChecked\n\n return isChecked && isSelected\n || !isChecked && !isSelected\n || !isChecked && isSelected\n })\n\n if (enable && atLeastOneChecked) this.enableButton()\n }\n\n disableButton() {\n this.submitTarget.disabled = true\n }\n\n enableButton() {\n this.submitTarget.disabled = false\n }\n\n itemTargetConnected() {\n this.itemTargets.forEach(item => {\n item.addEventListener('import-map-item:change', this.handleMapItemChange.bind(this))\n })\n }\n}\n"],"names":["map_form_controller","ApplicationController","event","atLeastOneChecked","element","isChecked","isSelected","item","__publicField"],"mappings":"uNAEe,MAAKA,UAASC,CAAsB,CAMjD,oBAAoBC,EAAO,CACzB,KAAK,cAAa,EAElB,IAAIC,EAAoB,GAET,KAAK,YAAY,MAAMC,GAAW,CAC/C,MAAMC,EAAYD,EAAQ,QAAQ,uBAAuB,IAAM,OACzDE,EAAaF,EAAQ,QAAQ,wBAAwB,IAAM,OAEjE,OAAAD,EAAoBA,GAAqBE,EAElCA,GAAaC,GACjB,CAACD,GAAa,CAACC,GACf,CAACD,GAAaC,CAClB,CAAA,GAEaH,GAAmB,KAAK,aAAY,CACtD,CAEE,eAAgB,CACd,KAAK,aAAa,SAAW,EACjC,CAEE,cAAe,CACb,KAAK,aAAa,SAAW,EACjC,CAEE,qBAAsB,CACpB,KAAK,YAAY,QAAQI,GAAQ,CAC/BA,EAAK,iBAAiB,yBAA0B,KAAK,oBAAoB,KAAK,IAAI,CAAC,CACpF,CAAA,CACL,CACA,CArCEC,EADkBR,EACX,UAAU,CACf,SACA,MACJ"}