phpvms/public/js/filament/forms/components/checkbox-list.js
Arthur Parienté acd38c9fa8
[8.x] feat: Filament Import Export (#2136)
* add migrations

* add setting to choose which importers to use

* bump filament

* enable database notifications

* add AirportImporter and AirportExporter

* move the untrash code to beforeUpdate

* fix validation rules

* add AircraftImporter and AircraftExporter

* fix phpstan

* add ExpenseImporter and ExpenseExporter

* add FareImporter and FareExporter

* add FlightImporter and FlightExporter

* add SubfleetImporter and SubfleetExporter

* change how relationships are processed in FlightImporter

* restore records if they are trashed after import

* phpstan and types

* fix packages

* remove foreign keys

* apply some of the fixes suggested by CodeRabbit

* fix docstring

* re add the fk

* bump filament
2026-01-09 16:10:53 -06:00

2 lines
1.6 KiB
JavaScript

function c({livewireId:s}){return{areAllCheckboxesChecked:!1,checkboxListOptions:[],search:"",visibleCheckboxListOptions:[],init(){this.checkboxListOptions=Array.from(this.$root.querySelectorAll(".fi-fo-checkbox-list-option")),this.updateVisibleCheckboxListOptions(),this.$nextTick(()=>{this.checkIfAllCheckboxesAreChecked()}),Livewire.hook("commit",({component:e,commit:t,succeed:i,fail:o,respond:h})=>{i(({snapshot:r,effect:l})=>{this.$nextTick(()=>{e.id===s&&(this.checkboxListOptions=Array.from(this.$root.querySelectorAll(".fi-fo-checkbox-list-option")),this.updateVisibleCheckboxListOptions(),this.checkIfAllCheckboxesAreChecked())})})}),this.$watch("search",()=>{this.updateVisibleCheckboxListOptions(),this.checkIfAllCheckboxesAreChecked()})},checkIfAllCheckboxesAreChecked(){this.areAllCheckboxesChecked=this.visibleCheckboxListOptions.length===this.visibleCheckboxListOptions.filter(e=>e.querySelector("input[type=checkbox]:checked, input[type=checkbox]:disabled")).length},toggleAllCheckboxes(){this.checkIfAllCheckboxesAreChecked();let e=!this.areAllCheckboxesChecked;this.visibleCheckboxListOptions.forEach(t=>{let i=t.querySelector("input[type=checkbox]");i.disabled||i.checked!==e&&(i.checked=e,i.dispatchEvent(new Event("change")))}),this.areAllCheckboxesChecked=e},updateVisibleCheckboxListOptions(){this.visibleCheckboxListOptions=this.checkboxListOptions.filter(e=>["",null,void 0].includes(this.search)||e.querySelector(".fi-fo-checkbox-list-option-label")?.innerText.toLowerCase().includes(this.search.toLowerCase())?!0:e.querySelector(".fi-fo-checkbox-list-option-description")?.innerText.toLowerCase().includes(this.search.toLowerCase()))}}}export{c as default};