@leav/ui 1.5.0 → 1.5.1-170d77cc

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.
Files changed (101) hide show
  1. package/dist/__mocks__/common/attribute.js +1 -0
  2. package/dist/__mocks__/common/attribute.js.map +1 -1
  3. package/dist/__mocks__/common/library.d.ts +9 -0
  4. package/dist/_gqlTypes/index.d.ts +222 -27
  5. package/dist/_gqlTypes/index.js +150 -12
  6. package/dist/_gqlTypes/index.js.map +1 -1
  7. package/dist/_queries/attributes/attributeDetailsFragment.js +1 -0
  8. package/dist/_queries/attributes/attributeDetailsFragment.js.map +1 -1
  9. package/dist/_queries/libraries/libraryDetailsFragment.js +7 -0
  10. package/dist/_queries/libraries/libraryDetailsFragment.js.map +1 -1
  11. package/dist/components/Explorer/DataView.js +4 -3
  12. package/dist/components/Explorer/DataView.js.map +1 -1
  13. package/dist/components/Explorer/Explorer.d.ts +1 -1
  14. package/dist/components/Explorer/Explorer.js +17 -4
  15. package/dist/components/Explorer/Explorer.js.map +1 -1
  16. package/dist/components/Explorer/ExplorerFiltersAndSorts.d.ts +1 -0
  17. package/dist/components/Explorer/ExplorerFiltersAndSorts.js +2 -2
  18. package/dist/components/Explorer/ExplorerFiltersAndSorts.js.map +1 -1
  19. package/dist/components/Explorer/ExplorerToolbar.d.ts +1 -0
  20. package/dist/components/Explorer/ExplorerToolbar.js +2 -2
  21. package/dist/components/Explorer/ExplorerToolbar.js.map +1 -1
  22. package/dist/components/Explorer/IdCard.js +2 -2
  23. package/dist/components/Explorer/IdCard.js.map +1 -1
  24. package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.d.ts +13 -0
  25. package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.js +20 -0
  26. package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.js.map +1 -0
  27. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.d.ts +10 -0
  28. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js +38 -0
  29. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js.map +1 -0
  30. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.d.ts +8 -0
  31. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js +16 -0
  32. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js.map +1 -0
  33. package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.d.ts +10 -0
  34. package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js +28 -0
  35. package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js.map +1 -0
  36. package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.d.ts +5 -0
  37. package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js +12 -0
  38. package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js.map +1 -0
  39. package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.d.ts +5 -0
  40. package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js +20 -0
  41. package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js.map +1 -0
  42. package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js.map +1 -1
  43. package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.d.ts +11 -0
  44. package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js +106 -0
  45. package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js.map +1 -0
  46. package/dist/components/Explorer/actions-mass/useExportMassAction.js +5 -6
  47. package/dist/components/Explorer/actions-mass/useExportMassAction.js.map +1 -1
  48. package/dist/components/Explorer/useLoadView.js +0 -2
  49. package/dist/components/Explorer/useLoadView.js.map +1 -1
  50. package/dist/components/Filters/_types.d.ts +4 -0
  51. package/dist/components/Filters/_types.js.map +1 -1
  52. package/dist/components/Filters/context/filtersReducer.js +20 -11
  53. package/dist/components/Filters/context/filtersReducer.js.map +1 -1
  54. package/dist/components/Filters/context/useFiltersReducer.d.ts +2 -1
  55. package/dist/components/Filters/context/useFiltersReducer.js +9 -5
  56. package/dist/components/Filters/context/useFiltersReducer.js.map +1 -1
  57. package/dist/components/Filters/context/useGetTreeFilters.d.ts +15 -0
  58. package/dist/components/Filters/context/useGetTreeFilters.js +63 -0
  59. package/dist/components/Filters/context/useGetTreeFilters.js.map +1 -0
  60. package/dist/components/Filters/filter-items/filter-type/TextAttributeDropDown.js +24 -7
  61. package/dist/components/Filters/filter-items/filter-type/TextAttributeDropDown.js.map +1 -1
  62. package/dist/components/Filters/filter-items/filter-type/TreeAttributeDropDown.js +15 -17
  63. package/dist/components/Filters/filter-items/filter-type/TreeAttributeDropDown.js.map +1 -1
  64. package/dist/components/Filters/index.js.map +1 -1
  65. package/dist/components/Filters/prepareFiltersForRequest.js +14 -5
  66. package/dist/components/Filters/prepareFiltersForRequest.js.map +1 -1
  67. package/dist/components/Filters/useFilters.d.ts +4 -0
  68. package/dist/components/Filters/useTransformFilters.d.ts +5 -1
  69. package/dist/components/Filters/useTransformFilters.js +26 -3
  70. package/dist/components/Filters/useTransformFilters.js.map +1 -1
  71. package/dist/components/LibraryPicker/LibrariesList/LibrariesList.js +1 -1
  72. package/dist/components/LibraryPicker/LibrariesList/LibrariesList.js.map +1 -1
  73. package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/display-tree-node/TreeNodeList.js +1 -1
  74. package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/display-tree-node/TreeNodeList.js.map +1 -1
  75. package/dist/components/RecordHistory/RecordHistory.js +11 -6
  76. package/dist/components/RecordHistory/RecordHistory.js.map +1 -1
  77. package/dist/components/RecordHistory/RecordHistoryLogEntry.js +13 -7
  78. package/dist/components/RecordHistory/RecordHistoryLogEntry.js.map +1 -1
  79. package/dist/components/SearchModal/SearchModal.js +1 -1
  80. package/dist/components/SearchModal/SearchModal.js.map +1 -1
  81. package/dist/components/SelectTreeNode/SelectTreeNodeContent.js +4 -1
  82. package/dist/components/SelectTreeNode/SelectTreeNodeContent.js.map +1 -1
  83. package/dist/components/TreePicker/TreesList/TreesList.js +1 -1
  84. package/dist/components/TreePicker/TreesList/TreesList.js.map +1 -1
  85. package/dist/constants.d.ts +1 -0
  86. package/dist/constants.js +1 -0
  87. package/dist/constants.js.map +1 -1
  88. package/dist/hooks/useIFrameMessenger/messageHandlers.d.ts +3 -1
  89. package/dist/hooks/useIFrameMessenger/messageHandlers.js +12 -0
  90. package/dist/hooks/useIFrameMessenger/messageHandlers.js.map +1 -1
  91. package/dist/hooks/useIFrameMessenger/schema.d.ts +38 -4
  92. package/dist/hooks/useIFrameMessenger/schema.js +10 -5
  93. package/dist/hooks/useIFrameMessenger/schema.js.map +1 -1
  94. package/dist/hooks/useIFrameMessenger/types.d.ts +20 -2
  95. package/dist/hooks/useIFrameMessenger/types.js.map +1 -1
  96. package/dist/hooks/useIFrameMessenger/useIFrameMessenger.d.ts +2 -0
  97. package/dist/hooks/useIFrameMessengerClient/iFrameMessengerClientContext.d.ts +2 -0
  98. package/dist/hooks/useIFrameMessengerClient/useIFrameMessengerClient.d.ts +2 -0
  99. package/dist/locales/en/shared.json +14 -2
  100. package/dist/locales/fr/shared.json +14 -2
  101. package/package.json +6 -7
@@ -0,0 +1,38 @@
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 = ({ selectedAttribute, treeNodeValues, valueOccurrenceNodeId, valueOccurrenceCount, setAttributeMapping }) => {
14
+ const { t } = useSharedTranslation();
15
+ const treeNodeValueOfOccurrence = valueOccurrenceNodeId
16
+ ? treeNodeValues.find(node => node.id === valueOccurrenceNodeId)
17
+ : null;
18
+ const selectOptions = treeNodeValues
19
+ .filter(treeNode => treeNode.id !== valueOccurrenceNodeId)
20
+ .map(treeNode => ({
21
+ label: treeNode.record.whoAmI.label || treeNode.record.whoAmI.id,
22
+ value: treeNode.id,
23
+ }))
24
+ .concat(selectedAttribute.required || !treeNodeValueOfOccurrence
25
+ ? []
26
+ : [
27
+ {
28
+ label: t('explorer.massAction.editAttribute_value_undefined'),
29
+ value: UNDEFINED_VALUE,
30
+ },
31
+ ]);
32
+ return (_jsxs(DivContainer, { children: [treeNodeValueOfOccurrence ? (_jsx(KitIdCard, { title: treeNodeValueOfOccurrence.record.whoAmI.label, color: treeNodeValueOfOccurrence.record.whoAmI.color || DEFAULT_ID_CARD_COLOR })) : (_jsx(KitIdCard, { title: t('explorer.massAction.editAttribute_value_undefined'), color: DEFAULT_ID_CARD_COLOR })), _jsx(KitTypography.Text, { children: t('explorer.massAction.editAttribute_value_occurrences_to_edit', {
33
+ count: valueOccurrenceCount,
34
+ }) }), _jsx(KitSelect, { options: selectOptions, size: "middle", allowClear: false, placeholder: t('explorer.massAction.editAttribute_value_select_placeholder'), onChange: value => {
35
+ setAttributeMapping(valueOccurrenceNodeId, value === UNDEFINED_VALUE ? null : value || null);
36
+ } })] }));
37
+ };
38
+ //# sourceMappingURL=EditTreeAttributeValueLine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditTreeAttributeValueLine.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,oBAAoB,EA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ACzB,KAAC,SAAS,IACN,KAAK,EAAE,yBAAyB,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EACpD,KAAK,EAAE,yBAAyB,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,IAAI,qBAAqB,GAC/E,CACL,CAAC,CAAC,CAAC,CACA,KAAC,SAAS,IACN,KAAK,EAAE,CAAC,CAAC,mDAAmD,CAAC,EAC7D,KAAK,EAAE,qBAAqB,GAC9B,CACL,EACD,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 TreeAttributeNodeValue} 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: TreeAttributeNodeValue[];\n selectedAttribute: AttributeDetailsTreeAttributeFragment;\n valueOccurrenceNodeId: string | null;\n valueOccurrenceCount: number;\n setAttributeMapping: (before: string | null, after: string | null) => void;\n}> = ({selectedAttribute, treeNodeValues, valueOccurrenceNodeId, valueOccurrenceCount, setAttributeMapping}) => {\n const {t} = useSharedTranslation();\n\n const treeNodeValueOfOccurrence = valueOccurrenceNodeId\n ? treeNodeValues.find(node => node.id === valueOccurrenceNodeId)\n : null;\n\n const selectOptions = treeNodeValues\n .filter(treeNode => treeNode.id !== valueOccurrenceNodeId)\n .map(treeNode => ({\n label: treeNode.record.whoAmI.label || treeNode.record.whoAmI.id,\n value: treeNode.id,\n }))\n .concat(\n selectedAttribute.required || !treeNodeValueOfOccurrence\n ? []\n : [\n {\n label: t('explorer.massAction.editAttribute_value_undefined'),\n value: UNDEFINED_VALUE,\n },\n ],\n );\n\n return (\n <DivContainer>\n {treeNodeValueOfOccurrence ? (\n <KitIdCard\n title={treeNodeValueOfOccurrence.record.whoAmI.label}\n color={treeNodeValueOfOccurrence.record.whoAmI.color || DEFAULT_ID_CARD_COLOR}\n />\n ) : (\n <KitIdCard\n title={t('explorer.massAction.editAttribute_value_undefined')}\n color={DEFAULT_ID_CARD_COLOR}\n />\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"]}
@@ -0,0 +1,8 @@
1
+ import { type AttributeDetailsTreeAttributeFragment } from '../../../../_gqlTypes';
2
+ import { type FunctionComponent } from 'react';
3
+ import { type ValuesOccurrences } from './useCountValuesOccurrencesHook';
4
+ export declare const EditTreeAttributeValuesMapping: FunctionComponent<{
5
+ selectedAttribute: AttributeDetailsTreeAttributeFragment;
6
+ valuesOccurrences: ValuesOccurrences;
7
+ setAttributeMapping: (before: string | null, after: string | null) => void;
8
+ }>;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { KitSpace } from 'aristid-ds';
3
+ import { useListTreeAttributeValuesHook } from './useListTreeAttributeValuesHook';
4
+ import { EditTreeAttributeValueLine } from './EditTreeAttributeValueLine';
5
+ export const EditTreeAttributeValuesMapping = ({ selectedAttribute, valuesOccurrences, setAttributeMapping }) => {
6
+ const treeAttributeValues = useListTreeAttributeValuesHook({ treeAttribute: selectedAttribute });
7
+ const { occurrences, noValueCount } = valuesOccurrences;
8
+ return (_jsxs(KitSpace, { direction: "vertical", size: "xs", style: { display: 'flex' }, children: [treeAttributeValues.map((nodeForOccurrence, index) => {
9
+ const occurrence = occurrences.find(occ => occ.value.id === nodeForOccurrence.id);
10
+ if (!occurrence) {
11
+ return null;
12
+ }
13
+ return (_jsx(EditTreeAttributeValueLine, { treeNodeValues: treeAttributeValues, selectedAttribute: selectedAttribute, valueOccurrenceNodeId: occurrence.value.id, valueOccurrenceCount: occurrence.count, setAttributeMapping: setAttributeMapping }, index));
14
+ }), noValueCount > 0 && (_jsx(EditTreeAttributeValueLine, { treeNodeValues: treeAttributeValues, selectedAttribute: selectedAttribute, valueOccurrenceNodeId: null, valueOccurrenceCount: noValueCount, setAttributeMapping: setAttributeMapping }))] }));
15
+ };
16
+ //# sourceMappingURL=EditTreeAttributeValuesMapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditTreeAttributeValuesMapping.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAA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L,IACM,CACd,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 {KitSpace} from 'aristid-ds';\nimport {type FunctionComponent} from 'react';\nimport {type ValuesOccurrences} from './useCountValuesOccurrencesHook';\nimport {useListTreeAttributeValuesHook} from './useListTreeAttributeValuesHook';\nimport {EditTreeAttributeValueLine} from './EditTreeAttributeValueLine';\n\nexport const EditTreeAttributeValuesMapping: FunctionComponent<{\n selectedAttribute: AttributeDetailsTreeAttributeFragment;\n valuesOccurrences: ValuesOccurrences;\n setAttributeMapping: (before: string | null, after: string | null) => void;\n}> = ({selectedAttribute, valuesOccurrences, setAttributeMapping}) => {\n const treeAttributeValues = useListTreeAttributeValuesHook({treeAttribute: selectedAttribute});\n const {occurrences, noValueCount} = valuesOccurrences;\n\n return (\n <KitSpace direction=\"vertical\" size=\"xs\" style={{display: 'flex'}}>\n {treeAttributeValues.map((nodeForOccurrence, index) => {\n const occurrence = occurrences.find(occ => occ.value.id === nodeForOccurrence.id);\n if (!occurrence) {\n return null;\n }\n return (\n <EditTreeAttributeValueLine\n key={index}\n treeNodeValues={treeAttributeValues}\n selectedAttribute={selectedAttribute}\n valueOccurrenceNodeId={occurrence.value.id}\n valueOccurrenceCount={occurrence.count}\n setAttributeMapping={setAttributeMapping}\n />\n );\n })}\n {noValueCount > 0 && (\n <EditTreeAttributeValueLine\n treeNodeValues={treeAttributeValues}\n selectedAttribute={selectedAttribute}\n valueOccurrenceNodeId={null}\n valueOccurrenceCount={noValueCount}\n setAttributeMapping={setAttributeMapping}\n />\n )}\n </KitSpace>\n );\n};\n"]}
@@ -0,0 +1,10 @@
1
+ import { type CountValuesOccurrencesQuery, type RecordFilterInput } from '../../../../_gqlTypes';
2
+ export type ValuesOccurrences = NonNullable<CountValuesOccurrencesQuery['countValuesOccurrences']> & {
3
+ loading?: boolean;
4
+ };
5
+ export type ValueOccurrence = ValuesOccurrences['occurrences'][0];
6
+ export declare const useCountValuesOccurrencesHook: ({ attributeId, libraryId, recordFilters, }: {
7
+ attributeId?: string;
8
+ libraryId: string;
9
+ recordFilters: RecordFilterInput[];
10
+ }) => ValuesOccurrences;
@@ -0,0 +1,28 @@
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 } 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
+ return {
23
+ occurrences: valuesOccurrences?.countValuesOccurrences?.occurrences || [],
24
+ noValueCount: valuesOccurrences?.countValuesOccurrences?.noValueCount || 0,
25
+ loading,
26
+ };
27
+ };
28
+ //# sourceMappingURL=useCountValuesOccurrencesHook.js.map
@@ -0,0 +1 @@
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,EAGH,kCAAkC,GACrC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAMhC,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,OAAO;QACH,WAAW,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,WAAW,IAAI,EAAE;QACzE,YAAY,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,YAAY,IAAI,CAAC;QAC1E,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 {\n type CountValuesOccurrencesQuery,\n type RecordFilterInput,\n useCountValuesOccurrencesLazyQuery,\n} from '_ui/_gqlTypes';\nimport {useEffect} from 'react';\n\nexport type ValuesOccurrences = NonNullable<CountValuesOccurrencesQuery['countValuesOccurrences']> & {\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 return {\n occurrences: valuesOccurrences?.countValuesOccurrences?.occurrences || [],\n noValueCount: valuesOccurrences?.countValuesOccurrences?.noValueCount || 0,\n loading,\n };\n};\n"]}
@@ -0,0 +1,5 @@
1
+ import { type AttributeDetailsTreeAttributeFragment } from '../../../../_gqlTypes';
2
+ export type EditableAttributes = AttributeDetailsTreeAttributeFragment[];
3
+ export declare const useListEditableAttributeHook: ({ libraryId }: {
4
+ libraryId: string;
5
+ }) => EditableAttributes;
@@ -0,0 +1,12 @@
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 => attr.type === AttributeType.tree && !attr.multiple_values), [attributeDetailsById]);
10
+ return treeMonoValuedAttributes;
11
+ };
12
+ //# sourceMappingURL=useListEditableAttributeHook.js.map
@@ -0,0 +1 @@
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,CACtC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,eAAe,CACpE,EACL,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(\n attr => attr.type === AttributeType.tree && !attr.multiple_values,\n ),\n [attributeDetailsById],\n );\n\n return treeMonoValuedAttributes;\n};\n"]}
@@ -0,0 +1,5 @@
1
+ import { type AttributeDetailsTreeAttributeFragment, type TreeNodeChildrenQuery } from '../../../../_gqlTypes';
2
+ export type TreeAttributeNodeValue = TreeNodeChildrenQuery['treeNodeChildren']['list'][0];
3
+ export declare const useListTreeAttributeValuesHook: ({ treeAttribute: treeAttribute, }: {
4
+ treeAttribute: AttributeDetailsTreeAttributeFragment;
5
+ }) => TreeAttributeNodeValue[];
@@ -0,0 +1,20 @@
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 { useTreeNodeChildrenLazyQuery, } from '../../../../_gqlTypes';
5
+ import { useEffect } from 'react';
6
+ export const useListTreeAttributeValuesHook = ({ treeAttribute: treeAttribute, }) => {
7
+ const [loadTreeContent, { data: treeContent }] = useTreeNodeChildrenLazyQuery();
8
+ useEffect(() => {
9
+ if (!treeAttribute.linked_tree) {
10
+ throw new Error('Fatal: selected attribute not found');
11
+ }
12
+ loadTreeContent({
13
+ variables: {
14
+ treeId: treeAttribute.linked_tree.id,
15
+ },
16
+ });
17
+ }, [treeAttribute]);
18
+ return treeContent?.treeNodeChildren.list || [];
19
+ };
20
+ //# sourceMappingURL=useListTreeAttributeValuesHook.js.map
@@ -0,0 +1 @@
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,EAGH,4BAA4B,GAC/B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAGhC,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,EAC3C,aAAa,EAAE,aAAa,GAG/B,EAA4B,EAAE;IAC3B,MAAM,CAAC,eAAe,EAAE,EAAC,IAAI,EAAE,WAAW,EAAC,CAAC,GAAG,4BAA4B,EAAE,CAAC;IAC9E,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QAC3D,CAAC;QACD,eAAe,CAAC;YACZ,SAAS,EAAE;gBACP,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,EAAE;aACvC;SACJ,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,OAAO,WAAW,EAAE,gBAAgB,CAAC,IAAI,IAAI,EAAE,CAAC;AACpD,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 {\n type AttributeDetailsTreeAttributeFragment,\n type TreeNodeChildrenQuery,\n useTreeNodeChildrenLazyQuery,\n} from '_ui/_gqlTypes';\nimport {useEffect} from 'react';\n\nexport type TreeAttributeNodeValue = TreeNodeChildrenQuery['treeNodeChildren']['list'][0];\nexport const useListTreeAttributeValuesHook = ({\n treeAttribute: treeAttribute,\n}: {\n treeAttribute: AttributeDetailsTreeAttributeFragment;\n}): TreeAttributeNodeValue[] => {\n const [loadTreeContent, {data: treeContent}] = useTreeNodeChildrenLazyQuery();\n useEffect(() => {\n if (!treeAttribute.linked_tree) {\n throw new Error('Fatal: selected attribute not found');\n }\n loadTreeContent({\n variables: {\n treeId: treeAttribute.linked_tree.id,\n },\n });\n }, [treeAttribute]);\n\n return treeContent?.treeNodeChildren.list || [];\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useDeleteLinkValues.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useDeleteLinkValues.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,yBAAyB,MAAM,uFAAuF,CAAC;AAE9H,OAAO,EAAoD,uBAAuB,EAAC,MAAM,yBAAyB,CAAC;AACnH,OAAO,EAA0B,OAAO,EAAC,MAAM,OAAO,CAAC;AACvD,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,OAAO,EAA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AAI;KAC5E,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 useSaveValueBatchMutation from '_ui/components/RecordEdition/EditRecordContent/hooks/useExecuteSaveValueBatchMutation';\nimport {type FeatureHook, type IEntrypointLink, type IMassActions} from '../_types';\nimport {type IViewSettingsAction, type IViewSettingsState, ViewSettingsActionTypes} from '../manage-view-settings';\nimport {type Dispatch, type Key, useMemo} from 'react';\nimport {useExplorerData} from '../_queries/useExplorerData';\nimport {FaTrash} from 'react-icons/fa';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {KitModal} from 'aristid-ds';\nimport {BREAK_TWO_LINES, MASS_SELECTION_ALL} from '../_constants';\nimport {type IValueToSubmit} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {FiltersOperator, UIFilter} from '_ui/components/Filters';\nimport {type IUIFiltersState} from '_ui/components/Filters/context/filtersReducer';\n\nexport const useDeleteLinkValues = ({\n isEnabled,\n store: {view, dispatch},\n filtersStore: {filters, filtersOperator},\n pagination,\n allVisibleKeys,\n onDelete,\n refetch,\n}: FeatureHook<{\n pagination: null | {limit: number; offset: number};\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n filtersStore: IUIFiltersState;\n allVisibleKeys: string[];\n onDelete?: IMassActions['callback'];\n refetch: ReturnType<typeof useExplorerData>['refetch'];\n}>) => {\n const {t} = useSharedTranslation();\n const {saveValues} = useSaveValueBatchMutation();\n\n const isLink = view.entrypoint.type === 'link';\n const {data: linkData, canEditLinkAttributeValues: canUnlinkValues} = useExplorerData({\n entrypoint: view.entrypoint,\n libraryId: view.libraryId,\n attributeIds: view.attributesIds,\n fulltextSearch: view.fulltextSearch,\n pagination,\n sorts: view.sort,\n filtersOperator,\n filters,\n skip: !isLink,\n });\n\n const _unlinkMassAction: IMassActions = useMemo(\n () => ({\n label: t('explorer.massAction.deactivate'),\n icon: <FaTrash />,\n deselectAll: true,\n callback: massSelectionFilter => {\n KitModal.confirm({\n width: '100%',\n style: {content: {width: '90vw', maxWidth: '656px'}},\n type: 'confirm',\n icon: false,\n title:\n t('explorer.delete_link', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) ?? undefined,\n content:\n t('explorer.delete_link_description', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) +\n BREAK_TWO_LINES +\n t('global.are_you_sure'),\n okText: t('global.submit') ?? undefined,\n cancelText: t('global.cancel') ?? undefined,\n onOk: async () => {\n const entrypoint = view.entrypoint as IEntrypointLink;\n let values: IValueToSubmit[];\n if (\n view.massSelection === MASS_SELECTION_ALL ||\n allVisibleKeys.every(key => view.massSelection.includes(key))\n ) {\n values =\n (linkData?.records ?? []).map(({id_value}) => ({\n attribute: entrypoint.linkAttributeId,\n idValue: id_value ?? null,\n value: null,\n })) ?? [];\n } else {\n values = (linkData?.records ?? []).reduce<IValueToSubmit[]>((acc, {id_value, key}) => {\n if (view.massSelection.includes(key)) {\n acc.push({\n attribute: entrypoint.linkAttributeId,\n idValue: id_value ?? null,\n value: null,\n });\n }\n return acc;\n }, []);\n }\n\n if (values.length > 0) {\n await saveValues(\n {\n id: entrypoint.parentRecordId,\n library: {\n id: entrypoint.parentLibraryId,\n },\n },\n values,\n undefined,\n true,\n );\n\n onDelete?.(\n massSelectionFilter,\n values.map(({idValue}) => idValue as Key),\n );\n await refetch();\n }\n dispatch({\n type: ViewSettingsActionTypes.SET_SELECTED_KEYS,\n payload: [],\n });\n },\n });\n },\n }),\n [t, saveValues, view.massSelection, dispatch, view.libraryId, allVisibleKeys],\n );\n\n return {\n unlinkMassAction: isEnabled && canUnlinkValues ? _unlinkMassAction : null,\n };\n};\n"]}
1
+ {"version":3,"file":"useDeleteLinkValues.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass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AO,EAAE,EAAE;qBACd,CAAC,CAAC;gBACP,CAAC;aACJ,CAAC,CAAC;QACP,CAAC;KACJ,CAAC,EACF,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAChF,CAAC;IAEF,OAAO;QACH,gBAAgB,EAAE,SAAS,IAAI,eAAe,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI;KAC5E,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 useSaveValueBatchMutation from '_ui/components/RecordEdition/EditRecordContent/hooks/useExecuteSaveValueBatchMutation';\nimport {type FeatureHook, type IEntrypointLink, type IMassActions} from '../_types';\nimport {type IViewSettingsAction, type IViewSettingsState, ViewSettingsActionTypes} from '../manage-view-settings';\nimport {type Dispatch, type Key, useMemo} from 'react';\nimport {useExplorerData} from '../_queries/useExplorerData';\nimport {FaTrash} from 'react-icons/fa';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {KitModal} from 'aristid-ds';\nimport {BREAK_TWO_LINES, MASS_SELECTION_ALL} from '../_constants';\nimport {type IValueToSubmit} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {type IUIFiltersState} from '_ui/components/Filters/context/filtersReducer';\n\nexport const useDeleteLinkValues = ({\n isEnabled,\n store: {view, dispatch},\n filtersStore: {filters, filtersOperator},\n pagination,\n allVisibleKeys,\n onDelete,\n refetch,\n}: FeatureHook<{\n pagination: null | {limit: number; offset: number};\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n filtersStore: IUIFiltersState;\n allVisibleKeys: string[];\n onDelete?: IMassActions['callback'];\n refetch: ReturnType<typeof useExplorerData>['refetch'];\n}>) => {\n const {t} = useSharedTranslation();\n const {saveValues} = useSaveValueBatchMutation();\n\n const isLink = view.entrypoint.type === 'link';\n const {data: linkData, canEditLinkAttributeValues: canUnlinkValues} = useExplorerData({\n entrypoint: view.entrypoint,\n libraryId: view.libraryId,\n attributeIds: view.attributesIds,\n fulltextSearch: view.fulltextSearch,\n pagination,\n sorts: view.sort,\n filtersOperator,\n filters,\n skip: !isLink,\n });\n\n const _unlinkMassAction: IMassActions = useMemo(\n () => ({\n label: t('explorer.massAction.deactivate'),\n icon: <FaTrash />,\n deselectAll: true,\n callback: massSelectionFilter => {\n KitModal.confirm({\n width: '100%',\n style: {content: {width: '90vw', maxWidth: '656px'}},\n type: 'confirm',\n icon: false,\n title:\n t('explorer.delete_link', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) ?? undefined,\n content:\n t('explorer.delete_link_description', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) +\n BREAK_TWO_LINES +\n t('global.are_you_sure'),\n okText: t('global.submit') ?? undefined,\n cancelText: t('global.cancel') ?? undefined,\n onOk: async () => {\n const entrypoint = view.entrypoint as IEntrypointLink;\n let values: IValueToSubmit[];\n if (\n view.massSelection === MASS_SELECTION_ALL ||\n allVisibleKeys.every(key => view.massSelection.includes(key))\n ) {\n values =\n (linkData?.records ?? []).map(({id_value}) => ({\n attribute: entrypoint.linkAttributeId,\n idValue: id_value ?? null,\n value: null,\n })) ?? [];\n } else {\n values = (linkData?.records ?? []).reduce<IValueToSubmit[]>((acc, {id_value, key}) => {\n if (view.massSelection.includes(key)) {\n acc.push({\n attribute: entrypoint.linkAttributeId,\n idValue: id_value ?? null,\n value: null,\n });\n }\n return acc;\n }, []);\n }\n\n if (values.length > 0) {\n await saveValues(\n {\n id: entrypoint.parentRecordId,\n library: {\n id: entrypoint.parentLibraryId,\n },\n },\n values,\n undefined,\n true,\n );\n\n onDelete?.(\n massSelectionFilter,\n values.map(({idValue}) => idValue as Key),\n );\n await refetch();\n }\n dispatch({\n type: ViewSettingsActionTypes.SET_SELECTED_KEYS,\n payload: [],\n });\n },\n });\n },\n }),\n [t, saveValues, view.massSelection, dispatch, view.libraryId, allVisibleKeys],\n );\n\n return {\n unlinkMassAction: isEnabled && canUnlinkValues ? _unlinkMassAction : null,\n };\n};\n"]}
@@ -0,0 +1,11 @@
1
+ import { type FeatureHook, type IMassActions } from '../_types';
2
+ import { type IViewSettingsState } from '../manage-view-settings';
3
+ export declare const useEditAttributeMassAction: ({ isEnabled, store: { view }, totalCount, }: FeatureHook<{
4
+ store: {
5
+ view: IViewSettingsState;
6
+ };
7
+ totalCount: number;
8
+ }>) => {
9
+ editAttributeMassAction: IMassActions;
10
+ editAttributeMassActionModal: JSX.Element;
11
+ };
@@ -0,0 +1,106 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } 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 { AttributeType, useSaveValueBulkMutation, } from '../../../_gqlTypes';
6
+ import { useSharedTranslation } from '../../../hooks/useSharedTranslation';
7
+ import { useEffect, useMemo, useState } from 'react';
8
+ import { FaEdit } from 'react-icons/fa';
9
+ import { MASS_SELECTION_ALL } from '../_constants';
10
+ import { EditTreeAttributeValuesMapping } from './edit-attribute/EditTreeAttributeValuesMapping';
11
+ import { EditAttributeMassActionModal } from './edit-attribute/EditAttributeMassActionModal';
12
+ import { useListEditableAttributeHook } from './edit-attribute/useListEditableAttributeHook';
13
+ import { useCountValuesOccurrencesHook } from './edit-attribute/useCountValuesOccurrencesHook';
14
+ import { KitAlert, useKitNotification } from 'aristid-ds';
15
+ import { ERROR_ALERT_DURATION, INFO_NOTIFICATION_DURATION_SECONDS } from '../../../constants';
16
+ import { Loading } from '../../../components/Loading';
17
+ export const useEditAttributeMassAction = ({ isEnabled, store: { view }, totalCount, }) => {
18
+ if (!isEnabled) {
19
+ return {
20
+ editAttributeMassAction: null,
21
+ editAttributeMassActionModal: null,
22
+ };
23
+ }
24
+ const { t } = useSharedTranslation();
25
+ const { kitNotification } = useKitNotification();
26
+ const [selectedAttribute, setSelectedAttribute] = useState(undefined);
27
+ const [massSelectionFilter, setMassSelectionFilter] = useState([]);
28
+ const [openModal, setOpenModal] = useState(false);
29
+ const [editionMapping, setEditionMapping] = useState([]);
30
+ const editableAttributes = useListEditableAttributeHook({ libraryId: view.libraryId });
31
+ const valuesOccurrences = useCountValuesOccurrencesHook({
32
+ attributeId: selectedAttribute?.id,
33
+ libraryId: view.libraryId,
34
+ recordFilters: massSelectionFilter,
35
+ });
36
+ const [executeSaveValueBulk] = useSaveValueBulkMutation();
37
+ useEffect(() => {
38
+ setEditionMapping([]);
39
+ }, [selectedAttribute]);
40
+ const _editAttributeMassAction = useMemo(() => ({
41
+ label: t('explorer.massAction.editAttribute'),
42
+ icon: _jsx(FaEdit, {}),
43
+ deselectAll: false,
44
+ callback: _massSelectionFilter => {
45
+ setMassSelectionFilter(_massSelectionFilter);
46
+ setEditionMapping([]);
47
+ setOpenModal(true);
48
+ },
49
+ }), [t, view.massSelection]);
50
+ const closeModal = () => {
51
+ setOpenModal(false);
52
+ setMassSelectionFilter([]);
53
+ setSelectedAttribute(undefined);
54
+ setEditionMapping([]);
55
+ };
56
+ const isMappingCompleted = useMemo(() => valuesOccurrences.noValueCount === 0
57
+ ? editionMapping.length === valuesOccurrences.occurrences.length
58
+ : editionMapping.length === valuesOccurrences.occurrences.length + 1, // for undefined values
59
+ [editionMapping, valuesOccurrences]);
60
+ const bulkCounter = useMemo(() => (view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length), [view.massSelection, totalCount]);
61
+ const onOkButtonClick = async () => {
62
+ if (!selectedAttribute || !isMappingCompleted) {
63
+ return;
64
+ }
65
+ try {
66
+ await executeSaveValueBulk({
67
+ variables: {
68
+ libraryId: view.libraryId,
69
+ recordsFilters: massSelectionFilter,
70
+ attributeId: selectedAttribute.id,
71
+ mapValues: editionMapping,
72
+ },
73
+ });
74
+ closeModal();
75
+ kitNotification.info({
76
+ message: t('explorer.massAction.editAttribute_submit_notification_title'),
77
+ description: t('explorer.massAction.editAttribute_submit_notification_description', {
78
+ counter: bulkCounter,
79
+ }),
80
+ duration: INFO_NOTIFICATION_DURATION_SECONDS,
81
+ });
82
+ }
83
+ catch (error) {
84
+ KitAlert.error({
85
+ showIcon: true,
86
+ duration: ERROR_ALERT_DURATION,
87
+ message: t('error.error_occurred'),
88
+ description: t('explorer.massAction.editAttribute_submit_error'),
89
+ closable: true,
90
+ });
91
+ }
92
+ };
93
+ if (editableAttributes.length === 0) {
94
+ return {
95
+ editAttributeMassAction: null,
96
+ editAttributeMassActionModal: null,
97
+ };
98
+ }
99
+ return {
100
+ editAttributeMassAction: _editAttributeMassAction,
101
+ editAttributeMassActionModal: (_jsxs(EditAttributeMassActionModal, { isOpen: openModal, attributes: editableAttributes, setSelectedAttribute: setSelectedAttribute, massSelectionFilter: massSelectionFilter, elementsCount: bulkCounter, disableOkButton: !isMappingCompleted, onOkButtonClick: onOkButtonClick, onCancelButtonClick: closeModal, children: [selectedAttribute != null && valuesOccurrences.loading ? _jsx(Loading, {}) : null, selectedAttribute?.type === AttributeType.tree && (_jsx(EditTreeAttributeValuesMapping, { selectedAttribute: selectedAttribute, valuesOccurrences: valuesOccurrences, setAttributeMapping: (before, after) => {
102
+ setEditionMapping(editionMapping.filter(mapping => mapping.before !== before).concat([{ before, after }]));
103
+ } }))] })),
104
+ };
105
+ };
106
+ //# sourceMappingURL=useEditAttributeMassAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEditAttributeMassAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useEditAttributeMassAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAEH,aAAa,EAEb,wBAAwB,GAC3B,MAAM,e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C,CAAC,gDAAgD,CAAC;gBAChE,QAAQ,EAAE,IAAI;aACjB,CAAC,CAAC;QACP,CAAC;IACL,CAAC,CAAC;IAEF,IAAI,kBAAkB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO;YACH,uBAAuB,EAAE,IAAI;YAC7B,4BAA4B,EAAE,IAAI;SACrC,CAAC;IACN,CAAC;IAED,OAAO;QACH,uBAAuB,EAAE,wBAAwB;QACjD,4BAA4B,EAAE,CAC1B,MAAC,4BAA4B,IACzB,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,kBAAkB,EAC9B,oBAAoB,EAAE,oBAAoB,EAC1C,mBAAmB,EAAE,mBAAmB,EACxC,aAAa,EAAE,WAAW,EAC1B,eAAe,EAAE,CAAC,kBAAkB,EACpC,eAAe,EAAE,eAAe,EAChC,mBAAmB,EAAE,UAAU,aAE9B,iBAAiB,IAAI,IAAI,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,KAAC,OAAO,KAAG,CAAC,CAAC,CAAC,IAAI,EAC3E,iBAAiB,EAAE,IAAI,KAAK,aAAa,CAAC,IAAI,IAAI,CAC/C,KAAC,8BAA8B,IAC3B,iBAAiB,EAAE,iBAAiB,EACpC,iBAAiB,EAAE,iBAAiB,EACpC,mBAAmB,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;wBACnC,iBAAiB,CACb,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,EAAC,MAAM,EAAE,KAAK,EAAC,CAAC,CAAC,CACxF,CAAC;oBACN,CAAC,GACH,CACL,IAC0B,CAClC;KACJ,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 {\n type AttributeDetailsFragment,\n AttributeType,\n type RecordFilterInput,\n useSaveValueBulkMutation,\n} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {useEffect, useMemo, useState} from 'react';\nimport {FaEdit} from 'react-icons/fa';\nimport {MASS_SELECTION_ALL} from '../_constants';\nimport {type FeatureHook, type IMassActions} from '../_types';\nimport {type IViewSettingsState} from '../manage-view-settings';\nimport {EditTreeAttributeValuesMapping} from './edit-attribute/EditTreeAttributeValuesMapping';\nimport {EditAttributeMassActionModal} from './edit-attribute/EditAttributeMassActionModal';\nimport {useListEditableAttributeHook} from './edit-attribute/useListEditableAttributeHook';\nimport {useCountValuesOccurrencesHook} from './edit-attribute/useCountValuesOccurrencesHook';\nimport {KitAlert, useKitNotification} from 'aristid-ds';\nimport {ERROR_ALERT_DURATION, INFO_NOTIFICATION_DURATION_SECONDS} from '_ui/constants';\nimport {Loading} from '_ui/components/Loading';\n\nexport const useEditAttributeMassAction = ({\n isEnabled,\n store: {view},\n totalCount,\n}: FeatureHook<{\n store: {\n view: IViewSettingsState;\n };\n totalCount: number;\n}>) => {\n if (!isEnabled) {\n return {\n editAttributeMassAction: null,\n editAttributeMassActionModal: null,\n };\n }\n\n const {t} = useSharedTranslation();\n const {kitNotification} = useKitNotification();\n\n const [selectedAttribute, setSelectedAttribute] = useState<AttributeDetailsFragment | undefined>(undefined);\n const [massSelectionFilter, setMassSelectionFilter] = useState<RecordFilterInput[]>([]);\n const [openModal, setOpenModal] = useState<boolean>(false);\n const [editionMapping, setEditionMapping] = useState<Array<{before: string | null; after: string | null}>>([]);\n\n const editableAttributes = useListEditableAttributeHook({libraryId: view.libraryId});\n const valuesOccurrences = useCountValuesOccurrencesHook({\n attributeId: selectedAttribute?.id,\n libraryId: view.libraryId,\n recordFilters: massSelectionFilter,\n });\n\n const [executeSaveValueBulk] = useSaveValueBulkMutation();\n\n useEffect(() => {\n setEditionMapping([]);\n }, [selectedAttribute]);\n\n const _editAttributeMassAction: IMassActions = useMemo(\n () => ({\n label: t('explorer.massAction.editAttribute'),\n icon: <FaEdit />,\n deselectAll: false,\n callback: _massSelectionFilter => {\n setMassSelectionFilter(_massSelectionFilter);\n setEditionMapping([]);\n setOpenModal(true);\n },\n }),\n [t, view.massSelection],\n );\n\n const closeModal = () => {\n setOpenModal(false);\n setMassSelectionFilter([]);\n setSelectedAttribute(undefined);\n setEditionMapping([]);\n };\n\n const isMappingCompleted = useMemo(\n () =>\n valuesOccurrences.noValueCount === 0\n ? editionMapping.length === valuesOccurrences.occurrences.length\n : editionMapping.length === valuesOccurrences.occurrences.length + 1, // for undefined values\n [editionMapping, valuesOccurrences],\n );\n\n const bulkCounter = useMemo(\n () => (view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length),\n [view.massSelection, totalCount],\n );\n\n const onOkButtonClick = async () => {\n if (!selectedAttribute || !isMappingCompleted) {\n return;\n }\n try {\n await executeSaveValueBulk({\n variables: {\n libraryId: view.libraryId,\n recordsFilters: massSelectionFilter,\n attributeId: selectedAttribute.id,\n mapValues: editionMapping,\n },\n });\n\n closeModal();\n kitNotification.info({\n message: t('explorer.massAction.editAttribute_submit_notification_title'),\n description: t('explorer.massAction.editAttribute_submit_notification_description', {\n counter: bulkCounter,\n }),\n duration: INFO_NOTIFICATION_DURATION_SECONDS,\n });\n } catch (error) {\n KitAlert.error({\n showIcon: true,\n duration: ERROR_ALERT_DURATION,\n message: t('error.error_occurred'),\n description: t('explorer.massAction.editAttribute_submit_error'),\n closable: true,\n });\n }\n };\n\n if (editableAttributes.length === 0) {\n return {\n editAttributeMassAction: null,\n editAttributeMassActionModal: null,\n };\n }\n\n return {\n editAttributeMassAction: _editAttributeMassAction,\n editAttributeMassActionModal: (\n <EditAttributeMassActionModal\n isOpen={openModal}\n attributes={editableAttributes}\n setSelectedAttribute={setSelectedAttribute}\n massSelectionFilter={massSelectionFilter}\n elementsCount={bulkCounter}\n disableOkButton={!isMappingCompleted}\n onOkButtonClick={onOkButtonClick}\n onCancelButtonClick={closeModal}\n >\n {selectedAttribute != null && valuesOccurrences.loading ? <Loading /> : null}\n {selectedAttribute?.type === AttributeType.tree && (\n <EditTreeAttributeValuesMapping\n selectedAttribute={selectedAttribute}\n valuesOccurrences={valuesOccurrences}\n setAttributeMapping={(before, after) => {\n setEditionMapping(\n editionMapping.filter(mapping => mapping.before !== before).concat([{before, after}]),\n );\n }}\n />\n )}\n </EditAttributeMassActionModal>\n ),\n };\n};\n"]}
@@ -4,17 +4,18 @@ import { jsx as _jsx } from "react/jsx-runtime";
4
4
  // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
5
5
  import { useMemo } from 'react';
6
6
  import { FaFileExport } from 'react-icons/fa';
7
- import { KitAlert, KitModal } from 'aristid-ds';
7
+ import { KitAlert, KitModal, useKitNotification } from 'aristid-ds';
8
8
  import { useExportLazyQuery } from '../../../_gqlTypes';
9
9
  import { useSharedTranslation } from '../../../hooks/useSharedTranslation';
10
10
  import { BREAK_TWO_LINES, MASS_SELECTION_ALL } from '../_constants';
11
- import { ERROR_ALERT_DURATION, SUCCESS_ALERT_DURATION } from '../../../constants';
11
+ import { ERROR_ALERT_DURATION, INFO_NOTIFICATION_DURATION_SECONDS } from '../../../constants';
12
12
  /**
13
13
  * Hook that provides a mass action configuration for exporting selected or all items
14
14
  * from a view/data set
15
15
  */
16
16
  export const useExportMassAction = ({ isEnabled, store: { view, dispatch }, totalCount, onExport, }) => {
17
17
  const { t } = useSharedTranslation();
18
+ const { kitNotification } = useKitNotification();
18
19
  const [exportQuery] = useExportLazyQuery();
19
20
  const _exportMassAction = useMemo(() => ({
20
21
  label: t('explorer.massAction.export'),
@@ -53,15 +54,13 @@ export const useExportMassAction = ({ isEnabled, store: { view, dispatch }, tota
53
54
  errorWithExtensions.extensions = graphQLError?.extensions;
54
55
  throw errorWithExtensions;
55
56
  }
56
- KitAlert.success({
57
- showIcon: true,
58
- duration: SUCCESS_ALERT_DURATION,
57
+ kitNotification.info({
59
58
  message: t('explorer.massAction.export_message', { count: total }),
60
59
  description: t('explorer.massAction.export_description', {
61
60
  count: total,
62
61
  total,
63
62
  }),
64
- closable: true,
63
+ duration: INFO_NOTIFICATION_DURATION_SECONDS,
65
64
  });
66
65
  onExport?.(massSelectionFilter, view.massSelection);
67
66
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useExportMassAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useExportMassAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAgB,OAAO,EAAC,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACjD,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAGpE,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAClE,OAAO,EAAC,oBAAoB,EAAE,sBAAsB,EAAC,MAAM,eAAe,CAAC;AAE3E;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAChC,SAAS,EACT,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,EACvB,UAAU,EACV,QAAQ,GAQV,EAAE,EAAE;IACF,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,CAAC,WAAW,CAAC,GAAG,kBAAkB,EAAE,CAAC;IAE3C,MAAM,iBAAiB,GAAiB,OAAO,CAC3C,GAAG,EAAE,CAAC,CAAC;QACH,KAAK,EAAE,CAAC,CAAC,4BAA4B,CAAC;QACtC,IAAI,EAAE,KAAC,YAAY,KAAG;QACtB,WAAW,EAAE,KAAK;QAClB,QAAQ,EAAE,mBAAmB,CAAC,EAAE;YAC5B,QAAQ,CAAC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;gCAC9E,QAAQ,EAAE,IAAI;6BACjB,CAAC,CAAC;wBACP,CAAC;oBACL,CAAC;gBACL,CAAC;aACJ,CAAC,CAAC;QACP,CAAC;KACJ,CAAC,EACF,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CACjE,CAAC;IAEF,OAAO;QACH,gBAAgB,EAAE,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI;KACzD,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 Dispatch, useMemo} from 'react';\nimport {FaFileExport} from 'react-icons/fa';\nimport {KitAlert, KitModal} from 'aristid-ds';\nimport {useExportLazyQuery} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type FeatureHook, type IMassActions} from '../_types';\nimport {type IViewSettingsAction, type IViewSettingsState, ViewSettingsActionTypes} from '../manage-view-settings';\nimport {BREAK_TWO_LINES, MASS_SELECTION_ALL} from '../_constants';\nimport {ERROR_ALERT_DURATION, SUCCESS_ALERT_DURATION} from '_ui/constants';\n\n/**\n * Hook that provides a mass action configuration for exporting selected or all items\n * from a view/data set\n */\nexport const useExportMassAction = ({\n isEnabled,\n store: {view, dispatch},\n totalCount,\n onExport,\n}: FeatureHook<{\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n totalCount: number;\n onExport?: IMassActions['callback'];\n}>) => {\n const {t} = useSharedTranslation();\n\n const [exportQuery] = useExportLazyQuery();\n\n const _exportMassAction: IMassActions = useMemo(\n () => ({\n label: t('explorer.massAction.export'),\n icon: <FaFileExport />,\n deselectAll: false,\n callback: massSelectionFilter => {\n KitModal.confirm({\n width: '100%',\n style: {content: {width: '90vw', maxWidth: '656px'}},\n icon: false,\n type: 'confirm',\n title:\n t('explorer.export_item', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) ?? undefined,\n content:\n t('explorer.export_item_description', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) +\n BREAK_TWO_LINES +\n t('global.are_you_sure'),\n okText: t('global.confirm') ?? undefined,\n cancelText: t('global.cancel') ?? undefined,\n onOk: async () => {\n const total =\n view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;\n try {\n const {data, error} = await exportQuery({\n variables: {\n library: view.libraryId,\n filters: massSelectionFilter,\n profile: 'default', // Set 'default' by default, it'll change when we can select a profile from the UI\n },\n });\n if (error) {\n // Preserve the extensions property which contains the error code\n const graphQLError = error.graphQLErrors?.[0];\n const errorWithExtensions = new Error(error.message);\n (errorWithExtensions as any).extensions = graphQLError?.extensions;\n throw errorWithExtensions;\n }\n\n KitAlert.success({\n showIcon: true,\n duration: SUCCESS_ALERT_DURATION,\n message: t('explorer.massAction.export_message', {count: total}),\n description: t('explorer.massAction.export_description', {\n count: total,\n total,\n }),\n closable: true,\n });\n onExport?.(massSelectionFilter, view.massSelection);\n } catch (e) {\n if (e.extensions?.code === 'CUSTOM_CONFIG_ERROR') {\n KitAlert.error({\n showIcon: true,\n duration: ERROR_ALERT_DURATION,\n message: t('error.error_occurred', {count: total}),\n description: t('explorer.massAction.export_config_error_description', {\n library: view.libraryId,\n }),\n closable: true,\n });\n } else {\n KitAlert.error({\n showIcon: true,\n duration: ERROR_ALERT_DURATION,\n message: t('error.error_occurred'),\n description: t('explorer.massAction.export_error_description', {count: total}),\n closable: true,\n });\n }\n }\n },\n });\n },\n }),\n [t, exportQuery, view.massSelection, dispatch, view.libraryId],\n );\n\n return {\n exportMassAction: isEnabled ? _exportMassAction : null,\n };\n};\n"]}
1
+ {"version":3,"file":"useExportMassAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useExportMassAction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ACH,gBAAgB,EAAE,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI;KACzD,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 Dispatch, useMemo} from 'react';\nimport {FaFileExport} from 'react-icons/fa';\nimport {KitAlert, KitModal, useKitNotification} from 'aristid-ds';\nimport {useExportLazyQuery} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type FeatureHook, type IMassActions} from '../_types';\nimport {type IViewSettingsAction, type IViewSettingsState} from '../manage-view-settings';\nimport {BREAK_TWO_LINES, MASS_SELECTION_ALL} from '../_constants';\nimport {ERROR_ALERT_DURATION, INFO_NOTIFICATION_DURATION_SECONDS} from '_ui/constants';\n\n/**\n * Hook that provides a mass action configuration for exporting selected or all items\n * from a view/data set\n */\nexport const useExportMassAction = ({\n isEnabled,\n store: {view, dispatch},\n totalCount,\n onExport,\n}: FeatureHook<{\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n totalCount: number;\n onExport?: IMassActions['callback'];\n}>) => {\n const {t} = useSharedTranslation();\n const {kitNotification} = useKitNotification();\n\n const [exportQuery] = useExportLazyQuery();\n\n const _exportMassAction: IMassActions = useMemo(\n () => ({\n label: t('explorer.massAction.export'),\n icon: <FaFileExport />,\n deselectAll: false,\n callback: massSelectionFilter => {\n KitModal.confirm({\n width: '100%',\n style: {content: {width: '90vw', maxWidth: '656px'}},\n icon: false,\n type: 'confirm',\n title:\n t('explorer.export_item', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) ?? undefined,\n content:\n t('explorer.export_item_description', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) +\n BREAK_TWO_LINES +\n t('global.are_you_sure'),\n okText: t('global.confirm') ?? undefined,\n cancelText: t('global.cancel') ?? undefined,\n onOk: async () => {\n const total =\n view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;\n try {\n const {data, error} = await exportQuery({\n variables: {\n library: view.libraryId,\n filters: massSelectionFilter,\n profile: 'default', // Set 'default' by default, it'll change when we can select a profile from the UI\n },\n });\n if (error) {\n // Preserve the extensions property which contains the error code\n const graphQLError = error.graphQLErrors?.[0];\n const errorWithExtensions = new Error(error.message);\n (errorWithExtensions as any).extensions = graphQLError?.extensions;\n throw errorWithExtensions;\n }\n\n kitNotification.info({\n message: t('explorer.massAction.export_message', {count: total}),\n description: t('explorer.massAction.export_description', {\n count: total,\n total,\n }),\n duration: INFO_NOTIFICATION_DURATION_SECONDS,\n });\n\n onExport?.(massSelectionFilter, view.massSelection);\n } catch (e) {\n if (e.extensions?.code === 'CUSTOM_CONFIG_ERROR') {\n KitAlert.error({\n showIcon: true,\n duration: ERROR_ALERT_DURATION,\n message: t('error.error_occurred', {count: total}),\n description: t('explorer.massAction.export_config_error_description', {\n library: view.libraryId,\n }),\n closable: true,\n });\n } else {\n KitAlert.error({\n showIcon: true,\n duration: ERROR_ALERT_DURATION,\n message: t('error.error_occurred'),\n description: t('explorer.massAction.export_error_description', {count: total}),\n closable: true,\n });\n }\n }\n },\n });\n },\n }),\n [t, exportQuery, view.massSelection, dispatch, view.libraryId],\n );\n\n return {\n exportMassAction: isEnabled ? _exportMassAction : null,\n };\n};\n"]}
@@ -6,14 +6,12 @@ import { useRef } from 'react';
6
6
  import { useViewSettingsContext } from './manage-view-settings/store-view-settings/useViewSettingsContext';
7
7
  import { useEditSettings, ViewSettingsActionTypes } from './manage-view-settings';
8
8
  import { mapViewTypeFromExplorerToLegacy, mapViewTypeFromLegacyToExplorer } from './_constants';
9
- import { useTransformFilters } from '../../components/Filters/useTransformFilters';
10
9
  import { useFiltersContext } from '../../components/Filters/useFiltersContext';
11
10
  import { FiltersActionTypes } from '../../components/Filters/context/filtersReducer';
12
11
  export const useLoadView = () => {
13
12
  const { view, dispatch } = useViewSettingsContext();
14
13
  const { dispatch: filtersDispatch } = useFiltersContext();
15
14
  const { closeSettingsPanel } = useEditSettings();
16
- const { toUIFilters, toValidFilters } = useTransformFilters();
17
15
  const currentView = useRef(null);
18
16
  const [fetchAttributes] = useExplorerAttributesLazyQuery({
19
17
  fetchPolicy: 'network-only',
@@ -1 +1 @@
1
- {"version":3,"file":"useLoadView.js","sourceRoot":"","sources":["../../../src/components/Explorer/useLoadView.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,8BAA8B,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AACzE,OAAO,EAAC,MAAM,EAAC,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAC,sBAAsB,EAAC,MAAM,mEAAmE,CAAC;AAEzG,OAAO,EAAC,eAAe,EAAE,uBAAuB,EAAC,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAC,+BAA+B,EAAE,+BAA+B,EAAC,MAAM,cAAc,CAAC;AAE9F,OAAO,EAAC,mBAAmB,EAA4B,MAAM,4CAA4C,CAAC;AAC1G,OAAO,EAAC,iBAAiB,EAAC,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAC,kBAAkB,EAAC,MAAM,+CAA+C,CAAC;AAGjF,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC5B,MAAM,EAAC,IAAI,EAAE,QAAQ,EAAC,GAAG,sBAAsB,EAAE,CAAC;IAClD,MAAM,EAAC,QAAQ,EAAE,eAAe,EAAC,GAAG,iBAAiB,EAAE,CAAC;IACxD,MAAM,EAAC,kBAAkB,EAAC,GAAG,eAAe,EAAE,CAAC;IAC/C,MAAM,EAAC,WAAW,EAAE,cAAc,EAAC,GAAG,mBAAmB,EAAE,CAAC;IAC5D,MAAM,WAAW,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAEnD,MA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,CAAC,CAAC;QACP,CAAC;KACJ,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 {useExplorerAttributesLazyQuery, useMeQuery} from '_ui/_gqlTypes';\nimport {useRef} from 'react';\nimport {useViewSettingsContext} from './manage-view-settings/store-view-settings/useViewSettingsContext';\nimport {type IUserView} from './_types';\nimport {useEditSettings, ViewSettingsActionTypes} from './manage-view-settings';\nimport {mapViewTypeFromExplorerToLegacy, mapViewTypeFromLegacyToExplorer} from './_constants';\nimport {type IViewSettingsActionLoadViewPayload} from './manage-view-settings/store-view-settings/viewSettingsReducer';\nimport {useTransformFilters, type ValidFiltersArgument} from '_ui/components/Filters/useTransformFilters';\nimport {useFiltersContext} from '_ui/components/Filters/useFiltersContext';\nimport {FiltersActionTypes} from '_ui/components/Filters/context/filtersReducer';\nimport {type ValidFilter} from '../Filters/_types';\n\nexport const useLoadView = () => {\n const {view, dispatch} = useViewSettingsContext();\n const {dispatch: filtersDispatch} = useFiltersContext();\n const {closeSettingsPanel} = useEditSettings();\n const {toUIFilters, toValidFilters} = useTransformFilters();\n const currentView = useRef<IUserView | null>(null);\n\n const [fetchAttributes] = useExplorerAttributesLazyQuery({\n fetchPolicy: 'network-only',\n });\n\n const {data} = useMeQuery();\n\n return {\n loadView: async (viewId: string | null) => {\n let viewData: IUserView | null;\n if (!viewId) {\n viewData = {\n ...view.defaultViewSettings,\n id: null,\n ownerId: data?.me?.whoAmI?.id ?? null,\n display: {type: mapViewTypeFromExplorerToLegacy[view.viewType]},\n label: {},\n shared: false,\n filters: view.defaultViewSettings.filters as ValidFilter[],\n };\n } else {\n viewData = view.savedViews.find(v => v.id === viewId) ?? null;\n }\n\n if (!viewData) {\n return;\n }\n\n currentView.current = viewData;\n\n const attributesToHydrate = [\n ...new Set([...(viewData?.filters ?? []), ...(viewData?.sort ?? [])].map(({field}) => field)),\n ];\n\n const fetchAttributesResult = await fetchAttributes({\n variables: {\n ids: attributesToHydrate,\n },\n });\n\n closeSettingsPanel();\n\n const attributesDataById = (fetchAttributesResult.data?.attributes?.list ?? []).reduce((acc, attr) => {\n acc[attr.id] = attr;\n return acc;\n }, {});\n\n const viewSettings: IViewSettingsActionLoadViewPayload = {\n viewId: currentView.current?.id ?? null,\n viewLabels: currentView.current?.label ?? {},\n viewType: currentView.current?.display\n ? mapViewTypeFromLegacyToExplorer[currentView.current?.display.type]\n : view.viewType,\n attributesIds: currentView.current?.attributes ?? [],\n sort: (currentView.current?.sort ?? []).map(s => ({\n field: s.field,\n order: s.order,\n })),\n };\n\n dispatch({\n type: ViewSettingsActionTypes.LOAD_VIEW,\n payload: viewSettings,\n });\n filtersDispatch({\n type: FiltersActionTypes.LOAD_VIEW,\n payload: {\n viewId: currentView.current?.id ?? null,\n filters: [],\n attributesDataById,\n },\n });\n },\n };\n};\n"]}
1
+ {"version":3,"file":"useLoadView.js","sourceRoot":"","sources":["../../../src/components/Explorer/useLoadView.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,8BAA8B,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AACzE,OAAO,EAAC,MAAM,EAAC,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAC,sBAAsB,EAAC,MAAM,mEAAmE,CAAC;AAEzG,OAAO,EAAC,eAAe,EAAE,uBAAuB,EAAC,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAC,+BAA+B,EAAE,+BAA+B,EAAC,MAAM,cAAc,CAAC;AAE9F,OAAO,EAAC,iBAAiB,EAAC,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAC,kBAAkB,EAAC,MAAM,+CAA+C,CAAC;AAGjF,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC5B,MAAM,EAAC,IAAI,EAAE,QAAQ,EAAC,GAA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AE,YAAY;aACxB,CAAC,CAAC;YACH,eAAe,CAAC;gBACZ,IAAI,EAAE,kBAAkB,CAAC,SAAS;gBAClC,OAAO,EAAE;oBACL,MAAM,EAAE,WAAW,CAAC,OAAO,EAAE,EAAE,IAAI,IAAI;oBACvC,OAAO,EAAE,EAAE;oBACX,kBAAkB;iBACrB;aACJ,CAAC,CAAC;QACP,CAAC;KACJ,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 {useExplorerAttributesLazyQuery, useMeQuery} from '_ui/_gqlTypes';\nimport {useRef} from 'react';\nimport {useViewSettingsContext} from './manage-view-settings/store-view-settings/useViewSettingsContext';\nimport {type IUserView} from './_types';\nimport {useEditSettings, ViewSettingsActionTypes} from './manage-view-settings';\nimport {mapViewTypeFromExplorerToLegacy, mapViewTypeFromLegacyToExplorer} from './_constants';\nimport {type IViewSettingsActionLoadViewPayload} from './manage-view-settings/store-view-settings/viewSettingsReducer';\nimport {useFiltersContext} from '_ui/components/Filters/useFiltersContext';\nimport {FiltersActionTypes} from '_ui/components/Filters/context/filtersReducer';\nimport {type ValidFilter} from '../Filters/_types';\n\nexport const useLoadView = () => {\n const {view, dispatch} = useViewSettingsContext();\n const {dispatch: filtersDispatch} = useFiltersContext();\n const {closeSettingsPanel} = useEditSettings();\n const currentView = useRef<IUserView | null>(null);\n\n const [fetchAttributes] = useExplorerAttributesLazyQuery({\n fetchPolicy: 'network-only',\n });\n\n const {data} = useMeQuery();\n\n return {\n loadView: async (viewId: string | null) => {\n let viewData: IUserView | null;\n if (!viewId) {\n viewData = {\n ...view.defaultViewSettings,\n id: null,\n ownerId: data?.me?.whoAmI?.id ?? null,\n display: {type: mapViewTypeFromExplorerToLegacy[view.viewType]},\n label: {},\n shared: false,\n filters: view.defaultViewSettings.filters as ValidFilter[],\n };\n } else {\n viewData = view.savedViews.find(v => v.id === viewId) ?? null;\n }\n\n if (!viewData) {\n return;\n }\n\n currentView.current = viewData;\n\n const attributesToHydrate = [\n ...new Set([...(viewData?.filters ?? []), ...(viewData?.sort ?? [])].map(({field}) => field)),\n ];\n\n const fetchAttributesResult = await fetchAttributes({\n variables: {\n ids: attributesToHydrate,\n },\n });\n\n closeSettingsPanel();\n\n const attributesDataById = (fetchAttributesResult.data?.attributes?.list ?? []).reduce((acc, attr) => {\n acc[attr.id] = attr;\n return acc;\n }, {});\n\n const viewSettings: IViewSettingsActionLoadViewPayload = {\n viewId: currentView.current?.id ?? null,\n viewLabels: currentView.current?.label ?? {},\n viewType: currentView.current?.display\n ? mapViewTypeFromLegacyToExplorer[currentView.current?.display.type]\n : view.viewType,\n attributesIds: currentView.current?.attributes ?? [],\n sort: (currentView.current?.sort ?? []).map(s => ({\n field: s.field,\n order: s.order,\n })),\n };\n\n dispatch({\n type: ViewSettingsActionTypes.LOAD_VIEW,\n payload: viewSettings,\n });\n filtersDispatch({\n type: FiltersActionTypes.LOAD_VIEW,\n payload: {\n viewId: currentView.current?.id ?? null,\n filters: [],\n attributesDataById,\n },\n });\n },\n };\n};\n"]}
@@ -67,6 +67,10 @@ export interface IUIFilterTree extends Omit<IUIFilterBase, 'value' | 'formattedV
67
67
  condition: RecordFilterCondition | null;
68
68
  value: string[] | null;
69
69
  formattedValue?: string[] | null;
70
+ nodes?: null | Array<{
71
+ nodeId: string;
72
+ libraryId: string;
73
+ }>;
70
74
  field: string[];
71
75
  }
72
76
  export interface IUIFilterValueList extends Omit<IUIFilterBase, 'value' | 'formattedValue'> {
@@ -1 +1 @@
1
- {"version":3,"file":"_types.js","sourceRoot":"","sources":["../../../src/components/Filters/_types.ts"],"names":[],"mappings":"AAIA,OAAO,EAEH,aAAa,GAKhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AAmHxD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CA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;AAEpH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAgB,EAA2B,EAAE,CACxE,MAAM,CAAC,SAAS,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI,CAAC;AAEjD,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,MAAgB,EAAoC,EAAE,CAC9F,cAAc,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;AAElD,MAAM,WAAW,GAAG,CAAC,MAAgB,EAAmE,EAAE,CACtG,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,IAAI,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,MAAM,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 Override} from '@leav/utils';\nimport {\n type AttributeFormat,\n AttributeType,\n type LinkAttributeDetailsFragment,\n type RecordFilterCondition,\n type StandardAttributeDetailsFragment,\n type ViewDetailsFilterFragment,\n} from '_ui/_gqlTypes';\nimport {ThroughConditionFilter} from '_ui/types/search';\n\nexport type FiltersOperator = 'AND' | 'OR';\n\nexport interface IUIFilterBaseAttribute {\n type: AttributeType;\n /**\n * Used to display the label of the filter.\n *\n * > Not displayed when filter is hidden\n */\n label: string;\n /**\n * Used to verify unicity: one filter per attribute\n */\n id: string;\n format?: AttributeFormat | null | undefined;\n valuesList?:\n | NonNullable<StandardAttributeDetailsFragment['valuesList']>\n | NonNullable<LinkAttributeDetailsFragment['valuesList']>;\n}\n\nexport interface IUIFilterStandardAttribute extends IUIFilterBaseAttribute {\n format: AttributeFormat;\n}\n\nexport interface IUIFilterLinkAttribute extends IUIFilterBaseAttribute {\n linkedLibrary?: {\n id: string;\n };\n}\n\nexport interface IUIFilterTreeAttribute extends IUIFilterBaseAttribute {\n linkedTree?: {\n id: string;\n };\n}\n\ninterface IUIFilterBase {\n id: string;\n attribute: IUIFilterBaseAttribute;\n condition: RecordFilterCondition | ThroughConditionFilter | null;\n /**\n * Used to build filter field.\n *\n * - ex: `campaigns_id_pac`\n * - ex with **subField**: `campaigns_id_pac.id`\n */\n field: any;\n value: string | null;\n formattedValue?: string | null;\n hidden?: boolean | undefined;\n}\n\nexport interface IUIFilterStandard extends Omit<IUIFilterBase, 'field'> {\n attribute: IUIFilterStandardAttribute;\n condition: RecordFilterCondition | null;\n field: string;\n}\n\nexport interface IUIFilterLink extends Omit<IUIFilterBase, 'field'> {\n attribute: IUIFilterLinkAttribute;\n condition: RecordFilterCondition | null;\n field: string;\n}\n\nexport interface IUIFilterThrough extends Omit<IUIFilterBase, 'field'> {\n attribute: IUIFilterLinkAttribute;\n condition: ThroughConditionFilter.THROUGH | null;\n subCondition: RecordFilterCondition | null;\n subField: string | null;\n field: string;\n}\n\nexport interface IUIFilterTree extends Omit<IUIFilterBase, 'value' | 'formattedValue' | 'field'> {\n attribute: IUIFilterTreeAttribute;\n condition: RecordFilterCondition | null;\n value: string[] | null;\n formattedValue?: string[] | null;\n field: string[];\n}\n\nexport interface IUIFilterValueList extends Omit<IUIFilterBase, 'value' | 'formattedValue'> {\n attribute: (IUIFilterStandardAttribute | IUIFilterLinkAttribute) & {\n valuesList:\n | NonNullable<StandardAttributeDetailsFragment['valuesList']>\n | NonNullable<LinkAttributeDetailsFragment['valuesList']>;\n };\n value: string[] | null;\n condition: RecordFilterCondition | null;\n field: string | string[];\n}\n\nexport interface IUIFilterStandardValueList extends Omit<IUIFilterStandard, 'attribute' | 'value'>, IUIFilterValueList {\n attribute: IUIFilterStandardAttribute & {\n valuesList: NonNullable<StandardAttributeDetailsFragment['valuesList']>;\n };\n field: string;\n}\n\nexport interface IUIFilterLinkValueList extends Omit<IUIFilterLink, 'attribute' | 'value'>, IUIFilterValueList {\n attribute: IUIFilterLinkAttribute & {\n valuesList: NonNullable<LinkAttributeDetailsFragment['valuesList']>;\n };\n field: string;\n}\nexport interface IUIFilterTreeValueList extends Omit<IUIFilterTree, 'attribute' | 'value'>, IUIFilterValueList {\n attribute: IUIFilterLinkAttribute & {\n valuesList: NonNullable<LinkAttributeDetailsFragment['valuesList']>;\n };\n field: string[];\n}\n\nexport type UIFilter = IUIFilterStandard | IUIFilterLink | IUIFilterThrough | IUIFilterValueList | IUIFilterTree;\n\nexport const isUIFilterStandard = (filter: UIFilter): filter is IUIFilterStandard =>\n [AttributeType.simple, AttributeType.advanced].includes(filter.attribute.type);\n\nexport const isUIFilterLink = (filter: UIFilter): filter is IUIFilterLink =>\n [AttributeType.simple_link, AttributeType.advanced_link].includes(filter.attribute.type) &&\n filter.condition !== ThroughConditionFilter.THROUGH;\n\nexport const isUIFilterThrough = (filter: UIFilter): filter is IUIFilterThrough =>\n [AttributeType.simple_link, AttributeType.advanced_link].includes(filter.attribute.type) &&\n filter.condition === ThroughConditionFilter.THROUGH;\n\nexport const isUIFilterValueList = (filter: UIFilter): filter is IUIFilterValueList =>\n (isUIFilterStandard(filter) || isUIFilterLink(filter)) && isValueList(filter);\n\nexport const isUIFilterStandardWithValueList = (filter: UIFilter): filter is IUIFilterStandardValueList =>\n [AttributeType.simple, AttributeType.advanced].includes(filter.attribute.type) && isValueList(filter);\n\nexport const isUIFilterLinkWithValueList = (filter: UIFilter): filter is IUIFilterLinkValueList =>\n [AttributeType.simple_link, AttributeType.advanced_link].includes(filter.attribute.type) && isValueList(filter);\n\nexport const isUIFilterTree = (filter: UIFilter): filter is IUIFilterTree =>\n filter.attribute.type === AttributeType.tree;\n\nexport const isUIFilterTreeWithValueList = (filter: UIFilter): filter is IUIFilterTreeValueList =>\n isUIFilterTree(filter) && isValueList(filter);\n\nconst isValueList = (filter: UIFilter): filter is UIFilter & {attribute: {valuesList: {enabled: true}}} =>\n !!filter.attribute?.valuesList && filter.attribute?.valuesList.enable;\n\nexport interface IUIFilterDropDownProps {\n filter: UIFilter;\n canRemove: boolean;\n}\n\nexport type ValidFieldFilter = Override<\n ViewDetailsFilterFragment,\n {\n field: NonNullable<ViewDetailsFilterFragment['field']>;\n condition: NonNullable<ViewDetailsFilterFragment['condition']>;\n hidden: boolean;\n }\n>;\n\nexport type ValidFieldFilterStandardValuesList = Override<\n ValidFieldFilter,\n {\n valuesList: StandardAttributeDetailsFragment['valuesList'];\n }\n>;\n\nexport type ValidFieldFilterLinkValuesList = Override<\n ValidFieldFilter,\n {\n valuesList: LinkAttributeDetailsFragment['valuesList'];\n }\n>;\n\nexport type ValidFieldFilterThrough = Override<\n ValidFieldFilter,\n {\n condition: ThroughConditionFilter.THROUGH;\n hidden: boolean;\n }\n> & {\n subField: NonNullable<ViewDetailsFilterFragment['field']>;\n subCondition?: ViewDetailsFilterFragment['condition'];\n};\n\nexport type ValidFilter =\n | ValidFieldFilter\n | ValidFieldFilterThrough\n | ValidFieldFilterStandardValuesList\n | ValidFieldFilterLinkValuesList;\n"]}
1
+ {"version":3,"file":"_types.js","sourceRoot":"","sources":["../../../src/components/Filters/_types.ts"],"names":[],"mappings":"AAIA,OAAO,EAEH,aAAa,GAKhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AAoHxD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAgB,EAA+B,EAAE,CAChF,CAAC,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAEnF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAgB,EAA2B,EAAE,CACxE,CAAC,aAAa,CAAC,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;IACxF,MAAM,CAAC,SAAS,KAAK,sBAAsB,CAAC,OAAO,CAAC;AAExD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAgB,EAA8B,EAAE,CAC9E,CAAC,aAAa,CAAC,W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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 {type Override} from '@leav/utils';\nimport {\n type AttributeFormat,\n AttributeType,\n type LinkAttributeDetailsFragment,\n type RecordFilterCondition,\n type StandardAttributeDetailsFragment,\n type ViewDetailsFilterFragment,\n} from '_ui/_gqlTypes';\nimport {ThroughConditionFilter} from '_ui/types/search';\n\nexport type FiltersOperator = 'AND' | 'OR';\n\nexport interface IUIFilterBaseAttribute {\n type: AttributeType;\n /**\n * Used to display the label of the filter.\n *\n * > Not displayed when filter is hidden\n */\n label: string;\n /**\n * Used to verify unicity: one filter per attribute\n */\n id: string;\n format?: AttributeFormat | null | undefined;\n valuesList?:\n | NonNullable<StandardAttributeDetailsFragment['valuesList']>\n | NonNullable<LinkAttributeDetailsFragment['valuesList']>;\n}\n\nexport interface IUIFilterStandardAttribute extends IUIFilterBaseAttribute {\n format: AttributeFormat;\n}\n\nexport interface IUIFilterLinkAttribute extends IUIFilterBaseAttribute {\n linkedLibrary?: {\n id: string;\n };\n}\n\nexport interface IUIFilterTreeAttribute extends IUIFilterBaseAttribute {\n linkedTree?: {\n id: string;\n };\n}\n\ninterface IUIFilterBase {\n id: string;\n attribute: IUIFilterBaseAttribute;\n condition: RecordFilterCondition | ThroughConditionFilter | null;\n /**\n * Used to build filter field.\n *\n * - ex: `campaigns_id_pac`\n * - ex with **subField**: `campaigns_id_pac.id`\n */\n field: any;\n value: string | null;\n formattedValue?: string | null;\n hidden?: boolean | undefined;\n}\n\nexport interface IUIFilterStandard extends Omit<IUIFilterBase, 'field'> {\n attribute: IUIFilterStandardAttribute;\n condition: RecordFilterCondition | null;\n field: string;\n}\n\nexport interface IUIFilterLink extends Omit<IUIFilterBase, 'field'> {\n attribute: IUIFilterLinkAttribute;\n condition: RecordFilterCondition | null;\n field: string;\n}\n\nexport interface IUIFilterThrough extends Omit<IUIFilterBase, 'field'> {\n attribute: IUIFilterLinkAttribute;\n condition: ThroughConditionFilter.THROUGH | null;\n subCondition: RecordFilterCondition | null;\n subField: string | null;\n field: string;\n}\n\nexport interface IUIFilterTree extends Omit<IUIFilterBase, 'value' | 'formattedValue' | 'field'> {\n attribute: IUIFilterTreeAttribute;\n condition: RecordFilterCondition | null;\n value: string[] | null;\n formattedValue?: string[] | null;\n nodes?: null | Array<{nodeId: string; libraryId: string}>;\n field: string[];\n}\n\nexport interface IUIFilterValueList extends Omit<IUIFilterBase, 'value' | 'formattedValue'> {\n attribute: (IUIFilterStandardAttribute | IUIFilterLinkAttribute) & {\n valuesList:\n | NonNullable<StandardAttributeDetailsFragment['valuesList']>\n | NonNullable<LinkAttributeDetailsFragment['valuesList']>;\n };\n value: string[] | null;\n condition: RecordFilterCondition | null;\n field: string | string[];\n}\n\nexport interface IUIFilterStandardValueList extends Omit<IUIFilterStandard, 'attribute' | 'value'>, IUIFilterValueList {\n attribute: IUIFilterStandardAttribute & {\n valuesList: NonNullable<StandardAttributeDetailsFragment['valuesList']>;\n };\n field: string;\n}\n\nexport interface IUIFilterLinkValueList extends Omit<IUIFilterLink, 'attribute' | 'value'>, IUIFilterValueList {\n attribute: IUIFilterLinkAttribute & {\n valuesList: NonNullable<LinkAttributeDetailsFragment['valuesList']>;\n };\n field: string;\n}\nexport interface IUIFilterTreeValueList extends Omit<IUIFilterTree, 'attribute' | 'value'>, IUIFilterValueList {\n attribute: IUIFilterLinkAttribute & {\n valuesList: NonNullable<LinkAttributeDetailsFragment['valuesList']>;\n };\n field: string[];\n}\n\nexport type UIFilter = IUIFilterStandard | IUIFilterLink | IUIFilterThrough | IUIFilterValueList | IUIFilterTree;\n\nexport const isUIFilterStandard = (filter: UIFilter): filter is IUIFilterStandard =>\n [AttributeType.simple, AttributeType.advanced].includes(filter.attribute.type);\n\nexport const isUIFilterLink = (filter: UIFilter): filter is IUIFilterLink =>\n [AttributeType.simple_link, AttributeType.advanced_link].includes(filter.attribute.type) &&\n filter.condition !== ThroughConditionFilter.THROUGH;\n\nexport const isUIFilterThrough = (filter: UIFilter): filter is IUIFilterThrough =>\n [AttributeType.simple_link, AttributeType.advanced_link].includes(filter.attribute.type) &&\n filter.condition === ThroughConditionFilter.THROUGH;\n\nexport const isUIFilterValueList = (filter: UIFilter): filter is IUIFilterValueList =>\n (isUIFilterStandard(filter) || isUIFilterLink(filter)) && isValueList(filter);\n\nexport const isUIFilterStandardWithValueList = (filter: UIFilter): filter is IUIFilterStandardValueList =>\n [AttributeType.simple, AttributeType.advanced].includes(filter.attribute.type) && isValueList(filter);\n\nexport const isUIFilterLinkWithValueList = (filter: UIFilter): filter is IUIFilterLinkValueList =>\n [AttributeType.simple_link, AttributeType.advanced_link].includes(filter.attribute.type) && isValueList(filter);\n\nexport const isUIFilterTree = (filter: UIFilter): filter is IUIFilterTree =>\n filter.attribute.type === AttributeType.tree;\n\nexport const isUIFilterTreeWithValueList = (filter: UIFilter): filter is IUIFilterTreeValueList =>\n isUIFilterTree(filter) && isValueList(filter);\n\nconst isValueList = (filter: UIFilter): filter is UIFilter & {attribute: {valuesList: {enabled: true}}} =>\n !!filter.attribute?.valuesList && filter.attribute?.valuesList.enable;\n\nexport interface IUIFilterDropDownProps {\n filter: UIFilter;\n canRemove: boolean;\n}\n\nexport type ValidFieldFilter = Override<\n ViewDetailsFilterFragment,\n {\n field: NonNullable<ViewDetailsFilterFragment['field']>;\n condition: NonNullable<ViewDetailsFilterFragment['condition']>;\n hidden: boolean;\n }\n>;\n\nexport type ValidFieldFilterStandardValuesList = Override<\n ValidFieldFilter,\n {\n valuesList: StandardAttributeDetailsFragment['valuesList'];\n }\n>;\n\nexport type ValidFieldFilterLinkValuesList = Override<\n ValidFieldFilter,\n {\n valuesList: LinkAttributeDetailsFragment['valuesList'];\n }\n>;\n\nexport type ValidFieldFilterThrough = Override<\n ValidFieldFilter,\n {\n condition: ThroughConditionFilter.THROUGH;\n hidden: boolean;\n }\n> & {\n subField: NonNullable<ViewDetailsFilterFragment['field']>;\n subCondition?: ViewDetailsFilterFragment['condition'];\n};\n\nexport type ValidFilter =\n | ValidFieldFilter\n | ValidFieldFilterThrough\n | ValidFieldFilterStandardValuesList\n | ValidFieldFilterLinkValuesList;\n"]}