@leav/ui 1.6.0-e2820b2f → 1.6.0-f4ee7377

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 (135) hide show
  1. package/dist/_gqlTypes/index.d.ts +633 -701
  2. package/dist/_gqlTypes/index.js +49 -167
  3. package/dist/_gqlTypes/index.js.map +1 -1
  4. package/dist/_queries/trees/treeNodeChildrenQuery.js +2 -0
  5. package/dist/_queries/trees/treeNodeChildrenQuery.js.map +1 -1
  6. package/dist/components/AttributesSelectionList/sharedComponents.d.ts +159 -153
  7. package/dist/components/Explorer/Explorer.js +5 -3
  8. package/dist/components/Explorer/Explorer.js.map +1 -1
  9. package/dist/components/Explorer/TableCell.js +5 -7
  10. package/dist/components/Explorer/TableCell.js.map +1 -1
  11. package/dist/components/Explorer/TableNameCell.js +3 -2
  12. package/dist/components/Explorer/TableNameCell.js.map +1 -1
  13. package/dist/components/Explorer/_queries/useExplorerData.d.ts +7 -7
  14. package/dist/components/Explorer/actions-item/useEditStatusItemAction.js +3 -2
  15. package/dist/components/Explorer/actions-item/useEditStatusItemAction.js.map +1 -1
  16. package/dist/components/Explorer/actions-item/useReplaceItemAction.d.ts +2 -1
  17. package/dist/components/Explorer/actions-item/useReplaceItemAction.js +5 -4
  18. package/dist/components/Explorer/actions-item/useReplaceItemAction.js.map +1 -1
  19. package/dist/components/Explorer/actions-mass/export/ExportProfileSelectionModal.d.ts +10 -0
  20. package/dist/components/Explorer/actions-mass/export/ExportProfileSelectionModal.js +46 -0
  21. package/dist/components/Explorer/actions-mass/export/ExportProfileSelectionModal.js.map +1 -0
  22. package/dist/components/Explorer/actions-mass/export/content/NoProfiles.d.ts +1 -0
  23. package/dist/components/Explorer/actions-mass/export/content/NoProfiles.js +17 -0
  24. package/dist/components/Explorer/actions-mass/export/content/NoProfiles.js.map +1 -0
  25. package/dist/components/Explorer/actions-mass/export/content/ProfilesSelection.d.ts +8 -0
  26. package/dist/components/Explorer/actions-mass/export/content/ProfilesSelection.js +49 -0
  27. package/dist/components/Explorer/actions-mass/export/content/ProfilesSelection.js.map +1 -0
  28. package/dist/components/Explorer/actions-mass/export/useGetLibraryExportProfiles.d.ts +27 -0
  29. package/dist/components/Explorer/actions-mass/export/useGetLibraryExportProfiles.js +48 -0
  30. package/dist/components/Explorer/actions-mass/export/useGetLibraryExportProfiles.js.map +1 -0
  31. package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js +3 -2
  32. package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js.map +1 -1
  33. package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js +3 -2
  34. package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js.map +1 -1
  35. package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js +3 -2
  36. package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js.map +1 -1
  37. package/dist/components/Explorer/actions-mass/useExportMassAction.d.ts +7 -4
  38. package/dist/components/Explorer/actions-mass/useExportMassAction.js +80 -73
  39. package/dist/components/Explorer/actions-mass/useExportMassAction.js.map +1 -1
  40. package/dist/components/Explorer/actions-mass/useMassActions.js +3 -2
  41. package/dist/components/Explorer/actions-mass/useMassActions.js.map +1 -1
  42. package/dist/components/Explorer/actions-primary/useCreatePrimaryAction.js +3 -2
  43. package/dist/components/Explorer/actions-primary/useCreatePrimaryAction.js.map +1 -1
  44. package/dist/components/Explorer/actions-primary/useLinkPrimaryAction.d.ts +2 -1
  45. package/dist/components/Explorer/actions-primary/useLinkPrimaryAction.js +5 -4
  46. package/dist/components/Explorer/actions-primary/useLinkPrimaryAction.js.map +1 -1
  47. package/dist/components/Explorer/link-item/LinkModal.d.ts +1 -0
  48. package/dist/components/Explorer/link-item/LinkModal.js +2 -2
  49. package/dist/components/Explorer/link-item/LinkModal.js.map +1 -1
  50. package/dist/components/Explorer/list-saved-views/SavedViews.js +4 -3
  51. package/dist/components/Explorer/list-saved-views/SavedViews.js.map +1 -1
  52. package/dist/components/Explorer/manage-view-settings/_shared/ColumnItem.js +5 -8
  53. package/dist/components/Explorer/manage-view-settings/_shared/ColumnItem.js.map +1 -1
  54. package/dist/components/Explorer/manage-view-settings/configure-display/attributes/SelectVisibleAttributes.js +3 -2
  55. package/dist/components/Explorer/manage-view-settings/configure-display/attributes/SelectVisibleAttributes.js.map +1 -1
  56. package/dist/components/Explorer/manage-view-settings/filter-items/FilterItems.js +7 -6
  57. package/dist/components/Explorer/manage-view-settings/filter-items/FilterItems.js.map +1 -1
  58. package/dist/components/Explorer/manage-view-settings/filter-items/FilterListItem.js +3 -2
  59. package/dist/components/Explorer/manage-view-settings/filter-items/FilterListItem.js.map +1 -1
  60. package/dist/components/Explorer/manage-view-settings/open-view-settings/useOpenViewSettings.js +4 -3
  61. package/dist/components/Explorer/manage-view-settings/open-view-settings/useOpenViewSettings.js.map +1 -1
  62. package/dist/components/Explorer/manage-view-settings/router-menu/SettingItem.js +3 -2
  63. package/dist/components/Explorer/manage-view-settings/router-menu/SettingItem.js.map +1 -1
  64. package/dist/components/Explorer/manage-view-settings/router-menu/SettingsPanel.js +3 -2
  65. package/dist/components/Explorer/manage-view-settings/router-menu/SettingsPanel.js.map +1 -1
  66. package/dist/components/Explorer/manage-view-settings/save-view/LabelViewFormModal.js +3 -2
  67. package/dist/components/Explorer/manage-view-settings/save-view/LabelViewFormModal.js.map +1 -1
  68. package/dist/components/Explorer/manage-view-settings/save-view/useCreateNewView.js +3 -2
  69. package/dist/components/Explorer/manage-view-settings/save-view/useCreateNewView.js.map +1 -1
  70. package/dist/components/Explorer/manage-view-settings/save-view/useDeleteView.js +4 -3
  71. package/dist/components/Explorer/manage-view-settings/save-view/useDeleteView.js.map +1 -1
  72. package/dist/components/Explorer/manage-view-settings/save-view/useEditLabelView.js +3 -2
  73. package/dist/components/Explorer/manage-view-settings/save-view/useEditLabelView.js.map +1 -1
  74. package/dist/components/Explorer/manage-view-settings/save-view/useResetView.js +3 -2
  75. package/dist/components/Explorer/manage-view-settings/save-view/useResetView.js.map +1 -1
  76. package/dist/components/Explorer/manage-view-settings/save-view/useShareView.js +3 -2
  77. package/dist/components/Explorer/manage-view-settings/save-view/useShareView.js.map +1 -1
  78. package/dist/components/Explorer/manage-view-settings/save-view/useUpdateView.js +3 -2
  79. package/dist/components/Explorer/manage-view-settings/save-view/useUpdateView.js.map +1 -1
  80. package/dist/components/Explorer/manage-view-settings/sort-items/SortItems.js +7 -6
  81. package/dist/components/Explorer/manage-view-settings/sort-items/SortItems.js.map +1 -1
  82. package/dist/components/Explorer/manage-view-settings/sort-items/SortListItem.js +3 -2
  83. package/dist/components/Explorer/manage-view-settings/sort-items/SortListItem.js.map +1 -1
  84. package/dist/components/Filters/filter-items/filter-type/BooleanAttributeDropdown.js +23 -9
  85. package/dist/components/Filters/filter-items/filter-type/BooleanAttributeDropdown.js.map +1 -1
  86. package/dist/components/Filters/filter-items/filter-type/FilterDropDown.js +3 -2
  87. package/dist/components/Filters/filter-items/filter-type/FilterDropDown.js.map +1 -1
  88. package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.js +4 -3
  89. package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.js.map +1 -1
  90. package/dist/components/LibraryItemsList/MenuView/MenuView.js +4 -4
  91. package/dist/components/LibraryItemsList/MenuView/MenuView.js.map +1 -1
  92. package/dist/components/LibraryItemsList/ViewPanel/View/View.js +3 -2
  93. package/dist/components/LibraryItemsList/ViewPanel/View/View.js.map +1 -1
  94. package/dist/components/Notifications/hooks/useNotificationSubscription.js +3 -2
  95. package/dist/components/Notifications/hooks/useNotificationSubscription.js.map +1 -1
  96. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/ValuesVersionBtn.js +5 -20
  97. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/ValuesVersionBtn.js.map +1 -1
  98. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/useLinkRecords.js +4 -3
  99. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/useLinkRecords.js.map +1 -1
  100. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/ExplorerWrapper.d.ts +53 -51
  101. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardField.js +4 -3
  102. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardField.js.map +1 -1
  103. package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/TreeField.js +9 -2
  104. package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/TreeField.js.map +1 -1
  105. package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/display-tree-node/TreeFieldWrapper.d.ts +53 -51
  106. package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/display-tree-node/TreeNodeItem.js +3 -2
  107. package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/display-tree-node/TreeNodeItem.js.map +1 -1
  108. package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/SelectTreeNodeModal.d.ts +2 -1
  109. package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/SelectTreeNodeModal.js +4 -7
  110. package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/SelectTreeNodeModal.js.map +1 -1
  111. package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/useManageTreeNodeSelection.d.ts +3 -2
  112. package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/useManageTreeNodeSelection.js +2 -2
  113. package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/useManageTreeNodeSelection.js.map +1 -1
  114. package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/ComputeIndicator.js +3 -2
  115. package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/ComputeIndicator.js.map +1 -1
  116. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/RecordInformations.js +3 -2
  117. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/RecordInformations.js.map +1 -1
  118. package/dist/components/RecordEdition/EditRecordSidebar/ValuesSummary/ValuesSummary.js +4 -3
  119. package/dist/components/RecordEdition/EditRecordSidebar/ValuesSummary/ValuesSummary.js.map +1 -1
  120. package/dist/components/RecordEdition/EditRecordSidebar/ValuesVersions/ValuesVersions.js +3 -2
  121. package/dist/components/RecordEdition/EditRecordSidebar/ValuesVersions/ValuesVersions.js.map +1 -1
  122. package/dist/components/SelectRecordForLinkModal/SelectRecordForLinkModal.d.ts +1 -0
  123. package/dist/components/SelectRecordForLinkModal/SelectRecordForLinkModal.js +7 -7
  124. package/dist/components/SelectRecordForLinkModal/SelectRecordForLinkModal.js.map +1 -1
  125. package/dist/components/SelectTreeNode/SelectTreeNode.d.ts +2 -1
  126. package/dist/components/SelectTreeNode/SelectTreeNode.js +3 -3
  127. package/dist/components/SelectTreeNode/SelectTreeNode.js.map +1 -1
  128. package/dist/components/SelectTreeNode/SelectTreeNodeContent.d.ts +2 -1
  129. package/dist/components/SelectTreeNode/SelectTreeNodeContent.js +6 -2
  130. package/dist/components/SelectTreeNode/SelectTreeNodeContent.js.map +1 -1
  131. package/dist/components/SelectTreeNode/TreeNodeTitle.js +3 -2
  132. package/dist/components/SelectTreeNode/TreeNodeTitle.js.map +1 -1
  133. package/dist/locales/en/shared.json +13 -2
  134. package/dist/locales/fr/shared.json +13 -2
  135. package/package.json +6 -4
@@ -2,13 +2,15 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  // Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
3
3
  // This file is released under LGPL V3
4
4
  // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
5
- import { useMemo } from 'react';
6
- import { FaFileExport } from 'react-icons/fa';
7
- import { KitAlert, KitModal, KitNotification } from 'aristid-ds';
5
+ import { useCallback, useMemo, useState } from 'react';
6
+ import { KitAlert, KitNotification } from 'aristid-ds';
8
7
  import { useExportLazyQuery } from '../../../_gqlTypes';
9
8
  import { useSharedTranslation } from '../../../hooks/useSharedTranslation';
10
- import { BREAK_TWO_LINES, MASS_SELECTION_ALL } from '../_constants';
9
+ import { MASS_SELECTION_ALL } from '../_constants';
11
10
  import { ERROR_ALERT_DURATION, INFO_NOTIFICATION_DURATION } from '../../../constants';
11
+ import { ExportProfileSelectionModal } from './export/ExportProfileSelectionModal';
12
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
13
+ import { faFileExport } from '@fortawesome/free-solid-svg-icons';
12
14
  /**
13
15
  * Hook that provides a mass action configuration for exporting selected or all items
14
16
  * from a view/data set
@@ -16,81 +18,86 @@ import { ERROR_ALERT_DURATION, INFO_NOTIFICATION_DURATION } from '../../../const
16
18
  export const useExportMassAction = ({ isEnabled, store: { view, dispatch }, totalCount, onExport, }) => {
17
19
  const { t } = useSharedTranslation();
18
20
  const [exportQuery] = useExportLazyQuery();
21
+ const [isModalOpen, setIsModalOpen] = useState(false);
22
+ const [isExporting, setIsExporting] = useState(false);
23
+ const [massSelectionFilter, setMassSelectionFilter] = useState();
24
+ const _handleConfirmExport = useCallback(async (profileLabel) => {
25
+ if (!massSelectionFilter) {
26
+ return;
27
+ }
28
+ const total = view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;
29
+ setIsExporting(true);
30
+ try {
31
+ const { error } = await exportQuery({
32
+ fetchPolicy: 'no-cache',
33
+ variables: {
34
+ library: view.libraryId,
35
+ filters: massSelectionFilter,
36
+ profile: profileLabel,
37
+ },
38
+ });
39
+ if (error) {
40
+ // Preserve the extensions property which contains the error code
41
+ const graphQLError = error.graphQLErrors?.[0];
42
+ const errorWithExtensions = new Error(error.message);
43
+ errorWithExtensions.extensions = graphQLError?.extensions;
44
+ throw errorWithExtensions;
45
+ }
46
+ KitNotification.info({
47
+ message: t('explorer.massAction.export_message'),
48
+ description: t('explorer.massAction.export_description', {
49
+ count: total,
50
+ total,
51
+ }),
52
+ duration: INFO_NOTIFICATION_DURATION,
53
+ closable: true,
54
+ });
55
+ onExport?.(massSelectionFilter, view.massSelection);
56
+ setIsModalOpen(false);
57
+ }
58
+ catch (e) {
59
+ if (e.extensions?.code === 'CUSTOM_CONFIG_ERROR') {
60
+ KitAlert.error({
61
+ showIcon: true,
62
+ duration: ERROR_ALERT_DURATION,
63
+ message: t('error.error_occurred', { count: total }),
64
+ description: t('explorer.massAction.export_config_error_description', {
65
+ library: view.libraryId,
66
+ }),
67
+ closable: true,
68
+ });
69
+ }
70
+ else {
71
+ KitAlert.error({
72
+ showIcon: true,
73
+ duration: ERROR_ALERT_DURATION,
74
+ message: t('error.error_occurred'),
75
+ description: t('explorer.massAction.export_error_description', { count: total }),
76
+ closable: true,
77
+ });
78
+ }
79
+ }
80
+ finally {
81
+ setIsExporting(false);
82
+ }
83
+ }, [exportQuery, view.libraryId, view.massSelection, totalCount, massSelectionFilter, onExport, t]);
84
+ const _handleCloseModal = useCallback(() => {
85
+ setIsModalOpen(false);
86
+ setMassSelectionFilter(undefined);
87
+ }, []);
19
88
  const _exportMassAction = useMemo(() => ({
20
89
  label: t('explorer.massAction.export'),
21
- icon: _jsx(FaFileExport, {}),
90
+ icon: _jsx(FontAwesomeIcon, { icon: faFileExport }),
22
91
  deselectAll: false,
23
- callback: massSelectionFilter => {
24
- KitModal.confirm({
25
- width: '100%',
26
- style: { content: { width: '90vw', maxWidth: '656px' } },
27
- icon: false,
28
- type: 'confirm',
29
- title: t('explorer.export_item', {
30
- count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,
31
- }) ?? undefined,
32
- content: t('explorer.export_item_description', {
33
- count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,
34
- }) +
35
- BREAK_TWO_LINES +
36
- t('global.are_you_sure'),
37
- okText: t('global.confirm') ?? undefined,
38
- cancelText: t('global.cancel') ?? undefined,
39
- onOk: async () => {
40
- const total = view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;
41
- try {
42
- const { error } = await exportQuery({
43
- fetchPolicy: 'no-cache',
44
- variables: {
45
- library: view.libraryId,
46
- filters: massSelectionFilter,
47
- profile: 'default', // Set 'default' by default, it'll change when we can select a profile from the UI
48
- },
49
- });
50
- if (error) {
51
- // Preserve the extensions property which contains the error code
52
- const graphQLError = error.graphQLErrors?.[0];
53
- const errorWithExtensions = new Error(error.message);
54
- errorWithExtensions.extensions = graphQLError?.extensions;
55
- throw errorWithExtensions;
56
- }
57
- KitNotification.info({
58
- message: t('explorer.massAction.export_message'),
59
- description: t('explorer.massAction.export_description', {
60
- count: total,
61
- total,
62
- }),
63
- duration: INFO_NOTIFICATION_DURATION,
64
- closable: true,
65
- });
66
- onExport?.(massSelectionFilter, view.massSelection);
67
- }
68
- catch (e) {
69
- if (e.extensions?.code === 'CUSTOM_CONFIG_ERROR') {
70
- KitAlert.error({
71
- showIcon: true,
72
- duration: ERROR_ALERT_DURATION,
73
- message: t('explorer.massAction.export_config_error_message'),
74
- description: t('explorer.massAction.export_config_error_description'),
75
- closable: true,
76
- });
77
- }
78
- else {
79
- KitAlert.error({
80
- showIcon: true,
81
- duration: ERROR_ALERT_DURATION,
82
- message: t('explorer.massAction.export_error_message'),
83
- description: t('explorer.massAction.export_error_description', { count: total }),
84
- closable: true,
85
- });
86
- }
87
- }
88
- },
89
- });
92
+ callback: filter => {
93
+ setMassSelectionFilter(filter);
94
+ setIsModalOpen(true);
90
95
  },
91
- }), [t, exportQuery, view.massSelection, dispatch, view.libraryId]);
96
+ }), [t]);
97
+ const exportModal = isEnabled ? (_jsx(ExportProfileSelectionModal, { open: isModalOpen, libraryId: view.libraryId, isLoading: isExporting, onClose: _handleCloseModal, onConfirm: _handleConfirmExport })) : null;
92
98
  return {
93
99
  exportMassAction: isEnabled ? _exportMassAction : null,
100
+ ExportModal: exportModal,
94
101
  };
95
102
  };
96
103
  //# sourceMappingURL=useExportMassAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useExportMassAction.js","sourceRoot":"","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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, KitNotification} 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} 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 {error} = await exportQuery({\n fetchPolicy: 'no-cache',\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'),\n description: t('explorer.massAction.export_description', {\n count: total,\n total,\n }),\n duration: INFO_NOTIFICATION_DURATION,\n closable: true,\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('explorer.massAction.export_config_error_message'),\n description: t('explorer.massAction.export_config_error_description'),\n closable: true,\n });\n } else {\n KitAlert.error({\n showIcon: true,\n duration: ERROR_ALERT_DURATION,\n message: t('explorer.massAction.export_error_message'),\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.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAmC,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvF,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAC,MAAM,YAAY,CAAC;AACrD,OAAO,EAAC,kBAAkB,EAAyB,MAAM,eAAe,CAAC;AACzE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAGpE,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACj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IAAI;QACtD,WAAW,EAAE,WAAW;KAC3B,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, type ReactElement, useCallback, useMemo, useState} from 'react';\nimport {KitAlert, KitNotification} from 'aristid-ds';\nimport {useExportLazyQuery, type RecordFilterInput} 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 {MASS_SELECTION_ALL} from '../_constants';\nimport {ERROR_ALERT_DURATION, INFO_NOTIFICATION_DURATION} from '_ui/constants';\nimport {ExportProfileSelectionModal} from './export/ExportProfileSelectionModal';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faFileExport} from '@fortawesome/free-solid-svg-icons';\n\ninterface IUseExportMassActionReturn {\n exportMassAction: IMassActions | null;\n ExportModal: ReactElement | null;\n}\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}>): IUseExportMassActionReturn => {\n const {t} = useSharedTranslation();\n\n const [exportQuery] = useExportLazyQuery();\n\n const [isModalOpen, setIsModalOpen] = useState(false);\n const [isExporting, setIsExporting] = useState(false);\n const [massSelectionFilter, setMassSelectionFilter] = useState<RecordFilterInput[] | undefined>();\n\n const _handleConfirmExport = useCallback(\n async (profileLabel: string) => {\n if (!massSelectionFilter) {\n return;\n }\n\n const total = view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;\n setIsExporting(true);\n\n try {\n const {error} = await exportQuery({\n fetchPolicy: 'no-cache',\n variables: {\n library: view.libraryId,\n filters: massSelectionFilter,\n profile: profileLabel,\n },\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'),\n description: t('explorer.massAction.export_description', {\n count: total,\n total,\n }),\n duration: INFO_NOTIFICATION_DURATION,\n closable: true,\n });\n\n onExport?.(massSelectionFilter, view.massSelection);\n setIsModalOpen(false);\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 } finally {\n setIsExporting(false);\n }\n },\n [exportQuery, view.libraryId, view.massSelection, totalCount, massSelectionFilter, onExport, t],\n );\n\n const _handleCloseModal = useCallback(() => {\n setIsModalOpen(false);\n setMassSelectionFilter(undefined);\n }, []);\n\n const _exportMassAction: IMassActions = useMemo(\n () => ({\n label: t('explorer.massAction.export'),\n icon: <FontAwesomeIcon icon={faFileExport} />,\n deselectAll: false,\n callback: filter => {\n setMassSelectionFilter(filter);\n setIsModalOpen(true);\n },\n }),\n [t],\n );\n\n const exportModal = isEnabled ? (\n <ExportProfileSelectionModal\n open={isModalOpen}\n libraryId={view.libraryId}\n isLoading={isExporting}\n onClose={_handleCloseModal}\n onConfirm={_handleConfirmExport}\n />\n ) : null;\n\n return {\n exportMassAction: isEnabled ? _exportMassAction : null,\n ExportModal: exportModal,\n };\n};\n"]}
@@ -4,13 +4,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
5
5
  import { closeKitSnackBar, KitCheckbox, KitDropDown, KitSpace, openKitSnackBar } from 'aristid-ds';
6
6
  import { useCallback, useEffect } from 'react';
7
- import { FaChevronDown } from 'react-icons/fa';
8
7
  import { RecordFilterCondition, RecordFilterOperator } from '../../../_gqlTypes';
9
8
  import { useSharedTranslation } from '../../../hooks/useSharedTranslation';
10
9
  import { interleaveElement } from '../../../_utils/interleaveElement';
11
10
  import { MASS_SELECTION_ALL } from '../_constants';
12
11
  import { ViewSettingsActionTypes } from '../manage-view-settings';
13
12
  import { prepareFiltersForRequest } from '../../../components/Filters';
13
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
14
+ import { faChevronDown } from '@fortawesome/free-solid-svg-icons';
14
15
  /**
15
16
  * Hook used to manage mass selection as the snackbar and all kind of selection (manual, all in page, all in filters)
16
17
  *
@@ -102,7 +103,7 @@ export const useMassActions = ({ isEnabled, store: { dispatch, view }, filtersSt
102
103
  },
103
104
  },
104
105
  ],
105
- }, children: _jsx(KitCheckbox, { "aria-checked": hasSelectedSomeItems ? 'mixed' : hasSelectedAllAvailableItems ? 'true' : 'false', indeterminate: hasSelectedSomeItems, checked: hasSelectedAllAvailableItems, children: _jsxs(KitSpace, { size: "s", children: [t('explorer.massAction.itemsTotal', { count: totalCount }), _jsx(FaChevronDown, {})] }) }) }));
106
+ }, children: _jsx(KitCheckbox, { "aria-checked": hasSelectedSomeItems ? 'mixed' : hasSelectedAllAvailableItems ? 'true' : 'false', indeterminate: hasSelectedSomeItems, checked: hasSelectedAllAvailableItems, children: _jsxs(KitSpace, { size: "s", children: [t('explorer.massAction.itemsTotal', { count: totalCount }), _jsx(FontAwesomeIcon, { icon: faChevronDown })] }) }) }));
106
107
  const _setSelectedKeys = useCallback((keys) => dispatch({
107
108
  type: ViewSettingsActionTypes.SET_SELECTED_KEYS,
108
109
  payload: keys,
@@ -1 +1 @@
1
- {"version":3,"file":"useMassActions.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useMassActions.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,EAAC,MAAM,YAAY,CAAC;AACjG,OAAO,EAAgB,WAAW,EAAE,SAAS,EAAS,MAAM,OAAO,CAAC;AACpE,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAC,qBAAqB,EAAE,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,iBAAiB,EAAC,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACjD,OAAO,EAAoD,uBAAuB,EAAC,MAAM,yBAAyB,CAAC;AACnH,OAAO,EAAC,wBAAwB,EAAC,MAAM,wBAAwB,CAAC;AAGhE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAC3B,SAAS,EACT,KAAK,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,EACvB,YAAY,EAAE,EAAC,OAAO,EAAE,eAAe,EAAC,EACxC,UAAU,EACV,cAAc,EACd,WAAW,EACX,UAAU,GAYb,EAAE,EAAE;IACD,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,IAAI,CAAC,aAAa,KAAK,kBAAkB,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/E,eAAe,CAAC;gBACZ,QAAQ,EAAE,CAAC;gBACX,QAAQ,EAAE,IAAI;gBACd,UAAU;gBACV,SAAS,EAAE,UAAU;gBACrB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eAAe,EAAE,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI;QACpD,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI;KACvD,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 {closeKitSnackBar, KitCheckbox, KitDropDown, KitSpace, openKitSnackBar} from 'aristid-ds';\nimport {type Dispatch, useCallback, useEffect, useRef} from 'react';\nimport {FaChevronDown} from 'react-icons/fa';\nimport {RecordFilterCondition, RecordFilterOperator} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {interleaveElement} from '_ui/_utils/interleaveElement';\nimport {type IMassActions, type MassSelection} from '../_types';\nimport {MASS_SELECTION_ALL} from '../_constants';\nimport {type IViewSettingsAction, type IViewSettingsState, ViewSettingsActionTypes} from '../manage-view-settings';\nimport {prepareFiltersForRequest} from '_ui/components/Filters';\nimport {type IUIFiltersState} from '_ui/components/Filters/context/filtersReducer';\n\n/**\n * Hook used to manage mass selection as the snackbar and all kind of selection (manual, all in page, all in filters)\n *\n * @param isEnabled - whether the selection is present\n * @param view - represent the current view\n * @param dispatch - method to change the current view\n * @param totalCount - used for display only\n * @param allVisibleKeys - list of all ids currently selected\n * @param massActions - array of all actions available on mass selection\n * @param snackbarId - id of the snackbar displayed\n */\nexport const useMassActions = ({\n isEnabled,\n store: {dispatch, view},\n filtersStore: {filters, filtersOperator},\n totalCount,\n allVisibleKeys,\n massActions,\n snackbarId,\n}: {\n isEnabled: boolean;\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n filtersStore: IUIFiltersState;\n totalCount: number;\n allVisibleKeys: string[];\n massActions: IMassActions[];\n snackbarId: string;\n}) => {\n const {t} = useSharedTranslation();\n\n useEffect(() => {\n if (view.massSelection === MASS_SELECTION_ALL || view.massSelection.length !== 0) {\n openKitSnackBar({\n duration: 0,\n closable: true,\n snackbarId,\n toasterId: snackbarId,\n onClose: () => _setSelectedKeys([]),\n message: t('explorer.massAction.selectedItems', {\n count: view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length,\n }),\n actions: massActions.map(({label, icon, deselectAll, callback}, index) => ({\n key: index,\n label,\n icon,\n onClick: async () => {\n await callback(\n view.massSelection === MASS_SELECTION_ALL\n ? prepareFiltersForRequest(filters, filtersOperator)\n : interleaveElement(\n {operator: RecordFilterOperator.OR},\n view.massSelection.map(key => [\n {\n field: 'id',\n condition: RecordFilterCondition.EQUAL,\n value: String(key),\n },\n ]),\n ),\n view.massSelection,\n );\n if (deselectAll) {\n dispatch({\n type: ViewSettingsActionTypes.SET_SELECTED_KEYS,\n payload: [],\n });\n }\n },\n })),\n });\n } else {\n closeKitSnackBar(snackbarId);\n }\n }, [view.massSelection, filters, totalCount]);\n\n useEffect(() => () => closeKitSnackBar(snackbarId), []);\n\n const isOnePage = view.pageSize > totalCount;\n const hasSelectedAllAvailableItems =\n view.massSelection === MASS_SELECTION_ALL || view.massSelection.length === totalCount;\n const hasSelectedSomeItems =\n view.massSelection !== MASS_SELECTION_ALL &&\n view.massSelection.length > 0 &&\n view.massSelection.length < totalCount;\n\n const _selectAllButton = isOnePage ? (\n <KitCheckbox\n aria-checked={hasSelectedSomeItems ? 'mixed' : hasSelectedAllAvailableItems ? 'true' : 'false'}\n indeterminate={hasSelectedSomeItems}\n checked={hasSelectedAllAvailableItems}\n onChange={_ => {\n if (hasSelectedAllAvailableItems) {\n _setSelectedKeys([]);\n } else {\n _setSelectedKeys(allVisibleKeys);\n }\n }}\n >\n {t('explorer.massAction.itemsTotal', {count: totalCount})}\n </KitCheckbox>\n ) : (\n <KitDropDown\n trigger={['click']}\n menu={{\n items: [\n hasSelectedAllAvailableItems\n ? null\n : {\n key: 'toggle_page_selection',\n label: t('explorer.massAction.toggle_selection.select_page', {count: view.pageSize}),\n onClick: () => {\n _setSelectedKeys([...new Set([...view.massSelection, ...allVisibleKeys])]);\n },\n },\n {\n key: 'toggle_all_selection',\n label: hasSelectedAllAvailableItems\n ? t('explorer.massAction.toggle_selection.deselect_all', {count: totalCount})\n : t('explorer.massAction.toggle_selection.select_all', {count: totalCount}),\n onClick: async () => {\n if (hasSelectedAllAvailableItems) {\n _setSelectedKeys([]);\n } else {\n _setSelectedKeys(MASS_SELECTION_ALL);\n }\n },\n },\n ],\n }}\n >\n <KitCheckbox\n aria-checked={hasSelectedSomeItems ? 'mixed' : hasSelectedAllAvailableItems ? 'true' : 'false'}\n indeterminate={hasSelectedSomeItems}\n checked={hasSelectedAllAvailableItems}\n >\n <KitSpace size=\"s\">\n {t('explorer.massAction.itemsTotal', {count: totalCount})}\n <FaChevronDown />\n </KitSpace>\n </KitCheckbox>\n </KitDropDown>\n );\n\n const _setSelectedKeys = useCallback(\n (keys: MassSelection) =>\n dispatch({\n type: ViewSettingsActionTypes.SET_SELECTED_KEYS,\n payload: keys,\n }),\n [dispatch],\n );\n\n return {\n selectAllButton: isEnabled ? _selectAllButton : null,\n setSelectedKeys: isEnabled ? _setSelectedKeys : null,\n };\n};\n"]}
1
+ {"version":3,"file":"useMassActions.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useMassActions.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,EAAC,MAAM,YAAY,CAAC;AACjG,OAAO,EAAgB,WAAW,EAAE,SAAS,EAAS,MAAM,OAAO,CAAC;AACpE,OAAO,EAAC,qBAAqB,EAAE,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,iBAAiB,EAAC,MAA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AAC,KAAK,EAAE,UAAU,EAAC,CAAC;oBAC/E,OAAO,EAAE,KAAK,IAAI,EAAE;wBAChB,IAAI,4BAA4B,EAAE,CAAC;4BAC/B,gBAAgB,CAAC,EAAE,CAAC,CAAC;wBACzB,CAAC;6BAAM,CAAC;4BACJ,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;wBACzC,CAAC;oBACL,CAAC;iBACJ;aACJ;SACJ,YAED,KAAC,WAAW,oBACM,oBAAoB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAC9F,aAAa,EAAE,oBAAoB,EACnC,OAAO,EAAE,4BAA4B,YAErC,MAAC,QAAQ,IAAC,IAAI,EAAC,GAAG,aACb,CAAC,CAAC,gCAAgC,EAAE,EAAC,KAAK,EAAE,UAAU,EAAC,CAAC,EACzD,KAAC,eAAe,IAAC,IAAI,EAAE,aAAa,GAAI,IACjC,GACD,GACJ,CACjB,CAAC;IAEF,MAAM,gBAAgB,GAAG,WAAW,CAChC,CAAC,IAAmB,EAAE,EAAE,CACpB,QAAQ,CAAC;QACL,IAAI,EAAE,uBAAuB,CAAC,iBAAiB;QAC/C,OAAO,EAAE,IAAI;KAChB,CAAC,EACN,CAAC,QAAQ,CAAC,CACb,CAAC;IAEF,OAAO;QACH,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI;QACpD,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI;KACvD,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 {closeKitSnackBar, KitCheckbox, KitDropDown, KitSpace, openKitSnackBar} from 'aristid-ds';\nimport {type Dispatch, useCallback, useEffect, useRef} from 'react';\nimport {RecordFilterCondition, RecordFilterOperator} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {interleaveElement} from '_ui/_utils/interleaveElement';\nimport {type IMassActions, type MassSelection} from '../_types';\nimport {MASS_SELECTION_ALL} from '../_constants';\nimport {type IViewSettingsAction, type IViewSettingsState, ViewSettingsActionTypes} from '../manage-view-settings';\nimport {prepareFiltersForRequest} from '_ui/components/Filters';\nimport {type IUIFiltersState} from '_ui/components/Filters/context/filtersReducer';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faChevronDown} from '@fortawesome/free-solid-svg-icons';\n\n/**\n * Hook used to manage mass selection as the snackbar and all kind of selection (manual, all in page, all in filters)\n *\n * @param isEnabled - whether the selection is present\n * @param view - represent the current view\n * @param dispatch - method to change the current view\n * @param totalCount - used for display only\n * @param allVisibleKeys - list of all ids currently selected\n * @param massActions - array of all actions available on mass selection\n * @param snackbarId - id of the snackbar displayed\n */\nexport const useMassActions = ({\n isEnabled,\n store: {dispatch, view},\n filtersStore: {filters, filtersOperator},\n totalCount,\n allVisibleKeys,\n massActions,\n snackbarId,\n}: {\n isEnabled: boolean;\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n filtersStore: IUIFiltersState;\n totalCount: number;\n allVisibleKeys: string[];\n massActions: IMassActions[];\n snackbarId: string;\n}) => {\n const {t} = useSharedTranslation();\n\n useEffect(() => {\n if (view.massSelection === MASS_SELECTION_ALL || view.massSelection.length !== 0) {\n openKitSnackBar({\n duration: 0,\n closable: true,\n snackbarId,\n toasterId: snackbarId,\n onClose: () => _setSelectedKeys([]),\n message: t('explorer.massAction.selectedItems', {\n count: view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length,\n }),\n actions: massActions.map(({label, icon, deselectAll, callback}, index) => ({\n key: index,\n label,\n icon,\n onClick: async () => {\n await callback(\n view.massSelection === MASS_SELECTION_ALL\n ? prepareFiltersForRequest(filters, filtersOperator)\n : interleaveElement(\n {operator: RecordFilterOperator.OR},\n view.massSelection.map(key => [\n {\n field: 'id',\n condition: RecordFilterCondition.EQUAL,\n value: String(key),\n },\n ]),\n ),\n view.massSelection,\n );\n if (deselectAll) {\n dispatch({\n type: ViewSettingsActionTypes.SET_SELECTED_KEYS,\n payload: [],\n });\n }\n },\n })),\n });\n } else {\n closeKitSnackBar(snackbarId);\n }\n }, [view.massSelection, filters, totalCount]);\n\n useEffect(() => () => closeKitSnackBar(snackbarId), []);\n\n const isOnePage = view.pageSize > totalCount;\n const hasSelectedAllAvailableItems =\n view.massSelection === MASS_SELECTION_ALL || view.massSelection.length === totalCount;\n const hasSelectedSomeItems =\n view.massSelection !== MASS_SELECTION_ALL &&\n view.massSelection.length > 0 &&\n view.massSelection.length < totalCount;\n\n const _selectAllButton = isOnePage ? (\n <KitCheckbox\n aria-checked={hasSelectedSomeItems ? 'mixed' : hasSelectedAllAvailableItems ? 'true' : 'false'}\n indeterminate={hasSelectedSomeItems}\n checked={hasSelectedAllAvailableItems}\n onChange={_ => {\n if (hasSelectedAllAvailableItems) {\n _setSelectedKeys([]);\n } else {\n _setSelectedKeys(allVisibleKeys);\n }\n }}\n >\n {t('explorer.massAction.itemsTotal', {count: totalCount})}\n </KitCheckbox>\n ) : (\n <KitDropDown\n trigger={['click']}\n menu={{\n items: [\n hasSelectedAllAvailableItems\n ? null\n : {\n key: 'toggle_page_selection',\n label: t('explorer.massAction.toggle_selection.select_page', {count: view.pageSize}),\n onClick: () => {\n _setSelectedKeys([...new Set([...view.massSelection, ...allVisibleKeys])]);\n },\n },\n {\n key: 'toggle_all_selection',\n label: hasSelectedAllAvailableItems\n ? t('explorer.massAction.toggle_selection.deselect_all', {count: totalCount})\n : t('explorer.massAction.toggle_selection.select_all', {count: totalCount}),\n onClick: async () => {\n if (hasSelectedAllAvailableItems) {\n _setSelectedKeys([]);\n } else {\n _setSelectedKeys(MASS_SELECTION_ALL);\n }\n },\n },\n ],\n }}\n >\n <KitCheckbox\n aria-checked={hasSelectedSomeItems ? 'mixed' : hasSelectedAllAvailableItems ? 'true' : 'false'}\n indeterminate={hasSelectedSomeItems}\n checked={hasSelectedAllAvailableItems}\n >\n <KitSpace size=\"s\">\n {t('explorer.massAction.itemsTotal', {count: totalCount})}\n <FontAwesomeIcon icon={faChevronDown} />\n </KitSpace>\n </KitCheckbox>\n </KitDropDown>\n );\n\n const _setSelectedKeys = useCallback(\n (keys: MassSelection) =>\n dispatch({\n type: ViewSettingsActionTypes.SET_SELECTED_KEYS,\n payload: keys,\n }),\n [dispatch],\n );\n\n return {\n selectAllButton: isEnabled ? _selectAllButton : null,\n setSelectedKeys: isEnabled ? _setSelectedKeys : null,\n };\n};\n"]}
@@ -3,7 +3,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  // This file is released under LGPL V3
4
4
  // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
5
5
  import { useState } from 'react';
6
- import { FaPlus } from 'react-icons/fa';
7
6
  import { KitAlert } from 'aristid-ds';
8
7
  import { CreateDirectory, EditRecordModal, UploadFiles } from '../../../components';
9
8
  import { useSharedTranslation } from '../../../hooks/useSharedTranslation';
@@ -13,6 +12,8 @@ import { CREATE_RECORD_MODAL_CLASSNAME } from '../_constants';
13
12
  import { SUCCESS_ALERT_DURATION } from '../../../constants';
14
13
  import { localizedTranslation } from '@leav/utils';
15
14
  import { useLang } from '../../../hooks';
15
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
16
+ import { faPlus } from '@fortawesome/free-solid-svg-icons';
16
17
  /**
17
18
  * Hook used to get the action for the `<DataView />` component.
18
19
  *
@@ -59,7 +60,7 @@ export const useCreatePrimaryAction = ({ isEnabled, isVisible, libraryId, entryp
59
60
  callback: () => {
60
61
  setIsModalCreationVisible(true);
61
62
  },
62
- icon: _jsx(FaPlus, {}),
63
+ icon: _jsx(FontAwesomeIcon, { icon: faPlus }),
63
64
  disabled: !canCreateRecord,
64
65
  label: t('explorer.create-one'),
65
66
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useCreatePrimaryAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-primary/useCreatePrimaryAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAoB,QAAQ,EAAC,MAAM,OAAO,CAAC;AAClD,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,eAAe,EAAE,eAAe,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,yBAAyB,MAAM,uFAAuF,CAAC;AAE9H,OAAO,EACH,aAAa,EAEb,eAAe,EACf,8BAA8B,GACjC,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAC,6BAA6B,EAAC,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAC,sBAAsB,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EACnC,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,EACV,UAAU,EACV,qBAAqB,EACrB,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,kBAAkB,EAClB,OAAO,GAiBT,EAAE,EAAE;IACF,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,EAAC,IAAI,EAAC,GAAG,OAAO,EAAE,CAAC;IAEzB,MAAM,CAAC,sBAAsB,EAAE,yBAAyB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5E,MAAM,EAAC,UAAU,EAAC,GAAG,yBA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AM,CAAC;wBACJ,MAAM,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,EAAC,eAAe,EAAE,SAAS,CAAC,EAAE,EAAC,CAAC,CAAC,CAAC;oBACvE,CAAC;oBACD,OAAO,EAAE,CAAC;gBACd,CAAC,EACD,aAAa,EAAE,CAAC,QAAQ,CAAC,GAC3B,CACL,CAAC;YACF,MAAM;IACd,CAAC;IAED,OAAO;QACH,mBAAmB,EAAE,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI;QAC5D,WAAW,EAAE,sBAAsB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI;KAC5D,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 ReactElement, useState} from 'react';\nimport {FaPlus} from 'react-icons/fa';\nimport {KitAlert} from 'aristid-ds';\nimport {CreateDirectory, EditRecordModal, UploadFiles} from '_ui/components';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport useSaveValueBatchMutation from '_ui/components/RecordEdition/EditRecordContent/hooks/useExecuteSaveValueBatchMutation';\nimport {type ISubmitMultipleResult} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {\n AttributeType,\n type JoinLibraryContextFragment,\n LibraryBehavior,\n useExplorerLibraryDetailsQuery,\n} from '_ui/_gqlTypes';\nimport {type FeatureHook, type Entrypoint, type IPrimaryAction} from '../_types';\nimport {CREATE_RECORD_MODAL_CLASSNAME} from '../_constants';\nimport {SUCCESS_ALERT_DURATION} from '_ui/constants';\nimport {localizedTranslation} from '@leav/utils';\nimport {useLang} from '_ui/hooks';\n\n/**\n * Hook used to get the action for the `<DataView />` component.\n *\n * When the creation is done, we refresh all data even if the new record is not visible due to some filters.\n *\n * It returns also two parts: one for the call action button - one for displaying the modal required by the action.\n *\n * @param isEnabled - whether the action is present\n * @param isVisible - whether the button should be visible or not\n * @param libraryId - the library's id to add new item\n * @param entrypoint - represent the current entrypoint\n * @param totalCount - used for display purpose only\n * @param onCreate - callback to let outside world known about creating item (and linking)\n * @param refetch - method to call to refresh the list. A new item will be visible if it matches filters and sorts\n */\nexport const useCreatePrimaryAction = ({\n isEnabled,\n isVisible,\n libraryId,\n entrypoint,\n totalCount,\n canCreateAndLinkValue,\n isMultivalue,\n onCreate,\n formId,\n joinLibraryContext,\n refetch,\n}: FeatureHook<{\n libraryId: string;\n entrypoint: Entrypoint;\n totalCount: number;\n canCreateAndLinkValue: boolean;\n isMultivalue: boolean;\n onCreate?: ({\n recordIdCreated,\n saveValuesResultOnLink,\n }: {\n recordIdCreated: string;\n saveValuesResultOnLink?: ISubmitMultipleResult;\n }) => void;\n joinLibraryContext?: JoinLibraryContextFragment;\n formId?: string;\n refetch: () => void;\n}>) => {\n const {t} = useSharedTranslation();\n const {lang} = useLang();\n\n const [isModalCreationVisible, setIsModalCreationVisible] = useState(false);\n const {saveValues} = useSaveValueBatchMutation();\n\n const _getLibraryId = () =>\n (joinLibraryContext?.mandatoryAttribute &&\n 'linked_library' in joinLibraryContext.mandatoryAttribute &&\n joinLibraryContext.mandatoryAttribute.linked_library?.id) ||\n libraryId;\n\n const {data, loading, error} = useExplorerLibraryDetailsQuery({\n variables: {libraryId: _getLibraryId()},\n skip: !isEnabled,\n });\n\n const hasCreateRecordPermission = data?.libraries?.list[0]?.permissions?.create_record ?? false;\n\n if (error || loading || !isVisible || !hasCreateRecordPermission) {\n return {createPrimaryAction: null, createModal: null};\n }\n\n let canCreateRecord;\n if (joinLibraryContext?.mandatoryAttribute?.type === AttributeType.tree) {\n canCreateRecord = false;\n } else if (entrypoint.type === 'library') {\n canCreateRecord = true;\n } else {\n canCreateRecord = canCreateAndLinkValue && (isMultivalue || totalCount === 0);\n }\n\n const _createPrimaryAction: IPrimaryAction = {\n callback: () => {\n setIsModalCreationVisible(true);\n },\n icon: <FaPlus />,\n disabled: !canCreateRecord,\n label: t('explorer.create-one'),\n };\n\n const _notifyNewCreation = (label?: string | null) => {\n KitAlert.success({\n showIcon: true,\n duration: SUCCESS_ALERT_DURATION,\n message: t('items_list.created_in_success.message', {\n libName:\n localizedTranslation(data?.libraries?.list[0]?.label, lang) ||\n t('items_list.created_in_success.item'),\n }),\n description: t('items_list.created_in_success.description', {\n libName:\n localizedTranslation(data?.libraries?.list[0]?.label, lang) ||\n t('items_list.created_in_success.item'),\n itemName: label || t('items_list.created_in_success.item'),\n }),\n closable: true,\n });\n };\n\n let _createModal: ReactElement | null = null;\n switch (data?.libraries?.list[0]?.behavior) {\n case LibraryBehavior.files:\n _createModal = (\n <UploadFiles\n libraryId={_getLibraryId()}\n multiple\n onClose={() => setIsModalCreationVisible(false)}\n onCompleted={() => {\n refetch();\n _notifyNewCreation(t('upload.file'));\n setIsModalCreationVisible(false);\n }}\n />\n );\n break;\n case LibraryBehavior.directories:\n _createModal = (\n <CreateDirectory\n libraryId={_getLibraryId()}\n onClose={() => setIsModalCreationVisible(false)}\n onCompleted={() => {\n refetch();\n _notifyNewCreation(t('upload.folder'));\n setIsModalCreationVisible(false);\n }}\n />\n );\n break;\n case LibraryBehavior.standard:\n case LibraryBehavior.join:\n _createModal = (\n <EditRecordModal\n className={CREATE_RECORD_MODAL_CLASSNAME}\n open\n record={null}\n library={_getLibraryId()}\n creationFormId={formId}\n onClose={() => {\n setIsModalCreationVisible(false);\n }}\n onCreate={async newRecord => {\n _notifyNewCreation(newRecord.label);\n setIsModalCreationVisible(false);\n if (entrypoint.type === 'link') {\n await saveValues(\n {\n id: entrypoint.parentRecordId,\n library: {\n id: entrypoint.parentLibraryId,\n },\n },\n [\n {\n attribute: entrypoint.linkAttributeId,\n idValue: null,\n value: newRecord.id,\n },\n ],\n ).then(async saveValuesResult =>\n onCreate?.({\n recordIdCreated: newRecord.id,\n saveValuesResultOnLink: saveValuesResult,\n }),\n );\n } else {\n await Promise.resolve(onCreate?.({recordIdCreated: newRecord.id}));\n }\n refetch();\n }}\n submitButtons={['create']}\n />\n );\n break;\n }\n\n return {\n createPrimaryAction: isEnabled ? _createPrimaryAction : null,\n createModal: isModalCreationVisible ? _createModal : null,\n };\n};\n"]}
1
+ {"version":3,"file":"useCreatePrimaryAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-primary/useCreatePrimaryAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAoB,QAAQ,EAAC,MAAM,OAAO,CAAC;AAClD,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,eAAe,EAAE,eAAe,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,yBAAyB,MAAM,uFAAuF,CAAC;AAE9H,OAAO,EACH,aAAa,EAEb,eAAe,EACf,8BAA8B,GACjC,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAC,6BAA6B,EAAC,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAC,sBAAsB,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAEzD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EACnC,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,EACV,UAAU,EACV,qBAAqB,EACrB,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,kBAAkB,EAClB,OAAO,GAiBT,EAAE,EAAE;IACF,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;I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ACtB;yBACJ,CACJ,CAAC,IAAI,CAAC,KAAK,EAAC,gBAAgB,EAAC,EAAE,CAC5B,QAAQ,EAAE,CAAC;4BACP,eAAe,EAAE,SAAS,CAAC,EAAE;4BAC7B,sBAAsB,EAAE,gBAAgB;yBAC3C,CAAC,CACL,CAAC;oBACN,CAAC;yBAAM,CAAC;wBACJ,MAAM,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,EAAC,eAAe,EAAE,SAAS,CAAC,EAAE,EAAC,CAAC,CAAC,CAAC;oBACvE,CAAC;oBACD,OAAO,EAAE,CAAC;gBACd,CAAC,EACD,aAAa,EAAE,CAAC,QAAQ,CAAC,GAC3B,CACL,CAAC;YACF,MAAM;IACd,CAAC;IAED,OAAO;QACH,mBAAmB,EAAE,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI;QAC5D,WAAW,EAAE,sBAAsB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI;KAC5D,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 ReactElement, useState} from 'react';\nimport {KitAlert} from 'aristid-ds';\nimport {CreateDirectory, EditRecordModal, UploadFiles} from '_ui/components';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport useSaveValueBatchMutation from '_ui/components/RecordEdition/EditRecordContent/hooks/useExecuteSaveValueBatchMutation';\nimport {type ISubmitMultipleResult} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {\n AttributeType,\n type JoinLibraryContextFragment,\n LibraryBehavior,\n useExplorerLibraryDetailsQuery,\n} from '_ui/_gqlTypes';\nimport {type FeatureHook, type Entrypoint, type IPrimaryAction} from '../_types';\nimport {CREATE_RECORD_MODAL_CLASSNAME} from '../_constants';\nimport {SUCCESS_ALERT_DURATION} from '_ui/constants';\nimport {localizedTranslation} from '@leav/utils';\nimport {useLang} from '_ui/hooks';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faPlus} from '@fortawesome/free-solid-svg-icons';\n\n/**\n * Hook used to get the action for the `<DataView />` component.\n *\n * When the creation is done, we refresh all data even if the new record is not visible due to some filters.\n *\n * It returns also two parts: one for the call action button - one for displaying the modal required by the action.\n *\n * @param isEnabled - whether the action is present\n * @param isVisible - whether the button should be visible or not\n * @param libraryId - the library's id to add new item\n * @param entrypoint - represent the current entrypoint\n * @param totalCount - used for display purpose only\n * @param onCreate - callback to let outside world known about creating item (and linking)\n * @param refetch - method to call to refresh the list. A new item will be visible if it matches filters and sorts\n */\nexport const useCreatePrimaryAction = ({\n isEnabled,\n isVisible,\n libraryId,\n entrypoint,\n totalCount,\n canCreateAndLinkValue,\n isMultivalue,\n onCreate,\n formId,\n joinLibraryContext,\n refetch,\n}: FeatureHook<{\n libraryId: string;\n entrypoint: Entrypoint;\n totalCount: number;\n canCreateAndLinkValue: boolean;\n isMultivalue: boolean;\n onCreate?: ({\n recordIdCreated,\n saveValuesResultOnLink,\n }: {\n recordIdCreated: string;\n saveValuesResultOnLink?: ISubmitMultipleResult;\n }) => void;\n joinLibraryContext?: JoinLibraryContextFragment;\n formId?: string;\n refetch: () => void;\n}>) => {\n const {t} = useSharedTranslation();\n const {lang} = useLang();\n\n const [isModalCreationVisible, setIsModalCreationVisible] = useState(false);\n const {saveValues} = useSaveValueBatchMutation();\n\n const _getLibraryId = () =>\n (joinLibraryContext?.mandatoryAttribute &&\n 'linked_library' in joinLibraryContext.mandatoryAttribute &&\n joinLibraryContext.mandatoryAttribute.linked_library?.id) ||\n libraryId;\n\n const {data, loading, error} = useExplorerLibraryDetailsQuery({\n variables: {libraryId: _getLibraryId()},\n skip: !isEnabled,\n });\n\n const hasCreateRecordPermission = data?.libraries?.list[0]?.permissions?.create_record ?? false;\n\n if (error || loading || !isVisible || !hasCreateRecordPermission) {\n return {createPrimaryAction: null, createModal: null};\n }\n\n let canCreateRecord;\n if (joinLibraryContext?.mandatoryAttribute?.type === AttributeType.tree) {\n canCreateRecord = false;\n } else if (entrypoint.type === 'library') {\n canCreateRecord = true;\n } else {\n canCreateRecord = canCreateAndLinkValue && (isMultivalue || totalCount === 0);\n }\n\n const _createPrimaryAction: IPrimaryAction = {\n callback: () => {\n setIsModalCreationVisible(true);\n },\n icon: <FontAwesomeIcon icon={faPlus} />,\n disabled: !canCreateRecord,\n label: t('explorer.create-one'),\n };\n\n const _notifyNewCreation = (label?: string | null) => {\n KitAlert.success({\n showIcon: true,\n duration: SUCCESS_ALERT_DURATION,\n message: t('items_list.created_in_success.message', {\n libName:\n localizedTranslation(data?.libraries?.list[0]?.label, lang) ||\n t('items_list.created_in_success.item'),\n }),\n description: t('items_list.created_in_success.description', {\n libName:\n localizedTranslation(data?.libraries?.list[0]?.label, lang) ||\n t('items_list.created_in_success.item'),\n itemName: label || t('items_list.created_in_success.item'),\n }),\n closable: true,\n });\n };\n\n let _createModal: ReactElement | null = null;\n switch (data?.libraries?.list[0]?.behavior) {\n case LibraryBehavior.files:\n _createModal = (\n <UploadFiles\n libraryId={_getLibraryId()}\n multiple\n onClose={() => setIsModalCreationVisible(false)}\n onCompleted={() => {\n refetch();\n _notifyNewCreation(t('upload.file'));\n setIsModalCreationVisible(false);\n }}\n />\n );\n break;\n case LibraryBehavior.directories:\n _createModal = (\n <CreateDirectory\n libraryId={_getLibraryId()}\n onClose={() => setIsModalCreationVisible(false)}\n onCompleted={() => {\n refetch();\n _notifyNewCreation(t('upload.folder'));\n setIsModalCreationVisible(false);\n }}\n />\n );\n break;\n case LibraryBehavior.standard:\n case LibraryBehavior.join:\n _createModal = (\n <EditRecordModal\n className={CREATE_RECORD_MODAL_CLASSNAME}\n open\n record={null}\n library={_getLibraryId()}\n creationFormId={formId}\n onClose={() => {\n setIsModalCreationVisible(false);\n }}\n onCreate={async newRecord => {\n _notifyNewCreation(newRecord.label);\n setIsModalCreationVisible(false);\n if (entrypoint.type === 'link') {\n await saveValues(\n {\n id: entrypoint.parentRecordId,\n library: {\n id: entrypoint.parentLibraryId,\n },\n },\n [\n {\n attribute: entrypoint.linkAttributeId,\n idValue: null,\n value: newRecord.id,\n },\n ],\n ).then(async saveValuesResult =>\n onCreate?.({\n recordIdCreated: newRecord.id,\n saveValuesResultOnLink: saveValuesResult,\n }),\n );\n } else {\n await Promise.resolve(onCreate?.({recordIdCreated: newRecord.id}));\n }\n refetch();\n }}\n submitButtons={['create']}\n />\n );\n break;\n }\n\n return {\n createPrimaryAction: isEnabled ? _createPrimaryAction : null,\n createModal: isModalCreationVisible ? _createModal : null,\n };\n};\n"]}
@@ -13,13 +13,14 @@ import { type JoinLibraryContextFragment } from '../../../_gqlTypes';
13
13
  * @param maxItemsLeft - the number of items that can be added
14
14
  * @param onLink - callback to let outside world know about linking feedback
15
15
  */
16
- export declare const useLinkPrimaryAction: ({ isEnabled, isVisible, maxItemsLeft, linkId, canAddLinkValue, joinLibraryContext, isMultivalue, onLink, }: FeatureHook<{
16
+ export declare const useLinkPrimaryAction: ({ isEnabled, isVisible, maxItemsLeft, linkId, canAddLinkValue, joinLibraryContext, isMultivalue, onLink, columnsToDisplay, }: FeatureHook<{
17
17
  linkId?: string;
18
18
  maxItemsLeft: number | null;
19
19
  canAddLinkValue: boolean;
20
20
  joinLibraryContext?: JoinLibraryContextFragment;
21
21
  isMultivalue: boolean;
22
22
  onLink?: (saveValuesResult: ISubmitMultipleResult) => void;
23
+ columnsToDisplay: string[];
23
24
  }>) => {
24
25
  linkPrimaryAction: IPrimaryAction;
25
26
  linkModal: JSX.Element;
@@ -3,9 +3,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  // This file is released under LGPL V3
4
4
  // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
5
5
  import { useState } from 'react';
6
- import { FaPlus } from 'react-icons/fa';
7
6
  import { useSharedTranslation } from '../../../hooks/useSharedTranslation';
8
7
  import { LinkModal } from '../link-item/LinkModal';
8
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
9
+ import { faPlus } from '@fortawesome/free-solid-svg-icons';
9
10
  /**
10
11
  * Hook used to get the action for `<DataView />` component.
11
12
  *
@@ -18,7 +19,7 @@ import { LinkModal } from '../link-item/LinkModal';
18
19
  * @param maxItemsLeft - the number of items that can be added
19
20
  * @param onLink - callback to let outside world know about linking feedback
20
21
  */
21
- export const useLinkPrimaryAction = ({ isEnabled, isVisible, maxItemsLeft, linkId, canAddLinkValue, joinLibraryContext, isMultivalue, onLink, }) => {
22
+ export const useLinkPrimaryAction = ({ isEnabled, isVisible, maxItemsLeft, linkId, canAddLinkValue, joinLibraryContext, isMultivalue, onLink, columnsToDisplay, }) => {
22
23
  const { t } = useSharedTranslation();
23
24
  const [isLinkModalVisible, setIsLinkModalVisible] = useState(false);
24
25
  const disableAddItemAction = maxItemsLeft === 0 || !canAddLinkValue;
@@ -27,7 +28,7 @@ export const useLinkPrimaryAction = ({ isEnabled, isVisible, maxItemsLeft, linkI
27
28
  callback: () => {
28
29
  setIsLinkModalVisible(true);
29
30
  },
30
- icon: _jsx(FaPlus, {}),
31
+ icon: _jsx(FontAwesomeIcon, { icon: faPlus }),
31
32
  disabled: disableAddItemAction,
32
33
  label: replacementMode ? t('record_edition.replace-by-existing-item') : t('explorer.add-existing-item'),
33
34
  };
@@ -35,7 +36,7 @@ export const useLinkPrimaryAction = ({ isEnabled, isVisible, maxItemsLeft, linkI
35
36
  linkPrimaryAction: isEnabled && isVisible ? _linkPrimaryAction : null,
36
37
  linkModal: isLinkModalVisible ? (_jsx(LinkModal, { open: true, onLink: onLink, joinLibraryContext: joinLibraryContext, isMultivalue: isMultivalue, linkId: replacementMode ? linkId : undefined, onClose: () => {
37
38
  setIsLinkModalVisible(false);
38
- } })) : null,
39
+ }, columnsToDisplay: columnsToDisplay })) : null,
39
40
  };
40
41
  };
41
42
  //# sourceMappingURL=useLinkPrimaryAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLinkPrimaryAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-primary/useLinkPrimaryAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAGpE,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAC;AAGjD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EACjC,SAAS,EACT,SAAS,EACT,YAAY,EACZ,MAAM,EACN,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,MAAM,GAQR,EAAE,EAAE;IACF,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEpE,MAAM,oBAAoB,GAAG,YAAY,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;IAEpE,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC;IAEhD,MAAM,kBAAkB,GAAmB;QACvC,QAAQ,EAAE,GAAG,EAAE;YACX,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,EAAE,KAAC,MAAM,KAAG;QAChB,QAAQ,EAAE,oBAAoB;QAC9B,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,yCAAyC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,4BAA4B,CAAC;KAC1G,CAAC;IAEF,OAAO;QACH,iBAAiB,EAAE,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI;QACrE,SAAS,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAC5B,KAAC,SAAS,IACN,IAAI,QACJ,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,kBAAkB,EACtC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAC5C,OAAO,EAAE,GAAG,EAAE;gBACV,qBAAqB,CAAC,KAAK,CAAC,CAAC;YACjC,CAAC,GACH,CACL,CAAC,CAAC,CAAC,IAAI;KACX,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 {useState} from 'react';\nimport {FaPlus} from 'react-icons/fa';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type ISubmitMultipleResult} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {type FeatureHook, type IPrimaryAction} from '../_types';\nimport {LinkModal} from '../link-item/LinkModal';\nimport {type JoinLibraryContextFragment} from '_ui/_gqlTypes';\n\n/**\n * Hook used to get the action for `<DataView />` component.\n *\n * When items are linked, the view is refreshed\n *\n * It returns also two parts : one for the call action button - one for displaying the modal required by the action.\n *\n * @param isEnabled - whether the action is present\n * @param isVisible - wether the button should be visible or not\n * @param maxItemsLeft - the number of items that can be added\n * @param onLink - callback to let outside world know about linking feedback\n */\nexport const useLinkPrimaryAction = ({\n isEnabled,\n isVisible,\n maxItemsLeft,\n linkId,\n canAddLinkValue,\n joinLibraryContext,\n isMultivalue,\n onLink,\n}: FeatureHook<{\n linkId?: string;\n maxItemsLeft: number | null;\n canAddLinkValue: boolean;\n joinLibraryContext?: JoinLibraryContextFragment;\n isMultivalue: boolean;\n onLink?: (saveValuesResult: ISubmitMultipleResult) => void;\n}>) => {\n const {t} = useSharedTranslation();\n\n const [isLinkModalVisible, setIsLinkModalVisible] = useState(false);\n\n const disableAddItemAction = maxItemsLeft === 0 || !canAddLinkValue;\n\n const replacementMode = linkId && !isMultivalue;\n\n const _linkPrimaryAction: IPrimaryAction = {\n callback: () => {\n setIsLinkModalVisible(true);\n },\n icon: <FaPlus />,\n disabled: disableAddItemAction,\n label: replacementMode ? t('record_edition.replace-by-existing-item') : t('explorer.add-existing-item'),\n };\n\n return {\n linkPrimaryAction: isEnabled && isVisible ? _linkPrimaryAction : null,\n linkModal: isLinkModalVisible ? (\n <LinkModal\n open\n onLink={onLink}\n joinLibraryContext={joinLibraryContext}\n isMultivalue={isMultivalue}\n linkId={replacementMode ? linkId : undefined}\n onClose={() => {\n setIsLinkModalVisible(false);\n }}\n />\n ) : null,\n };\n};\n"]}
1
+ {"version":3,"file":"useLinkPrimaryAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-primary/useLinkPrimaryAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAGpE,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAEzD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EACjC,SAAS,EACT,SAAS,EACT,YAAY,EACZ,MAAM,EACN,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,MAAM,EACN,gBAAgB,GASlB,EAAE,EAAE;IACF,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEpE,MAAM,oBAAoB,GAAG,YAAY,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;IAEpE,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC;IAEhD,MAAM,kBAAkB,GAAmB;QACvC,QAAQ,EAAE,GAAG,EAAE;YACX,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,EAAE,KAAC,eAAe,IAAC,IAAI,EAAE,MAAM,GAAI;QACvC,QAAQ,EAAE,oBAAoB;QAC9B,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,yCAAyC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,4BAA4B,CAAC;KAC1G,CAAC;IAEF,OAAO;QACH,iBAAiB,EAAE,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI;QACrE,SAAS,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAC5B,KAAC,SAAS,IACN,IAAI,QACJ,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,kBAAkB,EACtC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAC5C,OAAO,EAAE,GAAG,EAAE;gBACV,qBAAqB,CAAC,KAAK,CAAC,CAAC;YACjC,CAAC,EACD,gBAAgB,EAAE,gBAAgB,GACpC,CACL,CAAC,CAAC,CAAC,IAAI;KACX,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 {useState} from 'react';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type ISubmitMultipleResult} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {type FeatureHook, type IPrimaryAction} from '../_types';\nimport {LinkModal} from '../link-item/LinkModal';\nimport {type JoinLibraryContextFragment} from '_ui/_gqlTypes';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faPlus} from '@fortawesome/free-solid-svg-icons';\n\n/**\n * Hook used to get the action for `<DataView />` component.\n *\n * When items are linked, the view is refreshed\n *\n * It returns also two parts : one for the call action button - one for displaying the modal required by the action.\n *\n * @param isEnabled - whether the action is present\n * @param isVisible - wether the button should be visible or not\n * @param maxItemsLeft - the number of items that can be added\n * @param onLink - callback to let outside world know about linking feedback\n */\nexport const useLinkPrimaryAction = ({\n isEnabled,\n isVisible,\n maxItemsLeft,\n linkId,\n canAddLinkValue,\n joinLibraryContext,\n isMultivalue,\n onLink,\n columnsToDisplay,\n}: FeatureHook<{\n linkId?: string;\n maxItemsLeft: number | null;\n canAddLinkValue: boolean;\n joinLibraryContext?: JoinLibraryContextFragment;\n isMultivalue: boolean;\n onLink?: (saveValuesResult: ISubmitMultipleResult) => void;\n columnsToDisplay: string[];\n}>) => {\n const {t} = useSharedTranslation();\n\n const [isLinkModalVisible, setIsLinkModalVisible] = useState(false);\n\n const disableAddItemAction = maxItemsLeft === 0 || !canAddLinkValue;\n\n const replacementMode = linkId && !isMultivalue;\n\n const _linkPrimaryAction: IPrimaryAction = {\n callback: () => {\n setIsLinkModalVisible(true);\n },\n icon: <FontAwesomeIcon icon={faPlus} />,\n disabled: disableAddItemAction,\n label: replacementMode ? t('record_edition.replace-by-existing-item') : t('explorer.add-existing-item'),\n };\n\n return {\n linkPrimaryAction: isEnabled && isVisible ? _linkPrimaryAction : null,\n linkModal: isLinkModalVisible ? (\n <LinkModal\n open\n onLink={onLink}\n joinLibraryContext={joinLibraryContext}\n isMultivalue={isMultivalue}\n linkId={replacementMode ? linkId : undefined}\n onClose={() => {\n setIsLinkModalVisible(false);\n }}\n columnsToDisplay={columnsToDisplay}\n />\n ) : null,\n };\n};\n"]}
@@ -9,6 +9,7 @@ interface ILinkModalProps {
9
9
  onClose: () => void;
10
10
  onLink?: (saveValuesResult: ISubmitMultipleResult) => void;
11
11
  onReplace?: (replaceValuesResult: ISubmitMultipleResult) => void;
12
+ columnsToDisplay: string[];
12
13
  }
13
14
  export declare const LinkModal: FunctionComponent<ILinkModalProps>;
14
15
  export {};
@@ -11,7 +11,7 @@ import { useReplaceLinkMassAction } from './useReplaceLinkMassAction';
11
11
  import { LINK_RECORDS_MODAL_CLASSNAME } from '../_constants';
12
12
  import { SelectTreeNodeModal } from '../../../components';
13
13
  import { useSharedTranslation } from '../../../hooks/useSharedTranslation';
14
- export const LinkModal = ({ open, linkId, joinLibraryContext, isMultivalue, onLink, onReplace, onClose, }) => {
14
+ export const LinkModal = ({ open, linkId, joinLibraryContext, isMultivalue, onLink, onReplace, onClose, columnsToDisplay, }) => {
15
15
  const { t } = useSharedTranslation();
16
16
  const { view } = useViewSettingsContext();
17
17
  const linkedLibraryId = joinLibraryContext &&
@@ -68,6 +68,6 @@ export const LinkModal = ({ open, linkId, joinLibraryContext, isMultivalue, onLi
68
68
  },
69
69
  });
70
70
  }
71
- } })) : (_jsx(SelectRecordForLinkModal, { className: LINK_RECORDS_MODAL_CLASSNAME, open: open, childLibraryId: linkedLibraryId || view.libraryId, onSelectionCompleted: isReplacement ? replaceLink : createLinks, replacementMode: isReplacement, selectionMode: isReplacement || !isMultivalue ? 'simple' : 'multiple', hideSelectAllAction: (isReplacement || !isMultivalue) && view.entrypoint.type === 'link', valuesList: valuesList, allowFreeEntry: allowFreeEntry, isMultivalue: isMultivalue, onClose: onClose }));
71
+ } })) : (_jsx(SelectRecordForLinkModal, { className: LINK_RECORDS_MODAL_CLASSNAME, open: open, childLibraryId: linkedLibraryId || view.libraryId, onSelectionCompleted: isReplacement ? replaceLink : createLinks, replacementMode: isReplacement, selectionMode: isReplacement || !isMultivalue ? 'simple' : 'multiple', hideSelectAllAction: (isReplacement || !isMultivalue) && view.entrypoint.type === 'link', valuesList: valuesList, allowFreeEntry: allowFreeEntry, isMultivalue: isMultivalue, onClose: onClose, columnsToDisplay: columnsToDisplay }));
72
72
  };
73
73
  //# sourceMappingURL=LinkModal.js.map
@@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U,EACrE,mBAAmB,EAAE,CAAC,aAAa,IAAI,CAAC,YAAY,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,MAAM,EACxF,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,OAAO,GAClB,CACL,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 FunctionComponent, useMemo} from 'react';\nimport {type JoinLibraryContextFragment, useExplorerLinkAttributeQuery} from '_ui/_gqlTypes';\nimport {type ISubmitMultipleResult} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {SelectRecordForLinkModal} from '_ui/components/SelectRecordForLinkModal';\nimport {type IEntrypointLink} from '../_types';\nimport {useAddLinkMassAction} from './useAddLinkMassAction';\nimport {useViewSettingsContext} from '../manage-view-settings/store-view-settings/useViewSettingsContext';\nimport {useReplaceLinkMassAction} from './useReplaceLinkMassAction';\nimport {LINK_RECORDS_MODAL_CLASSNAME} from '../_constants';\nimport {SelectTreeNodeModal} from '_ui/components';\nimport {ITreeNodeWithRecord} from '_ui/types';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\n\ninterface ILinkModalProps {\n open: boolean;\n linkId?: string;\n joinLibraryContext?: JoinLibraryContextFragment;\n isMultivalue: boolean;\n onClose: () => void;\n onLink?: (saveValuesResult: ISubmitMultipleResult) => void;\n onReplace?: (replaceValuesResult: ISubmitMultipleResult) => void;\n}\n\nexport const LinkModal: FunctionComponent<ILinkModalProps> = ({\n open,\n linkId,\n joinLibraryContext,\n isMultivalue,\n onLink,\n onReplace,\n onClose,\n}) => {\n const {t} = useSharedTranslation();\n const {view} = useViewSettingsContext();\n const linkedLibraryId =\n joinLibraryContext &&\n 'linked_library' in joinLibraryContext.mandatoryAttribute &&\n joinLibraryContext.mandatoryAttribute.linked_library?.id;\n const linkedTreeId =\n joinLibraryContext &&\n 'linked_tree' in joinLibraryContext.mandatoryAttribute &&\n joinLibraryContext.mandatoryAttribute.linked_tree?.id;\n\n const isReplacement = !!linkId;\n\n const {data: attributeData} = useExplorerLinkAttributeQuery({\n skip: view.entrypoint.type !== 'link',\n variables: {\n id: (view.entrypoint as IEntrypointLink).linkAttributeId,\n },\n });\n\n const {createLinks} = useAddLinkMassAction({\n store: {view},\n linkAttributeId: (view.entrypoint as IEntrypointLink).linkAttributeId,\n onLink,\n closeModal: onClose,\n });\n\n const {replaceLink} = useReplaceLinkMassAction({\n store: {view},\n linkAttributeId: (view.entrypoint as IEntrypointLink).linkAttributeId,\n linkId,\n onReplace,\n closeModal: onClose,\n });\n\n const linkAttributeData = attributeData?.attributes?.list[0];\n const isValuesListEnabled =\n linkAttributeData && 'valuesList' in linkAttributeData && linkAttributeData.valuesList?.enable;\n\n const valuesList = useMemo(\n () => (isValuesListEnabled ? linkAttributeData.valuesList?.linkedValues?.map(value => value.id) : undefined),\n [isValuesListEnabled, linkAttributeData],\n );\n const allowFreeEntry = useMemo(\n () => (isValuesListEnabled ? Boolean(linkAttributeData.valuesList?.allowFreeEntry) : true),\n [isValuesListEnabled, linkAttributeData],\n );\n\n return linkedTreeId ? (\n <SelectTreeNodeModal\n open\n attribute={{\n multiple_values: isMultivalue,\n linked_tree: {\n id: linkedTreeId,\n },\n }}\n title={t(isMultivalue ? 'tree-node-selection.title_many' : 'tree-node-selection.title')}\n // We can select new node(s), ignoring current value(s).\n // Selected element might be duplicated in link attribute in backend for now.\n backendValues={[]}\n onClose={onClose}\n onConfirm={selectedNodes => {\n const nodeIds = selectedNodes.map(node => node.id);\n if (isReplacement) {\n replaceLink({\n records: {\n list: nodeIds.map(id => ({id})),\n },\n });\n } else {\n createLinks({\n records: {\n list: nodeIds.map(id => ({id})),\n },\n });\n }\n }}\n />\n ) : (\n <SelectRecordForLinkModal\n className={LINK_RECORDS_MODAL_CLASSNAME}\n open={open}\n childLibraryId={linkedLibraryId || view.libraryId}\n onSelectionCompleted={isReplacement ? replaceLink : createLinks}\n replacementMode={isReplacement}\n selectionMode={isReplacement || !isMultivalue ? 'simple' : 'multiple'}\n hideSelectAllAction={(isReplacement || !isMultivalue) && view.entrypoint.type === 'link'}\n valuesList={valuesList}\n allowFreeEntry={allowFreeEntry}\n isMultivalue={isMultivalue}\n onClose={onClose}\n />\n );\n};\n"]}
1
+ {"version":3,"file":"LinkModal.js","sourceRoot":"","sources":["../../../../src/components/Explorer/link-item/LinkModal.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAyB,OAAO,EAAC,MAAM,OAAO,CAAC;AACtD,OAAO,EAAkC,6BAA6B,EAAC,MAAM,eAAe,CAAC;AAE7F,OAAO,EAAC,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AAEjF,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAC,sBAAsB,EAAC,MAAM,oEAAoE,CAAC;AAC1G,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAC,4BAA4B,EAAC,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAC,mBAAmB,EAAC,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAapE,MAAM,CAAC,MAAM,SAAS,GAAuC,CAAC,EAC1D,IAAI,EACJ,MAAM,EACN,kBAAkB,EAClB,YAAY,EACZ,MAAM,EACN,SAAS,EACT,OAAO,EACP,gBAAgB,GACnB,EAAE,EAAE;IACD,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,EAAC,IAAI,EAAC,GAAG,sBAAsB,EAAE,CAAC;IACxC,MAAM,eAAe,GACjB,kBAAkB;QAClB,gBAAgB,IAAI,kBAAkB,CA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wB,IACrB,SAAS,EAAE,4BAA4B,EACvC,IAAI,EAAE,IAAI,EACV,cAAc,EAAE,eAAe,IAAI,IAAI,CAAC,SAAS,EACjD,oBAAoB,EAAE,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,EAC/D,eAAe,EAAE,aAAa,EAC9B,aAAa,EAAE,aAAa,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,EACrE,mBAAmB,EAAE,CAAC,aAAa,IAAI,CAAC,YAAY,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,MAAM,EACxF,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,gBAAgB,GACpC,CACL,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 FunctionComponent, useMemo} from 'react';\nimport {type JoinLibraryContextFragment, useExplorerLinkAttributeQuery} from '_ui/_gqlTypes';\nimport {type ISubmitMultipleResult} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {SelectRecordForLinkModal} from '_ui/components/SelectRecordForLinkModal';\nimport {type IEntrypointLink} from '../_types';\nimport {useAddLinkMassAction} from './useAddLinkMassAction';\nimport {useViewSettingsContext} from '../manage-view-settings/store-view-settings/useViewSettingsContext';\nimport {useReplaceLinkMassAction} from './useReplaceLinkMassAction';\nimport {LINK_RECORDS_MODAL_CLASSNAME} from '../_constants';\nimport {SelectTreeNodeModal} from '_ui/components';\nimport {ITreeNodeWithRecord} from '_ui/types';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\n\ninterface ILinkModalProps {\n open: boolean;\n linkId?: string;\n joinLibraryContext?: JoinLibraryContextFragment;\n isMultivalue: boolean;\n onClose: () => void;\n onLink?: (saveValuesResult: ISubmitMultipleResult) => void;\n onReplace?: (replaceValuesResult: ISubmitMultipleResult) => void;\n columnsToDisplay: string[];\n}\n\nexport const LinkModal: FunctionComponent<ILinkModalProps> = ({\n open,\n linkId,\n joinLibraryContext,\n isMultivalue,\n onLink,\n onReplace,\n onClose,\n columnsToDisplay,\n}) => {\n const {t} = useSharedTranslation();\n const {view} = useViewSettingsContext();\n const linkedLibraryId =\n joinLibraryContext &&\n 'linked_library' in joinLibraryContext.mandatoryAttribute &&\n joinLibraryContext.mandatoryAttribute.linked_library?.id;\n const linkedTreeId =\n joinLibraryContext &&\n 'linked_tree' in joinLibraryContext.mandatoryAttribute &&\n joinLibraryContext.mandatoryAttribute.linked_tree?.id;\n\n const isReplacement = !!linkId;\n\n const {data: attributeData} = useExplorerLinkAttributeQuery({\n skip: view.entrypoint.type !== 'link',\n variables: {\n id: (view.entrypoint as IEntrypointLink).linkAttributeId,\n },\n });\n\n const {createLinks} = useAddLinkMassAction({\n store: {view},\n linkAttributeId: (view.entrypoint as IEntrypointLink).linkAttributeId,\n onLink,\n closeModal: onClose,\n });\n\n const {replaceLink} = useReplaceLinkMassAction({\n store: {view},\n linkAttributeId: (view.entrypoint as IEntrypointLink).linkAttributeId,\n linkId,\n onReplace,\n closeModal: onClose,\n });\n\n const linkAttributeData = attributeData?.attributes?.list[0];\n const isValuesListEnabled =\n linkAttributeData && 'valuesList' in linkAttributeData && linkAttributeData.valuesList?.enable;\n\n const valuesList = useMemo(\n () => (isValuesListEnabled ? linkAttributeData.valuesList?.linkedValues?.map(value => value.id) : undefined),\n [isValuesListEnabled, linkAttributeData],\n );\n const allowFreeEntry = useMemo(\n () => (isValuesListEnabled ? Boolean(linkAttributeData.valuesList?.allowFreeEntry) : true),\n [isValuesListEnabled, linkAttributeData],\n );\n\n return linkedTreeId ? (\n <SelectTreeNodeModal\n open\n attribute={{\n multiple_values: isMultivalue,\n linked_tree: {\n id: linkedTreeId,\n },\n }}\n title={t(isMultivalue ? 'tree-node-selection.title_many' : 'tree-node-selection.title')}\n // We can select new node(s), ignoring current value(s).\n // Selected element might be duplicated in link attribute in backend for now.\n backendValues={[]}\n onClose={onClose}\n onConfirm={selectedNodes => {\n const nodeIds = selectedNodes.map(node => node.id);\n if (isReplacement) {\n replaceLink({\n records: {\n list: nodeIds.map(id => ({id})),\n },\n });\n } else {\n createLinks({\n records: {\n list: nodeIds.map(id => ({id})),\n },\n });\n }\n }}\n />\n ) : (\n <SelectRecordForLinkModal\n className={LINK_RECORDS_MODAL_CLASSNAME}\n open={open}\n childLibraryId={linkedLibraryId || view.libraryId}\n onSelectionCompleted={isReplacement ? replaceLink : createLinks}\n replacementMode={isReplacement}\n selectionMode={isReplacement || !isMultivalue ? 'simple' : 'multiple'}\n hideSelectAllAction={(isReplacement || !isMultivalue) && view.entrypoint.type === 'link'}\n valuesList={valuesList}\n allowFreeEntry={allowFreeEntry}\n isMultivalue={isMultivalue}\n onClose={onClose}\n columnsToDisplay={columnsToDisplay}\n />\n );\n};\n"]}
@@ -14,10 +14,11 @@ import { useLoadView } from '../useLoadView';
14
14
  import { useMeQuery } from '../../../_gqlTypes';
15
15
  import { useDeleteView } from '../manage-view-settings/save-view/useDeleteView';
16
16
  import { useEditLabelView } from '../manage-view-settings/save-view/useEditLabelView';
17
- import { IoCopy } from 'react-icons/io5';
18
17
  import classNames from 'classnames';
19
18
  import { DefaultViewId } from '../manage-view-settings/store-view-settings/viewSettingsInitialState';
20
19
  import { INFO_NOTIFICATION_DURATION } from '../../../constants';
20
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
21
+ import { faCopy } from '@fortawesome/free-solid-svg-icons';
21
22
  const ContentWrapperStyledDiv = styled.div `
22
23
  display: flex;
23
24
  flex-direction: column;
@@ -99,7 +100,7 @@ export const SavedViews = () => {
99
100
  duration: INFO_NOTIFICATION_DURATION,
100
101
  closable: true,
101
102
  });
102
- }, children: _jsx(IoCopy, {}) }))] }), _jsx(StyledIconsDiv, { children: _jsxs(KitSpace, { children: [iconEditLabel(viewItem), iconDelete(viewItem)] }) })] }, viewItem.id)))] }), _jsxs(StyleKitRadioGroup, { onChange: _onClickLoadView, value: currentView?.id, children: [_jsx(KitTypography.Title, { level: "h4", children: t('explorer.viewList.shared-views') }), sharedViews.length === 0 ? (_jsx(KitTypography.Text, { size: "fontSize5", children: t('explorer.viewList.no-shared-views') })) : (sharedViews.map(viewItem => (_jsxs(StyledViewDiv, { className: _selectedViewClass(viewItem.id), children: [_jsxs(KitRadio, { value: viewItem.id, children: [localizedTranslation(viewItem.label, availableLangs), viewItem?.id && (_jsx(StyledCopySpan, { title: `${t('explorer.viewList.copy-id')} : ${viewItem?.id}`, onClick: async (e) => {
103
+ }, children: _jsx(FontAwesomeIcon, { icon: faCopy }) }))] }), _jsx(StyledIconsDiv, { children: _jsxs(KitSpace, { children: [iconEditLabel(viewItem), iconDelete(viewItem)] }) })] }, viewItem.id)))] }), _jsxs(StyleKitRadioGroup, { onChange: _onClickLoadView, value: currentView?.id, children: [_jsx(KitTypography.Title, { level: "h4", children: t('explorer.viewList.shared-views') }), sharedViews.length === 0 ? (_jsx(KitTypography.Text, { size: "fontSize5", children: t('explorer.viewList.no-shared-views') })) : (sharedViews.map(viewItem => (_jsxs(StyledViewDiv, { className: _selectedViewClass(viewItem.id), children: [_jsxs(KitRadio, { value: viewItem.id, children: [localizedTranslation(viewItem.label, availableLangs), viewItem?.id && (_jsx(StyledCopySpan, { title: `${t('explorer.viewList.copy-id')} : ${viewItem?.id}`, onClick: async (e) => {
103
104
  e.preventDefault();
104
105
  e.stopPropagation();
105
106
  await navigator.clipboard.writeText(viewItem.id || '');
@@ -109,6 +110,6 @@ export const SavedViews = () => {
109
110
  duration: INFO_NOTIFICATION_DURATION,
110
111
  closable: true,
111
112
  });
112
- }, children: _jsx(IoCopy, {}) }))] }), isOwnerView(viewItem.ownerId) ? (_jsx(StyledIconsDiv, { children: _jsxs(KitSpace, { children: [iconEditLabel(viewItem), iconDelete(viewItem)] }) })) : null] }, viewItem.id))))] })] }), _jsx(ViewActionsButtons, {})] })] }));
113
+ }, children: _jsx(FontAwesomeIcon, { icon: faCopy }) }))] }), isOwnerView(viewItem.ownerId) ? (_jsx(StyledIconsDiv, { children: _jsxs(KitSpace, { children: [iconEditLabel(viewItem), iconDelete(viewItem)] }) })) : null] }, viewItem.id))))] })] }), _jsx(ViewActionsButtons, {})] })] }));
113
114
  };
114
115
  //# sourceMappingURL=SavedViews.js.map