@energycap/components 0.39.33 → 0.39.34
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/esm2020/lib/display/table/searchable-table.component.mjs +1 -1
- package/esm2020/lib/display/table/table.component.mjs +32 -28
- package/fesm2015/energycap-components.mjs +30 -26
- package/fesm2015/energycap-components.mjs.map +1 -1
- package/fesm2020/energycap-components.mjs +30 -26
- package/fesm2020/energycap-components.mjs.map +1 -1
- package/lib/display/table/searchable-table.component.d.ts +3 -3
- package/lib/display/table/table.component.d.ts +4 -2
- package/package.json +1 -1
@@ -7084,7 +7084,7 @@ class TableComponent {
|
|
7084
7084
|
if (this.sortable && changes.sort && changes.sort.currentValue && !changes.sort.firstChange) {
|
7085
7085
|
const newValue = changes.sort.currentValue;
|
7086
7086
|
if (!this.currentSort || !isEqual(newValue, this.currentSort)) {
|
7087
|
-
this.onSort(newValue
|
7087
|
+
this.onSort(newValue);
|
7088
7088
|
}
|
7089
7089
|
}
|
7090
7090
|
}
|
@@ -7133,7 +7133,14 @@ class TableComponent {
|
|
7133
7133
|
if (th.classList.contains('is-resizable') && event.target && event.target.classList.contains('handle')) {
|
7134
7134
|
return;
|
7135
7135
|
}
|
7136
|
-
|
7136
|
+
let direction;
|
7137
|
+
if (th.classList.contains('is-sorted-desc')) {
|
7138
|
+
direction = 'asc';
|
7139
|
+
}
|
7140
|
+
else {
|
7141
|
+
direction = 'desc';
|
7142
|
+
}
|
7143
|
+
this.onSort({ field, direction });
|
7137
7144
|
});
|
7138
7145
|
// Store unlisten function to remove listener when component is destroyed
|
7139
7146
|
this.unlisteners.push(unlisten);
|
@@ -7145,7 +7152,7 @@ class TableComponent {
|
|
7145
7152
|
});
|
7146
7153
|
// Set the initial sort
|
7147
7154
|
if (this.sort) {
|
7148
|
-
this.onSort(this.sort
|
7155
|
+
this.onSort(this.sort);
|
7149
7156
|
}
|
7150
7157
|
}
|
7151
7158
|
/**
|
@@ -7154,32 +7161,29 @@ class TableComponent {
|
|
7154
7161
|
* Emit the current field and direction of the sorted column
|
7155
7162
|
* @param field
|
7156
7163
|
*/
|
7157
|
-
onSort(
|
7158
|
-
|
7159
|
-
if (
|
7160
|
-
|
7161
|
-
}
|
7162
|
-
if (this.currentSort && this.currentSort.field !== field) {
|
7163
|
-
this.renderer.removeClass(this.sortableCols[this.currentSort.field], `is-sorted-${this.currentSort.direction}`);
|
7164
|
-
}
|
7165
|
-
if (th.classList.contains('is-sorted-desc')) {
|
7166
|
-
this.renderer.removeClass(th, 'is-sorted-desc');
|
7167
|
-
if (!direction) {
|
7168
|
-
direction = 'asc';
|
7169
|
-
}
|
7164
|
+
onSort(sort) {
|
7165
|
+
this.clearSort();
|
7166
|
+
if (Array.isArray(sort)) {
|
7167
|
+
sort.forEach(s => this.applySort(s));
|
7170
7168
|
}
|
7171
7169
|
else {
|
7172
|
-
|
7173
|
-
|
7174
|
-
|
7175
|
-
|
7176
|
-
|
7177
|
-
|
7170
|
+
this.applySort(sort);
|
7171
|
+
}
|
7172
|
+
this.currentSort = cloneDeep(sort);
|
7173
|
+
this.sortChange.emit(this.currentSort);
|
7174
|
+
}
|
7175
|
+
clearSort() {
|
7176
|
+
Object.values(this.sortableCols).forEach(th => {
|
7177
|
+
this.renderer.removeClass(th, `is-sorted-asc`);
|
7178
|
+
this.renderer.removeClass(th, `is-sorted-desc`);
|
7179
|
+
});
|
7180
|
+
}
|
7181
|
+
applySort(sort) {
|
7182
|
+
const th = this.sortableCols[sort.field];
|
7183
|
+
if (!th) {
|
7184
|
+
return;
|
7178
7185
|
}
|
7179
|
-
this.renderer.addClass(th, `is-sorted-${direction}`);
|
7180
|
-
const sortEvent = { field: field, direction: direction };
|
7181
|
-
this.currentSort = sortEvent;
|
7182
|
-
this.sortChange.emit(sortEvent);
|
7186
|
+
this.renderer.addClass(th, `is-sorted-${sort.direction}`);
|
7183
7187
|
}
|
7184
7188
|
initSelectable() {
|
7185
7189
|
this.selectionContext.rowCheckboxes.valueChanges.pipe(takeUntil(this.destroyed)).subscribe((value) => {
|