@leav/ui 1.7.0-e1ab594d → 1.7.0-e23db3d5
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/dist/__mocks__/common/library.d.ts +1 -0
- package/dist/_gqlTypes/index.d.ts +116 -69
- package/dist/_gqlTypes/index.js +79 -52
- package/dist/_gqlTypes/index.js.map +1 -1
- package/dist/_queries/libraries/libraryDetailsFragment.js +1 -0
- package/dist/_queries/libraries/libraryDetailsFragment.js.map +1 -1
- package/dist/components/Filters/context/useGetTreeFilters.d.ts +8 -6
- package/dist/components/Filters/context/useGetTreeFilters.js +41 -18
- package/dist/components/Filters/context/useGetTreeFilters.js.map +1 -1
- package/dist/components/Filters/filter-items/CommonFilterItem.js +1 -1
- package/dist/components/Filters/filter-items/CommonFilterItem.js.map +1 -1
- package/dist/components/Filters/filter-items/EmptyValueCheckbox.js +1 -1
- package/dist/components/Filters/filter-items/EmptyValueCheckbox.js.map +1 -1
- package/dist/components/Filters/filter-items/SelectAllCheckbox.d.ts +8 -0
- package/dist/components/Filters/filter-items/SelectAllCheckbox.js +22 -0
- package/dist/components/Filters/filter-items/SelectAllCheckbox.js.map +1 -0
- package/dist/components/Filters/filter-items/filter-type/FilterDropdownContent.js +1 -1
- package/dist/components/Filters/filter-items/filter-type/FilterDropdownContent.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.js +2 -2
- package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/{TreeAttributeDropDown.d.ts → tree/TreeAttributeDropDown.d.ts} +1 -1
- package/dist/components/Filters/filter-items/filter-type/tree/TreeAttributeDropDown.js +130 -0
- package/dist/components/Filters/filter-items/filter-type/tree/TreeAttributeDropDown.js.map +1 -0
- package/dist/components/Filters/filter-items/filter-type/tree/useGetTreeData.d.ts +20 -0
- package/dist/components/Filters/filter-items/filter-type/tree/useGetTreeData.js +72 -0
- package/dist/components/Filters/filter-items/filter-type/tree/useGetTreeData.js.map +1 -0
- package/dist/components/Filters/filter-items/filter-type/tree/useTreesSearch.d.ts +7 -0
- package/dist/components/Filters/filter-items/filter-type/tree/useTreesSearch.js +36 -0
- package/dist/components/Filters/filter-items/filter-type/tree/useTreesSearch.js.map +1 -0
- package/dist/components/Filters/filter-items/filter-type/tree/utils/buildFlattenTreeMap.d.ts +2 -0
- package/dist/components/Filters/filter-items/filter-type/tree/utils/buildFlattenTreeMap.js +14 -0
- package/dist/components/Filters/filter-items/filter-type/tree/utils/buildFlattenTreeMap.js.map +1 -0
- package/dist/components/Filters/filter-items/filter-type/tree/utils/filterTreeByPermission.d.ts +2 -0
- package/dist/components/Filters/filter-items/filter-type/tree/utils/filterTreeByPermission.js +15 -0
- package/dist/components/Filters/filter-items/filter-type/tree/utils/filterTreeByPermission.js.map +1 -0
- package/dist/components/Filters/filter-items/filter-type/tree/utils/getSelectAllState.d.ts +5 -0
- package/dist/components/Filters/filter-items/filter-type/tree/utils/getSelectAllState.js +17 -0
- package/dist/components/Filters/filter-items/filter-type/tree/utils/getSelectAllState.js.map +1 -0
- package/dist/components/Notifications/hooks/useNotificationSubscription.js +1 -1
- package/dist/components/Notifications/hooks/useNotificationSubscription.js.map +1 -1
- package/dist/locales/en/shared.json +4 -1
- package/dist/locales/fr/shared.json +4 -1
- package/dist/types/records.d.ts +1 -0
- package/dist/types/records.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/Filters/filter-items/filter-type/TreeAttributeDropDown.js +0 -71
- package/dist/components/Filters/filter-items/filter-type/TreeAttributeDropDown.js.map +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ITreeNode {
|
|
2
|
+
title: string;
|
|
3
|
+
id: string;
|
|
4
|
+
key: string;
|
|
5
|
+
children: ITreeNode[];
|
|
6
|
+
accessRecordByDefaultPermission?: boolean;
|
|
7
|
+
libraryId: string;
|
|
8
|
+
recordId: string;
|
|
9
|
+
}
|
|
10
|
+
interface IUseGetTreeDataProps {
|
|
11
|
+
treeId: string;
|
|
12
|
+
attributeId: string;
|
|
13
|
+
libraryId: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const useGetTreeData: ({ treeId, attributeId, libraryId }: IUseGetTreeDataProps) => {
|
|
16
|
+
treeData: ITreeNode[];
|
|
17
|
+
isLoading: boolean;
|
|
18
|
+
error: Error;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
2
|
+
// This file is released under LGPL V3
|
|
3
|
+
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
import { useGetTreeNodeChildrenWithAccessByDefaultPermissionQueryLazyQuery } from '../../../../../_gqlTypes';
|
|
6
|
+
import { defaultPaginationPageSize } from '../../../../../constants';
|
|
7
|
+
export const useGetTreeData = ({ treeId, attributeId, libraryId }) => {
|
|
8
|
+
const [loadTreeContent] = useGetTreeNodeChildrenWithAccessByDefaultPermissionQueryLazyQuery();
|
|
9
|
+
const [treeData, setTreeData] = useState([]);
|
|
10
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
11
|
+
const [error, setError] = useState(null);
|
|
12
|
+
const _fetchChildrenPage = async (parentNodeKey, offset) => {
|
|
13
|
+
const { data } = await loadTreeContent({
|
|
14
|
+
variables: {
|
|
15
|
+
treeId,
|
|
16
|
+
node: parentNodeKey,
|
|
17
|
+
pagination: { offset, limit: defaultPaginationPageSize },
|
|
18
|
+
accessRecordByDefaultPermission: {
|
|
19
|
+
attributeId,
|
|
20
|
+
libraryId,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
const { list, totalCount } = data?.treeNodeChildren ?? { list: [], totalCount: 0 };
|
|
25
|
+
const nodes = await Promise.all(list.map(async (node) => {
|
|
26
|
+
const children = node.childrenCount ? await _fetchAllChildren(node.id) : [];
|
|
27
|
+
return {
|
|
28
|
+
title: node.record.whoAmI.label || node.record.whoAmI.id,
|
|
29
|
+
id: node.id,
|
|
30
|
+
key: node.id,
|
|
31
|
+
children,
|
|
32
|
+
accessRecordByDefaultPermission: node.accessRecordByDefaultPermission,
|
|
33
|
+
libraryId: node.record.whoAmI.library.id,
|
|
34
|
+
recordId: node.record.id,
|
|
35
|
+
};
|
|
36
|
+
}));
|
|
37
|
+
return { nodes, totalCount };
|
|
38
|
+
};
|
|
39
|
+
const _fetchAllChildren = async (parentNodeKey, offset = 0, accumulated = []) => {
|
|
40
|
+
const { nodes, totalCount } = await _fetchChildrenPage(parentNodeKey, offset);
|
|
41
|
+
const allNodes = [...accumulated, ...nodes];
|
|
42
|
+
const nextOffset = offset + defaultPaginationPageSize;
|
|
43
|
+
if (nextOffset < totalCount) {
|
|
44
|
+
return _fetchAllChildren(parentNodeKey, nextOffset, allNodes);
|
|
45
|
+
}
|
|
46
|
+
return allNodes;
|
|
47
|
+
};
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (!treeId) {
|
|
50
|
+
setTreeData([]);
|
|
51
|
+
setIsLoading(false);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const loadTree = async () => {
|
|
55
|
+
setIsLoading(true);
|
|
56
|
+
setError(null);
|
|
57
|
+
try {
|
|
58
|
+
const children = await _fetchAllChildren(null);
|
|
59
|
+
setTreeData(children);
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
setError(err instanceof Error ? err : new Error('Failed to load tree'));
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
setIsLoading(false);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
loadTree();
|
|
69
|
+
}, [treeId, attributeId, libraryId]);
|
|
70
|
+
return { treeData, isLoading, error };
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=useGetTreeData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetTreeData.js","sourceRoot":"","sources":["../../../../../../src/components/Filters/filter-items/filter-type/tree/useGetTreeData.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAC,iEAAiE,EAAC,MAAM,eAAe,CAAC;AAChG,OAAO,EAAC,yBAAyB,EAAC,MAAM,eAAe,CAAC;AAkBxD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAuB,EAAE,EAAE;IACrF,MAAM,CAAC,eAAe,CAAC,GAAG,iEAAiE,EAAE,CAAC;IAC9F,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAc,EAAE,CAAC,CAAC;IAC1D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAC;IAEvD,MAAM,kBAAkB,GAAG,KAAK,EAAE,aAA4B,EAAE,MAAc,EAAE,EAAE;QAC9E,MAAM,EAAC,IAAI,EAAC,GAAG,MAAM,eAAe,CAAC;YACjC,SAAS,EAAE;gBACP,MAAM;gBACN,IAAI,EAAE,aAAa;gBACnB,UAAU,EAAE,EAAC,MAAM,EAAE,KAAK,EAAE,yBAAyB,EAAC;gBACtD,+BAA+B,EAAE;oBAC7B,WAAW;oBACX,SAAS;iBACZ;aACJ;SACJ,CAAC,CAAC;QAEH,MAAM,EAAC,IAAI,EAAE,UAAU,EAAC,GAAG,IAAI,EAAE,gBAAgB,IAAI,EAAC,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAC,CAAC;QAE/E,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAC3B,IAAI,CAAC,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AC,EAAE,CAAC,CAAC;YAChB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO;QACX,CAAC;QAED,MAAM,QAAQ,GAAG,KAAK,IAAI,EAAE;YACxB,YAAY,CAAC,IAAI,CAAC,CAAC;YACnB,QAAQ,CAAC,IAAI,CAAC,CAAC;YACf,IAAI,CAAC;gBACD,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,IAAI,CAAC,CAAC;gBAC/C,WAAW,CAAC,QAAQ,CAAC,CAAC;YAC1B,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACX,QAAQ,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC;YAC5E,CAAC;oBAAS,CAAC;gBACP,YAAY,CAAC,KAAK,CAAC,CAAC;YACxB,CAAC;QACL,CAAC,CAAC;QAEF,QAAQ,EAAE,CAAC;IACf,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC;IAErC,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAC,CAAC;AACxC,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {useEffect, useState} from 'react';\nimport {useGetTreeNodeChildrenWithAccessByDefaultPermissionQueryLazyQuery} from '_ui/_gqlTypes';\nimport {defaultPaginationPageSize} from '_ui/constants';\n\nexport interface ITreeNode {\n title: string;\n id: string;\n key: string;\n children: ITreeNode[];\n accessRecordByDefaultPermission?: boolean;\n libraryId: string;\n recordId: string;\n}\n\ninterface IUseGetTreeDataProps {\n treeId: string;\n attributeId: string;\n libraryId: string;\n}\n\nexport const useGetTreeData = ({treeId, attributeId, libraryId}: IUseGetTreeDataProps) => {\n const [loadTreeContent] = useGetTreeNodeChildrenWithAccessByDefaultPermissionQueryLazyQuery();\n const [treeData, setTreeData] = useState<ITreeNode[]>([]);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n const _fetchChildrenPage = async (parentNodeKey: string | null, offset: number) => {\n const {data} = await loadTreeContent({\n variables: {\n treeId,\n node: parentNodeKey,\n pagination: {offset, limit: defaultPaginationPageSize},\n accessRecordByDefaultPermission: {\n attributeId,\n libraryId,\n },\n },\n });\n\n const {list, totalCount} = data?.treeNodeChildren ?? {list: [], totalCount: 0};\n\n const nodes = await Promise.all(\n list.map(async node => {\n const children = node.childrenCount ? await _fetchAllChildren(node.id) : [];\n\n return {\n title: node.record.whoAmI.label || node.record.whoAmI.id,\n id: node.id,\n key: node.id,\n children,\n accessRecordByDefaultPermission: node.accessRecordByDefaultPermission,\n libraryId: node.record.whoAmI.library.id,\n recordId: node.record.id,\n };\n }),\n );\n\n return {nodes, totalCount};\n };\n\n const _fetchAllChildren = async (\n parentNodeKey: string | null,\n offset = 0,\n accumulated: ITreeNode[] = [],\n ): Promise<ITreeNode[]> => {\n const {nodes, totalCount} = await _fetchChildrenPage(parentNodeKey, offset);\n const allNodes = [...accumulated, ...nodes];\n\n const nextOffset = offset + defaultPaginationPageSize;\n if (nextOffset < totalCount) {\n return _fetchAllChildren(parentNodeKey, nextOffset, allNodes);\n }\n\n return allNodes;\n };\n\n useEffect(() => {\n if (!treeId) {\n setTreeData([]);\n setIsLoading(false);\n return;\n }\n\n const loadTree = async () => {\n setIsLoading(true);\n setError(null);\n try {\n const children = await _fetchAllChildren(null);\n setTreeData(children);\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Failed to load tree'));\n } finally {\n setIsLoading(false);\n }\n };\n\n loadTree();\n }, [treeId, attributeId, libraryId]);\n\n return {treeData, isLoading, error};\n};\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ITreeNode } from './useGetTreeData';
|
|
2
|
+
export declare const useTreesSearch: (visibleByDefaultTree: ITreeNode[], hiddenByDefaultTree: ITreeNode[]) => {
|
|
3
|
+
filteredVisibleByDefaultTree: ITreeNode[];
|
|
4
|
+
filteredHiddenByDefaultTree: ITreeNode[];
|
|
5
|
+
expandedNodeIdsFromSearch: string[];
|
|
6
|
+
SearchInput: JSX.Element;
|
|
7
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
3
|
+
// This file is released under LGPL V3
|
|
4
|
+
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
5
|
+
import { KitInput } from 'aristid-ds';
|
|
6
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
7
|
+
import { faSearch } from '@fortawesome/free-solid-svg-icons';
|
|
8
|
+
import { useSharedTranslation } from '../../../../../hooks/useSharedTranslation';
|
|
9
|
+
import { useState } from 'react';
|
|
10
|
+
export const useTreesSearch = (visibleByDefaultTree, hiddenByDefaultTree) => {
|
|
11
|
+
const { t } = useSharedTranslation();
|
|
12
|
+
const [searchValue, setSearchValue] = useState('');
|
|
13
|
+
const normalizedSearch = searchValue.trim().toLowerCase();
|
|
14
|
+
const nodeIds = [];
|
|
15
|
+
const _filterNodes = (nodes) => nodes
|
|
16
|
+
.map(node => {
|
|
17
|
+
const filteredChildren = node.children ? _filterNodes(node.children) : [];
|
|
18
|
+
const matchesSelf = node.title.toLowerCase().includes(normalizedSearch);
|
|
19
|
+
if (!matchesSelf && filteredChildren.length === 0) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
nodeIds.push(node.id);
|
|
23
|
+
return {
|
|
24
|
+
...node,
|
|
25
|
+
children: filteredChildren,
|
|
26
|
+
};
|
|
27
|
+
})
|
|
28
|
+
.filter((node) => node !== null);
|
|
29
|
+
return {
|
|
30
|
+
filteredVisibleByDefaultTree: !normalizedSearch ? visibleByDefaultTree : _filterNodes(visibleByDefaultTree),
|
|
31
|
+
filteredHiddenByDefaultTree: !normalizedSearch ? hiddenByDefaultTree : _filterNodes(hiddenByDefaultTree),
|
|
32
|
+
expandedNodeIdsFromSearch: !normalizedSearch ? [] : nodeIds,
|
|
33
|
+
SearchInput: (_jsx(KitInput, { prefix: _jsx(FontAwesomeIcon, { icon: faSearch }), placeholder: t('global.search'), value: searchValue, onChange: e => setSearchValue(e.target.value), allowClear: true })),
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=useTreesSearch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTreesSearch.js","sourceRoot":"","sources":["../../../../../../src/components/Filters/filter-items/filter-type/tree/useTreesSearch.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE/B,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,oBAAiC,EAAE,mBAAgC,EAAE,EAAE;IAClG,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEnD,MAAM,gBAAgB,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC1D,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,MAAM,YAAY,GAAG,CAAC,KAAkB,EAAe,EAAE,CACrD,KAAK;SACA,GAAG,CAAC,IAAI,CAAC,EAAE;QACR,MAA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11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {KitInput} from 'aristid-ds';\nimport {type ITreeNode} from './useGetTreeData';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faSearch} from '@fortawesome/free-solid-svg-icons';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {useState} from 'react';\n\nexport const useTreesSearch = (visibleByDefaultTree: ITreeNode[], hiddenByDefaultTree: ITreeNode[]) => {\n const {t} = useSharedTranslation();\n const [searchValue, setSearchValue] = useState('');\n\n const normalizedSearch = searchValue.trim().toLowerCase();\n const nodeIds: string[] = [];\n\n const _filterNodes = (nodes: ITreeNode[]): ITreeNode[] =>\n nodes\n .map(node => {\n const filteredChildren = node.children ? _filterNodes(node.children) : [];\n const matchesSelf = node.title.toLowerCase().includes(normalizedSearch);\n\n if (!matchesSelf && filteredChildren.length === 0) {\n return null;\n }\n\n nodeIds.push(node.id);\n\n return {\n ...node,\n children: filteredChildren,\n };\n })\n .filter((node): node is ITreeNode => node !== null);\n\n return {\n filteredVisibleByDefaultTree: !normalizedSearch ? visibleByDefaultTree : _filterNodes(visibleByDefaultTree),\n filteredHiddenByDefaultTree: !normalizedSearch ? hiddenByDefaultTree : _filterNodes(hiddenByDefaultTree),\n expandedNodeIdsFromSearch: !normalizedSearch ? [] : nodeIds,\n SearchInput: (\n <KitInput\n prefix={<FontAwesomeIcon icon={faSearch} />}\n placeholder={t('global.search')}\n value={searchValue}\n onChange={e => setSearchValue(e.target.value)}\n allowClear\n />\n ),\n };\n};\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const buildFlattenTree = (nodes) => {
|
|
2
|
+
const treeMap = new Map();
|
|
3
|
+
const _buildFlattenTreeRecursive = (nodeList) => {
|
|
4
|
+
for (const node of nodeList) {
|
|
5
|
+
treeMap.set(node.id, node);
|
|
6
|
+
if (node.children && node.children.length > 0) {
|
|
7
|
+
_buildFlattenTreeRecursive(node.children);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
_buildFlattenTreeRecursive(nodes);
|
|
12
|
+
return treeMap;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=buildFlattenTreeMap.js.map
|
package/dist/components/Filters/filter-items/filter-type/tree/utils/buildFlattenTreeMap.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildFlattenTreeMap.js","sourceRoot":"","sources":["../../../../../../../src/components/Filters/filter-items/filter-type/tree/utils/buildFlattenTreeMap.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAkB,EAA0B,EAAE;IAC3E,MAAM,OAAO,GAAG,IAAI,GAAG,EAAqB,CAAC;IAE7C,MAAM,0BAA0B,GAAG,CAAC,QAAqB,EAAE,EAAE;QACzD,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;YAC1B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;YAE3B,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC5C,0BAA0B,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC9C,CAAC;QACL,CAAC;IACL,CAAC,CAAC;IAEF,0BAA0B,CAAC,KAAK,CAAC,CAAC;IAElC,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type ITreeNode} from '../useGetTreeData';\n\nexport const buildFlattenTree = (nodes: ITreeNode[]): Map<string, ITreeNode> => {\n const treeMap = new Map<string, ITreeNode>();\n\n const _buildFlattenTreeRecursive = (nodeList: ITreeNode[]) => {\n for (const node of nodeList) {\n treeMap.set(node.id, node);\n\n if (node.children && node.children.length > 0) {\n _buildFlattenTreeRecursive(node.children);\n }\n }\n };\n\n _buildFlattenTreeRecursive(nodes);\n\n return treeMap;\n};\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const filterTreeByPermission = (nodes, accessRecordByDefaultPermission) => {
|
|
2
|
+
const result = [];
|
|
3
|
+
for (const node of nodes) {
|
|
4
|
+
const filteredChildren = filterTreeByPermission(node.children, accessRecordByDefaultPermission);
|
|
5
|
+
const nodeMatchesPermission = node.accessRecordByDefaultPermission === accessRecordByDefaultPermission;
|
|
6
|
+
if (nodeMatchesPermission || filteredChildren.length > 0) {
|
|
7
|
+
result.push({
|
|
8
|
+
...node,
|
|
9
|
+
children: filteredChildren,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=filterTreeByPermission.js.map
|
package/dist/components/Filters/filter-items/filter-type/tree/utils/filterTreeByPermission.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterTreeByPermission.js","sourceRoot":"","sources":["../../../../../../../src/components/Filters/filter-items/filter-type/tree/utils/filterTreeByPermission.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAkB,EAAE,+BAAwC,EAAe,EAAE;IAChH,MAAM,MAAM,GAAgB,EAAE,CAAC;IAE/B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,IAAI,CAAC,QAAQ,EAAE,+BAA+B,CAAC,CAAC;QAChG,MAAM,qBAAqB,GAAG,IAAI,CAAC,+BAA+B,KAAK,+BAA+B,CAAC;QAEvG,IAAI,qBAAqB,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvD,MAAM,CAAC,IAAI,CAAC;gBACR,GAAG,IAAI;gBACP,QAAQ,EAAE,gBAAgB;aAC7B,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type ITreeNode} from '../useGetTreeData';\n\nexport const filterTreeByPermission = (nodes: ITreeNode[], accessRecordByDefaultPermission: boolean): ITreeNode[] => {\n const result: ITreeNode[] = [];\n\n for (const node of nodes) {\n const filteredChildren = filterTreeByPermission(node.children, accessRecordByDefaultPermission);\n const nodeMatchesPermission = node.accessRecordByDefaultPermission === accessRecordByDefaultPermission;\n\n if (nodeMatchesPermission || filteredChildren.length > 0) {\n result.push({\n ...node,\n children: filteredChildren,\n });\n }\n }\n\n return result;\n};\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const getSelectAllState = (selectedNodesIds, flattenTree) => {
|
|
2
|
+
const totalCount = flattenTree.size;
|
|
3
|
+
if (totalCount === 0) {
|
|
4
|
+
return {
|
|
5
|
+
allSelected: false,
|
|
6
|
+
indeterminate: false,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
const selectedCount = selectedNodesIds.filter(id => flattenTree.has(id)).length;
|
|
10
|
+
const allSelected = selectedCount === totalCount;
|
|
11
|
+
const indeterminate = selectedCount > 0 && !allSelected;
|
|
12
|
+
return {
|
|
13
|
+
allSelected,
|
|
14
|
+
indeterminate,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=getSelectAllState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSelectAllState.js","sourceRoot":"","sources":["../../../../../../../src/components/Filters/filter-items/filter-type/tree/utils/getSelectAllState.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,gBAA0B,EAAE,WAAmC,EAAE,EAAE;IACjG,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC;IAEpC,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO;YACH,WAAW,EAAE,KAAK;YAClB,aAAa,EAAE,KAAK;SACvB,CAAC;IACN,CAAC;IAED,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAChF,MAAM,WAAW,GAAG,aAAa,KAAK,UAAU,CAAC;IACjD,MAAM,aAAa,GAAG,aAAa,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC;IAExD,OAAO;QACH,WAAW;QACX,aAAa;KAChB,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type ITreeNode} from '../useGetTreeData';\n\nexport const getSelectAllState = (selectedNodesIds: string[], flattenTree: Map<string, ITreeNode>) => {\n const totalCount = flattenTree.size;\n\n if (totalCount === 0) {\n return {\n allSelected: false,\n indeterminate: false,\n };\n }\n\n const selectedCount = selectedNodesIds.filter(id => flattenTree.has(id)).length;\n const allSelected = selectedCount === totalCount;\n const indeterminate = selectedCount > 0 && !allSelected;\n\n return {\n allSelected,\n indeterminate,\n };\n};\n"]}
|
|
@@ -26,7 +26,7 @@ export const useNotificationsSubscription = () => {
|
|
|
26
26
|
duration: SUBSCRIPTION_NOTIFICATION_DURATION,
|
|
27
27
|
footer: (_jsxs(KitSpace, { direction: "horizontal", size: "xs", children: [attachments?.map(attachment => (_jsx(KitButton, { type: "secondary", onClick: () => window.open(attachment.url, '_blank'), icon: _jsx(FontAwesomeIcon, { icon: faDownload }), children: t('global.download') }, attachment.url))), relatedEntities?.map(relatedEntity => (_jsx(KitButton, { type: "secondary", onClick: () => {
|
|
28
28
|
window.location.href = relatedEntity.url;
|
|
29
|
-
}, children: t('global.show') }, relatedEntity.url)))] })),
|
|
29
|
+
}, children: relatedEntity.label ?? t('global.show') }, relatedEntity.url)))] })),
|
|
30
30
|
});
|
|
31
31
|
},
|
|
32
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNotificationSubscription.js","sourceRoot":"","sources":["../../../../src/components/Notifications/hooks/useNotificationSubscription.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,2BAA2B,EAAC,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,kCAAkC,EAAC,MAAM,eAAe,CAAC;AACjE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAC/E,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,UAAU,EAAC,MAAM,mCAAmC,CAAC;AAE7D,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,EAAE;IAC7C,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IACnC,OAAO,2BAA2B,CAAC;QAC/B,MAAM,EAAE,CAAC,EAAC,IAAI,EAAC,EAAE,EAAE;YACf,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;gBACnC,OAAO;YACX,CAAC;YACD,MAAM,EAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,IAAI,EAAC,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;YAE3F,MAAM,oBAAoB,GAAG,OAAO,eAAe,CAAC,KAAK,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;YAE3F,eAAe,CAAC,oBAAoB,CAAC,CAAC;gBAClC,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,KAAK;gBACd,WAAW,EAAE,OAAO;gBACpB,YAAY,EAAE,CACV,KAAC,aAAa,CAAC,IAAI,IAAC,IAAI,EAAC,WAAW,YAC/B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,GAC3B,CACxB;gBACD,QAAQ,EAAE,kCAAkC;gBAC5C,MAAM,EAAE,CACJ,MAAC,QAAQ,IAAC,SAAS,EAAC,YAAY,EAAC,IAAI,EAAC,IAAI,aACrC,WAAW,EAAE,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAC5B,KAAC,SAAS,IAEN,IAAI,EAAC,WAAW,EAChB,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,EACpD,IAAI,EAAE,KAAC,eAAe,IAAC,IAAI,EAAE,UAAU,GAAI,YAE1C,CAAC,CAAC,iBAAiB,CAAC,IALhB,UAAU,CAAC,GAAG,CAMX,CACf,CAAC,EACD,eAAe,EAAE,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,CACnC,KAAC,SAAS,IAEN,IAAI,EAAC,WAAW,EAChB,OAAO,EAAE,GAAG,EAAE;gCACV,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC;4BAC7C,CAAC,YAEA,CAAC,CAAC,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"useNotificationSubscription.js","sourceRoot":"","sources":["../../../../src/components/Notifications/hooks/useNotificationSubscription.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,2BAA2B,EAAC,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,kCAAkC,EAAC,MAAM,eAAe,CAAC;AAC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,CAAC,UAAU,CAAC,EAAE,CAAC,CAC5B,KAAC,SAAS,IAEN,IAAI,EAAC,WAAW,EAChB,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,EACpD,IAAI,EAAE,KAAC,eAAe,IAAC,IAAI,EAAE,UAAU,GAAI,YAE1C,CAAC,CAAC,iBAAiB,CAAC,IALhB,UAAU,CAAC,GAAG,CAMX,CACf,CAAC,EACD,eAAe,EAAE,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,CACnC,KAAC,SAAS,IAEN,IAAI,EAAC,WAAW,EAChB,OAAO,EAAE,GAAG,EAAE;gCACV,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC;4BAC7C,CAAC,YAEA,aAAa,CAAC,KAAK,IAAI,CAAC,CAAC,aAAa,CAAC,IANnC,aAAa,CAAC,GAAG,CAOd,CACf,CAAC,IACK,CACd;aACJ,CAAC,CAAC;QACP,CAAC;KACJ,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,eAAe,4BAA4B,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {useNotificationSubscription} from '_ui/_gqlTypes';\nimport {SUBSCRIPTION_NOTIFICATION_DURATION} from '_ui/constants';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {KitButton, KitSpace, KitNotification, KitTypography} from 'aristid-ds';\nimport dayjs from 'dayjs';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faDownload} from '@fortawesome/free-solid-svg-icons';\n\nexport const useNotificationsSubscription = () => {\n const {t} = useSharedTranslation();\n return useNotificationSubscription({\n onData: ({data}) => {\n if (!data?.data?.notification?.title) {\n return;\n }\n const {level, title, message, attachments, relatedEntities, date} = data.data.notification;\n\n const kitNotificationLevel = typeof KitNotification[level] === 'function' ? level : 'info';\n\n KitNotification[kitNotificationLevel]({\n closable: true,\n message: title,\n description: message,\n messageExtra: (\n <KitTypography.Text size=\"fontSize7\">\n {dayjs.unix(date).format('HH:mm DD/MM/YYYY')}\n </KitTypography.Text>\n ),\n duration: SUBSCRIPTION_NOTIFICATION_DURATION,\n footer: (\n <KitSpace direction=\"horizontal\" size=\"xs\">\n {attachments?.map(attachment => (\n <KitButton\n key={attachment.url}\n type=\"secondary\"\n onClick={() => window.open(attachment.url, '_blank')}\n icon={<FontAwesomeIcon icon={faDownload} />}\n >\n {t('global.download')}\n </KitButton>\n ))}\n {relatedEntities?.map(relatedEntity => (\n <KitButton\n key={relatedEntity.url}\n type=\"secondary\"\n onClick={() => {\n window.location.href = relatedEntity.url;\n }}\n >\n {relatedEntity.label ?? t('global.show')}\n </KitButton>\n ))}\n </KitSpace>\n ),\n });\n },\n });\n};\n\nexport default useNotificationsSubscription;\n"]}
|
|
@@ -310,7 +310,10 @@
|
|
|
310
310
|
"activate": "Activate",
|
|
311
311
|
"add": "Add",
|
|
312
312
|
"add-condition": "Add condition",
|
|
313
|
-
"empty-value": "Undefined"
|
|
313
|
+
"empty-value": "Undefined",
|
|
314
|
+
"visible-by-default": "Value(s) visible by default",
|
|
315
|
+
"hidden-by-default": "Value(s) hidden by default",
|
|
316
|
+
"select-all": "Select All"
|
|
314
317
|
},
|
|
315
318
|
"filter-item": {
|
|
316
319
|
"no-operator": "If"
|
|
@@ -310,7 +310,10 @@
|
|
|
310
310
|
"activate": "Activer",
|
|
311
311
|
"add": "Ajouter",
|
|
312
312
|
"add-condition": "Ajouter une condition",
|
|
313
|
-
"empty-value": "Non défini"
|
|
313
|
+
"empty-value": "Non défini",
|
|
314
|
+
"visible-by-default": "Valeurs affichée(s) par défaut",
|
|
315
|
+
"hidden-by-default": "Valeurs masquée(s) par défaut",
|
|
316
|
+
"select-all": "Tout sélectionner"
|
|
314
317
|
},
|
|
315
318
|
"filter-item": {
|
|
316
319
|
"no-operator": "Si"
|
package/dist/types/records.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../src/types/records.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type IPreviewScalar} from '@leav/utils';\nimport {type SystemTranslation} from './scalars';\n\nexport interface IRecordIdentityLibrary {\n id: string;\n label?: SystemTranslation | null;\n}\n\nexport interface IRecordIdentityPreview {\n tiny: string | null;\n small: string | null;\n medium: string | null;\n big: string | null;\n huge: string | null;\n}\n\nexport interface IRecordIdentityWhoAmI {\n id: string;\n label?: string | null;\n subLabel?: string | null;\n color?: string | null;\n library: IRecordIdentityLibrary;\n preview?: IPreviewScalar | null;\n}\n\nexport interface IRecordIdentity {\n id: string;\n whoAmI: IRecordIdentityWhoAmI;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../src/types/records.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type IPreviewScalar} from '@leav/utils';\nimport {type SystemTranslation} from './scalars';\n\nexport interface IRecordIdentityLibrary {\n id: string;\n label?: SystemTranslation | null;\n}\n\nexport interface IRecordIdentityPreview {\n tiny: string | null;\n small: string | null;\n medium: string | null;\n big: string | null;\n huge: string | null;\n}\n\nexport interface IRecordIdentityWhoAmI {\n id: string;\n label?: string | null;\n subLabel?: string | null;\n color?: string | null;\n library: IRecordIdentityLibrary;\n preview?: IPreviewScalar | null;\n parentContext?: IRecordIdentityWhoAmI[] | null;\n}\n\nexport interface IRecordIdentity {\n id: string;\n whoAmI: IRecordIdentityWhoAmI;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { RecordFilterCondition } from '../../../../_gqlTypes';
|
|
3
|
-
import { SelectTreeNode } from '../../../../components/SelectTreeNode';
|
|
4
|
-
import styled from 'styled-components';
|
|
5
|
-
import { EmptyValueCheckbox } from '../EmptyValueCheckbox';
|
|
6
|
-
const DivStyled = styled.div `
|
|
7
|
-
max-height: 30rem;
|
|
8
|
-
overflow: auto;
|
|
9
|
-
`;
|
|
10
|
-
export const TreeAttributeDropDown = ({ filter, onFilterChange, }) => {
|
|
11
|
-
const selectedNodesIds = (filter.nodes ?? []).map(node => node.nodeId);
|
|
12
|
-
const _handleOnCheckEmptyValue = (selected) => {
|
|
13
|
-
onFilterChange({
|
|
14
|
-
...filter,
|
|
15
|
-
withEmptyValues: selected,
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
const _handleOnSelect = (node, selected) => {
|
|
19
|
-
let newSelectedIds;
|
|
20
|
-
if (selected) {
|
|
21
|
-
newSelectedIds = [...selectedNodesIds, node.id];
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
newSelectedIds = selectedNodesIds.filter(selectedValue => selectedValue !== node.id);
|
|
25
|
-
}
|
|
26
|
-
onFilterChange({
|
|
27
|
-
...filter,
|
|
28
|
-
nodes: newSelectedIds.map(id => ({ nodeId: id, libraryId: node.record.whoAmI.library.id })),
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
const _getRecursiveChildrenRecord = (nodes) => {
|
|
32
|
-
const records = [];
|
|
33
|
-
const collectRecordIdsRecursively = (nodeList) => {
|
|
34
|
-
for (const node of nodeList) {
|
|
35
|
-
if (node.id === filter.attribute.linkedTree?.id) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
if (node.record) {
|
|
39
|
-
records.push(node.record);
|
|
40
|
-
}
|
|
41
|
-
if (node.children && node.children.length > 0) {
|
|
42
|
-
collectRecordIdsRecursively(node.children);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
collectRecordIdsRecursively(nodes);
|
|
47
|
-
// Delete duplicates
|
|
48
|
-
return Array.from(new Set(records));
|
|
49
|
-
};
|
|
50
|
-
const _getRecursiveFieldsFromLibraries = (nodes) => nodes
|
|
51
|
-
.filter(node => !!node.record?.whoAmI?.library?.id)
|
|
52
|
-
.map(node => `${filter.attribute.id}.${node.record?.whoAmI?.library?.id}.id`);
|
|
53
|
-
const _handleOnCheck = (selection) => {
|
|
54
|
-
const newSelectedNodes = selection.filter(node => !node?.disabled);
|
|
55
|
-
const records = _getRecursiveChildrenRecord(selection);
|
|
56
|
-
const fields = _getRecursiveFieldsFromLibraries(selection);
|
|
57
|
-
onFilterChange({
|
|
58
|
-
...filter,
|
|
59
|
-
nodes: newSelectedNodes.map(node => ({
|
|
60
|
-
nodeId: node.id,
|
|
61
|
-
libraryId: node.record?.whoAmI.library.id ?? records[0]?.whoAmI.library.id ?? '',
|
|
62
|
-
})),
|
|
63
|
-
value: records.map(record => record.id),
|
|
64
|
-
formattedValue: records.map(record => record.whoAmI.label).filter(Boolean),
|
|
65
|
-
condition: RecordFilterCondition.EQUAL,
|
|
66
|
-
field: fields,
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
return (_jsxs(DivStyled, { children: [_jsx(EmptyValueCheckbox, { onSelect: _handleOnCheckEmptyValue, filter: filter }), _jsx(SelectTreeNode, { treeId: filter.attribute.linkedTree?.id ?? '', selectedNodes: selectedNodesIds, onSelect: _handleOnSelect, onCheck: _handleOnCheck, multiple: true, canSelectRoot: true, checkStrictly: false, checkable: true, loadRecursively: true, noPagination: true })] }));
|
|
70
|
-
};
|
|
71
|
-
//# sourceMappingURL=TreeAttributeDropDown.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TreeAttributeDropDown.js","sourceRoot":"","sources":["../../../../../src/components/Filters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AC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type FunctionComponent} from 'react';\nimport {type IRecordIdentity, type ITreeNodeWithRecord} from '_ui/types';\nimport {RecordFilterCondition} from '_ui/_gqlTypes';\nimport {type IFilterChildrenTreeDropDownProps} from './_types';\nimport {SelectTreeNode} from '_ui/components/SelectTreeNode';\nimport styled from 'styled-components';\nimport {EmptyValueCheckbox} from '../EmptyValueCheckbox';\n\nconst DivStyled = styled.div`\n max-height: 30rem;\n overflow: auto;\n`;\n\nexport const TreeAttributeDropDown: FunctionComponent<IFilterChildrenTreeDropDownProps> = ({\n filter,\n onFilterChange,\n}) => {\n const selectedNodesIds = (filter.nodes ?? []).map(node => node.nodeId);\n\n const _handleOnCheckEmptyValue = (selected: boolean) => {\n onFilterChange({\n ...filter,\n withEmptyValues: selected,\n });\n };\n\n const _handleOnSelect = (node: ITreeNodeWithRecord, selected: boolean) => {\n let newSelectedIds: string[];\n if (selected) {\n newSelectedIds = [...selectedNodesIds, node.id];\n } else {\n newSelectedIds = selectedNodesIds.filter(selectedValue => selectedValue !== node.id);\n }\n onFilterChange({\n ...filter,\n nodes: newSelectedIds.map(id => ({nodeId: id, libraryId: node.record.whoAmI.library.id})),\n });\n };\n\n const _getRecursiveChildrenRecord = (nodes: ITreeNodeWithRecord[]): IRecordIdentity[] => {\n const records: IRecordIdentity[] = [];\n const collectRecordIdsRecursively = (nodeList: ITreeNodeWithRecord[]) => {\n for (const node of nodeList) {\n if (node.id === filter.attribute.linkedTree?.id) {\n continue;\n }\n if (node.record) {\n records.push(node.record);\n }\n if (node.children && node.children.length > 0) {\n collectRecordIdsRecursively(node.children);\n }\n }\n };\n collectRecordIdsRecursively(nodes);\n // Delete duplicates\n return Array.from(new Set(records));\n };\n const _getRecursiveFieldsFromLibraries = (nodes: ITreeNodeWithRecord[]): string[] =>\n nodes\n .filter(node => !!node.record?.whoAmI?.library?.id)\n .map(node => `${filter.attribute.id}.${node.record?.whoAmI?.library?.id}.id`);\n\n const _handleOnCheck = (selection: ITreeNodeWithRecord[]) => {\n const newSelectedNodes = selection.filter(node => !node?.disabled);\n\n const records = _getRecursiveChildrenRecord(selection);\n const fields = _getRecursiveFieldsFromLibraries(selection);\n\n onFilterChange({\n ...filter,\n nodes: newSelectedNodes.map(node => ({\n nodeId: node.id,\n libraryId: node.record?.whoAmI.library.id ?? records[0]?.whoAmI.library.id ?? '',\n })),\n value: records.map(record => record.id),\n formattedValue: records.map(record => record.whoAmI.label).filter(Boolean),\n condition: RecordFilterCondition.EQUAL,\n field: fields,\n });\n };\n\n return (\n <DivStyled>\n <EmptyValueCheckbox onSelect={_handleOnCheckEmptyValue} filter={filter} />\n <SelectTreeNode\n treeId={filter.attribute.linkedTree?.id ?? ''}\n selectedNodes={selectedNodesIds}\n onSelect={_handleOnSelect}\n onCheck={_handleOnCheck}\n multiple\n canSelectRoot={true}\n checkStrictly={false}\n checkable\n loadRecursively={true}\n noPagination={true}\n />\n </DivStyled>\n );\n};\n"]}
|