Skip to content

Commit 7a945b6

Browse files
committed
Minor tweaks
1 parent 0eae886 commit 7a945b6

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

resources/js/laravel-livewire-tables.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,34 @@ document.addEventListener('alpine:init', () => {
790790
}
791791
}));
792792

793+
Alpine.data('filterPillsArrayExternalNew', (wire, filterKey) => ({
794+
externalFilterKey: filterKey,
795+
pillValues: [],
796+
optionsAvailable: wire.entangle('optionsAvailable'),
797+
optionsSelected: wire.entangle('optionsSelected').live,
798+
selectedItems: [],
799+
syncItems(items) {
800+
this.pillValues = [];
801+
items.forEach((item) => {
802+
this.pillValues.push(this.optionsAvailable[item]);
803+
});
804+
if(this.pillValues.length > 0)
805+
{
806+
this.pillValues.sort();
807+
this.syncExternalFilterPillsValues(this.externalFilterKey,this.pillValues);
808+
}
809+
this.optionsSelected = this.selectedItems;
810+
wire.set('value', this.selectedItems);
811+
812+
},
813+
init() {
814+
this.selectedItems = this.optionsSelected;
815+
this.syncItems(this.selectedItems);
816+
this.$watch('selectedItems', value => this.syncItems(value));
817+
}
818+
819+
}));
820+
793821
Alpine.data('filterPillsArrayExternal', (tableNameVal, filterKeyVal) => ({
794822
tableName: tableNameVal,
795823
filterKey: filterKeyVal,

0 commit comments

Comments
 (0)