@visns-studio/visns-components 3.0.7 → 3.0.8
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/components/crm/DataGrid.jsx +72 -105
- package/package.json +5 -5
|
@@ -573,8 +573,6 @@ const DataGrid = forwardRef(
|
|
|
573
573
|
const sortTrigger = () => {
|
|
574
574
|
const url = form.url.replace('/ajax', '');
|
|
575
575
|
|
|
576
|
-
console.info(ajaxSetting, columns, form);
|
|
577
|
-
|
|
578
576
|
const newState = {
|
|
579
577
|
form: form,
|
|
580
578
|
page: {
|
|
@@ -1013,6 +1011,8 @@ const DataGrid = forwardRef(
|
|
|
1013
1011
|
return {
|
|
1014
1012
|
...commonProps,
|
|
1015
1013
|
name: `${column.type}.${column.id}`,
|
|
1014
|
+
filterEditor: filterEditor,
|
|
1015
|
+
filterEditorProps: filterEditorProps,
|
|
1016
1016
|
render: ({ data }) => {
|
|
1017
1017
|
const addressFields = [
|
|
1018
1018
|
'address1',
|
|
@@ -1853,7 +1853,11 @@ const DataGrid = forwardRef(
|
|
|
1853
1853
|
''
|
|
1854
1854
|
);
|
|
1855
1855
|
} else {
|
|
1856
|
-
|
|
1856
|
+
if (column.type === 'address') {
|
|
1857
|
+
filterName = `address.${column.id}`;
|
|
1858
|
+
} else {
|
|
1859
|
+
filterName = column.id;
|
|
1860
|
+
}
|
|
1857
1861
|
}
|
|
1858
1862
|
|
|
1859
1863
|
if (column.nameFrom) {
|
|
@@ -1879,96 +1883,70 @@ const DataGrid = forwardRef(
|
|
|
1879
1883
|
}
|
|
1880
1884
|
}, [filterValue]);
|
|
1881
1885
|
|
|
1886
|
+
const createFilterName = (column) => {
|
|
1887
|
+
let filterName = Array.isArray(column.id)
|
|
1888
|
+
? column.id.join('.') + '.'
|
|
1889
|
+
: column.id;
|
|
1890
|
+
|
|
1891
|
+
if (column.nameFrom) {
|
|
1892
|
+
filterName += column.nameFrom;
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
if (column.jsonData) {
|
|
1896
|
+
filterName += column.jsonData;
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
return filterName;
|
|
1900
|
+
};
|
|
1901
|
+
|
|
1902
|
+
const updateFilterDataSource = (filterName, data) => {
|
|
1903
|
+
const filterIndex = filterDataSource.findIndex(
|
|
1904
|
+
(filter) => filter.id === filterName
|
|
1905
|
+
);
|
|
1906
|
+
|
|
1907
|
+
if (filterIndex >= 0) {
|
|
1908
|
+
const updatedFilter = {
|
|
1909
|
+
...filterDataSource[filterIndex],
|
|
1910
|
+
dataset: data,
|
|
1911
|
+
};
|
|
1912
|
+
setFilterDataSource([
|
|
1913
|
+
...filterDataSource.slice(0, filterIndex),
|
|
1914
|
+
updatedFilter,
|
|
1915
|
+
...filterDataSource.slice(filterIndex + 1),
|
|
1916
|
+
]);
|
|
1917
|
+
} else {
|
|
1918
|
+
const newFilter = {
|
|
1919
|
+
id: filterName,
|
|
1920
|
+
dataset: data,
|
|
1921
|
+
};
|
|
1922
|
+
setFilterDataSource((prevState) => [...prevState, newFilter]);
|
|
1923
|
+
}
|
|
1924
|
+
};
|
|
1925
|
+
|
|
1882
1926
|
useEffect(() => {
|
|
1883
1927
|
columns.forEach((column) => {
|
|
1884
1928
|
if (column.filter && column.filter.url) {
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
if (column.filter.where) {
|
|
1888
|
-
filterWhere = {
|
|
1889
|
-
...filterWhere,
|
|
1929
|
+
const filterWhere = {
|
|
1930
|
+
...(column.filter.where && {
|
|
1890
1931
|
where: column.filter.where,
|
|
1891
|
-
}
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
if (column.filter.fields) {
|
|
1895
|
-
filterWhere = {
|
|
1896
|
-
...filterWhere,
|
|
1932
|
+
}),
|
|
1933
|
+
...(column.filter.fields && {
|
|
1897
1934
|
fields: column.filter.fields,
|
|
1898
|
-
}
|
|
1899
|
-
}
|
|
1935
|
+
}),
|
|
1936
|
+
};
|
|
1900
1937
|
|
|
1901
1938
|
CustomFetch(
|
|
1902
1939
|
column.filter.url,
|
|
1903
1940
|
'POST',
|
|
1904
1941
|
filterWhere,
|
|
1905
1942
|
(res) => {
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
const concatenatedIds = column.id.reduce(
|
|
1909
|
-
(acc, id) => acc + `${id}.`,
|
|
1910
|
-
''
|
|
1911
|
-
);
|
|
1912
|
-
filterName = column.nameFrom
|
|
1913
|
-
? concatenatedIds + column.nameFrom
|
|
1914
|
-
: concatenatedIds;
|
|
1915
|
-
} else {
|
|
1916
|
-
filterName = column.nameFrom
|
|
1917
|
-
? column.id + column.nameFrom
|
|
1918
|
-
: column.id;
|
|
1919
|
-
}
|
|
1920
|
-
|
|
1921
|
-
if (column.jsonData) {
|
|
1922
|
-
filterName += column.jsonData;
|
|
1923
|
-
}
|
|
1924
|
-
|
|
1925
|
-
const filterIndex = filterDataSource.findIndex(
|
|
1926
|
-
(filter) => filter.id === filterName
|
|
1927
|
-
);
|
|
1928
|
-
if (filterIndex >= 0) {
|
|
1929
|
-
const updatedFilter = {
|
|
1930
|
-
...filterDataSource[filterIndex],
|
|
1931
|
-
dataset: res.data,
|
|
1932
|
-
};
|
|
1933
|
-
const updatedDataSource = [
|
|
1934
|
-
...filterDataSource.slice(0, filterIndex),
|
|
1935
|
-
updatedFilter,
|
|
1936
|
-
...filterDataSource.slice(filterIndex + 1),
|
|
1937
|
-
];
|
|
1938
|
-
setFilterDataSource(updatedDataSource);
|
|
1939
|
-
} else {
|
|
1940
|
-
const newFilter = {
|
|
1941
|
-
id: filterName,
|
|
1942
|
-
dataset: res.data,
|
|
1943
|
-
};
|
|
1944
|
-
setFilterDataSource((prevState) => [
|
|
1945
|
-
...prevState,
|
|
1946
|
-
newFilter,
|
|
1947
|
-
]);
|
|
1948
|
-
}
|
|
1943
|
+
const filterName = createFilterName(column);
|
|
1944
|
+
updateFilterDataSource(filterName, res.data);
|
|
1949
1945
|
}
|
|
1950
1946
|
);
|
|
1951
1947
|
} else if (column.filter && column.filter.options) {
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
: column.id;
|
|
1955
|
-
|
|
1956
|
-
if (column.nameFrom) {
|
|
1957
|
-
filterName += column.nameFrom;
|
|
1958
|
-
}
|
|
1959
|
-
|
|
1960
|
-
if (column.jsonData) {
|
|
1961
|
-
filterName += column.jsonData;
|
|
1962
|
-
}
|
|
1963
|
-
|
|
1964
|
-
const newFilter = {
|
|
1965
|
-
id: filterName,
|
|
1966
|
-
dataset: column.filter.options,
|
|
1967
|
-
};
|
|
1968
|
-
setFilterDataSource((prevState) => [
|
|
1969
|
-
...prevState,
|
|
1970
|
-
newFilter,
|
|
1971
|
-
]);
|
|
1948
|
+
const filterName = createFilterName(column);
|
|
1949
|
+
updateFilterDataSource(filterName, column.filter.options);
|
|
1972
1950
|
}
|
|
1973
1951
|
});
|
|
1974
1952
|
}, []);
|
|
@@ -1994,34 +1972,23 @@ const DataGrid = forwardRef(
|
|
|
1994
1972
|
};
|
|
1995
1973
|
|
|
1996
1974
|
useEffect(() => {
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
}));
|
|
2010
|
-
|
|
2011
|
-
let dgHeight =
|
|
2012
|
-
gridHeight && gridHeight > 0
|
|
2013
|
-
? gridHeight
|
|
2014
|
-
: dataCount > 5
|
|
2015
|
-
? dataCount > 8
|
|
2016
|
-
? windowHeight * 0.7 > 550
|
|
2017
|
-
? windowHeight * 0.7
|
|
2018
|
-
: 550
|
|
2019
|
-
: 450
|
|
2020
|
-
: 400;
|
|
1975
|
+
const getMinimumHeight = () => {
|
|
1976
|
+
if (gridHeight > 0) return gridHeight;
|
|
1977
|
+
if (dataCount > 0) {
|
|
1978
|
+
if (dataCount <= 5) return 400;
|
|
1979
|
+
if (dataCount <= 8) return 450;
|
|
1980
|
+
}
|
|
1981
|
+
return Math.max(window.innerHeight * 0.7, 550);
|
|
1982
|
+
};
|
|
1983
|
+
|
|
1984
|
+
const calculateRows = (height) => Math.floor((height - 100) / 40);
|
|
1985
|
+
|
|
1986
|
+
const minHeight = getMinimumHeight();
|
|
1987
|
+
setGridStyle((prevState) => ({ ...prevState, minHeight }));
|
|
2021
1988
|
|
|
2022
|
-
|
|
1989
|
+
const rowCount = calculateRows(minHeight);
|
|
2023
1990
|
setLimit(rowCount);
|
|
2024
|
-
}, [dataCount]);
|
|
1991
|
+
}, [dataCount, gridHeight, window.innerHeight]);
|
|
2025
1992
|
|
|
2026
1993
|
useEffect(() => {
|
|
2027
1994
|
const handleResize = () => {
|
package/package.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"akar-icons": "^1.9.30",
|
|
7
7
|
"array-move": "^4.0.0",
|
|
8
8
|
"awesome-debounce-promise": "^2.1.0",
|
|
9
|
-
"axios": "^1.6.
|
|
10
|
-
"framer-motion": "^10.
|
|
11
|
-
"html-react-parser": "^5.0
|
|
9
|
+
"axios": "^1.6.5",
|
|
10
|
+
"framer-motion": "^10.18.0",
|
|
11
|
+
"html-react-parser": "^5.1.0",
|
|
12
12
|
"lodash": "^4.17.21",
|
|
13
13
|
"moment": "^2.30.1",
|
|
14
|
-
"motion": "^10.
|
|
14
|
+
"motion": "^10.17.0",
|
|
15
15
|
"numeral": "^2.0.6",
|
|
16
16
|
"quill-image-uploader": "^1.3.0",
|
|
17
17
|
"react-color": "^2.19.3",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"react-dom": "^17.0.1"
|
|
47
47
|
},
|
|
48
48
|
"name": "@visns-studio/visns-components",
|
|
49
|
-
"version": "3.0.
|
|
49
|
+
"version": "3.0.8",
|
|
50
50
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
51
51
|
"main": "index.js",
|
|
52
52
|
"scripts": {
|