@leav/ui 1.6.0-4feacea4 → 1.6.0-65b13058

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 (73) hide show
  1. package/dist/__mocks__/react-i18next.d.ts +1 -1
  2. package/dist/_gqlTypes/index.d.ts +106 -0
  3. package/dist/_gqlTypes/index.js +68 -0
  4. package/dist/_gqlTypes/index.js.map +1 -1
  5. package/dist/_queries/attributes/attributeDetailsFragment.js +5 -0
  6. package/dist/_queries/attributes/attributeDetailsFragment.js.map +1 -1
  7. package/dist/components/AttributesSelectionList/reducer/__mocks__/attributesSelectionListStateContext.d.ts +1 -1
  8. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.d.ts +2 -4
  9. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js +18 -16
  10. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js.map +1 -1
  11. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js +2 -2
  12. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js.map +1 -1
  13. package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js +9 -1
  14. package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js.map +1 -1
  15. package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.d.ts +10 -3
  16. package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js +16 -6
  17. package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js.map +1 -1
  18. package/dist/components/RecordEdition/EditRecordContent/antdUtils.js.map +1 -1
  19. package/dist/components/RecordEdition/EditRecordContent/hooks/__mocks__/useDeleteValueMutation.d.ts +1 -1
  20. package/dist/components/RecordEdition/EditRecordContent/hooks/__mocks__/useSaveValueMutation.d.ts +1 -1
  21. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/LinkField.d.ts +1 -11
  22. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/LinkField.js +8 -95
  23. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/LinkField.js.map +1 -1
  24. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/_types.d.ts +8 -0
  25. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/_types.js +2 -0
  26. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/_types.js.map +1 -0
  27. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/explorer/LinkFieldExplorer.d.ts +6 -0
  28. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/explorer/LinkFieldExplorer.js +77 -0
  29. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/explorer/LinkFieldExplorer.js.map +1 -0
  30. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/{link-record → explorer/link-record}/useExplorerLinkRecords.d.ts +5 -7
  31. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/{link-record → explorer/link-record}/useExplorerLinkRecords.js +3 -10
  32. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/explorer/link-record/useExplorerLinkRecords.js.map +1 -0
  33. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/{link-record → explorer/link-record}/useLinkRecords.d.ts +5 -6
  34. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/{link-record → explorer/link-record}/useLinkRecords.js +18 -14
  35. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/explorer/link-record/useLinkRecords.js.map +1 -0
  36. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/{ExplorerWrapper.d.ts → InputExtraAlignLeft.d.ts} +1 -1
  37. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/{link-record/ActionButton.js → shared/InputExtraAlignLeft.js} +4 -4
  38. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/InputExtraAlignLeft.js.map +1 -0
  39. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/InputWrapper.d.ts +3 -0
  40. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/InputWrapper.js +31 -0
  41. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/InputWrapper.js.map +1 -0
  42. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/Wrapper.d.ts +3 -0
  43. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/Wrapper.js +8 -0
  44. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/Wrapper.js.map +1 -0
  45. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/LinkFieldTags.d.ts +3 -0
  46. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/LinkFieldTags.js +56 -0
  47. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/LinkFieldTags.js.map +1 -0
  48. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/link-record/useLinkRecord.d.ts +15 -0
  49. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/link-record/useLinkRecord.js +64 -0
  50. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/link-record/useLinkRecord.js.map +1 -0
  51. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.d.ts +19 -0
  52. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.js +43 -0
  53. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.js.map +1 -0
  54. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/unlink-all-records/useUnlinkAllRecords.d.ts +16 -0
  55. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/unlink-all-records/useUnlinkAllRecords.js +27 -0
  56. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/unlink-all-records/useUnlinkAllRecords.js.map +1 -0
  57. package/dist/hooks/useIFrameMessenger/messageHandlers.d.ts +2 -1
  58. package/dist/hooks/useIFrameMessenger/messageHandlers.js +8 -0
  59. package/dist/hooks/useIFrameMessenger/messageHandlers.js.map +1 -1
  60. package/dist/hooks/useIFrameMessenger/types.d.ts +21 -1
  61. package/dist/hooks/useIFrameMessenger/types.js.map +1 -1
  62. package/dist/hooks/useIFrameMessenger/useIFrameMessenger.d.ts +1 -0
  63. package/dist/hooks/useIFrameMessengerClient/iFrameMessengerClientContext.d.ts +1 -0
  64. package/dist/hooks/useIFrameMessengerClient/useIFrameMessengerClient.d.ts +1 -0
  65. package/dist/locales/en/shared.json +3 -0
  66. package/dist/locales/fr/shared.json +4 -1
  67. package/package.json +20 -21
  68. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/ActionButton.d.ts +0 -3
  69. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/ActionButton.js.map +0 -1
  70. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/useExplorerLinkRecords.js.map +0 -1
  71. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/useLinkRecords.js.map +0 -1
  72. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/ExplorerWrapper.js +0 -13
  73. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/ExplorerWrapper.js.map +0 -1
@@ -54,6 +54,11 @@ export const attributeDetailsFragment = gql `
54
54
  id
55
55
  label
56
56
  }
57
+ permissions_conf_dependent_values {
58
+ dependenciesTreeAttributes {
59
+ id
60
+ }
61
+ }
57
62
  }
58
63
  }
59
64
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"attributeDetailsFragment.js","sourceRoot":"","sources":["../../../src/_queries/attributes/attributeDetailsFragment.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,GAAG,EAAC,MAAM,gBAAgB,CAAC;AAEnC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsD1C,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 {gql} from '@apollo/client';\n\nexport const attributeDetailsFragment = gql`\n fragment AttributeDetails on Attribute {\n id\n type\n format\n system\n readonly\n label\n description\n required\n multiple_values\n multi_link_display_option\n multi_tree_display_option\n metadata_fields {\n id\n label\n type\n format\n }\n versions_conf {\n versionable\n mode\n profile {\n id\n label\n trees {\n id\n label\n }\n }\n }\n libraries {\n id\n label\n }\n\n ... on StandardAttribute {\n unique\n }\n\n ... on LinkAttribute {\n linked_library {\n id\n label\n }\n reverse_link\n }\n ... on TreeAttribute {\n linked_tree {\n id\n label\n }\n }\n }\n`;\n"]}
1
+ {"version":3,"file":"attributeDetailsFragment.js","sourceRoot":"","sources":["../../../src/_queries/attributes/attributeDetailsFragment.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,GAAG,EAAC,MAAM,gBAAgB,CAAC;AAEnC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2D1C,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 {gql} from '@apollo/client';\n\nexport const attributeDetailsFragment = gql`\n fragment AttributeDetails on Attribute {\n id\n type\n format\n system\n readonly\n label\n description\n required\n multiple_values\n multi_link_display_option\n multi_tree_display_option\n metadata_fields {\n id\n label\n type\n format\n }\n versions_conf {\n versionable\n mode\n profile {\n id\n label\n trees {\n id\n label\n }\n }\n }\n libraries {\n id\n label\n }\n\n ... on StandardAttribute {\n unique\n }\n\n ... on LinkAttribute {\n linked_library {\n id\n label\n }\n reverse_link\n }\n ... on TreeAttribute {\n linked_tree {\n id\n label\n }\n permissions_conf_dependent_values {\n dependenciesTreeAttributes {\n id\n }\n }\n }\n }\n`;\n"]}
@@ -7,5 +7,5 @@ export declare const useAttributesSelectionListState: () => {
7
7
  expandedAttributePath: string;
8
8
  attributes: import("../../../../_gqlTypes").AttributesByLibAttributeFragment[];
9
9
  };
10
- dispatch: jest.Mock<any, any>;
10
+ dispatch: jest.Mock<any, any, any>;
11
11
  };
@@ -1,9 +1,7 @@
1
- import { type AttributeDetailsTreeAttributeFragment } from '../../../../_gqlTypes';
2
1
  import { type FunctionComponent } from 'react';
3
- import { type TreeAttributeNodeValue } from './useListTreeAttributeValuesHook';
2
+ import { type ITreeAttributeNodeValue } from './useListTreeAttributeValuesHook';
4
3
  export declare const EditTreeAttributeValueLine: FunctionComponent<{
5
- treeNodeValues: TreeAttributeNodeValue[];
6
- selectedAttribute: AttributeDetailsTreeAttributeFragment;
4
+ treeNodeValues: ITreeAttributeNodeValue[];
7
5
  valueOccurrenceNodeId: string | null;
8
6
  valueOccurrenceCount: number;
9
7
  setAttributeMapping: (before: string | null, after: string | null) => void;
@@ -10,26 +10,28 @@ const DivContainer = styled.div `
10
10
  `;
11
11
  const UNDEFINED_VALUE = '__null__';
12
12
  const DEFAULT_ID_CARD_COLOR = 'rgba(200, 200, 200, 1)';
13
- export const EditTreeAttributeValueLine = ({ selectedAttribute, treeNodeValues, valueOccurrenceNodeId, valueOccurrenceCount, setAttributeMapping }) => {
13
+ export const EditTreeAttributeValueLine = ({ treeNodeValues, valueOccurrenceNodeId, valueOccurrenceCount, setAttributeMapping }) => {
14
14
  const { t } = useSharedTranslation();
15
- const treeNodeValueOfOccurrence = valueOccurrenceNodeId
16
- ? treeNodeValues.find(node => node.id === valueOccurrenceNodeId)
17
- : null;
15
+ const treeNodeValueOfOccurrence = treeNodeValues.find(node => node.id === valueOccurrenceNodeId);
16
+ if (!treeNodeValueOfOccurrence) {
17
+ return null;
18
+ }
19
+ const allowedDependentValues = treeNodeValueOfOccurrence ? treeNodeValueOfOccurrence.allowedDependentValues : null;
18
20
  const selectOptions = treeNodeValues
19
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))
20
24
  .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', {
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', {
33
35
  count: valueOccurrenceCount,
34
36
  }) }), _jsx(KitSelect, { options: selectOptions, size: "middle", allowClear: false, placeholder: t('explorer.massAction.editAttribute_value_select_placeholder'), onChange: value => {
35
37
  setAttributeMapping(valueOccurrenceNodeId, value === UNDEFINED_VALUE ? null : value || null);
@@ -1 +1 @@
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,GAMlC,CAAC,EAAC,iBAAiB,EAAE,cAAc,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,mBAAmB,EAAC,EAAE,EAAE;IAC3G,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,yBAAyB,GAAG,qBAAqB;QACnD,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,qBAAqB,CAAC;QAChE,CAAC,CAAC,IAAI,CAAC;IAEX,MAAM,aAAa,GAAG,cAAc;SAC/B,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,qBAAqB,CAAC;SACzD,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACd,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;QAChE,KAAK,EAAE,QAAQ,CAAC,EAAE;KACrB,CAAC,CAAC;SACF,MAAM,CACH,iBAAiB,CAAC,QAAQ,IAAI,CAAC,yBAAyB;QACpD,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC;YACI;gBACI,KAAK,EAAE,CAAC,CAAC,mDAAmD,CAAC;gBAC7D,KAAK,EAAE,eAAe;aACzB;SACJ,CACV,CAAC;IAEN,OAAO,CACH,MAAC,YAAY,eACR,yBAAyB,CAAC,CAAC,CAAC,CACzB,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"]}
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,QAA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yright 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"]}
@@ -10,7 +10,7 @@ export const EditTreeAttributeValuesMapping = ({ selectedAttribute, valuesOccurr
10
10
  if (!occurrence) {
11
11
  return null;
12
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 }))] }));
13
+ return (_jsx(EditTreeAttributeValueLine, { treeNodeValues: treeAttributeValues, valueOccurrenceNodeId: occurrence.value.id, valueOccurrenceCount: occurrence.count, setAttributeMapping: setAttributeMapping }, index));
14
+ }), noValueCount > 0 && (_jsx(EditTreeAttributeValueLine, { treeNodeValues: treeAttributeValues, valueOccurrenceNodeId: null, valueOccurrenceCount: noValueCount, setAttributeMapping: setAttributeMapping }))] }));
15
15
  };
16
16
  //# sourceMappingURL=EditTreeAttributeValuesMapping.js.map
@@ -1 +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,CAAC;AAGpC,OAAO,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C;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"]}
1
+ {"version":3,"file":"EditTreeAttributeValuesMapping.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.tsx"],"names":[],"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ACM,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 valueOccurrenceNodeId={occurrence.value.id}\n valueOccurrenceCount={occurrence.count}\n setAttributeMapping={setAttributeMapping}\n />\n );\n })}\n {noValueCount > 0 && (\n <EditTreeAttributeValueLine\n treeNodeValues={treeAttributeValues}\n valueOccurrenceNodeId={null}\n valueOccurrenceCount={noValueCount}\n setAttributeMapping={setAttributeMapping}\n />\n )}\n </KitSpace>\n );\n};\n"]}
@@ -6,7 +6,15 @@ import { useMemo } from 'react';
6
6
  import { useAttributeDetailsData } from '../../manage-view-settings/_shared/useAttributeDetailsData';
7
7
  export const useListEditableAttributeHook = ({ libraryId }) => {
8
8
  const { attributeDetailsById } = useAttributeDetailsData(libraryId);
9
- const treeMonoValuedAttributes = useMemo(() => Object.values(attributeDetailsById).filter(attr => attr.type === AttributeType.tree && !attr.multiple_values), [attributeDetailsById]);
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]);
10
18
  return treeMonoValuedAttributes;
11
19
  };
12
20
  //# sourceMappingURL=useListEditableAttributeHook.js.map
@@ -1 +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"]}
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"]}
@@ -1,5 +1,12 @@
1
- import { type AttributeDetailsTreeAttributeFragment, type TreeNodeChildrenQuery } from '../../../../_gqlTypes';
2
- export type TreeAttributeNodeValue = TreeNodeChildrenQuery['treeNodeChildren']['list'][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
+ }
3
10
  export declare const useListTreeAttributeValuesHook: ({ treeAttribute: treeAttribute, }: {
4
11
  treeAttribute: AttributeDetailsTreeAttributeFragment;
5
- }) => TreeAttributeNodeValue[];
12
+ }) => ITreeAttributeNodeValue[];
@@ -1,20 +1,30 @@
1
1
  // Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
2
2
  // This file is released under LGPL V3
3
3
  // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
4
- import { useTreeNodeChildrenLazyQuery, } from '../../../../_gqlTypes';
5
- import { useEffect } from 'react';
4
+ import { useAttributeWithValuesForMassEditionLazyQuery } from '../../../../_gqlTypes';
5
+ import { useSharedTranslation } from '../../../../hooks/useSharedTranslation';
6
+ import { useEffect, useMemo } from 'react';
6
7
  export const useListTreeAttributeValuesHook = ({ treeAttribute: treeAttribute, }) => {
7
- const [loadTreeContent, { data: treeContent }] = useTreeNodeChildrenLazyQuery();
8
+ const { t } = useSharedTranslation();
9
+ const [loadValues, { data: treeContent }] = useAttributeWithValuesForMassEditionLazyQuery();
8
10
  useEffect(() => {
9
11
  if (!treeAttribute.linked_tree) {
10
12
  throw new Error('Fatal: selected attribute not found');
11
13
  }
12
- loadTreeContent({
14
+ loadValues({
15
+ fetchPolicy: 'no-cache',
13
16
  variables: {
14
- treeId: treeAttribute.linked_tree.id,
17
+ attributeId: treeAttribute.id,
15
18
  },
16
19
  });
17
20
  }, [treeAttribute]);
18
- return treeContent?.treeNodeChildren.list || [];
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]);
19
29
  };
20
30
  //# sourceMappingURL=useListTreeAttributeValuesHook.js.map
@@ -1 +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
+ {"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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"antdUtils.js","sourceRoot":"","sources":["../../../../src/components/RecordEdition/EditRecordContent/antdUtils.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAC,eAAe,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAG7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,kBAAkB,GAAG,CAAC,SAAkB,EAAgC,EAAE,CAC3E,SAA6B,CAAC,IAAI,KAAK,SAAS,IAAK,SAA6B,CAAC,EAAE,KAAK,SAAS,CAAC;AAEzG,MAAM,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AAE9E,MAAM,iBAAiB,GAAG,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AAE5E,MAAM,iBAAiB,GAAG,MAAM,CAAC,EAAE,CAC/B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC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AC3B,CAAC,CAAC,gBAAgB;gBAClB,CAAC,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC;oBAC1B,CAAC,CAAC,eAAe;oBACjB,CAAC,CAAC,EAAE,CAAC;QAEjB,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACb,eAAe,CAAC,MAAM,KAAK,CAAC;gBACxB,CAAC,CAAC,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;gBACnC,CAAC,CAAC,eAAe;qBACV,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;qBACvD,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,0BAA0B,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;QACtE,OAAO,GAAG,CAAC;IACf,CAAC;IAED,MAAM,aAAa,GAAG,KAA6C,CAAC;IAEpE,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,0BAA0B,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAEzE,OAAO,GAAG,CAAC;AACf,CAAC,EAAE,EAAE,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 IRecordForm,\n type RecordFormElementAttribute,\n type RecordFormElementsValue,\n type RecordFormElementsValueLinkValue,\n type RecordFormElementsValueStandardValue,\n} from '_ui/hooks/useGetRecordForm';\nimport {AttributeFormat, AttributeType} from '_ui/_gqlTypes';\nimport {type IDateRangeValue} from '@leav/utils';\nimport {type Store} from 'antd/lib/form/interface';\nimport dayjs from 'dayjs';\n\nconst hasDateRangeValues = (dateRange: unknown): dateRange is IDateRangeValue =>\n (dateRange as IDateRangeValue).from !== undefined && (dateRange as IDateRangeValue).to !== undefined;\n\nconst getCalculatedValue = values => values.find(value => value.isCalculated);\n\nconst getInheritedValue = values => values.find(value => value.isInherited);\n\nconst getUserInputValue = values =>\n values.find(value => !value.isInherited && !value.isCalculated && value.raw_payload !== null);\n\nconst isRecordFormElementsValueLinkValue = (\n value: RecordFormElementsValue,\n attribute: RecordFormElementAttribute,\n): value is RecordFormElementsValueLinkValue =>\n attribute.type === AttributeType.simple_link ||\n (attribute.type === AttributeType.advanced_link && attribute.multiple_values === false);\n\nconst isRecordFormElementsValueLinkValues = (\n values: RecordFormElementsValue[],\n attribute: RecordFormElementAttribute,\n): values is RecordFormElementsValueLinkValue[] =>\n attribute.type === AttributeType.advanced_link && attribute.multiple_values === true;\n\nconst isRecordFormElementsMultipleValues = (attribute: RecordFormElementAttribute) =>\n attribute.type === AttributeType.advanced && attribute.multiple_values === true;\n\nconst formatStandardInitialValue = (\n standardValue: RecordFormElementsValueStandardValue,\n attribute: RecordFormElementAttribute,\n) => {\n if (!standardValue?.raw_payload) {\n return getEmptyInitialValue(attribute);\n }\n\n switch (attribute.format) {\n case AttributeFormat.color:\n case AttributeFormat.text:\n case AttributeFormat.rich_text:\n case AttributeFormat.boolean:\n return standardValue.raw_payload;\n case AttributeFormat.numeric:\n return Number(standardValue.raw_payload);\n case AttributeFormat.date:\n return dayjs.unix(Number(standardValue.raw_payload));\n case AttributeFormat.date_range:\n if (hasDateRangeValues(standardValue.raw_payload)) {\n return [\n dayjs.unix(Number(standardValue.raw_payload.from)),\n dayjs.unix(Number(standardValue.raw_payload.to)),\n ];\n } else if (typeof standardValue.raw_payload === 'string') {\n const convertedFieldValue = JSON.parse(standardValue.raw_payload) as any;\n return [dayjs.unix(Number(convertedFieldValue.from)), dayjs.unix(Number(convertedFieldValue.to))];\n }\n }\n};\n\nexport const EMPTY_INITIAL_VALUE_STRING = '';\nexport const EMPTY_INITIAL_VALUE_UNDEFINED = undefined;\n\nexport const getEmptyInitialValue = (attribute: RecordFormElementAttribute) => {\n if ([AttributeFormat.date_range, AttributeFormat.color].includes(attribute.format)) {\n return EMPTY_INITIAL_VALUE_UNDEFINED;\n }\n return EMPTY_INITIAL_VALUE_STRING;\n};\n\nexport const getAntdDisplayedValue = (\n values: RecordFormElementsValueStandardValue[],\n attribute: RecordFormElementAttribute,\n) =>\n formatStandardInitialValue(\n getUserInputValue(values) ?? getInheritedValue(values) ?? getCalculatedValue(values) ?? null,\n attribute,\n );\n\nexport const getAntdFormInitialValues = (recordForm: IRecordForm) =>\n recordForm.elements.reduce<Store>((acc, {attribute, values}) => {\n if (!attribute) {\n return acc;\n }\n\n const value = getUserInputValue(values) ?? getInheritedValue(values) ?? getCalculatedValue(values) ?? null;\n\n if (isRecordFormElementsValueLinkValue(value, attribute)) {\n acc[attribute.id] = value?.linkValue?.id;\n return acc;\n }\n\n if (isRecordFormElementsValueLinkValues(values, attribute)) {\n acc[attribute.id] = values.map(val => val?.linkValue?.id ?? undefined);\n return acc;\n }\n\n if (isRecordFormElementsMultipleValues(attribute)) {\n const userInputValues = values.filter(val => val.id_value);\n const calculatedValues = values.filter(val => val.isCalculated);\n const inheritedValues = values.filter(val => val.isInherited);\n\n const effectiveValues =\n userInputValues.length > 0\n ? userInputValues\n : calculatedValues.length > 0\n ? calculatedValues\n : inheritedValues.length > 0\n ? inheritedValues\n : [];\n\n acc[attribute.id] =\n effectiveValues.length === 0\n ? [getEmptyInitialValue(attribute)]\n : effectiveValues\n .sort((a, b) => Number(a.id_value) - Number(b.id_value))\n .map(val => formatStandardInitialValue(val, attribute));\n return acc;\n }\n\n const standardValue = value as RecordFormElementsValueStandardValue;\n\n acc[attribute.id] = formatStandardInitialValue(standardValue, attribute);\n\n return acc;\n }, {});\n"]}
1
+ {"version":3,"file":"antdUtils.js","sourceRoot":"","sources":["../../../../src/components/RecordEdition/EditRecordContent/antdUtils.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,eAAe,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAG7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAE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C,aAAa,EAAE,SAAS,CAAC,CAAC;IAEzE,OAAO,GAAG,CAAC;AACf,CAAC,EAAE,EAAE,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 IRecordForm,\n type RecordFormElementAttribute,\n type RecordFormElementsValue,\n type RecordFormElementsValueLinkValue,\n type RecordFormElementsValueStandardValue,\n} from '_ui/hooks/useGetRecordForm';\nimport {AttributeFormat, AttributeType} from '_ui/_gqlTypes';\nimport {type IDateRangeValue} from '@leav/utils';\nimport {type Store} from 'antd/lib/form/interface';\nimport dayjs from 'dayjs';\n\nconst hasDateRangeValues = (dateRange: unknown): dateRange is IDateRangeValue =>\n (dateRange as IDateRangeValue).from !== undefined && (dateRange as IDateRangeValue).to !== undefined;\n\nconst getCalculatedValue = values => values.find(value => value.isCalculated);\n\nconst getInheritedValue = values => values.find(value => value.isInherited);\n\nconst getUserInputValue = values =>\n values.find(value => !value.isInherited && !value.isCalculated && value.raw_payload !== null);\n\nconst isRecordFormElementsValueLinkValue = (\n value: RecordFormElementsValue,\n attribute: RecordFormElementAttribute,\n): value is RecordFormElementsValueLinkValue =>\n attribute.type === AttributeType.simple_link ||\n (attribute.type === AttributeType.advanced_link && attribute.multiple_values === false);\n\nconst isRecordFormElementsValueLinkValues = (\n values: RecordFormElementsValue[],\n attribute: RecordFormElementAttribute,\n): values is RecordFormElementsValueLinkValue[] =>\n attribute.type === AttributeType.advanced_link && attribute.multiple_values === true;\n\nconst isRecordFormElementsMultipleValues = (attribute: RecordFormElementAttribute) =>\n attribute.type === AttributeType.advanced && attribute.multiple_values === true;\n\nconst formatStandardInitialValue = (\n standardValue: RecordFormElementsValueStandardValue,\n attribute: RecordFormElementAttribute,\n) => {\n if (!standardValue?.raw_payload) {\n return getEmptyInitialValue(attribute);\n }\n\n switch (attribute.format) {\n case AttributeFormat.color:\n case AttributeFormat.text:\n case AttributeFormat.rich_text:\n case AttributeFormat.boolean:\n return standardValue.raw_payload;\n case AttributeFormat.numeric:\n return Number(standardValue.raw_payload);\n case AttributeFormat.date:\n return dayjs.unix(Number(standardValue.raw_payload));\n case AttributeFormat.date_range:\n if (hasDateRangeValues(standardValue.raw_payload)) {\n return [\n dayjs.unix(Number(standardValue.raw_payload.from)),\n dayjs.unix(Number(standardValue.raw_payload.to)),\n ];\n } else if (typeof standardValue.raw_payload === 'string') {\n const convertedFieldValue = JSON.parse(standardValue.raw_payload) as any;\n return [dayjs.unix(Number(convertedFieldValue.from)), dayjs.unix(Number(convertedFieldValue.to))];\n }\n }\n};\n\nexport const EMPTY_INITIAL_VALUE_STRING = '';\nexport const EMPTY_INITIAL_VALUE_UNDEFINED = undefined;\n\nexport const getEmptyInitialValue = (attribute: RecordFormElementAttribute) => {\n if ([AttributeFormat.date_range, AttributeFormat.color].includes(attribute.format)) {\n return EMPTY_INITIAL_VALUE_UNDEFINED;\n }\n return EMPTY_INITIAL_VALUE_STRING;\n};\n\nexport const getAntdDisplayedValue = (\n values: RecordFormElementsValueStandardValue[],\n attribute: RecordFormElementAttribute,\n) =>\n formatStandardInitialValue(\n getUserInputValue(values) ?? getInheritedValue(values) ?? getCalculatedValue(values) ?? null,\n attribute,\n );\n\nexport const getAntdFormInitialValues = (recordForm: IRecordForm) =>\n recordForm.elements.reduce<Store>((acc, {attribute, values}) => {\n if (!attribute) {\n return acc;\n }\n\n const value = getUserInputValue(values) ?? getInheritedValue(values) ?? getCalculatedValue(values) ?? null;\n\n if (isRecordFormElementsValueLinkValue(value, attribute)) {\n acc[attribute.id] = value?.linkValue?.id;\n return acc;\n }\n\n if (isRecordFormElementsValueLinkValues(values, attribute)) {\n acc[attribute.id] = values.map(val => val?.linkValue?.id ?? undefined);\n return acc;\n }\n\n if (isRecordFormElementsMultipleValues(attribute)) {\n const userInputValues = values.filter(val => val.id_value);\n const calculatedValues = values.filter(val => val.isCalculated);\n const inheritedValues = values.filter(val => val.isInherited);\n\n const effectiveValues =\n userInputValues.length > 0\n ? userInputValues\n : calculatedValues.length > 0\n ? calculatedValues\n : inheritedValues.length > 0\n ? inheritedValues\n : [];\n\n acc[attribute.id] =\n effectiveValues.length === 0\n ? [getEmptyInitialValue(attribute)]\n : effectiveValues\n .sort((a, b) => Number(a.id_value) - Number(b.id_value))\n .map(val => formatStandardInitialValue(val, attribute));\n return acc;\n }\n\n const standardValue = value as RecordFormElementsValueStandardValue;\n\n acc[attribute.id] = formatStandardInitialValue(standardValue, attribute);\n\n return acc;\n }, {});\n"]}
@@ -1,3 +1,3 @@
1
1
  export default function useDeleteValueMutation(): {
2
- deleteValue: jest.Mock<any, any>;
2
+ deleteValue: jest.Mock<any, any, any>;
3
3
  };
@@ -1,3 +1,3 @@
1
1
  export default function useSaveValueMutation(): {
2
- saveValue: jest.Mock<any, any>;
2
+ saveValue: jest.Mock<any, any, any>;
3
3
  };
@@ -1,14 +1,4 @@
1
1
  import { type FunctionComponent } from 'react';
2
- import { type RecordFormElementsValueLinkValue } from '../../../../../hooks/useGetRecordForm/useGetRecordForm';
3
- import { type ILinkFieldState } from '../../reducers/linkFieldReducer/linkFieldReducer';
4
- import { type IFormElementProps } from '../../_types';
5
- import { type IFormLinkFieldSettings } from '@leav/utils/src/types/forms';
6
- export type LinkFieldReducerState = ILinkFieldState<RecordFormElementsValueLinkValue>;
7
- type LinkFieldProps = IFormElementProps<IFormLinkFieldSettings & {
8
- columns?: Array<{
9
- id: string;
10
- label: Record<string, string>;
11
- }>;
12
- }>;
2
+ import { type LinkFieldProps } from './_types';
13
3
  declare const LinkField: FunctionComponent<LinkFieldProps>;
14
4
  export default LinkField;
@@ -1,99 +1,12 @@
1
- import { jsx as _jsx, Fragment as _Fragment, 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 { localizedTranslation } from '@leav/utils';
6
- import { useState } from 'react';
7
- import { useEditRecordReducer } from '../../../../../components/RecordEdition/editRecordReducer/useEditRecordReducer';
8
- import { AntForm, KitInputWrapper } from 'aristid-ds';
9
- import { useLang } from '../../../../../hooks';
10
- import styled, { css } from 'styled-components';
11
- import { LINK_FIELD_ID_PREFIX } from '../../../../../constants';
12
- import { computeCalculatedFlags, computeInheritedFlags } from '../shared/calculatedInheritedFlags';
13
- import { ComputeIndicator } from '../shared/ComputeIndicator';
14
- import { useOutsideInteractionDetector } from '../shared/useOutsideInteractionDetector';
15
- import { useLinkRecords } from './link-record/useLinkRecords';
16
- import { CREATE_RECORD_MODAL_CLASSNAME, EDIT_RECORD_MODAL_CLASSNAME, LINK_RECORDS_MODAL_CLASSNAME, } from '../../../../../components/Explorer/_constants';
17
- const Wrapper = styled.div `
18
- margin-bottom: ${props => (props.$metadataEdit ? 0 : '1.5em')};
19
- `;
20
- const KitInputExtraAlignLeft = styled.div `
21
- margin-right: auto;
22
- line-height: 12px;
23
- `;
24
- const KitInputWrapperStyled = styled(KitInputWrapper) `
25
- ${props => props.$readonlyBackground &&
26
- css `
27
- .kit-input-wrapper-content {
28
- background-color: var(--general-utilities-neutral-light);
29
- }
30
- `}
31
-
32
- &.disabled {
33
- .kit-input-wrapper-content {
34
- background-color: var(--general-utilities-neutral-light);
35
- }
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { LinkFieldExplorer } from './explorer/LinkFieldExplorer';
3
+ import { LinkFieldTags } from './tag/LinkFieldTags';
4
+ import { DisplayMode } from '@leav/utils';
5
+ const LinkField = ({ element, readonly, isFormCreationMode, onValueSubmit, onValueDelete, onDeleteMultipleValues, metadataEdit = false, }) => {
6
+ if (element.settings.displayMode === DisplayMode.TAG) {
7
+ return (_jsx(LinkFieldTags, { element: element, readonly: readonly, isFormCreationMode: isFormCreationMode, onValueSubmit: onValueSubmit, onValueDelete: onValueDelete, onDeleteMultipleValues: onDeleteMultipleValues, metadataEdit: metadataEdit }));
36
8
  }
37
-
38
- &.error:not(.disabled) {
39
- .kit-input-wrapper-content {
40
- background-color: var(--general-utilities-error-light);
41
- }
42
- }
43
-
44
- .ant-empty-image,
45
- .ant-empty-description {
46
- display: none;
47
- }
48
- `;
49
- const LinkField = ({ element, readonly, isFormCreationMode, onDeleteMultipleValues, metadataEdit = false, }) => {
50
- const { state, dispatch } = useEditRecordReducer();
51
- const { lang } = useLang();
52
- const { settings, attribute, joinLibraryContext, } = element;
53
- const [backendValues, setBackendValues] = useState(element.values);
54
- const calculatedFlags = computeCalculatedFlags(backendValues);
55
- const inheritedFlags = computeInheritedFlags(backendValues);
56
- const form = AntForm.useFormInstance();
57
- const label = localizedTranslation(settings.label, lang);
58
- const fieldErrors = form.getFieldError(attribute.id);
59
- // TODO: Temporary const that should be removed (and all it's usages) when we will have a proper way to override multiple values
60
- const tmpCantOverrideValues = attribute.multiple_values &&
61
- (calculatedFlags.calculatedValues?.length > 1 || inheritedFlags.inheritedValues?.length > 1);
62
- const columnsToDisplay = settings.columns?.map(({ id }) => id);
63
- const isReadOnly = attribute.readonly || !attribute.permissions.edit_value || readonly || tmpCantOverrideValues;
64
- const isFieldInError = fieldErrors.length > 0;
65
- useOutsideInteractionDetector({
66
- attribute,
67
- activeAttribute: state.activeAttribute,
68
- attributePrefix: LINK_FIELD_ID_PREFIX,
69
- dispatch,
70
- backendValues,
71
- allowedSelectors: [
72
- 'div[role="status"]:has(.kit-snackbar-message)',
73
- '.kit-modal-wrapper',
74
- `.${CREATE_RECORD_MODAL_CLASSNAME}`,
75
- `.${LINK_RECORDS_MODAL_CLASSNAME}`,
76
- `.${EDIT_RECORD_MODAL_CLASSNAME}`,
77
- '.kit-select-dropdown-content',
78
- ],
79
- });
80
- const editionFormId = settings.editFormId ? settings.editFormId : 'edition';
81
- const { UnlinkAllRecords, LinkRecordsExplorer } = useLinkRecords({
82
- libraryId: state.libraryId,
83
- recordId: state.record?.id,
84
- editionFormId,
85
- isFormCreationMode,
86
- attribute,
87
- joinLibraryContext,
88
- columnsToDisplay,
89
- backendValues,
90
- setBackendValues,
91
- isReadOnly,
92
- isFieldInError,
93
- hasNoValue: backendValues.length === 0,
94
- onDeleteMultipleValues,
95
- });
96
- return (_jsx(Wrapper, { "$metadataEdit": metadataEdit, children: _jsx(AntForm.Item, { name: attribute.id, noStyle: true, children: _jsx(KitInputWrapperStyled, { id: LINK_FIELD_ID_PREFIX + attribute.id, "data-testid": "link-field", label: label, required: attribute.required, bordered: true, status: isFieldInError ? 'error' : undefined, helper: isFieldInError ? String(fieldErrors[0]) : undefined, extra: _jsxs(_Fragment, { children: [_jsx(KitInputExtraAlignLeft, { children: _jsx(ComputeIndicator, { calculatedFlags: calculatedFlags, inheritedFlags: inheritedFlags }) }), UnlinkAllRecords] }), "$readonlyBackground": isReadOnly, children: LinkRecordsExplorer }) }) }));
9
+ return (_jsx(LinkFieldExplorer, { element: element, readonly: readonly, isFormCreationMode: isFormCreationMode, onDeleteMultipleValues: onDeleteMultipleValues, metadataEdit: metadataEdit }));
97
10
  };
98
11
  export default LinkField;
99
12
  //# sourceMappingURL=LinkField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LinkField.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/LinkField.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAoC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAClE,OAAO,EAAC,oBAAoB,EAAC,MAAM,qEAAqE,CAAC;AAKzG,OAAO,EAAC,OAAO,EAAE,eAAe,EAAC,MAAM,YAAY,CAAC;AACpD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,MAAM,EAAE,EAAC,GAAG,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,oB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K,CAAC,SAAS;QAC1B,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE;QAC1B,aAAa;QACb,kBAAkB;QAClB,SAAS;QACT,kBAAkB;QAClB,gBAAgB;QAChB,aAAa;QACb,gBAAgB;QAChB,UAAU;QACV,cAAc;QACd,UAAU,EAAE,aAAa,CAAC,MAAM,KAAK,CAAC;QACtC,sBAAsB;KACzB,CAAC,CAAC;IAEH,OAAO,CACH,KAAC,OAAO,qBAAgB,YAAY,YAChC,KAAC,OAAO,CAAC,IAAI,IAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,OAAO,kBACrC,KAAC,qBAAqB,IAClB,EAAE,EAAE,oBAAoB,GAAG,SAAS,CAAC,EAAE,iBAC3B,YAAY,EACxB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAC5B,QAAQ,QACR,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAC5C,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAC3D,KAAK,EACD,8BACI,KAAC,sBAAsB,cACnB,KAAC,gBAAgB,IAAC,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,GAAI,GACjE,EACxB,gBAAgB,IAClB,yBAEc,UAAU,YAE9B,mBAAmB,GACA,GACb,GACT,CACb,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,SAAS,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 {localizedTranslation} from '@leav/utils';\nimport {type FunctionComponent, useEffect, useState} from 'react';\nimport {useEditRecordReducer} from '_ui/components/RecordEdition/editRecordReducer/useEditRecordReducer';\nimport {type RecordFormElementsValueLinkValue} from '_ui/hooks/useGetRecordForm/useGetRecordForm';\nimport {type JoinLibraryContextFragment, type RecordFormAttributeLinkAttributeFragment} from '_ui/_gqlTypes';\nimport {type ILinkFieldState} from '../../reducers/linkFieldReducer/linkFieldReducer';\nimport {type IFormElementProps} from '../../_types';\nimport {AntForm, KitInputWrapper} from 'aristid-ds';\nimport {useLang} from '_ui/hooks';\nimport styled, {css} from 'styled-components';\nimport {LINK_FIELD_ID_PREFIX} from '_ui/constants';\nimport {computeCalculatedFlags, computeInheritedFlags} from '../shared/calculatedInheritedFlags';\nimport {ComputeIndicator} from '../shared/ComputeIndicator';\nimport {useOutsideInteractionDetector} from '../shared/useOutsideInteractionDetector';\nimport {useLinkRecords} from './link-record/useLinkRecords';\nimport {\n CREATE_RECORD_MODAL_CLASSNAME,\n EDIT_RECORD_MODAL_CLASSNAME,\n LINK_RECORDS_MODAL_CLASSNAME,\n} from '_ui/components/Explorer/_constants';\nimport {type IFormLinkFieldSettings} from '@leav/utils/src/types/forms';\n\nexport type LinkFieldReducerState = ILinkFieldState<RecordFormElementsValueLinkValue>;\n\nconst Wrapper = styled.div<{$metadataEdit: boolean}>`\n margin-bottom: ${props => (props.$metadataEdit ? 0 : '1.5em')};\n`;\n\nconst KitInputExtraAlignLeft = styled.div`\n margin-right: auto;\n line-height: 12px;\n`;\n\nconst KitInputWrapperStyled = styled(KitInputWrapper)<{$readonlyBackground: boolean}>`\n ${props =>\n props.$readonlyBackground &&\n css`\n .kit-input-wrapper-content {\n background-color: var(--general-utilities-neutral-light);\n }\n `}\n\n &.disabled {\n .kit-input-wrapper-content {\n background-color: var(--general-utilities-neutral-light);\n }\n }\n\n &.error:not(.disabled) {\n .kit-input-wrapper-content {\n background-color: var(--general-utilities-error-light);\n }\n }\n\n .ant-empty-image,\n .ant-empty-description {\n display: none;\n }\n`;\n\ntype LinkFieldProps = IFormElementProps<\n IFormLinkFieldSettings & {\n columns?: Array<{\n id: string;\n label: Record<string, string>;\n }>;\n }\n>;\n\nconst LinkField: FunctionComponent<LinkFieldProps> = ({\n element,\n readonly,\n isFormCreationMode,\n onDeleteMultipleValues,\n metadataEdit = false,\n}) => {\n const {state, dispatch} = useEditRecordReducer();\n const {lang} = useLang();\n const {\n settings,\n attribute,\n joinLibraryContext,\n }: {\n settings: typeof element.settings;\n attribute?: RecordFormAttributeLinkAttributeFragment;\n joinLibraryContext?: JoinLibraryContextFragment;\n } = element;\n\n const [backendValues, setBackendValues] = useState<RecordFormElementsValueLinkValue[]>(element.values);\n\n const calculatedFlags = computeCalculatedFlags(backendValues);\n const inheritedFlags = computeInheritedFlags(backendValues);\n const form = AntForm.useFormInstance();\n const label = localizedTranslation(settings.label, lang);\n const fieldErrors = form.getFieldError(attribute.id);\n\n // TODO: Temporary const that should be removed (and all it's usages) when we will have a proper way to override multiple values\n const tmpCantOverrideValues =\n attribute.multiple_values &&\n (calculatedFlags.calculatedValues?.length > 1 || inheritedFlags.inheritedValues?.length > 1);\n\n const columnsToDisplay = settings.columns?.map(({id}) => id);\n const isReadOnly = attribute.readonly || !attribute.permissions.edit_value || readonly || tmpCantOverrideValues;\n const isFieldInError = fieldErrors.length > 0;\n\n useOutsideInteractionDetector({\n attribute,\n activeAttribute: state.activeAttribute,\n attributePrefix: LINK_FIELD_ID_PREFIX,\n dispatch,\n backendValues,\n allowedSelectors: [\n 'div[role=\"status\"]:has(.kit-snackbar-message)',\n '.kit-modal-wrapper',\n `.${CREATE_RECORD_MODAL_CLASSNAME}`,\n `.${LINK_RECORDS_MODAL_CLASSNAME}`,\n `.${EDIT_RECORD_MODAL_CLASSNAME}`,\n '.kit-select-dropdown-content',\n ],\n });\n\n const editionFormId = settings.editFormId ? settings.editFormId : 'edition';\n\n const {UnlinkAllRecords, LinkRecordsExplorer} = useLinkRecords({\n libraryId: state.libraryId,\n recordId: state.record?.id,\n editionFormId,\n isFormCreationMode,\n attribute,\n joinLibraryContext,\n columnsToDisplay,\n backendValues,\n setBackendValues,\n isReadOnly,\n isFieldInError,\n hasNoValue: backendValues.length === 0,\n onDeleteMultipleValues,\n });\n\n return (\n <Wrapper $metadataEdit={metadataEdit}>\n <AntForm.Item name={attribute.id} noStyle>\n <KitInputWrapperStyled\n id={LINK_FIELD_ID_PREFIX + attribute.id}\n data-testid=\"link-field\"\n label={label}\n required={attribute.required}\n bordered\n status={isFieldInError ? 'error' : undefined}\n helper={isFieldInError ? String(fieldErrors[0]) : undefined}\n extra={\n <>\n <KitInputExtraAlignLeft>\n <ComputeIndicator calculatedFlags={calculatedFlags} inheritedFlags={inheritedFlags} />\n </KitInputExtraAlignLeft>\n {UnlinkAllRecords}\n </>\n }\n $readonlyBackground={isReadOnly}\n >\n {LinkRecordsExplorer}\n </KitInputWrapperStyled>\n </AntForm.Item>\n </Wrapper>\n );\n};\n\nexport default LinkField;\n"]}
1
+ {"version":3,"file":"LinkField.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/LinkField.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAC,iBAAiB,EAAC,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAExC,MAAM,SAAS,GAAsC,CAAC,EAClD,OAAO,EACP,QAAQ,EACR,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,sBAAsB,EACtB,YAAY,GAAG,KAAK,GACvB,EAAE,EAAE;IACD,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,KAAK,WAAW,CAAC,GAAG,EAAE,CAAC;QACnD,OAAO,CACH,KAAC,aAAa,IACV,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,kBAAkB,EAAE,kBAAkB,EACtC,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,sBAAsB,EAAE,sBAAsB,EAC9C,YAAY,EAAE,YAAY,GAC5B,CACL,CAAC;IACN,CAAC;IAED,OAAO,CACH,KAAC,iBAAiB,IACd,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,kBAAkB,EAAE,kBAAkB,EACtC,sBAAsB,EAAE,sBAAsB,EAC9C,YAAY,EAAE,YAAY,GAC5B,CACL,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type FunctionComponent} from 'react';\nimport {type LinkFieldProps} from './_types';\nimport {LinkFieldExplorer} from './explorer/LinkFieldExplorer';\nimport {LinkFieldTags} from './tag/LinkFieldTags';\nimport {DisplayMode} from '@leav/utils';\n\nconst LinkField: FunctionComponent<LinkFieldProps> = ({\n element,\n readonly,\n isFormCreationMode,\n onValueSubmit,\n onValueDelete,\n onDeleteMultipleValues,\n metadataEdit = false,\n}) => {\n if (element.settings.displayMode === DisplayMode.TAG) {\n return (\n <LinkFieldTags\n element={element}\n readonly={readonly}\n isFormCreationMode={isFormCreationMode}\n onValueSubmit={onValueSubmit}\n onValueDelete={onValueDelete}\n onDeleteMultipleValues={onDeleteMultipleValues}\n metadataEdit={metadataEdit}\n />\n );\n }\n\n return (\n <LinkFieldExplorer\n element={element}\n readonly={readonly}\n isFormCreationMode={isFormCreationMode}\n onDeleteMultipleValues={onDeleteMultipleValues}\n metadataEdit={metadataEdit}\n />\n );\n};\n\nexport default LinkField;\n"]}
@@ -0,0 +1,8 @@
1
+ import { type IFormLinkFieldSettings } from '@leav/utils';
2
+ import { type IFormElementProps } from '../../_types';
3
+ export type LinkFieldProps = IFormElementProps<IFormLinkFieldSettings & {
4
+ columns?: Array<{
5
+ id: string;
6
+ label: Record<string, string>;
7
+ }>;
8
+ }>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=_types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_types.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/_types.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type IFormLinkFieldSettings} from '@leav/utils';\nimport {type IFormElementProps} from '../../_types';\n\nexport type LinkFieldProps = IFormElementProps<\n IFormLinkFieldSettings & {\n columns?: Array<{\n id: string;\n label: Record<string, string>;\n }>;\n }\n>;\n"]}
@@ -0,0 +1,6 @@
1
+ import { type FunctionComponent } from 'react';
2
+ import { type RecordFormElementsValueLinkValue } from '../../../../../../hooks/useGetRecordForm/useGetRecordForm';
3
+ import { type ILinkFieldState } from '../../../reducers/linkFieldReducer/linkFieldReducer';
4
+ import { type LinkFieldProps } from '../_types';
5
+ export type LinkFieldReducerState = ILinkFieldState<RecordFormElementsValueLinkValue>;
6
+ export declare const LinkFieldExplorer: FunctionComponent<LinkFieldProps>;
@@ -0,0 +1,77 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, 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 { localizedTranslation } from '@leav/utils';
6
+ import { useState } from 'react';
7
+ import { useEditRecordReducer } from '../../../../../../components/RecordEdition/editRecordReducer/useEditRecordReducer';
8
+ import { AntForm } from 'aristid-ds';
9
+ import { useLang } from '../../../../../../hooks';
10
+ import { LINK_FIELD_ID_PREFIX } from '../../../../../../constants';
11
+ import { computeCalculatedFlags, computeInheritedFlags } from '../../shared/calculatedInheritedFlags';
12
+ import { ComputeIndicator } from '../../shared/ComputeIndicator';
13
+ import { useOutsideInteractionDetector } from '../../shared/useOutsideInteractionDetector';
14
+ import { useLinkRecords } from './link-record/useLinkRecords';
15
+ import { CREATE_RECORD_MODAL_CLASSNAME, EDIT_RECORD_MODAL_CLASSNAME, LINK_RECORDS_MODAL_CLASSNAME, } from '../../../../../../components/Explorer/_constants';
16
+ import { useUnlinkAllRecords } from '../unlink-all-records/useUnlinkAllRecords';
17
+ import { Wrapper } from '../shared/Wrapper';
18
+ import { InputExtraAlignLeft } from '../shared/InputExtraAlignLeft';
19
+ import { InputWrapper } from '../shared/InputWrapper';
20
+ export const LinkFieldExplorer = ({ element, readonly, isFormCreationMode, onDeleteMultipleValues, metadataEdit = false, }) => {
21
+ const { state, dispatch } = useEditRecordReducer();
22
+ const { lang } = useLang();
23
+ const { settings, attribute, joinLibraryContext, } = element;
24
+ const [backendValues, setBackendValues] = useState(element.values);
25
+ const calculatedFlags = computeCalculatedFlags(backendValues);
26
+ const inheritedFlags = computeInheritedFlags(backendValues);
27
+ const form = AntForm.useFormInstance();
28
+ const label = localizedTranslation(settings.label, lang);
29
+ const fieldErrors = form.getFieldError(attribute.id);
30
+ // TODO: Temporary const that should be removed (and all it's usages) when we will have a proper way to override multiple values
31
+ const tmpCantOverrideValues = attribute.multiple_values &&
32
+ (calculatedFlags.calculatedValues?.length > 1 || inheritedFlags.inheritedValues?.length > 1);
33
+ const columnsToDisplay = settings.columns?.map(({ id }) => id);
34
+ const isReadOnly = attribute.readonly || !attribute.permissions.edit_value || readonly || tmpCantOverrideValues;
35
+ const isFieldInError = fieldErrors.length > 0;
36
+ useOutsideInteractionDetector({
37
+ attribute,
38
+ activeAttribute: state.activeAttribute,
39
+ attributePrefix: LINK_FIELD_ID_PREFIX,
40
+ dispatch,
41
+ backendValues,
42
+ allowedSelectors: [
43
+ 'div[role="status"]:has(.kit-snackbar-message)',
44
+ '.kit-modal-wrapper',
45
+ `.${CREATE_RECORD_MODAL_CLASSNAME}`,
46
+ `.${LINK_RECORDS_MODAL_CLASSNAME}`,
47
+ `.${EDIT_RECORD_MODAL_CLASSNAME}`,
48
+ '.kit-select-dropdown-content',
49
+ ],
50
+ });
51
+ const editionFormId = settings.editFormId ? settings.editFormId : 'edition';
52
+ const { LinkRecordsExplorer } = useLinkRecords({
53
+ libraryId: state.libraryId,
54
+ recordId: state.record?.id,
55
+ editionFormId,
56
+ isFormCreationMode,
57
+ attribute,
58
+ joinLibraryContext,
59
+ columnsToDisplay,
60
+ backendValues,
61
+ setBackendValues,
62
+ isReadOnly,
63
+ isFieldInError,
64
+ hasNoValue: backendValues.length === 0,
65
+ onDeleteMultipleValues,
66
+ });
67
+ const { UnlinkAllRecordsButton } = useUnlinkAllRecords({
68
+ attribute,
69
+ backendValues,
70
+ setBackendValues,
71
+ onDeleteMultipleValues,
72
+ isReadOnly,
73
+ isFieldInError,
74
+ });
75
+ return (_jsx(Wrapper, { "$metadataEdit": metadataEdit, children: _jsx(AntForm.Item, { name: attribute.id, noStyle: true, children: _jsx(InputWrapper, { id: LINK_FIELD_ID_PREFIX + attribute.id, label: label, required: attribute.required, bordered: true, status: isFieldInError ? 'error' : undefined, helper: isFieldInError ? String(fieldErrors[0]) : undefined, extra: _jsxs(_Fragment, { children: [_jsx(InputExtraAlignLeft, { children: _jsx(ComputeIndicator, { calculatedFlags: calculatedFlags, inheritedFlags: inheritedFlags }) }), UnlinkAllRecordsButton] }), "$readonlyBackground": isReadOnly, children: LinkRecordsExplorer }) }) }));
76
+ };
77
+ //# sourceMappingURL=LinkFieldExplorer.js.map