basesite-shared-grid-lib 15.10.265 → 15.10.282

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.
@@ -1065,10 +1065,10 @@ class FillCellRendererComponent {
1065
1065
  <span class="status-fill-cell text-white" *ngIf="params.value && params.field === 'completionStatus'" [ngStyle]="{'background': rowData.pocIndicator? rowData.pocIndicator:'#fff'}" >
1066
1066
  {{ params.value }}
1067
1067
  </span>
1068
- <span class="status-fill-cell text-white" *ngIf="params.value && params.field === 'funding'" [ngStyle]="{'background': rowData.fundingIndicator? rowData.fundingIndicator:'#fff'}" >
1068
+ <span class="status-fill-cell" *ngIf="params.value && params.field === 'funding'">
1069
1069
  {{ params.value }}
1070
1070
  </span>
1071
- <span class="status-fill-cell text-white" *ngIf="params.value && params.field === 'layout'" [ngStyle]="{'background': rowData.layoutIndicator? rowData.layoutIndicator:'#fff'}" >
1071
+ <span class="status-fill-cell" *ngIf="params.value && params.field === 'layout'" >
1072
1072
  {{ params.value }}
1073
1073
  </span>
1074
1074
  <span class="info-fill-cell text-white" *ngIf="params.value && params.field === 'facilityName'" [ngStyle]="{'background': 'var(--primary)'}" >
@@ -1091,10 +1091,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
1091
1091
  <span class="status-fill-cell text-white" *ngIf="params.value && params.field === 'completionStatus'" [ngStyle]="{'background': rowData.pocIndicator? rowData.pocIndicator:'#fff'}" >
1092
1092
  {{ params.value }}
1093
1093
  </span>
1094
- <span class="status-fill-cell text-white" *ngIf="params.value && params.field === 'funding'" [ngStyle]="{'background': rowData.fundingIndicator? rowData.fundingIndicator:'#fff'}" >
1094
+ <span class="status-fill-cell" *ngIf="params.value && params.field === 'funding'">
1095
1095
  {{ params.value }}
1096
1096
  </span>
1097
- <span class="status-fill-cell text-white" *ngIf="params.value && params.field === 'layout'" [ngStyle]="{'background': rowData.layoutIndicator? rowData.layoutIndicator:'#fff'}" >
1097
+ <span class="status-fill-cell" *ngIf="params.value && params.field === 'layout'" >
1098
1098
  {{ params.value }}
1099
1099
  </span>
1100
1100
  <span class="info-fill-cell text-white" *ngIf="params.value && params.field === 'facilityName'" [ngStyle]="{'background': 'var(--primary)'}" >
@@ -1203,6 +1203,7 @@ class GridLibraryComponent {
1203
1203
  };
1204
1204
  // Custom right click Context Menu to support custom excel exports
1205
1205
  this.getContextMenuItems = (params) => {
1206
+ return [];
1206
1207
  let res = [
1207
1208
  'cut',
1208
1209
  'copy',
@@ -1250,7 +1251,9 @@ class GridLibraryComponent {
1250
1251
  }
1251
1252
  saveGridState(e) {
1252
1253
  if (!this.overrideColumnDefs) {
1253
- setTimeout(() => { this.onSaveGridColumnState(e); }, 2000);
1254
+ //setTimeout(() => {
1255
+ this.onSaveGridColumnState(e);
1256
+ //}, 2000)
1254
1257
  }
1255
1258
  }
1256
1259
  ngOnInit() {
@@ -1389,6 +1392,7 @@ class GridLibraryComponent {
1389
1392
  }
1390
1393
  else if (res.columnType === 'date') {
1391
1394
  return {
1395
+ width: 120,
1392
1396
  pinned: res.pinPosition,
1393
1397
  field: res.field,
1394
1398
  headerName: res.title,
@@ -1421,6 +1425,7 @@ class GridLibraryComponent {
1421
1425
  }
1422
1426
  else if (res.columnType === 'fill') {
1423
1427
  return {
1428
+ width: 120,
1424
1429
  pinned: res.pinPosition,
1425
1430
  field: res.field,
1426
1431
  headerName: res.title,
@@ -1460,6 +1465,7 @@ class GridLibraryComponent {
1460
1465
  else {
1461
1466
  // if (!hideDacStatus) {
1462
1467
  return {
1468
+ width: 120,
1463
1469
  pinned: res.pinPosition,
1464
1470
  field: res.field,
1465
1471
  headerName: res.title,
@@ -1579,7 +1585,6 @@ class GridLibraryComponent {
1579
1585
  return `${serverUrl}${options}`;
1580
1586
  }
1581
1587
  onGridReady(params) {
1582
- //this.gridPageSize = this.pageSize;
1583
1588
  this.gridAPI = params.api;
1584
1589
  if (this.enableServerSidePaging == true) {
1585
1590
  // Show loading overlay immediately when server-side paging is enabled
@@ -1598,11 +1603,9 @@ class GridLibraryComponent {
1598
1603
  const url = this.setExternalFilters(options);
1599
1604
  console.log('Server-side API call:', url);
1600
1605
  localStorage.setItem('ServerSideUrl', url);
1601
- // Create a timeout promise
1602
1606
  const timeoutPromise = new Promise((_, reject) => {
1603
1607
  setTimeout(() => reject(new Error('API request timeout')), API_TIMEOUT);
1604
1608
  });
1605
- // Create the fetch promise
1606
1609
  const fetchPromise = fetch(url, {
1607
1610
  headers: reqHeaders,
1608
1611
  })
@@ -1641,6 +1644,12 @@ class GridLibraryComponent {
1641
1644
  }
1642
1645
  }));
1643
1646
  }
1647
+ // Apply initial filter highlighting
1648
+ setTimeout(() => this.updateFilteredColumnHighlighting(), 500);
1649
+ // Event listeners for highlighting
1650
+ if (this.floatingFilter) {
1651
+ this.setupFilterInputListeners();
1652
+ }
1644
1653
  }
1645
1654
  setGridState() {
1646
1655
  if (this.gridColumns && this.gridColumns.length > 0) {
@@ -1658,6 +1667,7 @@ class GridLibraryComponent {
1658
1667
  }
1659
1668
  this.columnDefs = this.gridColumns;
1660
1669
  }
1670
+ debugger;
1661
1671
  if (this.gridColumnState) {
1662
1672
  this.gridAPI?.applyColumnState({ state: this.gridColumnState.columnSizing?.columnSizingModel, applyOrder: true });
1663
1673
  if (this.gridColumnState.sort) {
@@ -1666,35 +1676,61 @@ class GridLibraryComponent {
1666
1676
  if (this.gridColumnState.filter) {
1667
1677
  var filterModel = this.gridColumnState.filter.filterModel;
1668
1678
  this.gridAPI?.setFilterModel(filterModel);
1679
+ // Apply highlighting after setting filter model
1680
+ setTimeout(() => this.updateFilteredColumnHighlighting(), 100);
1669
1681
  }
1670
1682
  if (this.gridColumnState.columnVisibility) {
1671
1683
  var hiddenColumns = this.gridColumnState.columnVisibility.hiddenColIds;
1672
1684
  this.gridAPI?.setColumnsVisible(hiddenColumns, false);
1673
1685
  }
1686
+ this.applyPinnedColumnState(this.gridColumnState);
1674
1687
  }
1675
- else {
1676
- var columns = this.gridAPI.getColumns();
1677
- if (columns && columns.length > 0) {
1678
- if (columns.length > 15) {
1679
- const allColumnIds = [];
1680
- this.gridAPI.getColumns().forEach((column) => {
1681
- allColumnIds.push(column.getId());
1682
- });
1683
- this.gridAPI.autoSizeColumns(allColumnIds, false);
1684
- }
1685
- else {
1686
- this.gridAPI.sizeColumnsToFit();
1687
- }
1688
- }
1688
+ //else {
1689
+ // var columns = this.gridAPI.getColumns();
1690
+ // if (columns && columns.length > 0) {
1691
+ // if (columns.length > 15) {
1692
+ // const allColumnIds: string[] = [];
1693
+ // this.gridAPI!.getColumns()!.forEach((column: any) => {
1694
+ // allColumnIds.push(column.getId());
1695
+ // });
1696
+ // this.gridAPI.autoSizeColumns(allColumnIds, false);
1697
+ // } else {
1698
+ // this.gridAPI.sizeColumnsToFit();
1699
+ // }
1700
+ // }
1701
+ //}
1702
+ }
1703
+ applyPinnedColumnState(gridState) {
1704
+ const pinnedMap = {};
1705
+ for (const colId of gridState.columnPinning?.leftColIds || []) {
1706
+ pinnedMap[colId] = 'left';
1707
+ }
1708
+ for (const colId of gridState.columnPinning?.rightColIds || []) {
1709
+ pinnedMap[colId] = 'right';
1689
1710
  }
1711
+ // Create a map of column widths
1712
+ const widthMap = new Map((gridState.columnSizing?.columnSizingModel || []).map((c) => [c.colId, c.width]));
1713
+ // Merge all into a final state array
1714
+ const columnState = (gridState.columnOrder?.orderedColIds || []).map((colId) => ({
1715
+ colId: colId,
1716
+ pinned: pinnedMap[colId] || null,
1717
+ width: widthMap.get(colId),
1718
+ hide: gridState.columnVisibility?.hiddenColIds?.includes(colId) || false,
1719
+ }));
1720
+ // Apply the full column state
1721
+ this.gridAPI.applyColumnState({
1722
+ state: columnState,
1723
+ applyOrder: true
1724
+ });
1690
1725
  }
1691
1726
  overrideGridState(overrideStateData) {
1692
1727
  this.gridAPI.showLoadingOverlay();
1693
1728
  this.gridAPI.resetColumnState();
1729
+ this.gridAPI.setFilterModel(null);
1694
1730
  this.gridColumnState = JSON.parse(overrideStateData);
1695
1731
  this.setGridState();
1696
- this.gridAPI.autoSizeAllColumns();
1697
- setTimeout(() => { this.gridAPI.autoSizeAllColumns(); }, 2000);
1732
+ //this.gridAPI.autoSizeAllColumns();
1733
+ //setTimeout(() => { this.gridAPI.autoSizeAllColumns(); }, 2000);
1698
1734
  setTimeout(() => { this.gridAPI.hideOverlay(); }, 500);
1699
1735
  }
1700
1736
  getGridState() {
@@ -1711,7 +1747,6 @@ class GridLibraryComponent {
1711
1747
  this.gridAPI.showLoadingOverlay();
1712
1748
  this.gridColumnState = JSON.parse(response.result.gridConfig);
1713
1749
  this.setGridState();
1714
- setTimeout(() => { this.gridStateLoaded = true; this.gridAPI.hideOverlay(); }, 1000);
1715
1750
  //let manualEvent = { type: 'columnResized' };
1716
1751
  //this.onSaveGridColumnState(manualEvent);
1717
1752
  }
@@ -1719,6 +1754,7 @@ class GridLibraryComponent {
1719
1754
  //this.setGridState();
1720
1755
  console.log('no grid state found.');
1721
1756
  }
1757
+ setTimeout(() => { this.gridStateLoaded = true; this.gridAPI.hideOverlay(); }, 1000);
1722
1758
  if (this.overrideColumnDefs != null && this.overrideColumnDefs != undefined) {
1723
1759
  this.gridStateLoaded$.next(true);
1724
1760
  }
@@ -1823,6 +1859,63 @@ class GridLibraryComponent {
1823
1859
  onFilterChanged(e) {
1824
1860
  this.saveGridState(e);
1825
1861
  this.filterChanged.emit(e);
1862
+ this.updateFilteredColumnHighlighting();
1863
+ }
1864
+ clearFilterInputHighlighting() {
1865
+ if (!this.floatingFilter || !this.gridAPI)
1866
+ return;
1867
+ const allSelectors = [
1868
+ '.ag-floating-filter-body input',
1869
+ '.ag-floating-filter-body .ag-input-field-input',
1870
+ '.ag-floating-filter-body .ag-text-field-input',
1871
+ '.ag-floating-filter-body .ag-number-field-input',
1872
+ '.ag-floating-filter-body .ag-date-field-input',
1873
+ '.ag-floating-filter-body .ag-select-field-input',
1874
+ '.ag-floating-filter input',
1875
+ '.ag-floating-filter .ag-input-field-input',
1876
+ '.ag-floating-filter .ag-text-field-input',
1877
+ '.ag-floating-filter .ag-number-field-input',
1878
+ '.ag-floating-filter .ag-date-field-input',
1879
+ '.ag-floating-filter .ag-select-field-input'
1880
+ ];
1881
+ allSelectors.forEach(selector => {
1882
+ const inputs = document.querySelectorAll(selector);
1883
+ inputs.forEach((input) => {
1884
+ const inputElement = input;
1885
+ if (inputElement.value !== undefined) {
1886
+ inputElement.value = '';
1887
+ }
1888
+ // Remove highlighting
1889
+ inputElement.classList.remove('ag-filter-input-active');
1890
+ const inputEvent = new Event('input', { bubbles: true });
1891
+ const changeEvent = new Event('change', { bubbles: true });
1892
+ inputElement.dispatchEvent(inputEvent);
1893
+ inputElement.dispatchEvent(changeEvent);
1894
+ });
1895
+ });
1896
+ const filterContainers = document.querySelectorAll('.ag-floating-filter-body, .ag-floating-filter');
1897
+ filterContainers.forEach(container => {
1898
+ container.classList.remove('ag-filter-input-active');
1899
+ });
1900
+ setTimeout(() => {
1901
+ if (this.gridAPI) {
1902
+ this.gridAPI.redrawRows();
1903
+ }
1904
+ }, 50);
1905
+ }
1906
+ handleExternalFilterReset() {
1907
+ if (!this.gridAPI)
1908
+ return;
1909
+ // Clear all filter inputs and highlighting
1910
+ this.clearFilterInputHighlighting();
1911
+ // Force ag-grid to refresh all filter components
1912
+ setTimeout(() => {
1913
+ if (this.gridAPI) {
1914
+ this.gridAPI.refreshHeader();
1915
+ this.updateFilteredColumnHighlighting();
1916
+ this.gridAPI.redrawRows();
1917
+ }
1918
+ }, 100);
1826
1919
  }
1827
1920
  onFirstDataRendered(e) {
1828
1921
  const storedPageNumber = localStorage.getItem('pageNumber');
@@ -1832,6 +1925,7 @@ class GridLibraryComponent {
1832
1925
  }
1833
1926
  this.dataLoaded = true;
1834
1927
  setTimeout(() => this.updatePaginationInfo(), 0);
1928
+ setTimeout(() => this.updateFilteredColumnHighlighting(), 100);
1835
1929
  this.firstDataRendered.emit(e);
1836
1930
  }
1837
1931
  onGridReadyExcel(params) {
@@ -1909,6 +2003,143 @@ class GridLibraryComponent {
1909
2003
  }
1910
2004
  }
1911
2005
  //custom pagination ends...
2006
+ updateFilteredColumnHighlighting() {
2007
+ if (!this.gridAPI)
2008
+ 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');
2022
+ }
2023
+ }
2024
+ this.highlightFilterInputs(columnId, isFiltered);
2025
+ });
2026
+ }
2027
+ // If filter model is empty or null, clear all input highlighting
2028
+ if (!filterModel || Object.keys(filterModel).length === 0) {
2029
+ this.clearFilterInputHighlighting();
2030
+ }
2031
+ }
2032
+ // Highlight filter inputs when they have values
2033
+ highlightFilterInputs(columnId, isFiltered) {
2034
+ if (!this.floatingFilter)
2035
+ return;
2036
+ const selectors = [
2037
+ `[col-id="${columnId}"] .ag-floating-filter-body input`,
2038
+ `[col-id="${columnId}"] .ag-floating-filter-body .ag-input-field-input`,
2039
+ `[col-id="${columnId}"] .ag-floating-filter-body .ag-text-field-input`,
2040
+ `[col-id="${columnId}"] .ag-floating-filter-body .ag-number-field-input`,
2041
+ `[col-id="${columnId}"] .ag-floating-filter-body .ag-date-field-input`,
2042
+ `[col-id="${columnId}"] .ag-floating-filter-body .ag-select-field-input`
2043
+ ];
2044
+ selectors.forEach(selector => {
2045
+ const inputs = document.querySelectorAll(selector);
2046
+ inputs.forEach((input) => {
2047
+ const inputElement = input;
2048
+ if (isFiltered) {
2049
+ inputElement.classList.add('ag-filter-input-active');
2050
+ }
2051
+ else {
2052
+ inputElement.classList.remove('ag-filter-input-active');
2053
+ }
2054
+ });
2055
+ });
2056
+ // Check for filter values in the filter model
2057
+ if (isFiltered) {
2058
+ const filterModel = this.gridAPI.getFilterModel();
2059
+ const columnFilter = filterModel[columnId];
2060
+ if (columnFilter) {
2061
+ const hasValue = this.filterHasValue(columnFilter);
2062
+ if (hasValue) {
2063
+ const valueInputs = document.querySelectorAll(`[col-id="${columnId}"] .ag-floating-filter-body input[value], [col-id="${columnId}"] .ag-floating-filter-body .ag-input-field-input[value]`);
2064
+ valueInputs.forEach((input) => {
2065
+ const inputElement = input;
2066
+ if (inputElement.value && inputElement.value.trim() !== '') {
2067
+ inputElement.classList.add('ag-filter-input-active');
2068
+ }
2069
+ });
2070
+ }
2071
+ }
2072
+ }
2073
+ }
2074
+ filterHasValue(filter) {
2075
+ if (!filter)
2076
+ return false;
2077
+ if (filter.filter) {
2078
+ return filter.filter !== '' && filter.filter !== null && filter.filter !== undefined;
2079
+ }
2080
+ if (filter.condition1 && filter.condition1.filter) {
2081
+ return filter.condition1.filter !== '' && filter.condition1.filter !== null && filter.condition1.filter !== undefined;
2082
+ }
2083
+ if (filter.condition2 && filter.condition2.filter) {
2084
+ return filter.condition2.filter !== '' && filter.condition2.filter !== null && filter.condition2.filter !== undefined;
2085
+ }
2086
+ if (filter.dateFrom || filter.dateTo) {
2087
+ return (filter.dateFrom && filter.dateFrom !== '') || (filter.dateTo && filter.dateTo !== '');
2088
+ }
2089
+ if (filter.filterTo || filter.filterFrom) {
2090
+ return (filter.filterFrom !== null && filter.filterFrom !== undefined && filter.filterFrom !== '') ||
2091
+ (filter.filterTo !== null && filter.filterTo !== undefined && filter.filterTo !== '');
2092
+ }
2093
+ return false;
2094
+ }
2095
+ setupFilterInputListeners() {
2096
+ const observer = new MutationObserver((mutations) => {
2097
+ mutations.forEach((mutation) => {
2098
+ mutation.addedNodes.forEach((node) => {
2099
+ if (node.nodeType === Node.ELEMENT_NODE) {
2100
+ const element = node;
2101
+ this.addInputListenersToElement(element);
2102
+ // Check child elements
2103
+ 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');
2104
+ inputs.forEach(input => this.addInputListener(input));
2105
+ }
2106
+ });
2107
+ });
2108
+ });
2109
+ const gridContainer = document.querySelector('.ag-root-wrapper');
2110
+ if (gridContainer) {
2111
+ observer.observe(gridContainer, {
2112
+ childList: true,
2113
+ subtree: true
2114
+ });
2115
+ }
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);
2120
+ }
2121
+ addInputListenersToElement(element) {
2122
+ 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');
2123
+ inputs.forEach(input => this.addInputListener(input));
2124
+ }
2125
+ addInputListener(input) {
2126
+ if (!input)
2127
+ return;
2128
+ const highlightInput = () => {
2129
+ if (input.value && input.value.trim() !== '') {
2130
+ input.classList.add('ag-filter-input-active');
2131
+ }
2132
+ else {
2133
+ input.classList.remove('ag-filter-input-active');
2134
+ }
2135
+ };
2136
+ input.addEventListener('input', highlightInput);
2137
+ input.addEventListener('change', highlightInput);
2138
+ input.addEventListener('keyup', highlightInput);
2139
+ input.addEventListener('paste', highlightInput);
2140
+ // First check
2141
+ highlightInput();
2142
+ }
1912
2143
  //destroy all associated subscriptions on component destroy
1913
2144
  ngOnDestroy() {
1914
2145
  this.unsubscribe$.next();