basesite-shared-grid-lib 15.10.262 → 15.10.267

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.
@@ -1154,6 +1154,7 @@ class GridLibraryComponent {
1154
1154
  this.firstDataRendered = new EventEmitter();
1155
1155
  this.filterChanged = new EventEmitter();
1156
1156
  this.selectionChanged = new EventEmitter();
1157
+ this.totalRowCount = new EventEmitter();
1157
1158
  //viewChilds
1158
1159
  //@ViewChild('agGrid') agGrid!: AgGridAngular;
1159
1160
  //paramters
@@ -1578,7 +1579,6 @@ class GridLibraryComponent {
1578
1579
  return `${serverUrl}${options}`;
1579
1580
  }
1580
1581
  onGridReady(params) {
1581
- //this.gridPageSize = this.pageSize;
1582
1582
  this.gridAPI = params.api;
1583
1583
  if (this.enableServerSidePaging == true) {
1584
1584
  // Show loading overlay immediately when server-side paging is enabled
@@ -1596,11 +1596,10 @@ class GridLibraryComponent {
1596
1596
  callApi: (options) => {
1597
1597
  const url = this.setExternalFilters(options);
1598
1598
  console.log('Server-side API call:', url);
1599
- // Create a timeout promise
1599
+ localStorage.setItem('ServerSideUrl', url);
1600
1600
  const timeoutPromise = new Promise((_, reject) => {
1601
1601
  setTimeout(() => reject(new Error('API request timeout')), API_TIMEOUT);
1602
1602
  });
1603
- // Create the fetch promise
1604
1603
  const fetchPromise = fetch(url, {
1605
1604
  headers: reqHeaders,
1606
1605
  })
@@ -1621,6 +1620,7 @@ class GridLibraryComponent {
1621
1620
  });
1622
1621
  },
1623
1622
  afterLoadData: (options, rowData, totalCount) => {
1623
+ this.totalRowCount.emit(totalCount);
1624
1624
  // Ensure overlay is hidden after data loads
1625
1625
  setTimeout(() => {
1626
1626
  if (!rowData || rowData.length <= 0) {
@@ -1638,6 +1638,12 @@ class GridLibraryComponent {
1638
1638
  }
1639
1639
  }));
1640
1640
  }
1641
+ // Apply initial filter highlighting
1642
+ setTimeout(() => this.updateFilteredColumnHighlighting(), 500);
1643
+ // Event listeners for highlighting
1644
+ if (this.floatingFilter) {
1645
+ this.setupFilterInputListeners();
1646
+ }
1641
1647
  }
1642
1648
  setGridState() {
1643
1649
  if (this.gridColumns && this.gridColumns.length > 0) {
@@ -1663,6 +1669,8 @@ class GridLibraryComponent {
1663
1669
  if (this.gridColumnState.filter) {
1664
1670
  var filterModel = this.gridColumnState.filter.filterModel;
1665
1671
  this.gridAPI?.setFilterModel(filterModel);
1672
+ // Apply highlighting after setting filter model
1673
+ setTimeout(() => this.updateFilteredColumnHighlighting(), 100);
1666
1674
  }
1667
1675
  if (this.gridColumnState.columnVisibility) {
1668
1676
  var hiddenColumns = this.gridColumnState.columnVisibility.hiddenColIds;
@@ -1820,6 +1828,63 @@ class GridLibraryComponent {
1820
1828
  onFilterChanged(e) {
1821
1829
  this.saveGridState(e);
1822
1830
  this.filterChanged.emit(e);
1831
+ this.updateFilteredColumnHighlighting();
1832
+ }
1833
+ clearFilterInputHighlighting() {
1834
+ if (!this.floatingFilter || !this.gridAPI)
1835
+ return;
1836
+ const allSelectors = [
1837
+ '.ag-floating-filter-body input',
1838
+ '.ag-floating-filter-body .ag-input-field-input',
1839
+ '.ag-floating-filter-body .ag-text-field-input',
1840
+ '.ag-floating-filter-body .ag-number-field-input',
1841
+ '.ag-floating-filter-body .ag-date-field-input',
1842
+ '.ag-floating-filter-body .ag-select-field-input',
1843
+ '.ag-floating-filter input',
1844
+ '.ag-floating-filter .ag-input-field-input',
1845
+ '.ag-floating-filter .ag-text-field-input',
1846
+ '.ag-floating-filter .ag-number-field-input',
1847
+ '.ag-floating-filter .ag-date-field-input',
1848
+ '.ag-floating-filter .ag-select-field-input'
1849
+ ];
1850
+ allSelectors.forEach(selector => {
1851
+ const inputs = document.querySelectorAll(selector);
1852
+ inputs.forEach((input) => {
1853
+ const inputElement = input;
1854
+ if (inputElement.value !== undefined) {
1855
+ inputElement.value = '';
1856
+ }
1857
+ // Remove highlighting
1858
+ inputElement.classList.remove('ag-filter-input-active');
1859
+ const inputEvent = new Event('input', { bubbles: true });
1860
+ const changeEvent = new Event('change', { bubbles: true });
1861
+ inputElement.dispatchEvent(inputEvent);
1862
+ inputElement.dispatchEvent(changeEvent);
1863
+ });
1864
+ });
1865
+ const filterContainers = document.querySelectorAll('.ag-floating-filter-body, .ag-floating-filter');
1866
+ filterContainers.forEach(container => {
1867
+ container.classList.remove('ag-filter-input-active');
1868
+ });
1869
+ setTimeout(() => {
1870
+ if (this.gridAPI) {
1871
+ this.gridAPI.redrawRows();
1872
+ }
1873
+ }, 50);
1874
+ }
1875
+ handleExternalFilterReset() {
1876
+ if (!this.gridAPI)
1877
+ return;
1878
+ // Clear all filter inputs and highlighting
1879
+ this.clearFilterInputHighlighting();
1880
+ // Force ag-grid to refresh all filter components
1881
+ setTimeout(() => {
1882
+ if (this.gridAPI) {
1883
+ this.gridAPI.refreshHeader();
1884
+ this.updateFilteredColumnHighlighting();
1885
+ this.gridAPI.redrawRows();
1886
+ }
1887
+ }, 100);
1823
1888
  }
1824
1889
  onFirstDataRendered(e) {
1825
1890
  const storedPageNumber = localStorage.getItem('pageNumber');
@@ -1829,6 +1894,7 @@ class GridLibraryComponent {
1829
1894
  }
1830
1895
  this.dataLoaded = true;
1831
1896
  setTimeout(() => this.updatePaginationInfo(), 0);
1897
+ setTimeout(() => this.updateFilteredColumnHighlighting(), 100);
1832
1898
  this.firstDataRendered.emit(e);
1833
1899
  }
1834
1900
  onGridReadyExcel(params) {
@@ -1906,13 +1972,150 @@ class GridLibraryComponent {
1906
1972
  }
1907
1973
  }
1908
1974
  //custom pagination ends...
1975
+ updateFilteredColumnHighlighting() {
1976
+ if (!this.gridAPI)
1977
+ return;
1978
+ const filterModel = this.gridAPI.getFilterModel();
1979
+ const allColumns = this.gridAPI.getColumns();
1980
+ if (allColumns) {
1981
+ allColumns.forEach((column) => {
1982
+ const columnId = column.getColId();
1983
+ const isFiltered = filterModel && filterModel[columnId];
1984
+ const headerElement = document.querySelector(`[col-id="${columnId}"]`);
1985
+ if (headerElement) {
1986
+ if (isFiltered) {
1987
+ headerElement.classList.add('ag-header-cell-filtered');
1988
+ }
1989
+ else {
1990
+ headerElement.classList.remove('ag-header-cell-filtered');
1991
+ }
1992
+ }
1993
+ this.highlightFilterInputs(columnId, isFiltered);
1994
+ });
1995
+ }
1996
+ // If filter model is empty or null, clear all input highlighting
1997
+ if (!filterModel || Object.keys(filterModel).length === 0) {
1998
+ this.clearFilterInputHighlighting();
1999
+ }
2000
+ }
2001
+ // Highlight filter inputs when they have values
2002
+ highlightFilterInputs(columnId, isFiltered) {
2003
+ if (!this.floatingFilter)
2004
+ return;
2005
+ const selectors = [
2006
+ `[col-id="${columnId}"] .ag-floating-filter-body input`,
2007
+ `[col-id="${columnId}"] .ag-floating-filter-body .ag-input-field-input`,
2008
+ `[col-id="${columnId}"] .ag-floating-filter-body .ag-text-field-input`,
2009
+ `[col-id="${columnId}"] .ag-floating-filter-body .ag-number-field-input`,
2010
+ `[col-id="${columnId}"] .ag-floating-filter-body .ag-date-field-input`,
2011
+ `[col-id="${columnId}"] .ag-floating-filter-body .ag-select-field-input`
2012
+ ];
2013
+ selectors.forEach(selector => {
2014
+ const inputs = document.querySelectorAll(selector);
2015
+ inputs.forEach((input) => {
2016
+ const inputElement = input;
2017
+ if (isFiltered) {
2018
+ inputElement.classList.add('ag-filter-input-active');
2019
+ }
2020
+ else {
2021
+ inputElement.classList.remove('ag-filter-input-active');
2022
+ }
2023
+ });
2024
+ });
2025
+ // Check for filter values in the filter model
2026
+ if (isFiltered) {
2027
+ const filterModel = this.gridAPI.getFilterModel();
2028
+ const columnFilter = filterModel[columnId];
2029
+ if (columnFilter) {
2030
+ const hasValue = this.filterHasValue(columnFilter);
2031
+ if (hasValue) {
2032
+ 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]`);
2033
+ valueInputs.forEach((input) => {
2034
+ const inputElement = input;
2035
+ if (inputElement.value && inputElement.value.trim() !== '') {
2036
+ inputElement.classList.add('ag-filter-input-active');
2037
+ }
2038
+ });
2039
+ }
2040
+ }
2041
+ }
2042
+ }
2043
+ filterHasValue(filter) {
2044
+ if (!filter)
2045
+ return false;
2046
+ if (filter.filter) {
2047
+ return filter.filter !== '' && filter.filter !== null && filter.filter !== undefined;
2048
+ }
2049
+ if (filter.condition1 && filter.condition1.filter) {
2050
+ return filter.condition1.filter !== '' && filter.condition1.filter !== null && filter.condition1.filter !== undefined;
2051
+ }
2052
+ if (filter.condition2 && filter.condition2.filter) {
2053
+ return filter.condition2.filter !== '' && filter.condition2.filter !== null && filter.condition2.filter !== undefined;
2054
+ }
2055
+ if (filter.dateFrom || filter.dateTo) {
2056
+ return (filter.dateFrom && filter.dateFrom !== '') || (filter.dateTo && filter.dateTo !== '');
2057
+ }
2058
+ if (filter.filterTo || filter.filterFrom) {
2059
+ return (filter.filterFrom !== null && filter.filterFrom !== undefined && filter.filterFrom !== '') ||
2060
+ (filter.filterTo !== null && filter.filterTo !== undefined && filter.filterTo !== '');
2061
+ }
2062
+ return false;
2063
+ }
2064
+ setupFilterInputListeners() {
2065
+ const observer = new MutationObserver((mutations) => {
2066
+ mutations.forEach((mutation) => {
2067
+ mutation.addedNodes.forEach((node) => {
2068
+ if (node.nodeType === Node.ELEMENT_NODE) {
2069
+ const element = node;
2070
+ this.addInputListenersToElement(element);
2071
+ // Check child elements
2072
+ 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');
2073
+ inputs.forEach(input => this.addInputListener(input));
2074
+ }
2075
+ });
2076
+ });
2077
+ });
2078
+ const gridContainer = document.querySelector('.ag-root-wrapper');
2079
+ if (gridContainer) {
2080
+ observer.observe(gridContainer, {
2081
+ childList: true,
2082
+ subtree: true
2083
+ });
2084
+ }
2085
+ setTimeout(() => {
2086
+ 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');
2087
+ existingInputs.forEach(input => this.addInputListener(input));
2088
+ }, 1000);
2089
+ }
2090
+ addInputListenersToElement(element) {
2091
+ 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');
2092
+ inputs.forEach(input => this.addInputListener(input));
2093
+ }
2094
+ addInputListener(input) {
2095
+ if (!input)
2096
+ return;
2097
+ const highlightInput = () => {
2098
+ if (input.value && input.value.trim() !== '') {
2099
+ input.classList.add('ag-filter-input-active');
2100
+ }
2101
+ else {
2102
+ input.classList.remove('ag-filter-input-active');
2103
+ }
2104
+ };
2105
+ input.addEventListener('input', highlightInput);
2106
+ input.addEventListener('change', highlightInput);
2107
+ input.addEventListener('keyup', highlightInput);
2108
+ input.addEventListener('paste', highlightInput);
2109
+ // First check
2110
+ highlightInput();
2111
+ }
1909
2112
  //destroy all associated subscriptions on component destroy
1910
2113
  ngOnDestroy() {
1911
2114
  this.unsubscribe$.next();
1912
2115
  this.unsubscribe$.complete();
1913
2116
  }
1914
2117
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: GridLibraryComponent, deps: [{ token: GridLibraryService }, { token: ColumnValueFormatter }, { token: TokenSharingService }], target: i0.ɵɵFactoryTarget.Component }); }
1915
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.5", type: GridLibraryComponent, isStandalone: false, selector: "lib-basesite-shared-grid-lib", inputs: { overrideColumnDefs: "overrideColumnDefs", columnDefs: "columnDefs", rowData: "rowData", paginationAutoPageSize: "paginationAutoPageSize", rowSelection: "rowSelection", gridId: "gridId", loggedInUser: "loggedInUser", siteId: "siteId", enableServerSidePaging: "enableServerSidePaging", serverDataUrl: "serverDataUrl", environment: "environment", cacheBlockSize: "cacheBlockSize", rowMultiSelectWithClick: "rowMultiSelectWithClick", floatingFilter: "floatingFilter", token: "token", userRoles: "userRoles", overlayNoRowsTemplate: "overlayNoRowsTemplate", rowHeight: "rowHeight" }, outputs: { btnClickHandler: "btnClickHandler", firstDataRendered: "firstDataRendered", filterChanged: "filterChanged", selectionChanged: "selectionChanged" }, usesOnChanges: true, ngImport: i0, template: `
2118
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.5", type: GridLibraryComponent, isStandalone: false, selector: "lib-basesite-shared-grid-lib", inputs: { overrideColumnDefs: "overrideColumnDefs", columnDefs: "columnDefs", rowData: "rowData", paginationAutoPageSize: "paginationAutoPageSize", rowSelection: "rowSelection", gridId: "gridId", loggedInUser: "loggedInUser", siteId: "siteId", enableServerSidePaging: "enableServerSidePaging", serverDataUrl: "serverDataUrl", environment: "environment", cacheBlockSize: "cacheBlockSize", rowMultiSelectWithClick: "rowMultiSelectWithClick", floatingFilter: "floatingFilter", token: "token", userRoles: "userRoles", overlayNoRowsTemplate: "overlayNoRowsTemplate", rowHeight: "rowHeight" }, outputs: { btnClickHandler: "btnClickHandler", firstDataRendered: "firstDataRendered", filterChanged: "filterChanged", selectionChanged: "selectionChanged", totalRowCount: "totalRowCount" }, usesOnChanges: true, ngImport: i0, template: `
1916
2119
  <ag-grid-angular
1917
2120
  #agGrid
1918
2121
  style="width: 100%;height:98.2vh"
@@ -2117,6 +2320,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
2117
2320
  type: Output
2118
2321
  }], selectionChanged: [{
2119
2322
  type: Output
2323
+ }], totalRowCount: [{
2324
+ type: Output
2120
2325
  }] } });
2121
2326
 
2122
2327
  class DateHeaderComponent {