@ascentgl/ads-ui 21.53.0 → 21.55.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.
|
@@ -7723,32 +7723,6 @@ class AdsTableComponent {
|
|
|
7723
7723
|
this.columnVisibilityMenuOpen = false;
|
|
7724
7724
|
}
|
|
7725
7725
|
/** @ignore */
|
|
7726
|
-
syncColumnVisibilityWithGrid() {
|
|
7727
|
-
if (!this.gridApi)
|
|
7728
|
-
return;
|
|
7729
|
-
// Get current column state from grid
|
|
7730
|
-
const columnState = this.gridApi.getColumnState();
|
|
7731
|
-
const currentVisibilityList = this.columnVisibilityList();
|
|
7732
|
-
let hasChanges = false;
|
|
7733
|
-
// Update form controls to match grid state
|
|
7734
|
-
currentVisibilityList.forEach(item => {
|
|
7735
|
-
const gridColumn = columnState.find(col => col.colId === item.field);
|
|
7736
|
-
if (gridColumn) {
|
|
7737
|
-
const isVisible = !gridColumn.hide;
|
|
7738
|
-
// Only update if the value is different to avoid unnecessary change events
|
|
7739
|
-
if (item.control.value !== isVisible) {
|
|
7740
|
-
// Temporarily disable the subscription to prevent recursive updates
|
|
7741
|
-
item.control.setValue(isVisible, { emitEvent: false });
|
|
7742
|
-
hasChanges = true;
|
|
7743
|
-
}
|
|
7744
|
-
}
|
|
7745
|
-
});
|
|
7746
|
-
// Trigger change detection to update hideColumnButtonLabel and other computed properties
|
|
7747
|
-
if (hasChanges) {
|
|
7748
|
-
this.cdr.detectChanges();
|
|
7749
|
-
}
|
|
7750
|
-
}
|
|
7751
|
-
/** @ignore */
|
|
7752
7726
|
hideAllColumns() {
|
|
7753
7727
|
const currentList = this.columnVisibilityList();
|
|
7754
7728
|
currentList.forEach((item) => {
|
|
@@ -7832,30 +7806,6 @@ class AdsTableComponent {
|
|
|
7832
7806
|
return this.filteredColumns.length > 0;
|
|
7833
7807
|
}
|
|
7834
7808
|
/** @ignore */
|
|
7835
|
-
updateSortingState() {
|
|
7836
|
-
if (this.gridApi) {
|
|
7837
|
-
const sortModel = this.gridApi.getColumnState();
|
|
7838
|
-
const sortedColumns = sortModel.filter((col) => col.sort !== null);
|
|
7839
|
-
// Sort by sortIndex to maintain the order in which columns were clicked for sorting
|
|
7840
|
-
sortedColumns.sort((a, b) => {
|
|
7841
|
-
const indexA = a.sortIndex ?? 0;
|
|
7842
|
-
const indexB = b.sortIndex ?? 0;
|
|
7843
|
-
return indexA - indexB;
|
|
7844
|
-
});
|
|
7845
|
-
// Update sorted columns array in the correct order
|
|
7846
|
-
this.sortedColumns = sortedColumns.map((col) => col.colId);
|
|
7847
|
-
// Keep backward compatibility for single sort
|
|
7848
|
-
if (sortedColumns.length > 0) {
|
|
7849
|
-
this.currentSortField = sortedColumns[0].colId;
|
|
7850
|
-
this.currentSortDirection = sortedColumns[0].sort;
|
|
7851
|
-
}
|
|
7852
|
-
else {
|
|
7853
|
-
this.currentSortField = null;
|
|
7854
|
-
this.currentSortDirection = null;
|
|
7855
|
-
}
|
|
7856
|
-
}
|
|
7857
|
-
}
|
|
7858
|
-
/** @ignore */
|
|
7859
7809
|
updateFilteringState() {
|
|
7860
7810
|
const filteredColumnsList = [];
|
|
7861
7811
|
// Check AG Grid's internal filter model
|
|
@@ -7994,12 +7944,15 @@ class AdsTableComponent {
|
|
|
7994
7944
|
/** @ignore */
|
|
7995
7945
|
onColumnSortChanged(event) {
|
|
7996
7946
|
const newStates = new Map(this.columnSortStates());
|
|
7947
|
+
const isMultiSort = this.gridOptions?.alwaysMultiSort === true;
|
|
7997
7948
|
if (event.direction === null) {
|
|
7998
7949
|
newStates.delete(event.field);
|
|
7999
7950
|
}
|
|
8000
7951
|
else {
|
|
8001
|
-
//
|
|
8002
|
-
|
|
7952
|
+
// Only clear other sorts if not multi-sort mode
|
|
7953
|
+
if (!isMultiSort) {
|
|
7954
|
+
newStates.clear();
|
|
7955
|
+
}
|
|
8003
7956
|
newStates.set(event.field, event.direction);
|
|
8004
7957
|
}
|
|
8005
7958
|
this.columnSortStates.set(newStates);
|
|
@@ -8011,10 +7964,20 @@ class AdsTableComponent {
|
|
|
8011
7964
|
});
|
|
8012
7965
|
}
|
|
8013
7966
|
else {
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
7967
|
+
if (isMultiSort) {
|
|
7968
|
+
// For multi-sort, only update the specific column without clearing others
|
|
7969
|
+
const currentState = this.gridApi.getColumnState();
|
|
7970
|
+
const maxSortIndex = currentState.reduce((max, col) => col.sortIndex !== null && col.sortIndex !== undefined ? Math.max(max, col.sortIndex) : max, -1);
|
|
7971
|
+
this.gridApi.applyColumnState({
|
|
7972
|
+
state: [{ colId: event.field, sort: event.direction, sortIndex: maxSortIndex + 1 }],
|
|
7973
|
+
});
|
|
7974
|
+
}
|
|
7975
|
+
else {
|
|
7976
|
+
this.gridApi.applyColumnState({
|
|
7977
|
+
state: [{ colId: event.field, sort: event.direction }],
|
|
7978
|
+
defaultState: { sort: null },
|
|
7979
|
+
});
|
|
7980
|
+
}
|
|
8018
7981
|
}
|
|
8019
7982
|
this.updateSortingState();
|
|
8020
7983
|
}
|
|
@@ -8240,8 +8203,79 @@ class AdsTableComponent {
|
|
|
8240
8203
|
* Call this method after programmatically changing column visibility via gridApi.applyColumnState()
|
|
8241
8204
|
* This will also update the hideColumnButtonLabel to reflect the current state.
|
|
8242
8205
|
*/
|
|
8243
|
-
|
|
8244
|
-
this.
|
|
8206
|
+
syncColumnVisibilityWithGrid() {
|
|
8207
|
+
if (!this.gridApi)
|
|
8208
|
+
return;
|
|
8209
|
+
// Get current column state from grid
|
|
8210
|
+
const columnState = this.gridApi.getColumnState();
|
|
8211
|
+
const currentVisibilityList = this.columnVisibilityList();
|
|
8212
|
+
let hasChanges = false;
|
|
8213
|
+
// Update form controls to match grid state
|
|
8214
|
+
currentVisibilityList.forEach(item => {
|
|
8215
|
+
const gridColumn = columnState.find(col => col.colId === item.field);
|
|
8216
|
+
if (gridColumn) {
|
|
8217
|
+
const isVisible = !gridColumn.hide;
|
|
8218
|
+
// Only update if the value is different to avoid unnecessary change events
|
|
8219
|
+
if (item.control.value !== isVisible) {
|
|
8220
|
+
// Temporarily disable the subscription to prevent recursive updates
|
|
8221
|
+
item.control.setValue(isVisible, { emitEvent: false });
|
|
8222
|
+
hasChanges = true;
|
|
8223
|
+
}
|
|
8224
|
+
}
|
|
8225
|
+
});
|
|
8226
|
+
// Trigger change detection to update hideColumnButtonLabel and other computed properties
|
|
8227
|
+
if (hasChanges) {
|
|
8228
|
+
this.cdr.detectChanges();
|
|
8229
|
+
}
|
|
8230
|
+
}
|
|
8231
|
+
/**
|
|
8232
|
+
* Updates the internal sorting state to reflect the current grid column state.
|
|
8233
|
+
* Call this method after programmatically changing column sorting via gridApi.applyColumnState()
|
|
8234
|
+
*/
|
|
8235
|
+
updateSortingState() {
|
|
8236
|
+
if (this.gridApi) {
|
|
8237
|
+
const sortModel = this.gridApi.getColumnState();
|
|
8238
|
+
const sortedColumns = sortModel.filter((col) => col.sort !== null);
|
|
8239
|
+
// Sort by sortIndex to maintain the order in which columns were clicked for sorting
|
|
8240
|
+
sortedColumns.sort((a, b) => {
|
|
8241
|
+
const indexA = a.sortIndex ?? 0;
|
|
8242
|
+
const indexB = b.sortIndex ?? 0;
|
|
8243
|
+
return indexA - indexB;
|
|
8244
|
+
});
|
|
8245
|
+
// Update sorted columns array in the correct order
|
|
8246
|
+
this.sortedColumns = sortedColumns.map((col) => col.colId);
|
|
8247
|
+
// Keep backward compatibility for single sort
|
|
8248
|
+
if (sortedColumns.length > 0) {
|
|
8249
|
+
this.currentSortField = sortedColumns[0].colId;
|
|
8250
|
+
this.currentSortDirection = sortedColumns[0].sort;
|
|
8251
|
+
}
|
|
8252
|
+
else {
|
|
8253
|
+
this.currentSortField = null;
|
|
8254
|
+
this.currentSortDirection = null;
|
|
8255
|
+
}
|
|
8256
|
+
// Update columnSortStates signal for custom sort/filter headers
|
|
8257
|
+
const newSortStates = new Map();
|
|
8258
|
+
sortedColumns.forEach((col) => {
|
|
8259
|
+
newSortStates.set(col.colId, col.sort);
|
|
8260
|
+
});
|
|
8261
|
+
this.columnSortStates.set(newSortStates);
|
|
8262
|
+
}
|
|
8263
|
+
}
|
|
8264
|
+
/**
|
|
8265
|
+
* Sets the filter states for columns programmatically.
|
|
8266
|
+
* Call this method to apply saved filter preferences.
|
|
8267
|
+
* @param filterStates - A map or object where keys are field names and values are arrays of selected filter values
|
|
8268
|
+
*/
|
|
8269
|
+
setColumnFilterStates(filterStates) {
|
|
8270
|
+
const newStates = filterStates instanceof Map
|
|
8271
|
+
? new Map(filterStates)
|
|
8272
|
+
: new Map(Object.entries(filterStates));
|
|
8273
|
+
this.columnFilterStates.set(newStates);
|
|
8274
|
+
// Apply external filter to grid
|
|
8275
|
+
if (this.gridApi) {
|
|
8276
|
+
this.gridApi.onFilterChanged();
|
|
8277
|
+
this.updateFilteringState();
|
|
8278
|
+
}
|
|
8245
8279
|
}
|
|
8246
8280
|
/** @ignore */
|
|
8247
8281
|
ngOnDestroy() {
|