melondtable 1.18.5 → 1.19.0
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/LICENSE +1 -0
- package/dist/melondtable.cjs.js +88 -10
- package/dist/melondtable.css +4 -0
- package/dist/melondtable.js +155 -77
- package/dist/melondtable.min.css +1 -1
- package/dist/melondtable.min.js +1 -1
- package/package.json +1 -4
- package/src/cellmanager.js +15 -4
- package/src/columnmanager.js +47 -6
- package/src/datatable.js +26 -0
- package/src/style.css +4 -0
- package/src/translations/index.js +7 -7
- package/src/translations/pt.json +15 -0
- package/src/translations/sw.json +15 -0
- package/src/translations/de.json +0 -15
- package/src/translations/it.json +0 -15
package/LICENSE
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
MIT
|
package/dist/melondtable.cjs.js
CHANGED
|
@@ -2886,7 +2886,6 @@ class CellManager {
|
|
|
2886
2886
|
|
|
2887
2887
|
_selectArea($cell1, $cell2) {
|
|
2888
2888
|
if ($cell1 === $cell2) return false;
|
|
2889
|
-
|
|
2890
2889
|
const cells = this.getCellsInRange($cell1, $cell2);
|
|
2891
2890
|
if (!cells) return false;
|
|
2892
2891
|
|
|
@@ -2913,9 +2912,17 @@ class CellManager {
|
|
|
2913
2912
|
const cell2 = $.data($cell2);
|
|
2914
2913
|
|
|
2915
2914
|
colIndex1 = +cell1.colIndex;
|
|
2916
|
-
rowIndex1 = +cell1.rowIndex;
|
|
2917
2915
|
colIndex2 = +cell2.colIndex;
|
|
2918
|
-
|
|
2916
|
+
|
|
2917
|
+
if (this.columnmanager.sortState) {
|
|
2918
|
+
this.sortedColumn = true;
|
|
2919
|
+
rowIndex1 = this.datamanager.rowViewOrder.indexOf(parseInt(cell1.rowIndex, 10));
|
|
2920
|
+
rowIndex2 = this.datamanager.rowViewOrder.indexOf(parseInt(cell2.rowIndex, 10));
|
|
2921
|
+
} else {
|
|
2922
|
+
rowIndex1 = +cell1.rowIndex;
|
|
2923
|
+
rowIndex2 = +cell2.rowIndex;
|
|
2924
|
+
}
|
|
2925
|
+
|
|
2919
2926
|
}
|
|
2920
2927
|
|
|
2921
2928
|
if (rowIndex1 > rowIndex2) {
|
|
@@ -2947,7 +2954,11 @@ class CellManager {
|
|
|
2947
2954
|
}
|
|
2948
2955
|
colIndex = colIndex1;
|
|
2949
2956
|
});
|
|
2950
|
-
|
|
2957
|
+
if (this.columnmanager.sortState) {
|
|
2958
|
+
cells.forEach(selectedCells => {
|
|
2959
|
+
selectedCells[1] = this.datamanager.rowViewOrder[selectedCells[1]];
|
|
2960
|
+
});
|
|
2961
|
+
}
|
|
2951
2962
|
return cells;
|
|
2952
2963
|
}
|
|
2953
2964
|
|
|
@@ -3737,9 +3748,29 @@ class ColumnManager {
|
|
|
3737
3748
|
.then(() => this.instance.unfreeze())
|
|
3738
3749
|
.then(() => {
|
|
3739
3750
|
this.fireEvent('onSortColumn', this.getColumn(colIndex));
|
|
3751
|
+
this.setSortState();
|
|
3740
3752
|
});
|
|
3741
3753
|
}
|
|
3742
3754
|
|
|
3755
|
+
saveSorting(colIndex) {
|
|
3756
|
+
let currentColumn = this.getColumn(colIndex);
|
|
3757
|
+
let saveSorting = {
|
|
3758
|
+
[currentColumn.name]: {
|
|
3759
|
+
colIndex: colIndex,
|
|
3760
|
+
sortOrder: currentColumn.sortOrder
|
|
3761
|
+
}
|
|
3762
|
+
};
|
|
3763
|
+
this.sortingKey = this.options.sortingKey ? `${this.options.sortingKey}::sortedColumns` : 'sortedColumns' ;
|
|
3764
|
+
localStorage.setItem(this.sortingKey, JSON.stringify(saveSorting));
|
|
3765
|
+
}
|
|
3766
|
+
setSortState(sortOrder) {
|
|
3767
|
+
if (sortOrder === 'none') {
|
|
3768
|
+
this.sortState = false;
|
|
3769
|
+
} else {
|
|
3770
|
+
this.sortState = true;
|
|
3771
|
+
}
|
|
3772
|
+
}
|
|
3773
|
+
|
|
3743
3774
|
removeColumn(colIndex) {
|
|
3744
3775
|
const removedCol = this.getColumn(colIndex);
|
|
3745
3776
|
this.instance.freeze();
|
|
@@ -3838,6 +3869,19 @@ class ColumnManager {
|
|
|
3838
3869
|
}
|
|
3839
3870
|
}
|
|
3840
3871
|
|
|
3872
|
+
applySavedSortOrder() {
|
|
3873
|
+
|
|
3874
|
+
let key = this.options.sortingKey ? `${this.options.sortingKey}::sortedColumns` : 'sortedColumns' ;
|
|
3875
|
+
let sortingConfig = JSON.parse(localStorage.getItem(key));
|
|
3876
|
+
if (sortingConfig) {
|
|
3877
|
+
const columnsToSort = Object.values(sortingConfig);
|
|
3878
|
+
for (let column of columnsToSort) {
|
|
3879
|
+
this.sortColumn(column.colIndex, column.sortOrder);
|
|
3880
|
+
this.sortState = true;
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3883
|
+
}
|
|
3884
|
+
|
|
3841
3885
|
sortRows(colIndex, sortOrder) {
|
|
3842
3886
|
return this.datamanager.sortRows(colIndex, sortOrder);
|
|
3843
3887
|
}
|
|
@@ -3913,14 +3957,22 @@ class ColumnManager {
|
|
|
3913
3957
|
|
|
3914
3958
|
getDropdownListHTML() {
|
|
3915
3959
|
const { headerDropdown: dropdownItems } = this.options;
|
|
3916
|
-
|
|
3917
3960
|
return `
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3961
|
+
<div class="dt-dropdown__list">
|
|
3962
|
+
${dropdownItems.map((d, i) => `
|
|
3963
|
+
<div
|
|
3964
|
+
class="dt-dropdown__list-item${d.display ? ' dt-hidden' : ''}"
|
|
3965
|
+
data-index="${i}"
|
|
3966
|
+
>
|
|
3967
|
+
${d.label}
|
|
3922
3968
|
</div>
|
|
3923
|
-
|
|
3969
|
+
`).join('')}
|
|
3970
|
+
</div>
|
|
3971
|
+
`;
|
|
3972
|
+
}
|
|
3973
|
+
|
|
3974
|
+
toggleDropdownItem(index) {
|
|
3975
|
+
$('.dt-dropdown__list', this.instance.dropdownContainer).children[index].classList.toggle('dt-hidden');
|
|
3924
3976
|
}
|
|
3925
3977
|
}
|
|
3926
3978
|
|
|
@@ -5703,6 +5755,10 @@ class DataTable {
|
|
|
5703
5755
|
if (this.options.data) {
|
|
5704
5756
|
this.refresh();
|
|
5705
5757
|
this.columnmanager.applyDefaultSortOrder();
|
|
5758
|
+
if (this.options.saveSorting) {
|
|
5759
|
+
this.setupSaveSorting();
|
|
5760
|
+
this.columnmanager.applySavedSortOrder();
|
|
5761
|
+
}
|
|
5706
5762
|
}
|
|
5707
5763
|
}
|
|
5708
5764
|
|
|
@@ -5872,6 +5928,9 @@ class DataTable {
|
|
|
5872
5928
|
sortColumn(colIndex, sortOrder) {
|
|
5873
5929
|
this.columnmanager.sortColumn(colIndex, sortOrder);
|
|
5874
5930
|
}
|
|
5931
|
+
saveSorting(colIndex, nextSortOrder) {
|
|
5932
|
+
this.columnmanager.saveSorting(colIndex, nextSortOrder);
|
|
5933
|
+
}
|
|
5875
5934
|
|
|
5876
5935
|
removeColumn(colIndex) {
|
|
5877
5936
|
this.columnmanager.removeColumn(colIndex);
|
|
@@ -5925,6 +5984,25 @@ class DataTable {
|
|
|
5925
5984
|
translate(str, args) {
|
|
5926
5985
|
return this.translationManager.translate(str, args);
|
|
5927
5986
|
}
|
|
5987
|
+
setupSaveSorting() {
|
|
5988
|
+
// add options in default headerdropdown
|
|
5989
|
+
let action = {
|
|
5990
|
+
label: this.translate('Save Sorting'),
|
|
5991
|
+
action: function (column) {
|
|
5992
|
+
this.saveSorting(column.colIndex, column.sotOrder);
|
|
5993
|
+
},
|
|
5994
|
+
display: 'hidden'
|
|
5995
|
+
};
|
|
5996
|
+
this.options.headerDropdown.push(action);
|
|
5997
|
+
this.columnmanager.bindDropdown();
|
|
5998
|
+
// add events for onSortColumn
|
|
5999
|
+
this.on('onSortColumn', function (column) {
|
|
6000
|
+
this.columnmanager.toggleDropdownItem(4);
|
|
6001
|
+
if (column.sortOrder === 'none') {
|
|
6002
|
+
localStorage.removeItem(this.columnmanager.sortingKey);
|
|
6003
|
+
}
|
|
6004
|
+
});
|
|
6005
|
+
}
|
|
5928
6006
|
}
|
|
5929
6007
|
|
|
5930
6008
|
DataTable.instances = 0;
|