basesite-shared-grid-lib 15.10.225 → 15.10.237

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.
@@ -792,12 +792,7 @@ class OdataProvider {
792
792
  }
793
793
  Promise.race([me.cancelPromice.promise, me.callApi(query)]).then(async (x) => {
794
794
  if (!x) {
795
- if (isServerMode) {
796
- params.fail();
797
- }
798
- else {
799
- params.failCallback();
800
- }
795
+ // params.failCallback();
801
796
  return;
802
797
  }
803
798
  else {
@@ -883,13 +878,7 @@ class OdataProvider {
883
878
  }
884
879
  }
885
880
  }, (err) => {
886
- console.error('OdataProvider getRows error:', err);
887
- if (isServerMode) {
888
- params.fail();
889
- }
890
- else {
891
- params.failCallback();
892
- }
881
+ me.setResult(params, isServerMode, [], 0);
893
882
  if (this.setError) {
894
883
  this.setError(err, params);
895
884
  }
@@ -1249,7 +1238,12 @@ class GridLibraryComponent {
1249
1238
  }
1250
1239
  onSortChangedEvent(e) {
1251
1240
  this.gridColumnState = this.gridAPI.getState();
1252
- this.onSaveGridColumnState(e);
1241
+ this.saveGridState(e);
1242
+ }
1243
+ saveGridState(e) {
1244
+ if (!this.overrideColumnDefs) {
1245
+ setTimeout(() => { this.onSaveGridColumnState(e); }, 2000);
1246
+ }
1253
1247
  }
1254
1248
  ngOnInit() {
1255
1249
  this._tokenSharingService.updateToken(this.token);
@@ -1271,14 +1265,7 @@ class GridLibraryComponent {
1271
1265
  }
1272
1266
  configureDataState() {
1273
1267
  if (this.isOverride) {
1274
- // Ensure we have valid override data
1275
- if (this.overrideColumnDefs) {
1276
- this.overrideGridState(this.overrideColumnDefs);
1277
- }
1278
- else {
1279
- console.warn('Override column definitions are not available');
1280
- this.handleGridLoadingState(false);
1281
- }
1268
+ this.overrideGridState(this.overrideColumnDefs);
1282
1269
  }
1283
1270
  else {
1284
1271
  this.gridAPI.resetColumnState();
@@ -1286,88 +1273,16 @@ class GridLibraryComponent {
1286
1273
  //setTimeout(() => { this.setGridState(); }, 2000);
1287
1274
  }
1288
1275
  }
1289
- // Add method to handle loading state during grid operations
1290
- handleGridLoadingState(showLoading = true) {
1291
- if (this.enableServerSidePaging && this.gridAPI) {
1292
- if (showLoading) {
1293
- this.gridAPI.showLoadingOverlay();
1294
- }
1295
- else {
1296
- // Use setTimeout to ensure the loading state is properly managed
1297
- setTimeout(() => {
1298
- this.gridAPI.hideOverlay();
1299
- }, 100);
1300
- }
1301
- }
1302
- }
1303
- // Add method to validate grid state before applying
1304
- validateGridState(state) {
1305
- if (!state)
1306
- return false;
1307
- // Check if state has valid structure
1308
- const hasValidStructure = state && typeof state === 'object';
1309
- // Check if grid API is available
1310
- const hasGridAPI = this.gridAPI && typeof this.gridAPI.applyColumnState === 'function';
1311
- // Check if columns are available
1312
- const columns = this.gridAPI?.getColumns();
1313
- const hasColumns = columns && columns.length > 0;
1314
- console.log('Grid state validation:', {
1315
- hasValidStructure,
1316
- hasGridAPI,
1317
- hasColumns,
1318
- stateKeys: state ? Object.keys(state) : []
1319
- });
1320
- return hasValidStructure && hasGridAPI && hasColumns;
1321
- }
1322
- // Add method to ensure grid is ready before applying state
1323
- ensureGridReady() {
1324
- if (!this.isGridReady || !this.gridAPI) {
1325
- console.warn('Grid is not ready yet');
1326
- return false;
1327
- }
1328
- // Check if columns are defined
1329
- if (!this.columnDefs || this.columnDefs.length === 0) {
1330
- console.warn('Column definitions are not available');
1331
- return false;
1332
- }
1333
- return true;
1334
- }
1335
- // Add method to ensure grid has data and is properly configured
1336
- ensureGridDataReady() {
1337
- // Check if we have row data or if server-side paging is enabled
1338
- if (this.enableServerSidePaging) {
1339
- return true; // Server-side paging will handle data loading
1340
- }
1341
- // For client-side, check if we have row data
1342
- if (!this.rowData || (Array.isArray(this.rowData) && this.rowData.length === 0)) {
1343
- console.warn('No row data available for client-side grid');
1344
- return false;
1345
- }
1346
- return true;
1347
- }
1348
1276
  ngOnChanges(changes) {
1349
1277
  this.gridStateLoaded = false;
1350
- // Show loading state when changes occur
1351
- this.handleGridLoadingState(true);
1352
1278
  if (changes['userRoles']?.currentValue) {
1353
1279
  if (this.initialColumnDef?.length > 0 && this.userRoles?.length > 0) {
1354
1280
  this.columnDefs = this._mapColumnDef(this.initialColumnDef, this.userRoles);
1355
1281
  }
1356
1282
  }
1357
- // Handle override column definitions changes
1358
- if (changes['overrideColumnDefs']?.currentValue) {
1359
- console.log('Override column definitions changed:', changes['overrideColumnDefs'].currentValue);
1360
- if (this.isGridReady) {
1361
- this.configureDataState();
1362
- }
1363
- }
1364
1283
  if (this.isGridReady) {
1365
1284
  this.configureDataState();
1366
1285
  }
1367
- // Hide loading state after a short delay to allow grid to process changes
1368
- setTimeout(() => {
1369
- this.handleGridLoadingState(false);
1370
- }, 500);
1371
1286
  }
1372
1287
  getColDef() {
1373
1288
  if (this.gridId && this.loggedInUser) {
@@ -1382,9 +1297,6 @@ class GridLibraryComponent {
1382
1297
  this.exportColumnsList = response.result;
1383
1298
  //changes done by raghav
1384
1299
  if (this.isOverride) {
1385
- // Set column definitions first, then apply override state
1386
- this.columnDefs = coldef;
1387
- this.gridColumns = coldef;
1388
1300
  this.overrideGridState(this.overrideColumnDefs);
1389
1301
  }
1390
1302
  else {
@@ -1396,19 +1308,11 @@ class GridLibraryComponent {
1396
1308
  }
1397
1309
  else {
1398
1310
  console.log('ColDef Read Error=>', response.message);
1399
- // Ensure loading state is cleared on error
1400
- this.handleGridLoadingState(false);
1401
1311
  }
1402
- }, (error) => {
1403
- console.error('Error loading column definitions:', error);
1404
- // Ensure loading state is cleared on error
1405
- this.handleGridLoadingState(false);
1406
1312
  });
1407
1313
  }
1408
1314
  else {
1409
1315
  console.log('Please pass valid GridId and loggedIn user Id');
1410
- // Ensure loading state is cleared when required parameters are missing
1411
- this.handleGridLoadingState(false);
1412
1316
  }
1413
1317
  }
1414
1318
  _getColumnVisiblityStatus(column, userRoles) {
@@ -1733,256 +1637,59 @@ class GridLibraryComponent {
1733
1637
  this.isGridReady = true;
1734
1638
  }
1735
1639
  setGridState() {
1736
- try {
1737
- if (this.gridColumns && this.gridColumns.length > 0) {
1738
- var arrIndex = this.gridColumns.findIndex((x) => x.field == "createDac");
1739
- if (this.gridId == 1 && !this.canCreateDac(this.userRoles, "createDac")) {
1740
- if (arrIndex > -1)
1741
- this.gridColumns.splice(arrIndex, 1);
1742
- var dacStatusIndex = this.gridColumns.findIndex((x) => x.field == "dacStatus");
1743
- if (dacStatusIndex > -1)
1744
- this.gridColumns.splice(dacStatusIndex, 1);
1745
- this.columnDefs = this.gridColumns;
1746
- }
1747
- if (this.gridId == 1 && this.canCreateDac(this.userRoles, "createDac")) {
1748
- this.gridColumns[arrIndex].hide = false;
1749
- }
1640
+ if (this.gridColumns && this.gridColumns.length > 0) {
1641
+ var arrIndex = this.gridColumns.findIndex((x) => x.field == "createDac");
1642
+ if (this.gridId == 1 && !this.canCreateDac(this.userRoles, "createDac")) {
1643
+ if (arrIndex > -1)
1644
+ this.gridColumns.splice(arrIndex, 1);
1645
+ var dacStatusIndex = this.gridColumns.findIndex((x) => x.field == "dacStatus");
1646
+ if (dacStatusIndex > -1)
1647
+ this.gridColumns.splice(dacStatusIndex, 1);
1750
1648
  this.columnDefs = this.gridColumns;
1751
1649
  }
1752
- if (this.gridColumnState && this.gridAPI) {
1753
- // Apply column sizing if available
1754
- if (this.gridColumnState.columnSizing?.columnSizingModel) {
1755
- try {
1756
- this.gridAPI.applyColumnState({
1757
- state: this.gridColumnState.columnSizing.columnSizingModel,
1758
- applyOrder: true
1759
- });
1760
- }
1761
- catch (error) {
1762
- console.warn('Error applying column sizing state:', error);
1763
- }
1764
- }
1765
- // Apply sorting if available
1766
- if (this.gridColumnState.sort?.sortModel) {
1767
- try {
1768
- this.gridAPI.applyColumnState({
1769
- state: this.gridColumnState.sort.sortModel
1770
- });
1771
- }
1772
- catch (error) {
1773
- console.warn('Error applying sort state:', error);
1774
- }
1775
- }
1776
- // Apply filters if available
1777
- if (this.gridColumnState.filter?.filterModel) {
1778
- try {
1779
- var filterModel = this.gridColumnState.filter.filterModel;
1780
- this.gridAPI.setFilterModel(filterModel);
1781
- }
1782
- catch (error) {
1783
- console.warn('Error applying filter state:', error);
1784
- }
1785
- }
1786
- // Apply column visibility if available
1787
- if (this.gridColumnState.columnVisibility?.hiddenColIds) {
1788
- try {
1789
- var hiddenColumns = this.gridColumnState.columnVisibility.hiddenColIds;
1790
- this.gridAPI.setColumnsVisible(hiddenColumns, false);
1791
- }
1792
- catch (error) {
1793
- console.warn('Error applying column visibility state:', error);
1794
- }
1795
- }
1796
- }
1797
- else {
1798
- // Fallback: apply basic column sizing
1799
- var columns = this.gridAPI?.getColumns();
1800
- if (columns && columns.length > 0) {
1801
- if (columns.length > 15) {
1802
- const allColumnIds = [];
1803
- this.gridAPI.getColumns().forEach((column) => {
1804
- allColumnIds.push(column.getId());
1805
- });
1806
- this.gridAPI.autoSizeColumns(allColumnIds, false);
1807
- }
1808
- else {
1809
- this.gridAPI.sizeColumnsToFit();
1810
- }
1811
- }
1650
+ if (this.gridId == 1 && this.canCreateDac(this.userRoles, "createDac")) {
1651
+ this.gridColumns[arrIndex].hide = false;
1812
1652
  }
1653
+ this.columnDefs = this.gridColumns;
1813
1654
  }
1814
- catch (error) {
1815
- console.error('Error in setGridState:', error);
1816
- // Ensure loading state is cleared on error
1817
- this.handleGridLoadingState(false);
1818
- }
1819
- }
1820
- overrideGridState(overrideStateData) {
1821
- try {
1822
- console.log('Applying override grid state:', overrideStateData);
1823
- // Debug grid state
1824
- this.debugGridState();
1825
- // Ensure grid is ready before applying state
1826
- if (!this.ensureGridReady()) {
1827
- console.warn('Grid is not ready, deferring override state application');
1828
- // Defer the application until grid is ready
1829
- setTimeout(() => {
1830
- this.overrideGridState(overrideStateData);
1831
- }, 500);
1832
- return;
1655
+ if (this.gridColumnState) {
1656
+ this.gridAPI?.applyColumnState({ state: this.gridColumnState.columnSizing?.columnSizingModel, applyOrder: true });
1657
+ if (this.gridColumnState.sort) {
1658
+ this.gridAPI?.applyColumnState({ state: this.gridColumnState.sort.sortModel });
1833
1659
  }
1834
- // Ensure column definitions are set in the grid
1835
- if (this.columnDefs && this.columnDefs.length > 0 && this.gridAPI) {
1836
- // Set column definitions in the grid if not already set
1837
- const currentColDefs = this.gridAPI.getColumnDefs();
1838
- if (!currentColDefs || currentColDefs.length === 0) {
1839
- console.log('Setting column definitions in grid before applying override state');
1840
- this.gridAPI.setColumnDefs(this.columnDefs);
1841
- // Wait a bit for the columns to be set
1842
- setTimeout(() => {
1843
- this.applyOverrideState(overrideStateData);
1844
- }, 100);
1845
- return;
1846
- }
1660
+ if (this.gridColumnState.filter) {
1661
+ var filterModel = this.gridColumnState.filter.filterModel;
1662
+ this.gridAPI?.setFilterModel(filterModel);
1847
1663
  }
1848
- // Ensure grid has data ready
1849
- if (!this.ensureGridDataReady()) {
1850
- console.warn('Grid data is not ready, deferring override state application');
1851
- setTimeout(() => {
1852
- this.overrideGridState(overrideStateData);
1853
- }, 1000);
1854
- return;
1664
+ if (this.gridColumnState.columnVisibility) {
1665
+ var hiddenColumns = this.gridColumnState.columnVisibility.hiddenColIds;
1666
+ this.gridAPI?.setColumnsVisible(hiddenColumns, false);
1855
1667
  }
1856
- // Apply the override state
1857
- this.applyOverrideState(overrideStateData);
1858
1668
  }
1859
- catch (error) {
1860
- console.error('Error in overrideGridState:', error);
1861
- this.handleGridLoadingState(false);
1862
- }
1863
- }
1864
- // Separate method to apply the actual override state
1865
- applyOverrideState(overrideStateData) {
1866
- try {
1867
- // Parse the override state data
1868
- const parsedState = JSON.parse(overrideStateData);
1869
- // Validate the state before applying
1870
- if (!this.validateGridState(parsedState)) {
1871
- console.warn('Invalid grid state, skipping override');
1872
- this.handleGridLoadingState(false);
1873
- return;
1874
- }
1875
- // Store the override state
1876
- this.gridColumnState = parsedState;
1877
- // Apply the state without resetting column state first
1878
- if (parsedState) {
1879
- // Apply column sizing if available
1880
- if (parsedState.columnSizing?.columnSizingModel) {
1881
- try {
1882
- this.gridAPI?.applyColumnState({
1883
- state: parsedState.columnSizing.columnSizingModel,
1884
- applyOrder: true
1885
- });
1886
- }
1887
- catch (error) {
1888
- console.warn('Error applying column sizing in override:', error);
1889
- }
1890
- }
1891
- // Apply sorting if available
1892
- if (parsedState.sort?.sortModel) {
1893
- try {
1894
- this.gridAPI?.applyColumnState({
1895
- state: parsedState.sort.sortModel
1896
- });
1897
- }
1898
- catch (error) {
1899
- console.warn('Error applying sort in override:', error);
1900
- }
1901
- }
1902
- // Apply filters if available
1903
- if (parsedState.filter?.filterModel) {
1904
- try {
1905
- this.gridAPI?.setFilterModel(parsedState.filter.filterModel);
1906
- }
1907
- catch (error) {
1908
- console.warn('Error applying filter in override:', error);
1909
- }
1669
+ else {
1670
+ var columns = this.gridAPI.getColumns();
1671
+ if (columns && columns.length > 0) {
1672
+ if (columns.length > 15) {
1673
+ const allColumnIds = [];
1674
+ this.gridAPI.getColumns().forEach((column) => {
1675
+ allColumnIds.push(column.getId());
1676
+ });
1677
+ this.gridAPI.autoSizeColumns(allColumnIds, false);
1910
1678
  }
1911
- // Apply column visibility if available
1912
- if (parsedState.columnVisibility?.hiddenColIds) {
1913
- try {
1914
- this.gridAPI?.setColumnsVisible(parsedState.columnVisibility.hiddenColIds, false);
1915
- }
1916
- catch (error) {
1917
- console.warn('Error applying column visibility in override:', error);
1918
- }
1679
+ else {
1680
+ this.gridAPI.sizeColumnsToFit();
1919
1681
  }
1920
1682
  }
1921
- // Refresh grid after state is applied
1922
- setTimeout(() => {
1923
- this.refreshGridAfterStateChange();
1924
- this.handleGridLoadingState(false);
1925
- }, 100);
1926
- }
1927
- catch (error) {
1928
- console.error('Error applying override grid state:', error);
1929
- this.handleGridLoadingState(false);
1930
- // Fallback: refresh grid
1931
- setTimeout(() => {
1932
- this.refreshGridAfterStateChange();
1933
- }, 100);
1934
1683
  }
1935
1684
  }
1936
- // Add method to refresh grid after state changes
1937
- refreshGridAfterStateChange() {
1938
- if (this.gridAPI) {
1939
- // Force grid to refresh
1940
- this.gridAPI.refreshCells();
1941
- this.gridAPI.redrawRows();
1942
- // Ensure overlay is hidden
1943
- this.gridAPI.hideOverlay();
1944
- // Auto-size columns
1945
- setTimeout(() => {
1946
- this.gridAPI.autoSizeAllColumns();
1947
- }, 200);
1948
- }
1949
- }
1950
- // Add method to ensure grid is properly initialized with data
1951
- ensureGridInitialized() {
1952
- if (!this.gridAPI)
1953
- return false;
1954
- // Check if grid has columns
1955
- const columns = this.gridAPI.getColumns();
1956
- if (!columns || columns.length === 0) {
1957
- console.warn('Grid has no columns, cannot apply override state');
1958
- return false;
1959
- }
1960
- // For client-side grids, ensure we have data
1961
- if (!this.enableServerSidePaging) {
1962
- if (!this.rowData || (Array.isArray(this.rowData) && this.rowData.length === 0)) {
1963
- console.warn('Client-side grid has no data');
1964
- return false;
1965
- }
1966
- }
1967
- return true;
1968
- }
1969
- // Add debug method to help troubleshoot white screen issues
1970
- debugGridState() {
1971
- console.log('=== Grid Debug Info ===');
1972
- console.log('isGridReady:', this.isGridReady);
1973
- console.log('gridAPI exists:', !!this.gridAPI);
1974
- console.log('columnDefs length:', this.columnDefs?.length);
1975
- console.log('gridColumns length:', this.gridColumns?.length);
1976
- console.log('rowData length:', this.rowData?.length);
1977
- console.log('enableServerSidePaging:', this.enableServerSidePaging);
1978
- console.log('isOverride:', this.isOverride);
1979
- console.log('overrideColumnDefs:', this.overrideColumnDefs);
1980
- if (this.gridAPI) {
1981
- const columns = this.gridAPI.getColumns();
1982
- console.log('Grid columns count:', columns?.length);
1983
- console.log('Grid column definitions:', this.gridAPI.getColumnDefs()?.length);
1984
- }
1985
- console.log('========================');
1685
+ overrideGridState(overrideStateData) {
1686
+ this.gridAPI.showLoadingOverlay();
1687
+ this.gridAPI.resetColumnState();
1688
+ this.gridColumnState = JSON.parse(overrideStateData);
1689
+ this.setGridState();
1690
+ this.gridAPI.autoSizeAllColumns();
1691
+ setTimeout(() => { this.gridAPI.autoSizeAllColumns(); }, 2000);
1692
+ setTimeout(() => { this.gridAPI.hideOverlay(); }, 500);
1986
1693
  }
1987
1694
  getGridState() {
1988
1695
  this.gridStateLoaded = false;
@@ -1996,13 +1703,10 @@ class GridLibraryComponent {
1996
1703
  response.result.gridConfig) {
1997
1704
  this.defaultGridState = JSON.parse(response.result.gridConfig);
1998
1705
  if (!this.isOverride) {
1706
+ this.gridAPI.showLoadingOverlay();
1999
1707
  this.gridColumnState = JSON.parse(response.result.gridConfig);
2000
1708
  this.setGridState();
2001
- setTimeout(() => {
2002
- this.gridStateLoaded = true;
2003
- // Ensure loading state is properly managed after grid state is loaded
2004
- this.handleGridLoadingState(false);
2005
- }, 3000);
1709
+ setTimeout(() => { this.gridStateLoaded = true; this.gridAPI.hideOverlay(); }, 1000);
2006
1710
  //let manualEvent = { type: 'columnResized' };
2007
1711
  //this.onSaveGridColumnState(manualEvent);
2008
1712
  }
@@ -2010,13 +1714,7 @@ class GridLibraryComponent {
2010
1714
  else {
2011
1715
  //this.setGridState();
2012
1716
  console.log('Error while loading grid state');
2013
- // Ensure loading state is cleared even on error
2014
- this.handleGridLoadingState(false);
2015
1717
  }
2016
- }, (error) => {
2017
- console.error('Error loading grid state:', error);
2018
- // Ensure loading state is cleared on error
2019
- this.handleGridLoadingState(false);
2020
1718
  });
2021
1719
  }
2022
1720
  }
@@ -2117,7 +1815,7 @@ class GridLibraryComponent {
2117
1815
  this.selectionChanged.emit(e);
2118
1816
  }
2119
1817
  onFilterChanged(e) {
2120
- this.onSaveGridColumnState(e);
1818
+ this.saveGridState(e);
2121
1819
  this.filterChanged.emit(e);
2122
1820
  }
2123
1821
  onFirstDataRendered(e) {
@@ -2207,10 +1905,6 @@ class GridLibraryComponent {
2207
1905
  //custom pagination ends...
2208
1906
  //destroy all associated subscriptions on component destroy
2209
1907
  ngOnDestroy() {
2210
- // Ensure loading state is cleared when component is destroyed
2211
- if (this.gridAPI) {
2212
- this.gridAPI.hideOverlay();
2213
- }
2214
1908
  this.unsubscribe$.next();
2215
1909
  this.unsubscribe$.complete();
2216
1910
  }
@@ -2235,10 +1929,10 @@ class GridLibraryComponent {
2235
1929
  [cacheBlockSize]="cacheBlockSize"
2236
1930
  [maxConcurrentDatasourceRequests]="1"
2237
1931
  [blockLoadDebounceMillis]="100"
2238
- (columnVisible)="onSaveGridColumnState($event)"
2239
- (columnPinned)="onSaveGridColumnState($event)"
2240
- (columnResized)="onSaveGridColumnState($event)"
2241
- (columnMoved)="onSaveGridColumnState($event)"
1932
+ (columnVisible)="saveGridState($event)"
1933
+ (columnPinned)="saveGridState($event)"
1934
+ (columnResized)="saveGridState($event)"
1935
+ (columnMoved)="saveGridState($event)"
2242
1936
  (sortChanged)="onSortChangedEvent($event)"
2243
1937
  [rowMultiSelectWithClick]="rowMultiSelectWithClick"
2244
1938
  [getContextMenuItems]="getContextMenuItems"
@@ -2317,10 +2011,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
2317
2011
  [cacheBlockSize]="cacheBlockSize"
2318
2012
  [maxConcurrentDatasourceRequests]="1"
2319
2013
  [blockLoadDebounceMillis]="100"
2320
- (columnVisible)="onSaveGridColumnState($event)"
2321
- (columnPinned)="onSaveGridColumnState($event)"
2322
- (columnResized)="onSaveGridColumnState($event)"
2323
- (columnMoved)="onSaveGridColumnState($event)"
2014
+ (columnVisible)="saveGridState($event)"
2015
+ (columnPinned)="saveGridState($event)"
2016
+ (columnResized)="saveGridState($event)"
2017
+ (columnMoved)="saveGridState($event)"
2324
2018
  (sortChanged)="onSortChangedEvent($event)"
2325
2019
  [rowMultiSelectWithClick]="rowMultiSelectWithClick"
2326
2020
  [getContextMenuItems]="getContextMenuItems"