@leav/ui 1.12.0-ca805ec3 → 1.12.0-ce39d7e4
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__/utils.d.ts +3 -0
- package/dist/__mocks__/utils.js +2 -0
- package/dist/__mocks__/utils.js.map +1 -0
- package/dist/_gqlTypes/index.d.ts +352 -55
- package/dist/_gqlTypes/index.js +258 -46
- package/dist/_gqlTypes/index.js.map +1 -1
- package/dist/_queries/attributes/attributeDetailsFragment.js +3 -0
- package/dist/_queries/attributes/attributeDetailsFragment.js.map +1 -1
- package/dist/components/Explorer/DataView.js +30 -13
- package/dist/components/Explorer/DataView.js.map +1 -1
- package/dist/components/Explorer/_constants.d.ts +0 -1
- package/dist/components/Explorer/_constants.js +0 -1
- package/dist/components/Explorer/_constants.js.map +1 -1
- package/dist/components/Explorer/actions-item/useEditStatusItemAction.js +5 -9
- package/dist/components/Explorer/actions-item/useEditStatusItemAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.d.ts +4 -9
- package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.js +3 -11
- package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.js.map +1 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.d.ts +8 -8
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js +26 -13
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js.map +1 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/TreeNodeRemap.d.ts +7 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/TreeNodeRemap.js +30 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/TreeNodeRemap.js.map +1 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/_types.d.ts +23 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/_types.js +2 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/_types.js.map +1 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useMassEditableAttributes.d.ts +4 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useMassEditableAttributes.js +46 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useMassEditableAttributes.js.map +1 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.d.ts +12 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.js +24 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.js.map +1 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.d.ts +13 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.js +28 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.js.map +1 -0
- package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js +6 -10
- package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js +5 -8
- package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.d.ts +8 -2
- package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js +104 -80
- package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useMassActions.js +30 -19
- package/dist/components/Explorer/actions-mass/useMassActions.js.map +1 -1
- package/dist/components/Explorer/conditionsHelper.d.ts +2 -1
- package/dist/components/Explorer/conditionsHelper.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/prepareViewForRequest.js +6 -4
- package/dist/components/Explorer/manage-view-settings/save-view/prepareViewForRequest.js.map +1 -1
- package/dist/components/Filters/_types.d.ts +3 -0
- package/dist/components/Filters/_types.js.map +1 -1
- package/dist/components/Filters/conditionsHelper.d.ts +2 -1
- package/dist/components/Filters/conditionsHelper.js.map +1 -1
- package/dist/components/Filters/context/filtersReducer.js +14 -1
- package/dist/components/Filters/context/filtersReducer.js.map +1 -1
- package/dist/components/Filters/filter-items/CommonFilterItem.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/useConditionOptionsByType.js.map +1 -1
- package/dist/components/Filters/useFilters.d.ts +198 -0
- package/dist/components/Filters/useTransformFilters.js +4 -2
- package/dist/components/Filters/useTransformFilters.js.map +1 -1
- package/dist/components/RecordEdition/EditRecord/EditRecord.js +8 -1
- package/dist/components/RecordEdition/EditRecord/EditRecord.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.d.ts +1 -4
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.js +5 -9
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/DeleteAllValuesButton.js +4 -8
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/DeleteAllValuesButton.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js +1 -1
- package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js.map +1 -1
- package/dist/components/RecordEdition/hooks/useCreateCancelConfirm/useCreateCancelConfirm.js +4 -8
- package/dist/components/RecordEdition/hooks/useCreateCancelConfirm/useCreateCancelConfirm.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.js +4 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useConfirmModal/__mocks__/index.d.ts +1 -0
- package/dist/hooks/useConfirmModal/__mocks__/index.js +5 -0
- package/dist/hooks/useConfirmModal/__mocks__/index.js.map +1 -0
- package/dist/hooks/useConfirmModal/__mocks__/useConfirmModal.d.ts +3 -0
- package/dist/hooks/useConfirmModal/__mocks__/useConfirmModal.js +7 -0
- package/dist/hooks/useConfirmModal/__mocks__/useConfirmModal.js.map +1 -0
- package/dist/hooks/useConfirmModal/index.d.ts +1 -0
- package/dist/hooks/useConfirmModal/index.js +5 -0
- package/dist/hooks/useConfirmModal/index.js.map +1 -0
- package/dist/hooks/useConfirmModal/useConfirmModal.d.ts +7 -0
- package/dist/hooks/useConfirmModal/useConfirmModal.js +25 -0
- package/dist/hooks/useConfirmModal/useConfirmModal.js.map +1 -0
- package/dist/hooks/useGetRecordIdCard/index.d.ts +1 -0
- package/dist/hooks/useGetRecordIdCard/index.js +5 -0
- package/dist/hooks/useGetRecordIdCard/index.js.map +1 -0
- package/dist/hooks/useGetRecordIdCard/useGetRecordIdCard.d.ts +18 -0
- package/dist/hooks/useGetRecordIdCard/useGetRecordIdCard.js +20 -0
- package/dist/hooks/useGetRecordIdCard/useGetRecordIdCard.js.map +1 -0
- package/dist/hooks/useIFrameMessenger/iFrameMessengerContext.d.ts +6 -0
- package/dist/hooks/useIFrameMessenger/iFrameMessengerContext.js +8 -0
- package/dist/hooks/useIFrameMessenger/iFrameMessengerContext.js.map +1 -0
- package/dist/hooks/useIFrameMessenger/types.d.ts +5 -2
- package/dist/hooks/useIFrameMessenger/types.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.d.ts +10 -2
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.js +21 -9
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/useIFrameMessengerContext.d.ts +13 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessengerContext.js +59 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessengerContext.js.map +1 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessengerHandlers.d.ts +13 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessengerHandlers.js +29 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessengerHandlers.js.map +1 -0
- package/dist/hooks/useSharedTranslation/__mocks__/useSharedTranslation.js.map +1 -1
- package/dist/locales/en/shared.json +6 -4
- package/dist/locales/fr/shared.json +8 -6
- package/package.json +7 -7
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.d.ts +0 -8
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js +0 -40
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js.map +0 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.d.ts +0 -17
- package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js +0 -42
- package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js.map +0 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.d.ts +0 -5
- package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js +0 -20
- package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js.map +0 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.d.ts +0 -12
- package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js +0 -30
- package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leav/ui",
|
|
3
|
-
"version": "1.12.0-
|
|
3
|
+
"version": "1.12.0-ce39d7e4",
|
|
4
4
|
"description": "Shared React components and hooks",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepublishOnly": "yarn build",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"@babel/preset-react": "7.28.5",
|
|
30
30
|
"@graphql-codegen/add": "5.0.3",
|
|
31
31
|
"@graphql-codegen/cli": "6.2.1",
|
|
32
|
-
"@graphql-codegen/typescript": "5.0.
|
|
32
|
+
"@graphql-codegen/typescript": "5.0.10",
|
|
33
33
|
"@graphql-codegen/typescript-operations": "5.0.9",
|
|
34
|
-
"@graphql-codegen/typescript-react-apollo": "4.4.
|
|
34
|
+
"@graphql-codegen/typescript-react-apollo": "4.4.2",
|
|
35
35
|
"@testing-library/jest-dom": "5.17.0",
|
|
36
36
|
"@testing-library/react": "14.3.1",
|
|
37
37
|
"@testing-library/react-hooks": "8.0.1",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@types/lodash.isequal": "^4",
|
|
43
43
|
"@types/react": "18.2.14",
|
|
44
44
|
"@types/react-dom": "18.2.6",
|
|
45
|
-
"aristid-ds": "15.
|
|
45
|
+
"aristid-ds": "15.3.1-05878d4",
|
|
46
46
|
"babel-jest": "29.7.0",
|
|
47
47
|
"graphql": "16.13.2",
|
|
48
48
|
"i18next": "22.5.1",
|
|
@@ -56,11 +56,11 @@
|
|
|
56
56
|
"ts-jest": "29.4.9",
|
|
57
57
|
"tsc-alias": "1.8.16",
|
|
58
58
|
"typescript": "5.9.3",
|
|
59
|
-
"vite": "7.3.
|
|
59
|
+
"vite": "7.3.2"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@apollo/client": ">=3.8.1",
|
|
63
|
-
"aristid-ds": "15.
|
|
63
|
+
"aristid-ds": "15.3.1-05878d4",
|
|
64
64
|
"i18next": ">=22.5.1",
|
|
65
65
|
"react": "^18.2.0",
|
|
66
66
|
"react-dom": "^18.2.0",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@leav/utils": "1.12.0",
|
|
78
78
|
"@uidotdev/usehooks": "2.4.1",
|
|
79
79
|
"dayjs": "^1.11.13",
|
|
80
|
-
"dompurify": "3.
|
|
80
|
+
"dompurify": "3.4.0",
|
|
81
81
|
"html-react-parser": "4.2.10",
|
|
82
82
|
"i18next-resources-to-backend": "1.1.4",
|
|
83
83
|
"lodash.isequal": "4.5.0",
|
package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type FunctionComponent } from 'react';
|
|
2
|
-
import { type ITreeAttributeNodeValue } from './useListTreeAttributeValuesHook';
|
|
3
|
-
export declare const EditTreeAttributeValueLine: FunctionComponent<{
|
|
4
|
-
treeNodeValues: ITreeAttributeNodeValue[];
|
|
5
|
-
valueOccurrenceNodeId: string | null;
|
|
6
|
-
valueOccurrenceCount: number;
|
|
7
|
-
setAttributeMapping: (before: string | null, after: string | null) => void;
|
|
8
|
-
}>;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useSharedTranslation } from '../../../../hooks/useSharedTranslation';
|
|
3
|
-
import { KitIdCard, KitSelect, KitTypography } from 'aristid-ds';
|
|
4
|
-
import styled from 'styled-components';
|
|
5
|
-
const DivContainer = styled.div `
|
|
6
|
-
display: grid;
|
|
7
|
-
align-items: center;
|
|
8
|
-
grid-template-columns: repeat(3, 1fr);
|
|
9
|
-
grid-column-gap: calc(var(--general-spacing-l) * 1px);
|
|
10
|
-
`;
|
|
11
|
-
const UNDEFINED_VALUE = '__null__';
|
|
12
|
-
const DEFAULT_ID_CARD_COLOR = 'rgba(200, 200, 200, 1)';
|
|
13
|
-
export const EditTreeAttributeValueLine = ({ treeNodeValues, valueOccurrenceNodeId, valueOccurrenceCount, setAttributeMapping }) => {
|
|
14
|
-
const { t } = useSharedTranslation();
|
|
15
|
-
const treeNodeValueOfOccurrence = treeNodeValues.find(node => node.id === valueOccurrenceNodeId);
|
|
16
|
-
if (!treeNodeValueOfOccurrence) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
const allowedDependentValues = treeNodeValueOfOccurrence ? treeNodeValueOfOccurrence.allowedDependentValues : null;
|
|
20
|
-
const selectOptions = treeNodeValues
|
|
21
|
-
.filter(treeNode => treeNode.id !== valueOccurrenceNodeId)
|
|
22
|
-
.filter(treeNode => allowedDependentValues == null || // if no allowedDependentValues, all values are allowed
|
|
23
|
-
!!allowedDependentValues.find(dv => dv.nodeId === treeNode.id))
|
|
24
|
-
.map(treeNode => ({
|
|
25
|
-
label: treeNode.label,
|
|
26
|
-
value: treeNode.id || UNDEFINED_VALUE,
|
|
27
|
-
}));
|
|
28
|
-
if (selectOptions.length === 0 && valueOccurrenceNodeId) {
|
|
29
|
-
selectOptions.push({
|
|
30
|
-
label: t('explorer.massAction.editAttribute_value_do_not_change'),
|
|
31
|
-
value: valueOccurrenceNodeId,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
return (_jsxs(DivContainer, { children: [_jsx(KitIdCard, { title: treeNodeValueOfOccurrence.label, color: treeNodeValueOfOccurrence.color || DEFAULT_ID_CARD_COLOR }), _jsx(KitTypography.Text, { children: t('explorer.massAction.editAttribute_value_occurrences_to_edit', {
|
|
35
|
-
count: valueOccurrenceCount,
|
|
36
|
-
}) }), _jsx(KitSelect, { options: selectOptions, size: "middle", allowClear: false, placeholder: t('explorer.massAction.editAttribute_value_select_placeholder'), onChange: value => {
|
|
37
|
-
setAttributeMapping(valueOccurrenceNodeId, value === UNDEFINED_VALUE ? null : value || null);
|
|
38
|
-
} })] }));
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=EditTreeAttributeValueLine.js.map
|
package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EditTreeAttributeValueLine.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,SAAS,EAAE,SAAS,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAE/D,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAGvC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;CAK9B,CAAC;AAEF,MAAM,eAAe,GAAG,UAAU,CAAC;AACnC,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAEvD,MAAM,CAAC,MAAM,0BAA0B,GAKlC,CAAC,EAAC,cAAc,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,mBAAmB,EAAC,EAAE,EAAE;IACxF,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,yBAAyB,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,qBAAqB,CAAC,CAAC;IACjG,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,sBAAsB,GAAG,yBAAyB,CAAC,CAAC,CAAC,yBAAyB,CAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC;IAEnH,MAAM,aAAa,GAAG,cAAc;SAC/B,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,qBAAqB,CAAC;SACzD,MAAM,CACH,QAAQ,CAAC,EAAE,CACP,sBAAsB,IAAI,IAAI,IAAI,uDAAuD;QACzF,CAAC,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,KAAK,QAAQ,CAAC,EAAE,CAAC,CACrE;SACA,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACd,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,KAAK,EAAE,QAAQ,CAAC,EAAE,IAAI,eAAe;KACxC,CAAC,CAAC,CAAC;IAER,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,IAAI,qBAAqB,EAAE,CAAC;QACtD,aAAa,CAAC,IAAI,CAAC;YACf,KAAK,EAAE,CAAC,CAAC,uDAAuD,CAAC;YACjE,KAAK,EAAE,qBAAqB;SAC/B,CAAC,CAAC;IACP,CAAC;IAED,OAAO,CACH,MAAC,YAAY,eACT,KAAC,SAAS,IACN,KAAK,EAAE,yBAAyB,CAAC,KAAK,EACtC,KAAK,EAAE,yBAAyB,CAAC,KAAK,IAAI,qBAAqB,GACjE,EACF,KAAC,aAAa,CAAC,IAAI,cACd,CAAC,CAAC,6DAA6D,EAAE;oBAC9D,KAAK,EAAE,oBAAoB;iBAC9B,CAAC,GACe,EACrB,KAAC,SAAS,IACN,OAAO,EAAE,aAAa,EACtB,IAAI,EAAC,QAAQ,EACb,UAAU,EAAE,KAAK,EACjB,WAAW,EAAE,CAAC,CAAC,4DAA4D,CAAC,EAC5E,QAAQ,EAAE,KAAK,CAAC,EAAE;oBACd,mBAAmB,CAAC,qBAAqB,EAAE,KAAK,KAAK,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;gBACjG,CAAC,GACH,IACS,CAClB,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 AttributeDetailsTreeAttributeFragment} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {KitIdCard, KitSelect, KitTypography} from 'aristid-ds';\nimport {type FunctionComponent} from 'react';\nimport styled from 'styled-components';\nimport {type ITreeAttributeNodeValue} from './useListTreeAttributeValuesHook';\n\nconst DivContainer = styled.div`\n display: grid;\n align-items: center;\n grid-template-columns: repeat(3, 1fr);\n grid-column-gap: calc(var(--general-spacing-l) * 1px);\n`;\n\nconst UNDEFINED_VALUE = '__null__';\nconst DEFAULT_ID_CARD_COLOR = 'rgba(200, 200, 200, 1)';\n\nexport const EditTreeAttributeValueLine: FunctionComponent<{\n treeNodeValues: ITreeAttributeNodeValue[];\n valueOccurrenceNodeId: string | null;\n valueOccurrenceCount: number;\n setAttributeMapping: (before: string | null, after: string | null) => void;\n}> = ({treeNodeValues, valueOccurrenceNodeId, valueOccurrenceCount, setAttributeMapping}) => {\n const {t} = useSharedTranslation();\n\n const treeNodeValueOfOccurrence = treeNodeValues.find(node => node.id === valueOccurrenceNodeId);\n if (!treeNodeValueOfOccurrence) {\n return null;\n }\n\n const allowedDependentValues = treeNodeValueOfOccurrence ? treeNodeValueOfOccurrence.allowedDependentValues : null;\n\n const selectOptions = treeNodeValues\n .filter(treeNode => treeNode.id !== valueOccurrenceNodeId)\n .filter(\n treeNode =>\n allowedDependentValues == null || // if no allowedDependentValues, all values are allowed\n !!allowedDependentValues.find(dv => dv.nodeId === treeNode.id),\n )\n .map(treeNode => ({\n label: treeNode.label,\n value: treeNode.id || UNDEFINED_VALUE,\n }));\n\n if (selectOptions.length === 0 && valueOccurrenceNodeId) {\n selectOptions.push({\n label: t('explorer.massAction.editAttribute_value_do_not_change'),\n value: valueOccurrenceNodeId,\n });\n }\n\n return (\n <DivContainer>\n <KitIdCard\n title={treeNodeValueOfOccurrence.label}\n color={treeNodeValueOfOccurrence.color || DEFAULT_ID_CARD_COLOR}\n />\n <KitTypography.Text>\n {t('explorer.massAction.editAttribute_value_occurrences_to_edit', {\n count: valueOccurrenceCount,\n })}\n </KitTypography.Text>\n <KitSelect\n options={selectOptions}\n size=\"middle\"\n allowClear={false}\n placeholder={t('explorer.massAction.editAttribute_value_select_placeholder')}\n onChange={value => {\n setAttributeMapping(valueOccurrenceNodeId, value === UNDEFINED_VALUE ? null : value || null);\n }}\n />\n </DivContainer>\n );\n};\n"]}
|
package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type RecordFilterInput } from '../../../../_gqlTypes';
|
|
2
|
-
export type ValuesOccurrences = {
|
|
3
|
-
noValueCount: number;
|
|
4
|
-
occurrences: Array<{
|
|
5
|
-
count: number;
|
|
6
|
-
value: {
|
|
7
|
-
id: string;
|
|
8
|
-
};
|
|
9
|
-
}>;
|
|
10
|
-
loading?: boolean;
|
|
11
|
-
};
|
|
12
|
-
export type ValueOccurrence = ValuesOccurrences['occurrences'][0];
|
|
13
|
-
export declare const useCountValuesOccurrencesHook: ({ attributeId, libraryId, recordFilters, }: {
|
|
14
|
-
attributeId?: string;
|
|
15
|
-
libraryId: string;
|
|
16
|
-
recordFilters: RecordFilterInput[];
|
|
17
|
-
}) => ValuesOccurrences;
|
package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
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 { useCountValuesOccurrencesLazyQuery } from '../../../../_gqlTypes';
|
|
5
|
-
import { useEffect, useMemo } from 'react';
|
|
6
|
-
export const useCountValuesOccurrencesHook = ({ attributeId, libraryId, recordFilters, }) => {
|
|
7
|
-
const [countValuesOccurrences, { data: valuesOccurrences, loading }] = useCountValuesOccurrencesLazyQuery({
|
|
8
|
-
fetchPolicy: 'no-cache',
|
|
9
|
-
nextFetchPolicy: 'no-cache',
|
|
10
|
-
});
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
if (attributeId) {
|
|
13
|
-
countValuesOccurrences({
|
|
14
|
-
variables: {
|
|
15
|
-
attribute: attributeId,
|
|
16
|
-
library: libraryId,
|
|
17
|
-
recordFilters,
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}, [attributeId, libraryId, recordFilters]);
|
|
22
|
-
const noValueCount = useMemo(() => {
|
|
23
|
-
if (!valuesOccurrences) {
|
|
24
|
-
return 0;
|
|
25
|
-
}
|
|
26
|
-
return valuesOccurrences.listDistinctValues?.find(v => !('treeNode' in v) || v.treeNode === null)?.count || 0;
|
|
27
|
-
}, [valuesOccurrences]);
|
|
28
|
-
const occurrences = useMemo(() => {
|
|
29
|
-
if (!valuesOccurrences) {
|
|
30
|
-
return [];
|
|
31
|
-
}
|
|
32
|
-
return (valuesOccurrences.listDistinctValues
|
|
33
|
-
?.filter(v => 'treeNode' in v && v.treeNode !== null)
|
|
34
|
-
.map(v => ({ count: v.count, value: { id: v.treeNode.id } })) || []);
|
|
35
|
-
}, [valuesOccurrences]);
|
|
36
|
-
return {
|
|
37
|
-
occurrences,
|
|
38
|
-
noValueCount,
|
|
39
|
-
loading,
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=useCountValuesOccurrencesHook.js.map
|
package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCountValuesOccurrencesHook.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAyB,kCAAkC,EAAC,MAAM,eAAe,CAAC;AACzF,OAAO,EAAC,SAAS,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAQzC,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,EAC1C,WAAW,EACX,SAAS,EACT,aAAa,GAKhB,EAAqB,EAAE;IACpB,MAAM,CAAC,sBAAsB,EAAE,EAAC,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAC,CAAC,GAAG,kCAAkC,CAAC;QACpG,WAAW,EAAE,UAAU;QACvB,eAAe,EAAE,UAAU;KAC9B,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,WAAW,EAAE,CAAC;YACd,sBAAsB,CAAC;gBACnB,SAAS,EAAE;oBACP,SAAS,EAAE,WAAW;oBACtB,OAAO,EAAE,SAAS;oBAClB,aAAa;iBAChB;aACJ,CAAC,CAAC;QACP,CAAC;IACL,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC;IAE5C,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE;QAC9B,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACrB,OAAO,CAAC,CAAC;QACb,CAAC;QACD,OAAO,iBAAiB,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC;IAClH,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAExB,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE;QAC7B,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACrB,OAAO,EAAE,CAAC;QACd,CAAC;QACD,OAAO,CACH,iBAAiB,CAAC,kBAAkB;YAChC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC;aACpD,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAC,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAC,EAAE,EAAG,CAA8B,CAAC,QAAQ,CAAC,EAAE,EAAC,EAAC,CAAC,CAAC,IAAI,EAAE,CACpG,CAAC;IACN,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAExB,OAAO;QACH,WAAW;QACX,YAAY;QACZ,OAAO;KACV,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 RecordFilterInput, useCountValuesOccurrencesLazyQuery} from '_ui/_gqlTypes';\nimport {useEffect, useMemo} from 'react';\n\nexport type ValuesOccurrences = {\n noValueCount: number;\n occurrences: Array<{count: number; value: {id: string}}>;\n loading?: boolean;\n};\nexport type ValueOccurrence = ValuesOccurrences['occurrences'][0];\nexport const useCountValuesOccurrencesHook = ({\n attributeId,\n libraryId,\n recordFilters,\n}: {\n attributeId?: string;\n libraryId: string;\n recordFilters: RecordFilterInput[];\n}): ValuesOccurrences => {\n const [countValuesOccurrences, {data: valuesOccurrences, loading}] = useCountValuesOccurrencesLazyQuery({\n fetchPolicy: 'no-cache',\n nextFetchPolicy: 'no-cache',\n });\n\n useEffect(() => {\n if (attributeId) {\n countValuesOccurrences({\n variables: {\n attribute: attributeId,\n library: libraryId,\n recordFilters,\n },\n });\n }\n }, [attributeId, libraryId, recordFilters]);\n\n const noValueCount = useMemo(() => {\n if (!valuesOccurrences) {\n return 0;\n }\n return valuesOccurrences.listDistinctValues?.find(v => !('treeNode' in v) || v.treeNode === null)?.count || 0;\n }, [valuesOccurrences]);\n\n const occurrences = useMemo(() => {\n if (!valuesOccurrences) {\n return [];\n }\n return (\n valuesOccurrences.listDistinctValues\n ?.filter(v => 'treeNode' in v && v.treeNode !== null)\n .map(v => ({count: v.count, value: {id: (v as {treeNode: {id: string}}).treeNode.id}})) || []\n );\n }, [valuesOccurrences]);\n\n return {\n occurrences,\n noValueCount,\n loading,\n };\n};\n"]}
|
package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type AttributeDetailsTreeAttributeFragment } from '../../../../_gqlTypes';
|
|
2
|
-
export type EditableAttributes = AttributeDetailsTreeAttributeFragment[];
|
|
3
|
-
export declare const useListEditableAttributeHook: ({ libraryId }: {
|
|
4
|
-
libraryId: string;
|
|
5
|
-
}) => EditableAttributes;
|
package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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 { AttributeType } from '../../../../_gqlTypes';
|
|
5
|
-
import { useMemo } from 'react';
|
|
6
|
-
import { useAttributeDetailsData } from '../../manage-view-settings/_shared/useAttributeDetailsData';
|
|
7
|
-
export const useListEditableAttributeHook = ({ libraryId }) => {
|
|
8
|
-
const { attributeDetailsById } = useAttributeDetailsData(libraryId);
|
|
9
|
-
const treeMonoValuedAttributes = useMemo(() => Object.values(attributeDetailsById).filter(attr => {
|
|
10
|
-
const dependenciesTreeAttributes = ('permissions_conf_dependent_values' in attr &&
|
|
11
|
-
attr.permissions_conf_dependent_values?.dependenciesTreeAttributes) ||
|
|
12
|
-
[];
|
|
13
|
-
const dependentOnItself = dependenciesTreeAttributes.length === 1 && dependenciesTreeAttributes[0].id === attr.id;
|
|
14
|
-
return (attr.type === AttributeType.tree &&
|
|
15
|
-
!attr.multiple_values &&
|
|
16
|
-
(dependenciesTreeAttributes.length === 0 || dependentOnItself));
|
|
17
|
-
}), [attributeDetailsById]);
|
|
18
|
-
return treeMonoValuedAttributes;
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=useListEditableAttributeHook.js.map
|
package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useListEditableAttributeHook.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAA6C,aAAa,EAAC,MAAM,eAAe,CAAC;AACxF,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAC,uBAAuB,EAAC,MAAM,4DAA4D,CAAC;AAGnG,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,EAAC,SAAS,EAAsB,EAAsB,EAAE;IACjG,MAAM,EAAC,oBAAoB,EAAC,GAAG,uBAAuB,CAAC,SAAS,CAAC,CAAC;IAClE,MAAM,wBAAwB,GAA4C,OAAO,CAC7E,GAAG,EAAE,CACD,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;QAC9C,MAAM,0BAA0B,GAC5B,CAAC,mCAAmC,IAAI,IAAI;YACxC,IAAI,CAAC,iCAAiC,EAAE,0BAA0B,CAAC;YACvE,EAAE,CAAC;QACP,MAAM,iBAAiB,GACnB,0BAA0B,CAAC,MAAM,KAAK,CAAC,IAAI,0BAA0B,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC5F,OAAO,CACH,IAAI,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI;YAChC,CAAC,IAAI,CAAC,eAAe;YACrB,CAAC,0BAA0B,CAAC,MAAM,KAAK,CAAC,IAAI,iBAAiB,CAAC,CACjE,CAAC;IACN,CAAC,CAAC,EACN,CAAC,oBAAoB,CAAC,CACzB,CAAC;IAEF,OAAO,wBAAwB,CAAC;AACpC,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 AttributeDetailsTreeAttributeFragment, AttributeType} from '_ui/_gqlTypes';\nimport {useMemo} from 'react';\nimport {useAttributeDetailsData} from '../../manage-view-settings/_shared/useAttributeDetailsData';\n\nexport type EditableAttributes = AttributeDetailsTreeAttributeFragment[];\nexport const useListEditableAttributeHook = ({libraryId}: {libraryId: string}): EditableAttributes => {\n const {attributeDetailsById} = useAttributeDetailsData(libraryId);\n const treeMonoValuedAttributes: AttributeDetailsTreeAttributeFragment[] = useMemo(\n () =>\n Object.values(attributeDetailsById).filter(attr => {\n const dependenciesTreeAttributes =\n ('permissions_conf_dependent_values' in attr &&\n attr.permissions_conf_dependent_values?.dependenciesTreeAttributes) ||\n [];\n const dependentOnItself =\n dependenciesTreeAttributes.length === 1 && dependenciesTreeAttributes[0].id === attr.id;\n return (\n attr.type === AttributeType.tree &&\n !attr.multiple_values &&\n (dependenciesTreeAttributes.length === 0 || dependentOnItself)\n );\n }),\n [attributeDetailsById],\n );\n\n return treeMonoValuedAttributes;\n};\n"]}
|
package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type AttributeDetailsTreeAttributeFragment } from '../../../../_gqlTypes';
|
|
2
|
-
export interface ITreeAttributeNodeValue {
|
|
3
|
-
id: string | null;
|
|
4
|
-
label: string;
|
|
5
|
-
color?: string | null;
|
|
6
|
-
allowedDependentValues?: Array<{
|
|
7
|
-
nodeId?: string | null;
|
|
8
|
-
}> | null;
|
|
9
|
-
}
|
|
10
|
-
export declare const useListTreeAttributeValuesHook: ({ treeAttribute: treeAttribute, }: {
|
|
11
|
-
treeAttribute: AttributeDetailsTreeAttributeFragment;
|
|
12
|
-
}) => ITreeAttributeNodeValue[];
|
package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
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 { useAttributeWithValuesForMassEditionLazyQuery } from '../../../../_gqlTypes';
|
|
5
|
-
import { useSharedTranslation } from '../../../../hooks/useSharedTranslation';
|
|
6
|
-
import { useEffect, useMemo } from 'react';
|
|
7
|
-
export const useListTreeAttributeValuesHook = ({ treeAttribute: treeAttribute, }) => {
|
|
8
|
-
const { t } = useSharedTranslation();
|
|
9
|
-
const [loadValues, { data: treeContent }] = useAttributeWithValuesForMassEditionLazyQuery();
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
if (!treeAttribute.linked_tree) {
|
|
12
|
-
throw new Error('Fatal: selected attribute not found');
|
|
13
|
-
}
|
|
14
|
-
loadValues({
|
|
15
|
-
fetchPolicy: 'no-cache',
|
|
16
|
-
variables: {
|
|
17
|
-
attributeId: treeAttribute.id,
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
}, [treeAttribute]);
|
|
21
|
-
return useMemo(() => treeContent?.attributes?.list[0]?.tree_values?.map(treeValue => ({
|
|
22
|
-
id: treeValue.node?.id || null,
|
|
23
|
-
label: treeValue.node?.record.whoAmI.label ||
|
|
24
|
-
treeValue.node?.record.whoAmI.id ||
|
|
25
|
-
t('explorer.massAction.editAttribute_value_undefined'),
|
|
26
|
-
color: treeValue.node?.record.whoAmI.color,
|
|
27
|
-
allowedDependentValues: treeValue.allowedDependentValues || null,
|
|
28
|
-
})) || [], [treeContent]);
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=useListTreeAttributeValuesHook.js.map
|
package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useListTreeAttributeValuesHook.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,6CAA6C,EAA6C,MAAM,eAAe,CAAC;AACxH,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,SAAS,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AASzC,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,EAC3C,aAAa,EAAE,aAAa,GAG/B,EAA6B,EAAE;IAC5B,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,CAAC,UAAU,EAAE,EAAC,IAAI,EAAE,WAAW,EAAC,CAAC,GAAG,6CAA6C,EAAE,CAAC;IAE1F,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QAC3D,CAAC;QACD,UAAU,CAAC;YACP,WAAW,EAAE,UAAU;YACvB,SAAS,EAAE;gBACP,WAAW,EAAE,aAAa,CAAC,EAAE;aAChC;SACJ,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,OAAO,OAAO,CACV,GAAG,EAAE,CACD,WAAW,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAC7D,EAAE,EAAE,SAAS,CAAC,IAAI,EAAE,EAAE,IAAI,IAAI;QAC9B,KAAK,EACD,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK;YACnC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE;YAChC,CAAC,CAAC,mDAAmD,CAAC;QAC1D,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK;QAC1C,sBAAsB,EAAE,SAAS,CAAC,sBAAsB,IAAI,IAAI;KACnE,CAAC,CAAC,IAAI,EAAE,EACb,CAAC,WAAW,CAAC,CAChB,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 {useAttributeWithValuesForMassEditionLazyQuery, type AttributeDetailsTreeAttributeFragment} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {useEffect, useMemo} from 'react';\n\nexport interface ITreeAttributeNodeValue {\n id: string | null;\n label: string;\n color?: string | null;\n allowedDependentValues?: Array<{nodeId?: string | null}> | null;\n}\n\nexport const useListTreeAttributeValuesHook = ({\n treeAttribute: treeAttribute,\n}: {\n treeAttribute: AttributeDetailsTreeAttributeFragment;\n}): ITreeAttributeNodeValue[] => {\n const {t} = useSharedTranslation();\n const [loadValues, {data: treeContent}] = useAttributeWithValuesForMassEditionLazyQuery();\n\n useEffect(() => {\n if (!treeAttribute.linked_tree) {\n throw new Error('Fatal: selected attribute not found');\n }\n loadValues({\n fetchPolicy: 'no-cache',\n variables: {\n attributeId: treeAttribute.id,\n },\n });\n }, [treeAttribute]);\n\n return useMemo(\n () =>\n treeContent?.attributes?.list[0]?.tree_values?.map(treeValue => ({\n id: treeValue.node?.id || null,\n label:\n treeValue.node?.record.whoAmI.label ||\n treeValue.node?.record.whoAmI.id ||\n t('explorer.massAction.editAttribute_value_undefined'),\n color: treeValue.node?.record.whoAmI.color,\n allowedDependentValues: treeValue.allowedDependentValues || null,\n })) || [],\n [treeContent],\n );\n};\n"]}
|