basesite-shared-grid-lib 15.10.282 → 15.10.283

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.
@@ -1140,7 +1140,6 @@ class GridLibraryComponent {
1140
1140
  this.gridService = gridService;
1141
1141
  this.formatterService = formatterService;
1142
1142
  this._tokenSharingService = _tokenSharingService;
1143
- //@Input() pageSize: number = 20;
1144
1143
  this.paginationAutoPageSize = true;
1145
1144
  this.rowSelection = 'multiple';
1146
1145
  this.enableServerSidePaging = false;
@@ -1155,8 +1154,6 @@ class GridLibraryComponent {
1155
1154
  this.filterChanged = new EventEmitter();
1156
1155
  this.selectionChanged = new EventEmitter();
1157
1156
  this.totalRowCount = new EventEmitter();
1158
- //viewChilds
1159
- //@ViewChild('agGrid') agGrid!: AgGridAngular;
1160
1157
  //paramters
1161
1158
  this.initialColumnDef = [];
1162
1159
  this.rowDataHidden = [];
@@ -1239,6 +1236,10 @@ class GridLibraryComponent {
1239
1236
  setTimeout(() => this.updatePaginationInfo(), 0);
1240
1237
  }
1241
1238
  };
1239
+ this.filterHighlightingObserver = null;
1240
+ this.filterHighlightingRetryCount = 0;
1241
+ this.MAX_RETRY_ATTEMPTS = 10;
1242
+ this.RETRY_DELAY = 200;
1242
1243
  this.gridStateLoaded$.subscribe(val => {
1243
1244
  if (val) {
1244
1245
  this.configureDataState();
@@ -1266,11 +1267,23 @@ class GridLibraryComponent {
1266
1267
  else {
1267
1268
  this.rowModelType = 'clientSide';
1268
1269
  }
1269
- // this.gridPageSize = this.pageSize;
1270
1270
  this.cacheBlockSize = this.cacheBlockSize = 0 ? 100 : this.cacheBlockSize;
1271
1271
  this.gridService.setBaseUrl(this.environment);
1272
- //this.getGridState();
1273
- /*this.getColDef();*/
1272
+ this.setupWindowFocusListener();
1273
+ }
1274
+ // Handling page refresh scenarios
1275
+ setupWindowFocusListener() {
1276
+ const handleWindowFocus = () => {
1277
+ setTimeout(() => {
1278
+ if (this.gridAPI && this.floatingFilter) {
1279
+ this.applyFilterHighlightingWithRetry();
1280
+ }
1281
+ }, 500);
1282
+ };
1283
+ window.addEventListener('focus', handleWindowFocus);
1284
+ this.unsubscribe$.subscribe(() => {
1285
+ window.removeEventListener('focus', handleWindowFocus);
1286
+ });
1274
1287
  }
1275
1288
  get isOverride() {
1276
1289
  return (!!this.overrideColumnDefs);
@@ -1282,7 +1295,6 @@ class GridLibraryComponent {
1282
1295
  else {
1283
1296
  this.gridAPI.resetColumnState();
1284
1297
  this.getGridState();
1285
- //setTimeout(() => { this.setGridState(); }, 2000);
1286
1298
  }
1287
1299
  }
1288
1300
  ngOnChanges(changes) {
@@ -1316,7 +1328,6 @@ class GridLibraryComponent {
1316
1328
  this.columnDefs = coldef;
1317
1329
  this.gridColumns = coldef;
1318
1330
  this.getGridState();
1319
- // this.agGrid.gridOptions?.api?.setColumnDefs(coldef);
1320
1331
  }
1321
1332
  else {
1322
1333
  console.log('ColDef Read Error=>', response.message);
@@ -1404,7 +1415,6 @@ class GridLibraryComponent {
1404
1415
  valueFormatter: (params) => this.formatterService.colValueFormatter(params, res.columnType),
1405
1416
  filterable: res.filterable,
1406
1417
  filter: 'agDateColumnFilter',
1407
- //headerComponent: DateHeaderComponent,
1408
1418
  filterParams: {
1409
1419
  comparator: (filterLocalDateAtMidnight, cellValue) => {
1410
1420
  const dateAsString = cellValue;
@@ -1463,7 +1473,6 @@ class GridLibraryComponent {
1463
1473
  };
1464
1474
  }
1465
1475
  else {
1466
- // if (!hideDacStatus) {
1467
1476
  return {
1468
1477
  width: 120,
1469
1478
  pinned: res.pinPosition,
@@ -1505,14 +1514,9 @@ class GridLibraryComponent {
1505
1514
  buttons: ['reset'],
1506
1515
  },
1507
1516
  };
1508
- // }
1509
- // else {
1510
- // return;
1511
- // }
1512
1517
  }
1513
1518
  }
1514
1519
  else {
1515
- // if (!hideBtn) {
1516
1520
  return {
1517
1521
  field: res.field,
1518
1522
  headerName: res.title,
@@ -1540,9 +1544,6 @@ class GridLibraryComponent {
1540
1544
  lockPinned: true,
1541
1545
  width: res.label ? 100 : 40,
1542
1546
  };
1543
- // } else {
1544
- // return;
1545
- // }
1546
1547
  }
1547
1548
  });
1548
1549
  }
@@ -1551,7 +1552,6 @@ class GridLibraryComponent {
1551
1552
  const isAEGroup = this.userRoles.some((role) => role?.toLowerCase().includes('ae'));
1552
1553
  const isDesignManager = this.userRoles.includes(this._Design_Manager);
1553
1554
  return isAEGroup || isDesignManager ? true : false;
1554
- //return !(isAEGroup || isDesignManager);
1555
1555
  }
1556
1556
  return false;
1557
1557
  }
@@ -1644,8 +1644,8 @@ class GridLibraryComponent {
1644
1644
  }
1645
1645
  }));
1646
1646
  }
1647
- // Apply initial filter highlighting
1648
- setTimeout(() => this.updateFilteredColumnHighlighting(), 500);
1647
+ // Apply initial filter highlighting with retry mechanism
1648
+ this.applyFilterHighlightingWithRetry();
1649
1649
  // Event listeners for highlighting
1650
1650
  if (this.floatingFilter) {
1651
1651
  this.setupFilterInputListeners();
@@ -1747,11 +1747,8 @@ class GridLibraryComponent {
1747
1747
  this.gridAPI.showLoadingOverlay();
1748
1748
  this.gridColumnState = JSON.parse(response.result.gridConfig);
1749
1749
  this.setGridState();
1750
- //let manualEvent = { type: 'columnResized' };
1751
- //this.onSaveGridColumnState(manualEvent);
1752
1750
  }
1753
1751
  else {
1754
- //this.setGridState();
1755
1752
  console.log('no grid state found.');
1756
1753
  }
1757
1754
  setTimeout(() => { this.gridStateLoaded = true; this.gridAPI.hideOverlay(); }, 1000);
@@ -1784,7 +1781,6 @@ class GridLibraryComponent {
1784
1781
  this.gridService.saveColumnConfig(columnData)
1785
1782
  .pipe(takeUntil(this.unsubscribe$))
1786
1783
  .subscribe((res) => {
1787
- //this.setGridState();
1788
1784
  if (res.status == 0) {
1789
1785
  console.log('Error while saving column configuration:', res.message);
1790
1786
  }
@@ -1908,15 +1904,20 @@ class GridLibraryComponent {
1908
1904
  return;
1909
1905
  // Clear all filter inputs and highlighting
1910
1906
  this.clearFilterInputHighlighting();
1911
- // Force ag-grid to refresh all filter components
1907
+ // Force ag-grid to refresh all filter components with retry mechanism
1912
1908
  setTimeout(() => {
1913
1909
  if (this.gridAPI) {
1914
1910
  this.gridAPI.refreshHeader();
1915
- this.updateFilteredColumnHighlighting();
1911
+ // Use robust highlighting approach
1912
+ this.applyFilterHighlightingWithRetry();
1916
1913
  this.gridAPI.redrawRows();
1917
1914
  }
1918
1915
  }, 100);
1919
1916
  }
1917
+ // Public method to force refresh of filter highlighting (can be called externally when needed)
1918
+ refreshFilterHighlighting() {
1919
+ this.applyFilterHighlightingWithRetry();
1920
+ }
1920
1921
  onFirstDataRendered(e) {
1921
1922
  const storedPageNumber = localStorage.getItem('pageNumber');
1922
1923
  this.pageNumber = storedPageNumber ? parseInt(storedPageNumber) : 0;
@@ -1925,7 +1926,7 @@ class GridLibraryComponent {
1925
1926
  }
1926
1927
  this.dataLoaded = true;
1927
1928
  setTimeout(() => this.updatePaginationInfo(), 0);
1928
- setTimeout(() => this.updateFilteredColumnHighlighting(), 100);
1929
+ setTimeout(() => this.applyFilterHighlightingWithRetry(), 100);
1929
1930
  this.firstDataRendered.emit(e);
1930
1931
  }
1931
1932
  onGridReadyExcel(params) {
@@ -2006,29 +2007,64 @@ class GridLibraryComponent {
2006
2007
  updateFilteredColumnHighlighting() {
2007
2008
  if (!this.gridAPI)
2008
2009
  return;
2009
- const filterModel = this.gridAPI.getFilterModel();
2010
- const allColumns = this.gridAPI.getColumns();
2011
- if (allColumns) {
2012
- allColumns.forEach((column) => {
2013
- const columnId = column.getColId();
2014
- const isFiltered = filterModel && filterModel[columnId];
2015
- const headerElement = document.querySelector(`[col-id="${columnId}"]`);
2016
- if (headerElement) {
2017
- if (isFiltered) {
2018
- headerElement.classList.add('ag-header-cell-filtered');
2019
- }
2020
- else {
2021
- headerElement.classList.remove('ag-header-cell-filtered');
2010
+ try {
2011
+ const filterModel = this.gridAPI.getFilterModel();
2012
+ const allColumns = this.gridAPI.getColumns();
2013
+ if (allColumns) {
2014
+ allColumns.forEach((column) => {
2015
+ const columnId = column.getColId();
2016
+ const isFiltered = filterModel && filterModel[columnId];
2017
+ // Update header highlighting
2018
+ const headerElement = document.querySelector(`[col-id="${columnId}"]`);
2019
+ if (headerElement) {
2020
+ if (isFiltered) {
2021
+ headerElement.classList.add('ag-header-cell-filtered');
2022
+ }
2023
+ else {
2024
+ headerElement.classList.remove('ag-header-cell-filtered');
2025
+ }
2022
2026
  }
2023
- }
2024
- this.highlightFilterInputs(columnId, isFiltered);
2025
- });
2027
+ // Update filter input highlighting
2028
+ this.highlightFilterInputs(columnId, isFiltered);
2029
+ });
2030
+ }
2031
+ // Clear all highlighting when no filter model
2032
+ if (!filterModel || Object.keys(filterModel).length === 0) {
2033
+ this.clearFilterInputHighlighting();
2034
+ }
2035
+ this.ensureAllValuedInputsAreHighlighted();
2026
2036
  }
2027
- // If filter model is empty or null, clear all input highlighting
2028
- if (!filterModel || Object.keys(filterModel).length === 0) {
2029
- this.clearFilterInputHighlighting();
2037
+ catch (error) {
2038
+ console.warn('Error updating filter highlighting:', error);
2030
2039
  }
2031
2040
  }
2041
+ ensureAllValuedInputsAreHighlighted() {
2042
+ if (!this.floatingFilter)
2043
+ return;
2044
+ const allFilterInputs = document.querySelectorAll(`
2045
+ .ag-floating-filter-body input,
2046
+ .ag-floating-filter-body .ag-input-field-input,
2047
+ .ag-floating-filter-body .ag-text-field-input,
2048
+ .ag-floating-filter-body .ag-number-field-input,
2049
+ .ag-floating-filter-body .ag-date-field-input,
2050
+ .ag-floating-filter-body .ag-select-field-input,
2051
+ .ag-floating-filter input,
2052
+ .ag-floating-filter .ag-input-field-input,
2053
+ .ag-floating-filter .ag-text-field-input,
2054
+ .ag-floating-filter .ag-number-field-input,
2055
+ .ag-floating-filter .ag-date-field-input,
2056
+ .ag-floating-filter .ag-select-field-input
2057
+ `);
2058
+ allFilterInputs.forEach((input) => {
2059
+ const inputElement = input;
2060
+ if (inputElement.value && inputElement.value.trim() !== '') {
2061
+ inputElement.classList.add('ag-filter-input-active');
2062
+ }
2063
+ else {
2064
+ inputElement.classList.remove('ag-filter-input-active');
2065
+ }
2066
+ });
2067
+ }
2032
2068
  // Highlight filter inputs when they have values
2033
2069
  highlightFilterInputs(columnId, isFiltered) {
2034
2070
  if (!this.floatingFilter)
@@ -2093,11 +2129,20 @@ class GridLibraryComponent {
2093
2129
  return false;
2094
2130
  }
2095
2131
  setupFilterInputListeners() {
2132
+ if (this.filterHighlightingObserver) {
2133
+ this.filterHighlightingObserver.disconnect();
2134
+ }
2096
2135
  const observer = new MutationObserver((mutations) => {
2136
+ let shouldUpdateHighlighting = false;
2097
2137
  mutations.forEach((mutation) => {
2098
2138
  mutation.addedNodes.forEach((node) => {
2099
2139
  if (node.nodeType === Node.ELEMENT_NODE) {
2100
2140
  const element = node;
2141
+ if (element.classList.contains('ag-floating-filter-body') ||
2142
+ element.classList.contains('ag-floating-filter') ||
2143
+ element.querySelector('.ag-floating-filter-body, .ag-floating-filter')) {
2144
+ shouldUpdateHighlighting = true;
2145
+ }
2101
2146
  this.addInputListenersToElement(element);
2102
2147
  // Check child elements
2103
2148
  const inputs = element.querySelectorAll('input, .ag-input-field-input, .ag-text-field-input, .ag-number-field-input, .ag-date-field-input, .ag-select-field-input');
@@ -2105,18 +2150,56 @@ class GridLibraryComponent {
2105
2150
  }
2106
2151
  });
2107
2152
  });
2153
+ // Update highlighting if filter elements were added
2154
+ if (shouldUpdateHighlighting) {
2155
+ setTimeout(() => this.updateFilteredColumnHighlighting(), 50);
2156
+ }
2108
2157
  });
2109
- const gridContainer = document.querySelector('.ag-root-wrapper');
2158
+ this.filterHighlightingObserver = observer;
2159
+ // Observe the entire document body to catch all changes
2160
+ const gridContainer = document.querySelector('.ag-root-wrapper') || document.body;
2110
2161
  if (gridContainer) {
2111
2162
  observer.observe(gridContainer, {
2112
2163
  childList: true,
2113
- subtree: true
2164
+ subtree: true,
2165
+ attributes: true,
2166
+ attributeFilter: ['class', 'style']
2114
2167
  });
2115
2168
  }
2116
- setTimeout(() => {
2117
- const existingInputs = document.querySelectorAll('.ag-floating-filter-body input, .ag-floating-filter-body .ag-input-field-input, .ag-floating-filter-body .ag-text-field-input, .ag-floating-filter-body .ag-number-field-input, .ag-floating-filter-body .ag-date-field-input, .ag-floating-filter-body .ag-select-field-input');
2118
- existingInputs.forEach(input => this.addInputListener(input));
2119
- }, 1000);
2169
+ this.applyListenersToExistingInputs();
2170
+ }
2171
+ applyListenersToExistingInputs() {
2172
+ const selectors = [
2173
+ '.ag-floating-filter-body input',
2174
+ '.ag-floating-filter-body .ag-input-field-input',
2175
+ '.ag-floating-filter-body .ag-text-field-input',
2176
+ '.ag-floating-filter-body .ag-number-field-input',
2177
+ '.ag-floating-filter-body .ag-date-field-input',
2178
+ '.ag-floating-filter-body .ag-select-field-input',
2179
+ '.ag-floating-filter input',
2180
+ '.ag-floating-filter .ag-input-field-input',
2181
+ '.ag-floating-filter .ag-text-field-input',
2182
+ '.ag-floating-filter .ag-number-field-input',
2183
+ '.ag-floating-filter .ag-date-field-input',
2184
+ '.ag-floating-filter .ag-select-field-input'
2185
+ ];
2186
+ let attempts = 0;
2187
+ const maxAttempts = 5;
2188
+ const attemptInterval = 200;
2189
+ const attemptToApplyListeners = () => {
2190
+ const existingInputs = document.querySelectorAll(selectors.join(', '));
2191
+ if (existingInputs.length > 0) {
2192
+ existingInputs.forEach(input => this.addInputListener(input));
2193
+ // update highlighting for existing inputs
2194
+ setTimeout(() => this.updateFilteredColumnHighlighting(), 50);
2195
+ return;
2196
+ }
2197
+ if (attempts < maxAttempts) {
2198
+ attempts++;
2199
+ setTimeout(attemptToApplyListeners, attemptInterval * attempts);
2200
+ }
2201
+ };
2202
+ attemptToApplyListeners();
2120
2203
  }
2121
2204
  addInputListenersToElement(element) {
2122
2205
  const inputs = element.querySelectorAll('input, .ag-input-field-input, .ag-text-field-input, .ag-number-field-input, .ag-date-field-input, .ag-select-field-input');
@@ -2140,8 +2223,48 @@ class GridLibraryComponent {
2140
2223
  // First check
2141
2224
  highlightInput();
2142
2225
  }
2226
+ applyFilterHighlightingWithRetry() {
2227
+ this.filterHighlightingRetryCount = 0;
2228
+ this.attemptFilterHighlighting();
2229
+ }
2230
+ attemptFilterHighlighting() {
2231
+ if (!this.gridAPI) {
2232
+ this.scheduleRetry();
2233
+ return;
2234
+ }
2235
+ // Check if grid is ready/has columns
2236
+ const columns = this.gridAPI.getColumns();
2237
+ if (!columns || columns.length === 0) {
2238
+ this.scheduleRetry();
2239
+ return;
2240
+ }
2241
+ // Check if filter elements exist
2242
+ const filterElements = document.querySelectorAll('.ag-floating-filter-body, .ag-floating-filter');
2243
+ if (filterElements.length === 0) {
2244
+ this.scheduleRetry();
2245
+ return;
2246
+ }
2247
+ this.updateFilteredColumnHighlighting();
2248
+ this.setupFilterInputListeners();
2249
+ this.filterHighlightingRetryCount = 0;
2250
+ }
2251
+ scheduleRetry() {
2252
+ if (this.filterHighlightingRetryCount < this.MAX_RETRY_ATTEMPTS) {
2253
+ this.filterHighlightingRetryCount++;
2254
+ setTimeout(() => {
2255
+ this.attemptFilterHighlighting();
2256
+ }, this.RETRY_DELAY * this.filterHighlightingRetryCount);
2257
+ }
2258
+ else {
2259
+ console.warn('Filter highlighting retry limit reached. Some filter inputs may not be highlighted.');
2260
+ }
2261
+ }
2143
2262
  //destroy all associated subscriptions on component destroy
2144
2263
  ngOnDestroy() {
2264
+ if (this.filterHighlightingObserver) {
2265
+ this.filterHighlightingObserver.disconnect();
2266
+ this.filterHighlightingObserver = null;
2267
+ }
2145
2268
  this.unsubscribe$.next();
2146
2269
  this.unsubscribe$.complete();
2147
2270
  }