@zeedhi/teknisa-components-common 1.79.0 → 1.79.1
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.
- package/coverage/clover.xml +382 -382
- package/coverage/coverage-final.json +2 -2
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/index.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/index.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/mock-created-helper.ts.html +1 -1
- package/coverage/lcov.info +672 -672
- package/dist/tek-components-common.esm.js +130 -129
- package/dist/tek-components-common.umd.js +129 -128
- package/package.json +2 -2
- package/types/components/tek-grid/grid.d.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KeyMap, I18n, FormatterParserProvider, Messages, Metadata, DatasourceFactory,
|
|
1
|
+
import { KeyMap, I18n, FormatterParserProvider, Messages, Metadata, DatasourceFactory, MemoryDatasource, URL, Utils, RestDatasource, Loader, Config, Http, DateHelper, Singleton, VersionService } from '@zeedhi/core';
|
|
2
2
|
import { Form, Button, Tooltip, GridEditable, Grid, ComponentRender, Iterable, Carousel, IterableComponentRender as IterableComponentRender$1, Loading as Loading$1, ModalService, GridColumnEditable, Report, ColumnNotFoundError, IterableColumnsButtonController, IterableColumnsButton, TreeGridEditable, List } from '@zeedhi/common';
|
|
3
3
|
import debounce from 'lodash.debounce';
|
|
4
4
|
import merge from 'lodash.merge';
|
|
@@ -1006,6 +1006,7 @@ class GridBase {
|
|
|
1006
1006
|
{
|
|
1007
1007
|
name: `${this.grid.name}-filter-title`,
|
|
1008
1008
|
component: 'ZdText',
|
|
1009
|
+
cssStyle: `color: ${'var(--v-primary-base);'}`,
|
|
1009
1010
|
text: `${mergeModalFilterProps.title}`,
|
|
1010
1011
|
tag: 'h3',
|
|
1011
1012
|
},
|
|
@@ -1646,13 +1647,13 @@ const DynamicFilterRelations = {
|
|
|
1646
1647
|
OR: true,
|
|
1647
1648
|
};
|
|
1648
1649
|
|
|
1649
|
-
class
|
|
1650
|
+
class TekMemoryDatasource extends MemoryDatasource {
|
|
1650
1651
|
/**
|
|
1651
1652
|
* Create new datasource
|
|
1652
1653
|
* @param props Datasource properties
|
|
1653
1654
|
*/
|
|
1654
1655
|
constructor(props) {
|
|
1655
|
-
super(
|
|
1656
|
+
super(props);
|
|
1656
1657
|
/**
|
|
1657
1658
|
* Dynamic Filter Operations
|
|
1658
1659
|
*/
|
|
@@ -1669,13 +1670,10 @@ class TekRestDatasource extends RestDatasource {
|
|
|
1669
1670
|
this.dynamicFilter = this.getInitValue('dynamicFilter', props.dynamicFilter, {});
|
|
1670
1671
|
this.searchJoin = this.getInitValue('searchJoin', props.searchJoin, {});
|
|
1671
1672
|
}
|
|
1672
|
-
this.lazyLoad = this.getInitValue('lazyLoad', props.lazyLoad, this.lazyLoad);
|
|
1673
1673
|
this.createAccessors();
|
|
1674
1674
|
this.createObjAccessors(this.dynamicFilter, 'dynamicFilter');
|
|
1675
1675
|
this.createObjAccessors(this.searchJoin, 'searchJoin');
|
|
1676
|
-
|
|
1677
|
-
this.get();
|
|
1678
|
-
}
|
|
1676
|
+
this.get();
|
|
1679
1677
|
}
|
|
1680
1678
|
updateReservedKeys() {
|
|
1681
1679
|
this.reservedKeys.dynamic_filter = true;
|
|
@@ -1804,37 +1802,124 @@ class TekRestDatasource extends RestDatasource {
|
|
|
1804
1802
|
&& this.dynamicFilterRelations[filterValue.relation]
|
|
1805
1803
|
&& filterValue.value !== '' && filterValue.value !== null);
|
|
1806
1804
|
}
|
|
1805
|
+
clone() {
|
|
1806
|
+
return Object.assign(Object.assign({}, super.clone()), { dynamicFilter: this.dynamicFilter, searchJoin: this.searchJoin, type: 'tek-memory' });
|
|
1807
|
+
}
|
|
1807
1808
|
/**
|
|
1808
|
-
*
|
|
1809
|
+
* Updates filtered data
|
|
1809
1810
|
*/
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
if (isNotEmptyObj(this.dynamicFilter) && isValid) {
|
|
1818
|
-
requestParams.dynamic_filter = btoa(JSON.stringify(this.dynamicFilter));
|
|
1811
|
+
updateFilteredData() {
|
|
1812
|
+
// first apply filters (simple and dynamic)
|
|
1813
|
+
this.filteredData = Object.keys(this.filter).length
|
|
1814
|
+
? this.allData.filter((row) => this.getRowByFilter(row))
|
|
1815
|
+
: Array.from(this.allData);
|
|
1816
|
+
if (this.dynamicFilter && Object.keys(this.dynamicFilter).length) {
|
|
1817
|
+
this.filteredData = this.filteredData.filter((row) => this.getRowByDynamicFilter(row));
|
|
1819
1818
|
}
|
|
1820
|
-
|
|
1821
|
-
|
|
1819
|
+
const searchWithoutSearchJoin = (row) => {
|
|
1820
|
+
const searchRow = Object.assign({}, row);
|
|
1821
|
+
if (this.searchJoin) {
|
|
1822
|
+
// do not search on columns with searchJoin
|
|
1823
|
+
Object.keys(this.searchJoin).forEach((key) => delete searchRow[key]);
|
|
1824
|
+
}
|
|
1825
|
+
return this.getRowBySearch(searchRow);
|
|
1826
|
+
};
|
|
1827
|
+
// only after do the search
|
|
1828
|
+
const searchData = this.search
|
|
1829
|
+
? this.filteredData.filter(searchWithoutSearchJoin)
|
|
1830
|
+
: this.filteredData;
|
|
1831
|
+
let searchIds = searchData.map((row) => row[this.uniqueKey]);
|
|
1832
|
+
if (this.searchJoin && Object.keys(this.searchJoin).length) {
|
|
1833
|
+
const searchJoinData = this.filteredData.filter((row) => this.getRowBySearchJoin(row));
|
|
1834
|
+
// get the ids from search and searchJoin
|
|
1835
|
+
searchIds = searchIds
|
|
1836
|
+
.concat(searchJoinData.map((row) => row[this.uniqueKey]))
|
|
1837
|
+
.sort();
|
|
1822
1838
|
}
|
|
1823
|
-
|
|
1839
|
+
// filter filteredData using searchIds
|
|
1840
|
+
this.filteredData = this.allData.filter((row) => searchIds.indexOf(row[this.uniqueKey]) !== -1);
|
|
1824
1841
|
}
|
|
1825
|
-
|
|
1826
|
-
|
|
1842
|
+
getRowByDynamicFilter(row) {
|
|
1843
|
+
let filtered;
|
|
1844
|
+
try {
|
|
1845
|
+
Object.keys(this.dynamicFilter).forEach((key) => {
|
|
1846
|
+
const filterItems = this.dynamicFilter[key];
|
|
1847
|
+
filterItems.forEach((item) => {
|
|
1848
|
+
if (filtered === false && item.relation === 'AND')
|
|
1849
|
+
return;
|
|
1850
|
+
if (filtered === true && item.relation === 'OR')
|
|
1851
|
+
return;
|
|
1852
|
+
const columnValue = Utils.normalize(row[key].toString());
|
|
1853
|
+
let value = '';
|
|
1854
|
+
if (Array.isArray(item.value)) {
|
|
1855
|
+
value = item.value.map((val) => Utils.normalize(val.toString()));
|
|
1856
|
+
switch (item.operation) {
|
|
1857
|
+
case 'IN':
|
|
1858
|
+
filtered = value.includes(columnValue);
|
|
1859
|
+
break;
|
|
1860
|
+
case 'NOT_IN':
|
|
1861
|
+
filtered = !value.includes(columnValue);
|
|
1862
|
+
break;
|
|
1863
|
+
case 'BETWEEN':
|
|
1864
|
+
filtered = (Number(columnValue) || columnValue) >= (Number(value[0]) || value[0])
|
|
1865
|
+
&& (Number(columnValue) || columnValue) <= (Number(value[1]) || value[1]);
|
|
1866
|
+
break;
|
|
1867
|
+
default:
|
|
1868
|
+
break;
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
else {
|
|
1872
|
+
value = Utils.normalize(item.value.toString());
|
|
1873
|
+
switch (item.operation) {
|
|
1874
|
+
case 'CONTAINS':
|
|
1875
|
+
filtered = columnValue.indexOf(value) !== -1;
|
|
1876
|
+
break;
|
|
1877
|
+
case 'NOT_CONTAINS':
|
|
1878
|
+
filtered = columnValue.indexOf(value) === -1;
|
|
1879
|
+
break;
|
|
1880
|
+
case 'EQUALS':
|
|
1881
|
+
filtered = columnValue === value;
|
|
1882
|
+
break;
|
|
1883
|
+
case 'NOT_EQUALS':
|
|
1884
|
+
filtered = columnValue !== value;
|
|
1885
|
+
break;
|
|
1886
|
+
case 'GREATER_THAN':
|
|
1887
|
+
filtered = (Number(columnValue) || columnValue) > (Number(value) || value);
|
|
1888
|
+
break;
|
|
1889
|
+
case 'LESS_THAN':
|
|
1890
|
+
filtered = (Number(columnValue) || columnValue) < (Number(value) || value);
|
|
1891
|
+
break;
|
|
1892
|
+
case 'GREATER_THAN_EQUALS':
|
|
1893
|
+
filtered = (Number(columnValue) || columnValue) >= (Number(value) || value);
|
|
1894
|
+
break;
|
|
1895
|
+
case 'LESS_THAN_EQUALS':
|
|
1896
|
+
filtered = (Number(columnValue) || columnValue) <= (Number(value) || value);
|
|
1897
|
+
break;
|
|
1898
|
+
default:
|
|
1899
|
+
break;
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
});
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1905
|
+
catch (_a) {
|
|
1906
|
+
// do nothing
|
|
1907
|
+
}
|
|
1908
|
+
return filtered;
|
|
1909
|
+
}
|
|
1910
|
+
getRowBySearchJoin(row) {
|
|
1911
|
+
return Object.keys(this.searchJoin).some((key) => this.searchJoin[key].includes(row[key]));
|
|
1827
1912
|
}
|
|
1828
1913
|
}
|
|
1829
|
-
DatasourceFactory.register('tek-
|
|
1914
|
+
DatasourceFactory.register('tek-memory', TekMemoryDatasource);
|
|
1830
1915
|
|
|
1831
|
-
class
|
|
1916
|
+
class TekRestDatasource extends RestDatasource {
|
|
1832
1917
|
/**
|
|
1833
1918
|
* Create new datasource
|
|
1834
1919
|
* @param props Datasource properties
|
|
1835
1920
|
*/
|
|
1836
1921
|
constructor(props) {
|
|
1837
|
-
super(props);
|
|
1922
|
+
super(Object.assign(Object.assign({}, props), { lazyLoad: true }));
|
|
1838
1923
|
/**
|
|
1839
1924
|
* Dynamic Filter Operations
|
|
1840
1925
|
*/
|
|
@@ -1851,10 +1936,13 @@ class TekMemoryDatasource extends MemoryDatasource {
|
|
|
1851
1936
|
this.dynamicFilter = this.getInitValue('dynamicFilter', props.dynamicFilter, {});
|
|
1852
1937
|
this.searchJoin = this.getInitValue('searchJoin', props.searchJoin, {});
|
|
1853
1938
|
}
|
|
1939
|
+
this.lazyLoad = this.getInitValue('lazyLoad', props.lazyLoad, this.lazyLoad);
|
|
1854
1940
|
this.createAccessors();
|
|
1855
1941
|
this.createObjAccessors(this.dynamicFilter, 'dynamicFilter');
|
|
1856
1942
|
this.createObjAccessors(this.searchJoin, 'searchJoin');
|
|
1857
|
-
this.
|
|
1943
|
+
if (!this.lazyLoad) {
|
|
1944
|
+
this.get();
|
|
1945
|
+
}
|
|
1858
1946
|
}
|
|
1859
1947
|
updateReservedKeys() {
|
|
1860
1948
|
this.reservedKeys.dynamic_filter = true;
|
|
@@ -1983,116 +2071,29 @@ class TekMemoryDatasource extends MemoryDatasource {
|
|
|
1983
2071
|
&& this.dynamicFilterRelations[filterValue.relation]
|
|
1984
2072
|
&& filterValue.value !== '' && filterValue.value !== null);
|
|
1985
2073
|
}
|
|
1986
|
-
clone() {
|
|
1987
|
-
return Object.assign(Object.assign({}, super.clone()), { dynamicFilter: this.dynamicFilter, searchJoin: this.searchJoin, type: 'tek-memory' });
|
|
1988
|
-
}
|
|
1989
2074
|
/**
|
|
1990
|
-
*
|
|
2075
|
+
* Retrieves request params
|
|
1991
2076
|
*/
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
const searchRow = Object.assign({}, row);
|
|
2002
|
-
if (this.searchJoin) {
|
|
2003
|
-
// do not search on columns with searchJoin
|
|
2004
|
-
Object.keys(this.searchJoin).forEach((key) => delete searchRow[key]);
|
|
2005
|
-
}
|
|
2006
|
-
return this.getRowBySearch(searchRow);
|
|
2007
|
-
};
|
|
2008
|
-
// only after do the search
|
|
2009
|
-
const searchData = this.search
|
|
2010
|
-
? this.filteredData.filter(searchWithoutSearchJoin)
|
|
2011
|
-
: this.filteredData;
|
|
2012
|
-
let searchIds = searchData.map((row) => row[this.uniqueKey]);
|
|
2013
|
-
if (this.searchJoin && Object.keys(this.searchJoin).length) {
|
|
2014
|
-
const searchJoinData = this.filteredData.filter((row) => this.getRowBySearchJoin(row));
|
|
2015
|
-
// get the ids from search and searchJoin
|
|
2016
|
-
searchIds = searchIds
|
|
2017
|
-
.concat(searchJoinData.map((row) => row[this.uniqueKey]))
|
|
2018
|
-
.sort();
|
|
2019
|
-
}
|
|
2020
|
-
// filter filteredData using searchIds
|
|
2021
|
-
this.filteredData = this.allData.filter((row) => searchIds.indexOf(row[this.uniqueKey]) !== -1);
|
|
2022
|
-
}
|
|
2023
|
-
getRowByDynamicFilter(row) {
|
|
2024
|
-
let filtered;
|
|
2025
|
-
try {
|
|
2026
|
-
Object.keys(this.dynamicFilter).forEach((key) => {
|
|
2027
|
-
const filterItems = this.dynamicFilter[key];
|
|
2028
|
-
filterItems.forEach((item) => {
|
|
2029
|
-
if (filtered === false && item.relation === 'AND')
|
|
2030
|
-
return;
|
|
2031
|
-
if (filtered === true && item.relation === 'OR')
|
|
2032
|
-
return;
|
|
2033
|
-
const columnValue = Utils.normalize(row[key].toString());
|
|
2034
|
-
let value = '';
|
|
2035
|
-
if (Array.isArray(item.value)) {
|
|
2036
|
-
value = item.value.map((val) => Utils.normalize(val.toString()));
|
|
2037
|
-
switch (item.operation) {
|
|
2038
|
-
case 'IN':
|
|
2039
|
-
filtered = value.includes(columnValue);
|
|
2040
|
-
break;
|
|
2041
|
-
case 'NOT_IN':
|
|
2042
|
-
filtered = !value.includes(columnValue);
|
|
2043
|
-
break;
|
|
2044
|
-
case 'BETWEEN':
|
|
2045
|
-
filtered = (Number(columnValue) || columnValue) >= (Number(value[0]) || value[0])
|
|
2046
|
-
&& (Number(columnValue) || columnValue) <= (Number(value[1]) || value[1]);
|
|
2047
|
-
break;
|
|
2048
|
-
default:
|
|
2049
|
-
break;
|
|
2050
|
-
}
|
|
2051
|
-
}
|
|
2052
|
-
else {
|
|
2053
|
-
value = Utils.normalize(item.value.toString());
|
|
2054
|
-
switch (item.operation) {
|
|
2055
|
-
case 'CONTAINS':
|
|
2056
|
-
filtered = columnValue.indexOf(value) !== -1;
|
|
2057
|
-
break;
|
|
2058
|
-
case 'NOT_CONTAINS':
|
|
2059
|
-
filtered = columnValue.indexOf(value) === -1;
|
|
2060
|
-
break;
|
|
2061
|
-
case 'EQUALS':
|
|
2062
|
-
filtered = columnValue === value;
|
|
2063
|
-
break;
|
|
2064
|
-
case 'NOT_EQUALS':
|
|
2065
|
-
filtered = columnValue !== value;
|
|
2066
|
-
break;
|
|
2067
|
-
case 'GREATER_THAN':
|
|
2068
|
-
filtered = (Number(columnValue) || columnValue) > (Number(value) || value);
|
|
2069
|
-
break;
|
|
2070
|
-
case 'LESS_THAN':
|
|
2071
|
-
filtered = (Number(columnValue) || columnValue) < (Number(value) || value);
|
|
2072
|
-
break;
|
|
2073
|
-
case 'GREATER_THAN_EQUALS':
|
|
2074
|
-
filtered = (Number(columnValue) || columnValue) >= (Number(value) || value);
|
|
2075
|
-
break;
|
|
2076
|
-
case 'LESS_THAN_EQUALS':
|
|
2077
|
-
filtered = (Number(columnValue) || columnValue) <= (Number(value) || value);
|
|
2078
|
-
break;
|
|
2079
|
-
default:
|
|
2080
|
-
break;
|
|
2081
|
-
}
|
|
2082
|
-
}
|
|
2083
|
-
});
|
|
2084
|
-
});
|
|
2077
|
+
getRequestParams() {
|
|
2078
|
+
const requestParams = super.getRequestParams();
|
|
2079
|
+
const isNotEmptyObj = (obj) => !!(obj && Object.keys(obj).length);
|
|
2080
|
+
const isValid = this.dynamicFilter && Object.keys(this.dynamicFilter).every((column) => {
|
|
2081
|
+
const value = this.dynamicFilter[column];
|
|
2082
|
+
return value && value.length > 0 && this.isValidDynamicFilterValue(column, value);
|
|
2083
|
+
});
|
|
2084
|
+
if (isNotEmptyObj(this.dynamicFilter) && isValid) {
|
|
2085
|
+
requestParams.dynamic_filter = btoa(JSON.stringify(this.dynamicFilter));
|
|
2085
2086
|
}
|
|
2086
|
-
|
|
2087
|
-
|
|
2087
|
+
if (isNotEmptyObj(this.searchJoin)) {
|
|
2088
|
+
requestParams.search_join = btoa(JSON.stringify(this.searchJoin));
|
|
2088
2089
|
}
|
|
2089
|
-
return
|
|
2090
|
+
return requestParams;
|
|
2090
2091
|
}
|
|
2091
|
-
|
|
2092
|
-
return Object.
|
|
2092
|
+
clone() {
|
|
2093
|
+
return Object.assign(Object.assign({}, super.clone()), { dynamicFilter: this.dynamicFilter, searchJoin: this.searchJoin, type: 'tek-rest' });
|
|
2093
2094
|
}
|
|
2094
2095
|
}
|
|
2095
|
-
DatasourceFactory.register('tek-
|
|
2096
|
+
DatasourceFactory.register('tek-rest', TekRestDatasource);
|
|
2096
2097
|
|
|
2097
2098
|
/**
|
|
2098
2099
|
* Base class for TekGrid column
|