@neovici/cosmoz-omnitable 7.0.6 → 7.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cosmoz-omnitable.js +27 -104
- package/package.json +1 -1
package/cosmoz-omnitable.js
CHANGED
|
@@ -301,7 +301,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
|
|
|
301
301
|
groupOnDescending: {
|
|
302
302
|
type: Boolean,
|
|
303
303
|
value: false,
|
|
304
|
-
observer: '
|
|
304
|
+
observer: '_debounceProcessItems'
|
|
305
305
|
},
|
|
306
306
|
/**
|
|
307
307
|
* The column name to group on.
|
|
@@ -327,7 +327,6 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
|
|
|
327
327
|
*/
|
|
328
328
|
filteredItems: {
|
|
329
329
|
type: Array,
|
|
330
|
-
observer: '_debounceGroupItems',
|
|
331
330
|
value: () => []
|
|
332
331
|
},
|
|
333
332
|
|
|
@@ -418,8 +417,8 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
|
|
|
418
417
|
|
|
419
418
|
static get observers() {
|
|
420
419
|
return [
|
|
421
|
-
'_dataChanged(data
|
|
422
|
-
'
|
|
420
|
+
'_dataChanged(data.splices)',
|
|
421
|
+
'_debounceProcessItems(sortOn, descending)',
|
|
423
422
|
'_selectedItemsChanged(selectedItems.*)',
|
|
424
423
|
'renderFastLayoutCss(layoutCss, $.layoutStyle)'
|
|
425
424
|
];
|
|
@@ -430,7 +429,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
|
|
|
430
429
|
|
|
431
430
|
this.debouncers = {};
|
|
432
431
|
this._updateColumns = this._updateColumns.bind(this);
|
|
433
|
-
this.
|
|
432
|
+
this._processItems = this._processItems.bind(this);
|
|
434
433
|
this._groupItems = this._groupItems.bind(this);
|
|
435
434
|
this._sortFilteredGroupedItems = this._sortFilteredGroupedItems.bind(this);
|
|
436
435
|
this._onKey = this._onKey.bind(this);
|
|
@@ -479,16 +478,8 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
|
|
|
479
478
|
this.debouncers._updateColumnsDebouncer.flush();
|
|
480
479
|
}
|
|
481
480
|
|
|
482
|
-
if (this.debouncers.
|
|
483
|
-
this.debouncers.
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
if (this.debouncers._groupItemsDebouncer) {
|
|
487
|
-
this.debouncers._groupItemsDebouncer.flush();
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
if (this.debouncers._sortItemsDebouncer) {
|
|
491
|
-
this.debouncers._sortItemsDebouncer.flush();
|
|
481
|
+
if (this.debouncers._processItemsDebouncer) {
|
|
482
|
+
this.debouncers._processItemsDebouncer.flush();
|
|
492
483
|
}
|
|
493
484
|
}
|
|
494
485
|
|
|
@@ -596,70 +587,12 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
|
|
|
596
587
|
requestAnimationFrame(() => requestAnimationFrame(() => this.$.groupedList.$.list._render()));
|
|
597
588
|
}
|
|
598
589
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
if (acc.refilter) {
|
|
602
|
-
return acc;
|
|
603
|
-
}
|
|
604
|
-
const itemsReplaced = splice.type === 'splice' && splice.addedCount === splice.removed.length;
|
|
605
|
-
if (!itemsReplaced) {
|
|
606
|
-
acc.refilter = true;
|
|
607
|
-
return acc;
|
|
608
|
-
}
|
|
609
|
-
const filterFunctions = this.columns
|
|
610
|
-
.map(col => col.getFilterFn())
|
|
611
|
-
.filter(fn => fn !== undefined),
|
|
612
|
-
comparer = (oldItem, newItem, path) =>
|
|
613
|
-
this.get(path, oldItem) !== this.get(path, newItem);
|
|
614
|
-
|
|
615
|
-
splice.removed.some((oldItem, index) => {
|
|
616
|
-
const newItem = splice.object[splice.index + index];
|
|
617
|
-
if (!acc.refilter) {
|
|
618
|
-
const wasFiltered = this.filteredItems.includes(oldItem),
|
|
619
|
-
isFiltered = filterFunctions.every(filterFn => filterFn(newItem));
|
|
620
|
-
acc.refilter = wasFiltered !== isFiltered;
|
|
621
|
-
if (acc.refilter) {
|
|
622
|
-
return true;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
acc.regroup = acc.regroup || !!this.groupOnColumn && comparer(oldItem, newItem, this.groupOnColumn.valuePath);
|
|
626
|
-
acc.resort = acc.regroup || acc.resort || !!this.sortOnColumn && comparer(oldItem, newItem, this.sortOnColumn.valuePath);
|
|
627
|
-
return false;
|
|
628
|
-
});
|
|
629
|
-
return acc;
|
|
630
|
-
}, {
|
|
631
|
-
refilter: false,
|
|
632
|
-
regroup: false,
|
|
633
|
-
resort: false
|
|
634
|
-
});
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
_dataChanged(notify) {
|
|
638
|
-
if (!Array.isArray(this.columns) || notify == null || notify.path === 'data.length') {
|
|
590
|
+
_dataChanged() {
|
|
591
|
+
if (!Array.isArray(this.columns)) {
|
|
639
592
|
return;
|
|
640
593
|
}
|
|
641
594
|
this._setColumnValues();
|
|
642
|
-
|
|
643
|
-
if (notify.path !== 'data.splices') {
|
|
644
|
-
this._debounceFilterItems();
|
|
645
|
-
return;
|
|
646
|
-
}
|
|
647
|
-
const effects = this._getItemUpdateEffects(notify.value.indexSplices);
|
|
648
|
-
if (effects.refilter) {
|
|
649
|
-
this._debounceFilterItems();
|
|
650
|
-
} else if (effects.regroup) {
|
|
651
|
-
this._debounceGroupItems();
|
|
652
|
-
} else if (effects.resort) {
|
|
653
|
-
this._debounceSortItems();
|
|
654
|
-
} else if (notify.value.indexSplices.length === 1 && notify.value.indexSplices[0].addedCount === 1 && notify.value.indexSplices[0].removed.length === 1) {
|
|
655
|
-
// one item was replaced, but it did not affect the filtering, grouping and sorting
|
|
656
|
-
// replace the old item in the sortedFilteredGroupedItems directly
|
|
657
|
-
const indexInVisibleData = this.sortedFilteredGroupedItems.indexOf(notify.value.indexSplices[0].removed[0]);
|
|
658
|
-
if (indexInVisibleData === -1) {
|
|
659
|
-
return;
|
|
660
|
-
}
|
|
661
|
-
this.splice('sortedFilteredGroupedItems', indexInVisibleData, 1, notify.value.indexSplices[0].object[notify.value.indexSplices[0].index]);
|
|
662
|
-
}
|
|
595
|
+
this._debounceProcessItems();
|
|
663
596
|
}
|
|
664
597
|
|
|
665
598
|
_debounceUpdateColumns() {
|
|
@@ -723,7 +656,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
|
|
|
723
656
|
this._updateParamsFromHash();
|
|
724
657
|
|
|
725
658
|
if (Array.isArray(this.data)) {
|
|
726
|
-
this.
|
|
659
|
+
this._debounceProcessItems();
|
|
727
660
|
}
|
|
728
661
|
}
|
|
729
662
|
|
|
@@ -808,12 +741,26 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
|
|
|
808
741
|
if (!Array.isArray(this.columns) || this.columns.length < 1 || this.columns.indexOf(detail.column) < 0) {
|
|
809
742
|
return;
|
|
810
743
|
}
|
|
811
|
-
this.
|
|
744
|
+
this._debounceProcessItems();
|
|
812
745
|
this._filterForRouteChanged(detail.column);
|
|
813
746
|
}
|
|
814
747
|
|
|
815
|
-
|
|
816
|
-
|
|
748
|
+
_groupOnColumnChanged(column) {
|
|
749
|
+
if (column && column.hasFilter()) {
|
|
750
|
+
column.resetFilter();
|
|
751
|
+
} else {
|
|
752
|
+
this._debounceProcessItems();
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
_debounceProcessItems() {
|
|
757
|
+
this._debounce('_processItemsDebouncer', this._processItems);
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
_processItems() {
|
|
761
|
+
this._filterItems();
|
|
762
|
+
this._groupItems();
|
|
763
|
+
this._sortFilteredGroupedItems();
|
|
817
764
|
}
|
|
818
765
|
|
|
819
766
|
_filterItems() {
|
|
@@ -838,21 +785,6 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
|
|
|
838
785
|
}
|
|
839
786
|
}
|
|
840
787
|
|
|
841
|
-
_groupOnColumnChanged(column) {
|
|
842
|
-
if (column && column.hasFilter()) {
|
|
843
|
-
column.resetFilter();
|
|
844
|
-
} else {
|
|
845
|
-
this._debounce('_groupItemsDebouncer', this._groupItems);
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
_debounceGroupItems() {
|
|
850
|
-
if (!this.isConnected || !Array.isArray(this.filteredItems)) {
|
|
851
|
-
return;
|
|
852
|
-
}
|
|
853
|
-
this._debounce('_groupItemsDebouncer', this._groupItems);
|
|
854
|
-
}
|
|
855
|
-
|
|
856
788
|
/* eslint-disable-next-line max-statements */
|
|
857
789
|
_groupItems() {
|
|
858
790
|
// do not attempt to group items if no columns are defined
|
|
@@ -912,14 +844,6 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
|
|
|
912
844
|
this.filteredGroupedItems = groups;
|
|
913
845
|
}
|
|
914
846
|
|
|
915
|
-
_debounceSortItems() {
|
|
916
|
-
if (!Array.isArray(this.data) || this.data.length < 1 || !Array.isArray(this.columns)) {
|
|
917
|
-
return;
|
|
918
|
-
}
|
|
919
|
-
this._debounce('_sortItemsDebouncer', this._sortFilteredGroupedItems);
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
|
|
923
847
|
/* eslint-disable-next-line max-statements */
|
|
924
848
|
_genericSorter(a, b) {
|
|
925
849
|
if (a === b) {
|
|
@@ -1005,7 +929,6 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
|
|
|
1005
929
|
return;
|
|
1006
930
|
}
|
|
1007
931
|
|
|
1008
|
-
|
|
1009
932
|
// No grouping
|
|
1010
933
|
this.filteredGroupedItems.sort(sorter);
|
|
1011
934
|
if (this.descending) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neovici/cosmoz-omnitable",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.7",
|
|
4
4
|
"description": "[](https://travis-ci.org/Neovici/cosmoz-omnitable)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components"
|