@leav/ui 1.12.0 → 1.13.0-b8abd53d

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 (159) hide show
  1. package/dist/__mocks__/utils.d.ts +3 -0
  2. package/dist/__mocks__/utils.js +2 -0
  3. package/dist/__mocks__/utils.js.map +1 -0
  4. package/dist/_gqlTypes/index.d.ts +361 -116
  5. package/dist/_gqlTypes/index.js +261 -51
  6. package/dist/_gqlTypes/index.js.map +1 -1
  7. package/dist/_queries/attributes/attributeDetailsFragment.js +3 -0
  8. package/dist/_queries/attributes/attributeDetailsFragment.js.map +1 -1
  9. package/dist/components/Explorer/DataView.js +31 -14
  10. package/dist/components/Explorer/DataView.js.map +1 -1
  11. package/dist/components/Explorer/_constants.d.ts +0 -1
  12. package/dist/components/Explorer/_constants.js +0 -1
  13. package/dist/components/Explorer/_constants.js.map +1 -1
  14. package/dist/components/Explorer/actions-item/useEditStatusItemAction.js +22 -10
  15. package/dist/components/Explorer/actions-item/useEditStatusItemAction.js.map +1 -1
  16. package/dist/components/Explorer/actions-mass/ResultsCount.js +2 -2
  17. package/dist/components/Explorer/actions-mass/ResultsCount.js.map +1 -1
  18. package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.d.ts +4 -9
  19. package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.js +3 -11
  20. package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.js.map +1 -1
  21. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.d.ts +8 -8
  22. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js +26 -13
  23. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js.map +1 -1
  24. package/dist/components/Explorer/actions-mass/edit-attribute/TreeNodeRemap.d.ts +7 -0
  25. package/dist/components/Explorer/actions-mass/edit-attribute/TreeNodeRemap.js +30 -0
  26. package/dist/components/Explorer/actions-mass/edit-attribute/TreeNodeRemap.js.map +1 -0
  27. package/dist/components/Explorer/actions-mass/edit-attribute/_types.d.ts +23 -0
  28. package/dist/components/Explorer/actions-mass/edit-attribute/_types.js +2 -0
  29. package/dist/components/Explorer/actions-mass/edit-attribute/_types.js.map +1 -0
  30. package/dist/components/Explorer/actions-mass/edit-attribute/useMassEditableAttributes.d.ts +4 -0
  31. package/dist/components/Explorer/actions-mass/edit-attribute/useMassEditableAttributes.js +46 -0
  32. package/dist/components/Explorer/actions-mass/edit-attribute/useMassEditableAttributes.js.map +1 -0
  33. package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.d.ts +12 -0
  34. package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.js +24 -0
  35. package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.js.map +1 -0
  36. package/dist/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.d.ts +13 -0
  37. package/dist/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.js +28 -0
  38. package/dist/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.js.map +1 -0
  39. package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js +6 -10
  40. package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js.map +1 -1
  41. package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js +5 -8
  42. package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js.map +1 -1
  43. package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.d.ts +8 -2
  44. package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js +104 -72
  45. package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js.map +1 -1
  46. package/dist/components/Explorer/actions-mass/useMassActions.js +30 -19
  47. package/dist/components/Explorer/actions-mass/useMassActions.js.map +1 -1
  48. package/dist/components/Explorer/conditionsHelper.d.ts +2 -1
  49. package/dist/components/Explorer/conditionsHelper.js.map +1 -1
  50. package/dist/components/Explorer/manage-view-settings/save-view/prepareViewForRequest.js +6 -4
  51. package/dist/components/Explorer/manage-view-settings/save-view/prepareViewForRequest.js.map +1 -1
  52. package/dist/components/Filters/_types.d.ts +11 -0
  53. package/dist/components/Filters/_types.js.map +1 -1
  54. package/dist/components/Filters/conditionsHelper.d.ts +2 -1
  55. package/dist/components/Filters/conditionsHelper.js.map +1 -1
  56. package/dist/components/Filters/context/filtersReducer.js +36 -5
  57. package/dist/components/Filters/context/filtersReducer.js.map +1 -1
  58. package/dist/components/Filters/filter-items/CommonFilterItem.js +4 -1
  59. package/dist/components/Filters/filter-items/CommonFilterItem.js.map +1 -1
  60. package/dist/components/Filters/filter-items/filter-type/FilterDropDown.js +15 -3
  61. package/dist/components/Filters/filter-items/filter-type/FilterDropDown.js.map +1 -1
  62. package/dist/components/Filters/filter-items/filter-type/FilterDropdownContent.d.ts +3 -1
  63. package/dist/components/Filters/filter-items/filter-type/FilterDropdownContent.js +2 -2
  64. package/dist/components/Filters/filter-items/filter-type/FilterDropdownContent.js.map +1 -1
  65. package/dist/components/Filters/filter-items/filter-type/_types.d.ts +3 -1
  66. package/dist/components/Filters/filter-items/filter-type/_types.js.map +1 -1
  67. package/dist/components/Filters/filter-items/filter-type/tree/TreeAttributeDropDown.js +39 -83
  68. package/dist/components/Filters/filter-items/filter-type/tree/TreeAttributeDropDown.js.map +1 -1
  69. package/dist/components/Filters/filter-items/filter-type/tree/useGetTreeData.d.ts +1 -0
  70. package/dist/components/Filters/filter-items/filter-type/tree/useGetTreeData.js.map +1 -1
  71. package/dist/components/Filters/filter-items/filter-type/tree/useTreeNodeSelection.d.ts +21 -0
  72. package/dist/components/Filters/filter-items/filter-type/tree/useTreeNodeSelection.js +85 -0
  73. package/dist/components/Filters/filter-items/filter-type/tree/useTreeNodeSelection.js.map +1 -0
  74. package/dist/components/Filters/filter-items/filter-type/tree/useTreePermissions.d.ts +8 -0
  75. package/dist/components/Filters/filter-items/filter-type/tree/useTreePermissions.js +40 -0
  76. package/dist/components/Filters/filter-items/filter-type/tree/useTreePermissions.js.map +1 -0
  77. package/dist/components/Filters/filter-items/filter-type/tree/useTreesSearch.d.ts +2 -3
  78. package/dist/components/Filters/filter-items/filter-type/tree/useTreesSearch.js +2 -3
  79. package/dist/components/Filters/filter-items/filter-type/tree/useTreesSearch.js.map +1 -1
  80. package/dist/components/Filters/filter-items/filter-type/tree/utils/filterTreeByPermission.d.ts +1 -1
  81. package/dist/components/Filters/filter-items/filter-type/tree/utils/filterTreeByPermission.js +3 -4
  82. package/dist/components/Filters/filter-items/filter-type/tree/utils/filterTreeByPermission.js.map +1 -1
  83. package/dist/components/Filters/filter-items/filter-type/useConditionOptionsByType.js.map +1 -1
  84. package/dist/components/Filters/filter-items/shared/EmptyValueCheckbox.js +1 -7
  85. package/dist/components/Filters/filter-items/shared/EmptyValueCheckbox.js.map +1 -1
  86. package/dist/components/Filters/prepareFiltersForRequest.js +37 -14
  87. package/dist/components/Filters/prepareFiltersForRequest.js.map +1 -1
  88. package/dist/components/Filters/useFilters.d.ts +204 -0
  89. package/dist/components/Filters/useTransformFilters.js +4 -2
  90. package/dist/components/Filters/useTransformFilters.js.map +1 -1
  91. package/dist/components/RecordEdition/EditRecord/EditRecord.js +8 -1
  92. package/dist/components/RecordEdition/EditRecord/EditRecord.js.map +1 -1
  93. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.d.ts +1 -4
  94. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.js +5 -9
  95. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.js.map +1 -1
  96. package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/DeleteAllValuesButton.js +4 -8
  97. package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/DeleteAllValuesButton.js.map +1 -1
  98. package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js +1 -1
  99. package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js.map +1 -1
  100. package/dist/components/RecordEdition/hooks/useCreateCancelConfirm/useCreateCancelConfirm.js +4 -8
  101. package/dist/components/RecordEdition/hooks/useCreateCancelConfirm/useCreateCancelConfirm.js.map +1 -1
  102. package/dist/constants.d.ts +1 -0
  103. package/dist/constants.js +1 -0
  104. package/dist/constants.js.map +1 -1
  105. package/dist/hooks/index.d.ts +4 -0
  106. package/dist/hooks/index.js +4 -0
  107. package/dist/hooks/index.js.map +1 -1
  108. package/dist/hooks/useConfirmModal/__mocks__/index.d.ts +1 -0
  109. package/dist/hooks/useConfirmModal/__mocks__/index.js +5 -0
  110. package/dist/hooks/useConfirmModal/__mocks__/index.js.map +1 -0
  111. package/dist/hooks/useConfirmModal/__mocks__/useConfirmModal.d.ts +3 -0
  112. package/dist/hooks/useConfirmModal/__mocks__/useConfirmModal.js +7 -0
  113. package/dist/hooks/useConfirmModal/__mocks__/useConfirmModal.js.map +1 -0
  114. package/dist/hooks/useConfirmModal/index.d.ts +1 -0
  115. package/dist/hooks/useConfirmModal/index.js +5 -0
  116. package/dist/hooks/useConfirmModal/index.js.map +1 -0
  117. package/dist/hooks/useConfirmModal/useConfirmModal.d.ts +7 -0
  118. package/dist/hooks/useConfirmModal/useConfirmModal.js +25 -0
  119. package/dist/hooks/useConfirmModal/useConfirmModal.js.map +1 -0
  120. package/dist/hooks/useGetRecordIdCard/index.d.ts +1 -0
  121. package/dist/hooks/useGetRecordIdCard/index.js +5 -0
  122. package/dist/hooks/useGetRecordIdCard/index.js.map +1 -0
  123. package/dist/hooks/useGetRecordIdCard/useGetRecordIdCard.d.ts +18 -0
  124. package/dist/hooks/useGetRecordIdCard/useGetRecordIdCard.js +20 -0
  125. package/dist/hooks/useGetRecordIdCard/useGetRecordIdCard.js.map +1 -0
  126. package/dist/hooks/useIFrameMessenger/iFrameMessengerContext.d.ts +6 -0
  127. package/dist/hooks/useIFrameMessenger/iFrameMessengerContext.js +8 -0
  128. package/dist/hooks/useIFrameMessenger/iFrameMessengerContext.js.map +1 -0
  129. package/dist/hooks/useIFrameMessenger/types.d.ts +10 -3
  130. package/dist/hooks/useIFrameMessenger/types.js.map +1 -1
  131. package/dist/hooks/useIFrameMessenger/useIFrameMessenger.d.ts +11 -2
  132. package/dist/hooks/useIFrameMessenger/useIFrameMessenger.js +31 -10
  133. package/dist/hooks/useIFrameMessenger/useIFrameMessenger.js.map +1 -1
  134. package/dist/hooks/useIFrameMessenger/useIFrameMessengerContext.d.ts +13 -0
  135. package/dist/hooks/useIFrameMessenger/useIFrameMessengerContext.js +59 -0
  136. package/dist/hooks/useIFrameMessenger/useIFrameMessengerContext.js.map +1 -0
  137. package/dist/hooks/useIFrameMessenger/useIFrameMessengerHandlers.d.ts +13 -0
  138. package/dist/hooks/useIFrameMessenger/useIFrameMessengerHandlers.js +29 -0
  139. package/dist/hooks/useIFrameMessenger/useIFrameMessengerHandlers.js.map +1 -0
  140. package/dist/hooks/useIFrameMessengerClient/IFrameMessengerClient.js +3 -0
  141. package/dist/hooks/useIFrameMessengerClient/IFrameMessengerClient.js.map +1 -1
  142. package/dist/hooks/useIFrameMessengerClient/iFrameMessengerClientContext.d.ts +1 -0
  143. package/dist/hooks/useIFrameMessengerClient/useIFrameMessengerClient.d.ts +1 -0
  144. package/dist/hooks/useSharedTranslation/__mocks__/useSharedTranslation.js.map +1 -1
  145. package/dist/locales/en/shared.json +10 -5
  146. package/dist/locales/fr/shared.json +12 -7
  147. package/package.json +17 -17
  148. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.d.ts +0 -8
  149. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js +0 -40
  150. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js.map +0 -1
  151. package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.d.ts +0 -17
  152. package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js +0 -42
  153. package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js.map +0 -1
  154. package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.d.ts +0 -5
  155. package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js +0 -20
  156. package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js.map +0 -1
  157. package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.d.ts +0 -12
  158. package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js +0 -30
  159. package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js.map +0 -1
@@ -2,86 +2,52 @@ import { jsx as _jsx, jsxs as _jsxs } 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 { AttributeType, useSaveValueBulkMutation, } from '../../../_gqlTypes';
5
+ import { useEffect, useState } from 'react';
6
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
7
+ import { faEdit } from '@fortawesome/free-solid-svg-icons';
8
+ import { KitAlert, KitEmpty, KitNotification, KitSelect, KitSpace, KitTypography } from 'aristid-ds';
9
+ import { localizedTranslation } from '@leav/utils';
10
+ import { useSaveValueBulkMutation } from '../../../_gqlTypes';
6
11
  import { useSharedTranslation } from '../../../hooks/useSharedTranslation';
7
- import { useEffect, useMemo, useState } from 'react';
12
+ import { ERROR_ALERT_DURATION, INFO_NOTIFICATION_DURATION } from '../../../constants';
13
+ import { useLang } from '../../../hooks';
8
14
  import { MASS_SELECTION_ALL } from '../_constants';
9
15
  import { EditTreeAttributeValuesMapping } from './edit-attribute/EditTreeAttributeValuesMapping';
10
16
  import { EditAttributeMassActionModal } from './edit-attribute/EditAttributeMassActionModal';
11
- import { useListEditableAttributeHook } from './edit-attribute/useListEditableAttributeHook';
12
- import { useCountValuesOccurrencesHook } from './edit-attribute/useCountValuesOccurrencesHook';
13
- import { KitAlert, KitNotification } from 'aristid-ds';
14
- import { ERROR_ALERT_DURATION, INFO_NOTIFICATION_DURATION } from '../../../constants';
15
- import { Loading } from '../../../components/Loading';
16
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
17
- import { faEdit } from '@fortawesome/free-solid-svg-icons';
17
+ import { useMassEditableAttributes } from './edit-attribute/useMassEditableAttributes';
18
+ const EDITION_MAPPING_DEFAULT_VALUES = { count: 0, mapping: [] };
18
19
  export const useEditAttributeMassAction = ({ isEnabled, store: { view }, totalCount, }) => {
19
- if (!isEnabled) {
20
- return {
21
- editAttributeMassAction: null,
22
- editAttributeMassActionModal: null,
23
- };
24
- }
20
+ const { lang: availableLanguages } = useLang();
25
21
  const { t } = useSharedTranslation();
26
- const [selectedAttribute, setSelectedAttribute] = useState(undefined);
27
- const [massSelectionFilter, setMassSelectionFilter] = useState([]);
28
22
  const [openModal, setOpenModal] = useState(false);
29
- const [editionMapping, setEditionMapping] = useState([]);
30
- const editableAttributes = useListEditableAttributeHook({ libraryId: view.libraryId });
31
- const valuesOccurrences = useCountValuesOccurrencesHook({
32
- attributeId: selectedAttribute?.id,
33
- libraryId: view.libraryId,
34
- recordFilters: massSelectionFilter,
35
- });
23
+ // Represent the current selection, used to apply modifications to correct records
24
+ const [massSelectionFilters, setMassSelectionFilters] = useState([]);
25
+ const editableAttributes = useMassEditableAttributes({ libraryId: view.libraryId });
26
+ const [selectedAttribute, setSelectedAttribute] = useState(null);
36
27
  const [executeSaveValueBulk] = useSaveValueBulkMutation();
28
+ const [editionMapping, setEditionMapping] = useState(EDITION_MAPPING_DEFAULT_VALUES);
37
29
  useEffect(() => {
38
- setEditionMapping([]);
30
+ setEditionMapping(EDITION_MAPPING_DEFAULT_VALUES);
39
31
  }, [selectedAttribute]);
40
- const _editAttributeMassAction = useMemo(() => ({
41
- label: t('explorer.massAction.editAttribute'),
42
- icon: _jsx(FontAwesomeIcon, { icon: faEdit }),
43
- deselectAll: false,
44
- callback: _massSelectionFilter => {
45
- setMassSelectionFilter(_massSelectionFilter);
46
- setEditionMapping([]);
47
- setOpenModal(true);
48
- },
49
- }), [t, view.massSelection]);
50
- const closeModal = () => {
32
+ const _closeModal = () => {
51
33
  setOpenModal(false);
52
- setMassSelectionFilter([]);
53
- setSelectedAttribute(undefined);
54
- setEditionMapping([]);
34
+ setMassSelectionFilters([]);
35
+ setSelectedAttribute(null);
36
+ setEditionMapping(EDITION_MAPPING_DEFAULT_VALUES);
55
37
  };
56
- const isMappingCompleted = useMemo(() => valuesOccurrences.noValueCount === 0
57
- ? editionMapping.length === valuesOccurrences.occurrences.length
58
- : editionMapping.length === valuesOccurrences.occurrences.length + 1, // for undefined values
59
- [editionMapping, valuesOccurrences]);
60
- const bulkCounter = useMemo(() => (view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length), [view.massSelection, totalCount]);
61
- const onOkButtonClick = async () => {
62
- if (!selectedAttribute || !isMappingCompleted) {
38
+ const bulkCount = view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;
39
+ const _saveEditionMapping = () => {
40
+ if (!selectedAttribute || editionMapping.count === 0) {
63
41
  return;
64
42
  }
65
- try {
66
- await executeSaveValueBulk({
67
- variables: {
68
- libraryId: view.libraryId,
69
- recordsFilters: massSelectionFilter,
70
- attributeId: selectedAttribute.id,
71
- mapValues: editionMapping,
72
- },
73
- });
74
- closeModal();
75
- KitNotification.info({
76
- message: t('explorer.massAction.editAttribute_submit_notification_title'),
77
- description: t('explorer.massAction.editAttribute_submit_notification_description', {
78
- counter: bulkCounter,
79
- }),
80
- duration: INFO_NOTIFICATION_DURATION,
81
- closable: true,
82
- });
83
- }
84
- catch (error) {
43
+ executeSaveValueBulk({
44
+ variables: {
45
+ libraryId: view.libraryId,
46
+ recordsFilters: massSelectionFilters,
47
+ attributeId: selectedAttribute.id,
48
+ mapping: editionMapping.mapping,
49
+ },
50
+ }).catch(() => {
85
51
  KitAlert.error({
86
52
  showIcon: true,
87
53
  duration: ERROR_ALERT_DURATION,
@@ -89,19 +55,85 @@ export const useEditAttributeMassAction = ({ isEnabled, store: { view }, totalCo
89
55
  description: t('explorer.massAction.editAttribute_submit_error'),
90
56
  closable: true,
91
57
  });
92
- }
58
+ });
59
+ _closeModal();
60
+ KitNotification.info({
61
+ message: t('explorer.massAction.editAttribute_submit_notification_title'),
62
+ description: t('explorer.massAction.editAttribute_submit_notification_description', {
63
+ count: editionMapping.count,
64
+ }) ?? undefined,
65
+ duration: INFO_NOTIFICATION_DURATION,
66
+ closable: true,
67
+ });
93
68
  };
94
- if (editableAttributes.length === 0) {
69
+ // TODO: https://aristid.atlassian.net/browse/LEAVC-830
70
+ if (!isEnabled || editableAttributes.length === 0) {
95
71
  return {
96
72
  editAttributeMassAction: null,
97
73
  editAttributeMassActionModal: null,
98
74
  };
99
75
  }
100
76
  return {
101
- editAttributeMassAction: _editAttributeMassAction,
102
- editAttributeMassActionModal: (_jsxs(EditAttributeMassActionModal, { isOpen: openModal, attributes: editableAttributes, setSelectedAttribute: setSelectedAttribute, massSelectionFilter: massSelectionFilter, elementsCount: bulkCounter, disableOkButton: !isMappingCompleted, onOkButtonClick: onOkButtonClick, onCancelButtonClick: closeModal, children: [selectedAttribute != null && valuesOccurrences.loading ? _jsx(Loading, {}) : null, selectedAttribute?.type === AttributeType.tree && (_jsx(EditTreeAttributeValuesMapping, { selectedAttribute: selectedAttribute, valuesOccurrences: valuesOccurrences, setAttributeMapping: (before, after) => {
103
- setEditionMapping(editionMapping.filter(mapping => mapping.before !== before).concat([{ before, after }]));
104
- } }))] })),
77
+ editAttributeMassAction: {
78
+ label: t('explorer.massAction.editAttribute'),
79
+ icon: _jsx(FontAwesomeIcon, { icon: faEdit }),
80
+ deselectAll: false,
81
+ callback: (_massSelectionFilter) => {
82
+ setMassSelectionFilters(_massSelectionFilter);
83
+ setSelectedAttribute(null);
84
+ setEditionMapping(EDITION_MAPPING_DEFAULT_VALUES);
85
+ setOpenModal(true);
86
+ },
87
+ },
88
+ editAttributeMassActionModal: (_jsxs(EditAttributeMassActionModal, { isOpen: openModal, bulkCount: bulkCount, onOkButtonClick: _saveEditionMapping, onCancelButtonClick: _closeModal, children: [_jsxs(KitSpace, { direction: "vertical", size: "xxs", style: { width: '100%' }, children: [_jsx(KitTypography.Text, { children: t('explorer.massAction.editAttribute_attribute_select_title') }), _jsx(KitSelect, { size: "large", allowClear: false, placeholder: t('explorer.massAction.editAttribute_attribute_select_placeholder'), options: editableAttributes.map(attribute => ({
89
+ label: localizedTranslation(attribute.label, availableLanguages),
90
+ value: attribute.id,
91
+ })), onChange: (attributeId) => {
92
+ setSelectedAttribute(editableAttributes.find(attribute => attribute.id === attributeId));
93
+ } })] }), selectedAttribute != null &&
94
+ (selectedAttribute.hasEmptyDependency ? (_jsx(EditTreeAttributeValuesMapping, { libraryId: view.libraryId, attribute: selectedAttribute, massSelectionFilters: massSelectionFilters, setAttributeMapping: ({ before, after, occurrenceCount }) => {
95
+ setEditionMapping(before === after
96
+ ? {
97
+ count: editionMapping.count - occurrenceCount,
98
+ mapping: [
99
+ {
100
+ values: (editionMapping.mapping[0]?.values ?? []).filter(value => value.before !== before),
101
+ },
102
+ ],
103
+ }
104
+ : {
105
+ count: editionMapping.count + occurrenceCount,
106
+ mapping: [
107
+ {
108
+ values: (editionMapping.mapping[0]?.values ?? [])
109
+ .filter(value => value.before !== before)
110
+ .concat([{ before, after }]),
111
+ },
112
+ ],
113
+ });
114
+ } })) : selectedAttribute.isSimpleWorkflow ? (_jsx(EditTreeAttributeValuesMapping, { libraryId: view.libraryId, attribute: selectedAttribute, massSelectionFilters: massSelectionFilters, setAttributeMapping: ({ before, after, occurrenceCount }) => {
115
+ setEditionMapping(before === after
116
+ ? {
117
+ count: editionMapping.count - occurrenceCount,
118
+ mapping: [
119
+ {
120
+ values: (editionMapping.mapping[0]?.values ?? []).filter(value => value.before !== before),
121
+ },
122
+ ],
123
+ }
124
+ : {
125
+ count: editionMapping.count + occurrenceCount,
126
+ mapping: [
127
+ {
128
+ values: (editionMapping.mapping[0]?.values ?? [])
129
+ .filter(value => value.before !== before)
130
+ .concat([{ before, after }]),
131
+ },
132
+ ],
133
+ });
134
+ } })) : selectedAttribute.isMonoDependencyWorkflow ? (
135
+ /* TODO: */
136
+ _jsx(KitEmpty, { description: "WIP" })) : null)] })),
105
137
  };
106
138
  };
107
139
  //# sourceMappingURL=useEditAttributeMassAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useEditAttributeMassAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useEditAttributeMassAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAEH,aAAa,EAEb,wBAAwB,GAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACnD,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAGjD,OAAO,EAAC,8BAA8B,EAAC,MAAM,iDAAiD,CAAC;AAC/F,OAAO,EAAC,4BAA4B,EAAC,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EAAC,4BAA4B,EAAC,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EAAC,6BAA6B,EAAC,MAAM,gDAAgD,CAAC;AAC7F,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAC,MAAM,YAAY,CAAC;AACrD,OAAO,EAAC,oBAAoB,EAAE,0BAA0B,EAAC,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAC,OAAO,EAAC,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAEzD,MAAM,CAA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,iBAAiB,EAAE,IAAI,KAAK,aAAa,CAAC,IAAI,IAAI,CAC/C,KAAC,8BAA8B,IAC3B,iBAAiB,EAAE,iBAAiB,EACpC,iBAAiB,EAAE,iBAAiB,EACpC,mBAAmB,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;wBACnC,iBAAiB,CACb,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,EAAC,MAAM,EAAE,KAAK,EAAC,CAAC,CAAC,CACxF,CAAC;oBACN,CAAC,GACH,CACL,IAC0B,CAClC;KACJ,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {\n type AttributeDetailsFragment,\n AttributeType,\n type RecordFilterInput,\n useSaveValueBulkMutation,\n} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {useEffect, useMemo, useState} from 'react';\nimport {MASS_SELECTION_ALL} from '../_constants';\nimport {type FeatureHook, type IMassActions} from '../_types';\nimport {type IViewSettingsState} from '../manage-view-settings';\nimport {EditTreeAttributeValuesMapping} from './edit-attribute/EditTreeAttributeValuesMapping';\nimport {EditAttributeMassActionModal} from './edit-attribute/EditAttributeMassActionModal';\nimport {useListEditableAttributeHook} from './edit-attribute/useListEditableAttributeHook';\nimport {useCountValuesOccurrencesHook} from './edit-attribute/useCountValuesOccurrencesHook';\nimport {KitAlert, KitNotification} from 'aristid-ds';\nimport {ERROR_ALERT_DURATION, INFO_NOTIFICATION_DURATION} from '_ui/constants';\nimport {Loading} from '_ui/components/Loading';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faEdit} from '@fortawesome/free-solid-svg-icons';\n\nexport const useEditAttributeMassAction = ({\n isEnabled,\n store: {view},\n totalCount,\n}: FeatureHook<{\n store: {\n view: IViewSettingsState;\n };\n totalCount: number;\n}>) => {\n if (!isEnabled) {\n return {\n editAttributeMassAction: null,\n editAttributeMassActionModal: null,\n };\n }\n\n const {t} = useSharedTranslation();\n\n const [selectedAttribute, setSelectedAttribute] = useState<AttributeDetailsFragment | undefined>(undefined);\n const [massSelectionFilter, setMassSelectionFilter] = useState<RecordFilterInput[]>([]);\n const [openModal, setOpenModal] = useState<boolean>(false);\n const [editionMapping, setEditionMapping] = useState<Array<{before: string | null; after: string | null}>>([]);\n\n const editableAttributes = useListEditableAttributeHook({libraryId: view.libraryId});\n const valuesOccurrences = useCountValuesOccurrencesHook({\n attributeId: selectedAttribute?.id,\n libraryId: view.libraryId,\n recordFilters: massSelectionFilter,\n });\n\n const [executeSaveValueBulk] = useSaveValueBulkMutation();\n\n useEffect(() => {\n setEditionMapping([]);\n }, [selectedAttribute]);\n\n const _editAttributeMassAction: IMassActions = useMemo(\n () => ({\n label: t('explorer.massAction.editAttribute'),\n icon: <FontAwesomeIcon icon={faEdit} />,\n deselectAll: false,\n callback: _massSelectionFilter => {\n setMassSelectionFilter(_massSelectionFilter);\n setEditionMapping([]);\n setOpenModal(true);\n },\n }),\n [t, view.massSelection],\n );\n\n const closeModal = () => {\n setOpenModal(false);\n setMassSelectionFilter([]);\n setSelectedAttribute(undefined);\n setEditionMapping([]);\n };\n\n const isMappingCompleted = useMemo(\n () =>\n valuesOccurrences.noValueCount === 0\n ? editionMapping.length === valuesOccurrences.occurrences.length\n : editionMapping.length === valuesOccurrences.occurrences.length + 1, // for undefined values\n [editionMapping, valuesOccurrences],\n );\n\n const bulkCounter = useMemo(\n () => (view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length),\n [view.massSelection, totalCount],\n );\n\n const onOkButtonClick = async () => {\n if (!selectedAttribute || !isMappingCompleted) {\n return;\n }\n try {\n await executeSaveValueBulk({\n variables: {\n libraryId: view.libraryId,\n recordsFilters: massSelectionFilter,\n attributeId: selectedAttribute.id,\n mapValues: editionMapping,\n },\n });\n\n closeModal();\n KitNotification.info({\n message: t('explorer.massAction.editAttribute_submit_notification_title'),\n description: t('explorer.massAction.editAttribute_submit_notification_description', {\n counter: bulkCounter,\n }),\n duration: INFO_NOTIFICATION_DURATION,\n closable: true,\n });\n } catch (error) {\n KitAlert.error({\n showIcon: true,\n duration: ERROR_ALERT_DURATION,\n message: t('error.error_occurred'),\n description: t('explorer.massAction.editAttribute_submit_error'),\n closable: true,\n });\n }\n };\n\n if (editableAttributes.length === 0) {\n return {\n editAttributeMassAction: null,\n editAttributeMassActionModal: null,\n };\n }\n\n return {\n editAttributeMassAction: _editAttributeMassAction,\n editAttributeMassActionModal: (\n <EditAttributeMassActionModal\n isOpen={openModal}\n attributes={editableAttributes}\n setSelectedAttribute={setSelectedAttribute}\n massSelectionFilter={massSelectionFilter}\n elementsCount={bulkCounter}\n disableOkButton={!isMappingCompleted}\n onOkButtonClick={onOkButtonClick}\n onCancelButtonClick={closeModal}\n >\n {selectedAttribute != null && valuesOccurrences.loading ? <Loading /> : null}\n {selectedAttribute?.type === AttributeType.tree && (\n <EditTreeAttributeValuesMapping\n selectedAttribute={selectedAttribute}\n valuesOccurrences={valuesOccurrences}\n setAttributeMapping={(before, after) => {\n setEditionMapping(\n editionMapping.filter(mapping => mapping.before !== before).concat([{before, after}]),\n );\n }}\n />\n )}\n </EditAttributeMassActionModal>\n ),\n };\n};\n"]}
1
+ {"version":3,"file":"useEditAttributeMassAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useEditAttributeMassAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AACzD,OAAO,EAAC,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AAwB,CAAC,CAAC,CAAC;oBAC7C,WAAW;oBACX,KAAC,QAAQ,IAAC,WAAW,EAAC,KAAK,GAAG,CACjC,CAAC,CAAC,CAAC,IAAI,CAAC,IACc,CAClC;KACJ,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {useEffect, useState} from 'react';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faEdit} from '@fortawesome/free-solid-svg-icons';\nimport {KitAlert, KitEmpty, KitNotification, KitSelect, KitSpace, KitTypography} from 'aristid-ds';\nimport {localizedTranslation} from '@leav/utils';\nimport {type RecordFilterInput, type SaveValueBulkMappingInput, useSaveValueBulkMutation} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {ERROR_ALERT_DURATION, INFO_NOTIFICATION_DURATION} from '_ui/constants';\nimport {useLang} from '_ui/hooks';\nimport {MASS_SELECTION_ALL} from '../_constants';\nimport {type FeatureHook} from '../_types';\nimport {type IViewSettingsState} from '../manage-view-settings';\nimport {EditTreeAttributeValuesMapping} from './edit-attribute/EditTreeAttributeValuesMapping';\nimport {EditAttributeMassActionModal} from './edit-attribute/EditAttributeMassActionModal';\nimport {useMassEditableAttributes} from './edit-attribute/useMassEditableAttributes';\nimport {type MassEditableAttribute} from './edit-attribute/_types';\n\nconst EDITION_MAPPING_DEFAULT_VALUES = {count: 0, mapping: []};\n\nexport const useEditAttributeMassAction = ({\n isEnabled,\n store: {view},\n totalCount,\n}: FeatureHook<{\n store: {\n view: IViewSettingsState;\n };\n totalCount: number;\n}>) => {\n const {lang: availableLanguages} = useLang();\n const {t} = useSharedTranslation();\n\n const [openModal, setOpenModal] = useState(false);\n\n // Represent the current selection, used to apply modifications to correct records\n const [massSelectionFilters, setMassSelectionFilters] = useState<RecordFilterInput[]>([]);\n\n const editableAttributes = useMassEditableAttributes({libraryId: view.libraryId});\n\n const [selectedAttribute, setSelectedAttribute] = useState<MassEditableAttribute | null>(null);\n const [executeSaveValueBulk] = useSaveValueBulkMutation();\n const [editionMapping, setEditionMapping] = useState<{count: number; mapping: SaveValueBulkMappingInput[]}>(\n EDITION_MAPPING_DEFAULT_VALUES,\n );\n useEffect(() => {\n setEditionMapping(EDITION_MAPPING_DEFAULT_VALUES);\n }, [selectedAttribute]);\n\n const _closeModal = () => {\n setOpenModal(false);\n setMassSelectionFilters([]);\n setSelectedAttribute(null);\n setEditionMapping(EDITION_MAPPING_DEFAULT_VALUES);\n };\n\n const bulkCount = view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;\n\n const _saveEditionMapping = () => {\n if (!selectedAttribute || editionMapping.count === 0) {\n return;\n }\n\n executeSaveValueBulk({\n variables: {\n libraryId: view.libraryId,\n recordsFilters: massSelectionFilters,\n attributeId: selectedAttribute.id,\n mapping: editionMapping.mapping,\n },\n }).catch(() => {\n KitAlert.error({\n showIcon: true,\n duration: ERROR_ALERT_DURATION,\n message: t('error.error_occurred'),\n description: t('explorer.massAction.editAttribute_submit_error'),\n closable: true,\n });\n });\n\n _closeModal();\n\n KitNotification.info({\n message: t('explorer.massAction.editAttribute_submit_notification_title'),\n description:\n t('explorer.massAction.editAttribute_submit_notification_description', {\n count: editionMapping.count,\n }) ?? undefined,\n duration: INFO_NOTIFICATION_DURATION,\n closable: true,\n });\n };\n\n // TODO: https://aristid.atlassian.net/browse/LEAVC-830\n if (!isEnabled || editableAttributes.length === 0) {\n return {\n editAttributeMassAction: null,\n editAttributeMassActionModal: null,\n };\n }\n\n return {\n editAttributeMassAction: {\n label: t('explorer.massAction.editAttribute'),\n icon: <FontAwesomeIcon icon={faEdit} />,\n deselectAll: false,\n callback: (_massSelectionFilter: RecordFilterInput[]) => {\n setMassSelectionFilters(_massSelectionFilter);\n setSelectedAttribute(null);\n setEditionMapping(EDITION_MAPPING_DEFAULT_VALUES);\n setOpenModal(true);\n },\n },\n editAttributeMassActionModal: (\n <EditAttributeMassActionModal\n isOpen={openModal}\n bulkCount={bulkCount}\n onOkButtonClick={_saveEditionMapping}\n onCancelButtonClick={_closeModal}\n >\n <KitSpace direction=\"vertical\" size=\"xxs\" style={{width: '100%'}}>\n <KitTypography.Text>\n {t('explorer.massAction.editAttribute_attribute_select_title')}\n </KitTypography.Text>\n <KitSelect\n size=\"large\"\n allowClear={false}\n placeholder={t('explorer.massAction.editAttribute_attribute_select_placeholder')}\n options={editableAttributes.map(attribute => ({\n label: localizedTranslation(attribute.label, availableLanguages),\n value: attribute.id,\n }))}\n onChange={(attributeId: string) => {\n setSelectedAttribute(editableAttributes.find(attribute => attribute.id === attributeId)!);\n }}\n />\n </KitSpace>\n {selectedAttribute != null &&\n (selectedAttribute.hasEmptyDependency ? (\n <EditTreeAttributeValuesMapping\n libraryId={view.libraryId}\n attribute={selectedAttribute}\n massSelectionFilters={massSelectionFilters}\n setAttributeMapping={({before, after, occurrenceCount}) => {\n setEditionMapping(\n before === after\n ? {\n count: editionMapping.count - occurrenceCount,\n mapping: [\n {\n values: (editionMapping.mapping[0]?.values ?? []).filter(\n value => value.before !== before,\n ),\n },\n ],\n }\n : {\n count: editionMapping.count + occurrenceCount,\n mapping: [\n {\n values: (editionMapping.mapping[0]?.values ?? [])\n .filter(value => value.before !== before)\n .concat([{before, after}]),\n },\n ],\n },\n );\n }}\n />\n ) : selectedAttribute.isSimpleWorkflow ? (\n <EditTreeAttributeValuesMapping\n libraryId={view.libraryId}\n attribute={selectedAttribute}\n massSelectionFilters={massSelectionFilters}\n setAttributeMapping={({before, after, occurrenceCount}) => {\n setEditionMapping(\n before === after\n ? {\n count: editionMapping.count - occurrenceCount,\n mapping: [\n {\n values: (editionMapping.mapping[0]?.values ?? []).filter(\n value => value.before !== before,\n ),\n },\n ],\n }\n : {\n count: editionMapping.count + occurrenceCount,\n mapping: [\n {\n values: (editionMapping.mapping[0]?.values ?? [])\n .filter(value => value.before !== before)\n .concat([{before, after}]),\n },\n ],\n },\n );\n }}\n />\n ) : selectedAttribute.isMonoDependencyWorkflow ? (\n /* TODO: */\n <KitEmpty description=\"WIP\" />\n ) : null)}\n </EditAttributeMassActionModal>\n ),\n };\n};\n"]}
@@ -73,6 +73,8 @@ export const useMassActions = ({ isEnabled, store: { dispatch, view }, filtersSt
73
73
  useEffect(() => () => closeKitSnackBar(snackbarId), []);
74
74
  const isOnePage = view.pageSize > totalCountFiltered;
75
75
  const hasSelectedAllAvailableItems = view.massSelection === MASS_SELECTION_ALL || view.massSelection.length === totalCountFiltered;
76
+ const hasSelectedAllVisibleItems = view.massSelection.length >= allVisibleKeys.length &&
77
+ allVisibleKeys.find(visibleKey => view.massSelection.includes(visibleKey)) !== undefined;
76
78
  const hasSelectedSomeItems = view.massSelection !== MASS_SELECTION_ALL &&
77
79
  view.massSelection.length > 0 &&
78
80
  view.massSelection.length < totalCountFiltered;
@@ -87,27 +89,36 @@ export const useMassActions = ({ isEnabled, store: { dispatch, view }, filtersSt
87
89
  items: [
88
90
  hasSelectedAllAvailableItems
89
91
  ? null
90
- : {
91
- key: 'toggle_page_selection',
92
- label: t('explorer.massAction.toggle_selection.select_page', { count: view.pageSize }),
93
- onClick: () => {
94
- _setSelectedKeys([...new Set([...view.massSelection, ...allVisibleKeys])]);
95
- },
96
- },
97
- {
98
- key: 'toggle_all_selection',
99
- label: hasSelectedAllAvailableItems
100
- ? t('explorer.massAction.toggle_selection.deselect_all', { count: totalCountFiltered })
101
- : t('explorer.massAction.toggle_selection.select_all', { count: totalCountFiltered }),
102
- onClick: async () => {
103
- if (hasSelectedAllAvailableItems) {
104
- _setSelectedKeys([]);
92
+ : hasSelectedAllVisibleItems
93
+ ? {
94
+ key: 'toggle_page_selection',
95
+ label: t('explorer.massAction.toggle_selection.deselect_page', { count: view.pageSize }),
96
+ onClick: () => _setSelectedKeys([...view.massSelection].filter(key => allVisibleKeys.includes[key])),
105
97
  }
106
- else {
98
+ : {
99
+ key: 'toggle_page_selection',
100
+ label: t('explorer.massAction.toggle_selection.select_page', { count: view.pageSize }),
101
+ onClick: () => _setSelectedKeys([...new Set([...view.massSelection, ...allVisibleKeys])]),
102
+ },
103
+ !hasSelectedAllAvailableItems
104
+ ? {
105
+ key: 'select_all_selection',
106
+ label: t('explorer.massAction.toggle_selection.select_all', { count: totalCountFiltered }),
107
+ onClick: async () => {
107
108
  _setSelectedKeys(MASS_SELECTION_ALL);
108
- }
109
- },
110
- },
109
+ },
110
+ }
111
+ : null,
112
+ hasSelectedAllAvailableItems ||
113
+ (!hasSelectedAllAvailableItems && !hasSelectedAllVisibleItems && view.massSelection.length >= 2)
114
+ ? {
115
+ key: 'deselect_all_selection',
116
+ label: t('explorer.massAction.toggle_selection.deselect_all'),
117
+ onClick: async () => {
118
+ _setSelectedKeys([]);
119
+ },
120
+ }
121
+ : null,
111
122
  ],
112
123
  }, children: _jsx(KitCheckbox, { "aria-checked": hasSelectedSomeItems ? 'mixed' : hasSelectedAllAvailableItems ? 'true' : 'false', indeterminate: hasSelectedSomeItems, checked: hasSelectedAllAvailableItems, children: _jsxs(KitSpace, { size: "xxs", children: [_jsx(ResultsCount, { t: t, isInactive: isInactive, totalCountFiltered: totalCountFiltered, totalCountLibrary: totalCountLibrary }), _jsx(FontAwesomeIcon, { icon: faCaretDown, size: "2xs" })] }) }) }));
113
124
  const _setSelectedKeys = useCallback((keys) => dispatch({
@@ -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,EAAiB,eAAe,EAAC,MAAM,YAAY,CAAC;AAChH,OAAO,EAAgB,WAAW,EAAE,SAAS,EAAU,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAC,qB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,IAAI,EAAE,WAAW,EAAE,IAAI,EAAC,KAAK,GAAG,IAC1C,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, KitTypography, openKitSnackBar} from 'aristid-ds';\nimport {type Dispatch, useCallback, useEffect, useRef, useState} 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 {faCaretDown} from '@fortawesome/free-solid-svg-icons';\nimport {ResultsCount} from './ResultsCount';\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 totalCountFiltered - number of results with the current filters\n * @param totalCountLibrary - number of total items in the library (without filters)\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 totalCountFiltered,\n totalCountLibrary,\n allVisibleKeys,\n massActions,\n snackbarId,\n}: {\n isEnabled: boolean;\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n filtersStore: IUIFiltersState;\n totalCountFiltered: number;\n totalCountLibrary: number;\n allVisibleKeys: string[];\n massActions: IMassActions[];\n snackbarId: string;\n}) => {\n const {t} = useSharedTranslation();\n const [isInactive, setIsInactive] = useState(false);\n\n useEffect(() => {\n setIsInactive(filters.filter(f => f.field === 'active')?.[0]?.value === 'false');\n }, [filters]);\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 ? totalCountFiltered : 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, totalCountFiltered]);\n\n useEffect(() => () => closeKitSnackBar(snackbarId), []);\n\n const isOnePage = view.pageSize > totalCountFiltered;\n const hasSelectedAllAvailableItems =\n view.massSelection === MASS_SELECTION_ALL || view.massSelection.length === totalCountFiltered;\n const hasSelectedSomeItems =\n view.massSelection !== MASS_SELECTION_ALL &&\n view.massSelection.length > 0 &&\n view.massSelection.length < totalCountFiltered;\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 <ResultsCount\n t={t}\n isInactive={isInactive}\n totalCountFiltered={totalCountFiltered}\n totalCountLibrary={totalCountLibrary}\n />\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: totalCountFiltered})\n : t('explorer.massAction.toggle_selection.select_all', {count: totalCountFiltered}),\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=\"xxs\">\n <ResultsCount\n t={t}\n isInactive={isInactive}\n totalCountFiltered={totalCountFiltered}\n totalCountLibrary={totalCountLibrary}\n />\n <FontAwesomeIcon icon={faCaretDown} size=\"2xs\" />\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,EAAiB,eAAe,EAAC,MAAM,YAAY,CAAC;AAChH,OAAO,EAAgB,WAAW,EAAE,SAAS,EAAU,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC9E,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;AAEhE,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,WAAW,EAAC,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAG5C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAC3B,SAAS,EACT,KAAK,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,EACvB,YAAY,EAAE,EAAC,OAAO,EAAE,eAAe,E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EAAE,kBAAkB,EACtC,iBAAiB,EAAE,iBAAiB,GACtC,EACF,KAAC,eAAe,IAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAC,KAAK,GAAG,IAC1C,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, KitTypography, openKitSnackBar} from 'aristid-ds';\nimport {type Dispatch, useCallback, useEffect, useRef, useState} 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 {faCaretDown} from '@fortawesome/free-solid-svg-icons';\nimport {ResultsCount} from './ResultsCount';\nimport {IKitDropdown} from 'aristid-ds/dist/Kit/Navigation/DropDown/types';\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 totalCountFiltered - number of results with the current filters\n * @param totalCountLibrary - number of total items in the library (without filters)\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 totalCountFiltered,\n totalCountLibrary,\n allVisibleKeys,\n massActions,\n snackbarId,\n}: {\n isEnabled: boolean;\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n filtersStore: IUIFiltersState;\n totalCountFiltered: number;\n totalCountLibrary: number;\n allVisibleKeys: string[];\n massActions: IMassActions[];\n snackbarId: string;\n}) => {\n const {t} = useSharedTranslation();\n const [isInactive, setIsInactive] = useState(false);\n\n useEffect(() => {\n setIsInactive(filters.filter(f => f.field === 'active')?.[0]?.value === 'false');\n }, [filters]);\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 ? totalCountFiltered : 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, totalCountFiltered]);\n\n useEffect(() => () => closeKitSnackBar(snackbarId), []);\n\n const isOnePage = view.pageSize > totalCountFiltered;\n const hasSelectedAllAvailableItems =\n view.massSelection === MASS_SELECTION_ALL || view.massSelection.length === totalCountFiltered;\n const hasSelectedAllVisibleItems =\n view.massSelection.length >= allVisibleKeys.length &&\n allVisibleKeys.find(visibleKey => view.massSelection.includes(visibleKey)) !== undefined;\n const hasSelectedSomeItems =\n view.massSelection !== MASS_SELECTION_ALL &&\n view.massSelection.length > 0 &&\n view.massSelection.length < totalCountFiltered;\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 <ResultsCount\n t={t}\n isInactive={isInactive}\n totalCountFiltered={totalCountFiltered}\n totalCountLibrary={totalCountLibrary}\n />\n </KitCheckbox>\n ) : (\n <KitDropDown\n trigger={['click']}\n menu={{\n items: [\n hasSelectedAllAvailableItems\n ? null\n : hasSelectedAllVisibleItems\n ? {\n key: 'toggle_page_selection',\n label: t('explorer.massAction.toggle_selection.deselect_page', {count: view.pageSize}),\n onClick: () =>\n _setSelectedKeys(\n [...view.massSelection].filter(key => allVisibleKeys.includes[key]),\n ),\n }\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 !hasSelectedAllAvailableItems\n ? {\n key: 'select_all_selection',\n label: t('explorer.massAction.toggle_selection.select_all', {count: totalCountFiltered}),\n onClick: async () => {\n _setSelectedKeys(MASS_SELECTION_ALL);\n },\n }\n : null,\n hasSelectedAllAvailableItems ||\n (!hasSelectedAllAvailableItems && !hasSelectedAllVisibleItems && view.massSelection.length >= 2)\n ? {\n key: 'deselect_all_selection',\n label: t('explorer.massAction.toggle_selection.deselect_all'),\n onClick: async () => {\n _setSelectedKeys([]);\n },\n }\n : null,\n ],\n }}\n >\n <KitCheckbox\n aria-checked={hasSelectedSomeItems ? 'mixed' : hasSelectedAllAvailableItems ? 'true' : 'false'}\n indeterminate={hasSelectedSomeItems}\n checked={hasSelectedAllAvailableItems}\n >\n <KitSpace size=\"xxs\">\n <ResultsCount\n t={t}\n isInactive={isInactive}\n totalCountFiltered={totalCountFiltered}\n totalCountLibrary={totalCountLibrary}\n />\n <FontAwesomeIcon icon={faCaretDown} size=\"2xs\" />\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,2 +1,3 @@
1
- export declare const hasOnlyNoValueConditions: (attributeFormat: string) => boolean;
1
+ import { AttributeFormat } from '../../_gqlTypes';
2
+ export declare const hasOnlyNoValueConditions: (attributeFormat: AttributeFormat) => boolean;
2
3
  export declare const nullValueConditions: import("../../_gqlTypes").RecordFilterCondition[];
@@ -1 +1 @@
1
- {"version":3,"file":"conditionsHelper.js","sourceRoot":"","sources":["../../../src/components/Explorer/conditionsHelper.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,wBAAwB,EAAC,MAAM,WAAW,CAAC;AAEnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,eAAuB,EAAW,EAAE,CACzE,CAAC,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,UAAU,EAAE,eAAe,CAAC,SAAS,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAC7G,eAAe,CAClB,CAAC;AAEN,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,wBAAwB,CAAC,QAAQ;IACjC,wBAAwB,CAAC,YAAY;IACrC,wBAAwB,CAAC,KAAK;IAC9B,wBAAwB,CAAC,QAAQ;IACjC,wBAAwB,CAAC,SAAS;IAClC,wBAAwB,CAAC,UAAU;IACnC,wBAAwB,CAAC,UAAU;CACtC,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 {AttributeFormat} from '_ui/_gqlTypes';\nimport {AttributeConditionFilter} from '_ui/types';\n\nexport const hasOnlyNoValueConditions = (attributeFormat: string): boolean =>\n [AttributeFormat.color, AttributeFormat.date_range, AttributeFormat.encrypted, AttributeFormat.extended].includes(\n attributeFormat,\n );\n\nexport const nullValueConditions = [\n AttributeConditionFilter.IS_EMPTY,\n AttributeConditionFilter.IS_NOT_EMPTY,\n AttributeConditionFilter.TODAY,\n AttributeConditionFilter.TOMORROW,\n AttributeConditionFilter.YESTERDAY,\n AttributeConditionFilter.LAST_MONTH,\n AttributeConditionFilter.NEXT_MONTH,\n];\n"]}
1
+ {"version":3,"file":"conditionsHelper.js","sourceRoot":"","sources":["../../../src/components/Explorer/conditionsHelper.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,wBAAwB,EAAC,MAAM,WAAW,CAAC;AAEnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,eAAgC,EAAW,EAAE,CAClF,CAAC,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,UAAU,EAAE,eAAe,CAAC,SAAS,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAC7G,eAAe,CAClB,CAAC;AAEN,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,wBAAwB,CAAC,QAAQ;IACjC,wBAAwB,CAAC,YAAY;IACrC,wBAAwB,CAAC,KAAK;IAC9B,wBAAwB,CAAC,QAAQ;IACjC,wBAAwB,CAAC,SAAS;IAClC,wBAAwB,CAAC,UAAU;IACnC,wBAAwB,CAAC,UAAU;CACtC,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 {AttributeFormat} from '_ui/_gqlTypes';\nimport {AttributeConditionFilter} from '_ui/types';\n\nexport const hasOnlyNoValueConditions = (attributeFormat: AttributeFormat): boolean =>\n [AttributeFormat.color, AttributeFormat.date_range, AttributeFormat.encrypted, AttributeFormat.extended].includes(\n attributeFormat,\n );\n\nexport const nullValueConditions = [\n AttributeConditionFilter.IS_EMPTY,\n AttributeConditionFilter.IS_NOT_EMPTY,\n AttributeConditionFilter.TODAY,\n AttributeConditionFilter.TOMORROW,\n AttributeConditionFilter.YESTERDAY,\n AttributeConditionFilter.LAST_MONTH,\n AttributeConditionFilter.NEXT_MONTH,\n];\n"]}
@@ -28,11 +28,13 @@ export const prepareViewForRequest = (view, filters, label) => ({
28
28
  };
29
29
  }
30
30
  if (isUIFilterWithSmartFilter(filter)) {
31
+ const isThoughFilter = isUIFilterThrough(filter);
31
32
  return {
32
- field: filter.field, // We use the field here because we want to keep the full path to the attribute (ex: link_attribute.id)
33
- // TODO : save filter values as string[] when filter and handle fields with libraries
34
- value: filter.value?.[0],
35
- condition: filter.condition,
33
+ field: isThoughFilter
34
+ ? `${filter.field}.${filter.subField}`
35
+ : filter.field, // We use the field here because we want to keep the full path to the attribute (ex: link_attribute.id)
36
+ value: null, // Force no value to avoid broken load view, may be fix after LEAVC-569
37
+ condition: isThoughFilter ? filter.subCondition : filter.condition,
36
38
  withEmptyValues: filter.withEmptyValues,
37
39
  };
38
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"prepareViewForRequest.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/manage-view-settings/save-view/prepareViewForRequest.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,+BAA+B,EAAC,MAAM,kBAAkB,CAAC;AAEjE,OAAO,EACH,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EAEnB,yBAAyB,GAC5B,MAAM,+BAA+B,CAAC;AAEvC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACjC,IAAwB,EACxB,OAAmB,EACnB,KAA6B,EACpB,EAAE,CAAC,CAAC;IACb,OAAO,EAAE,IAAI,CAAC,SAAS;IACvB,MAAM,EAAE,KAAK;IACb,OAAO,EAAE;QACL,IAAI,EAAE,+BAA+B,CAAC,IAAI,CAAC,QAAQ,CAAC;KACvD;IACD,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAqB,EAAE;QAC/C,IAAI,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YACzB,OAAO;gBACH,oIAAoI;gBACpI,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE;gBAC1B,0FAA0F;gBAC1F,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;gBACxB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,eAAe,EAAE,MAAM,CAAC,eAAe;aAC1C,CAAC;QACN,CAAC;QAED,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9B,OAAO;gBACH,oIAAoI;gBACpI,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE;gBAC1B,qFAAqF;gBACrF,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;gBACxB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,eAAe,EAAE,MAAM,CAAC,eAAe;aAC1C,CAAC;QACN,CAAC;QAED,IAAI,yBAAyB,CAAC,MAAM,CAAC,EAAE,CAAC;YACpC,OAAO;gBACH,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,uGAAuG;gBAC5H,qFAAqF;gBACrF,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;gBACxB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,eAAe,EAAE,MAAM,CAAC,eAAe;aAC1C,CAAC;QACN,CAAC;QAED,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,OAAO;gBACH,KAAK,EAAE,GAAG,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,QAAQ,EAAE;gBAC3C,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,SAAS,EAAE,MAAM,CAAC,YAAY;aACjC,CAAC;QACN,CAAC;QAED,OAAO;YACH,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,eAAe,EAAE,MAAM,CAAC,eAAe;SAC1C,CAAC;IACN,CAAC,CAAC;IACF,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAC,KAAK,EAAE,KAAK,EAAC,EAAE,EAAE,CAAC,CAAC,EAAC,KAAK,EAAE,KAAK,EAAC,CAAC,CAAC;IACzD,UAAU,EAAE,IAAI,CAAC,aAAa;IAC9B,KAAK;CACR,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type RecordFilterInput, type ViewInput} from '_ui/_gqlTypes';\nimport {mapViewTypeFromExplorerToLegacy} from '../../_constants';\nimport {type IViewSettingsState} from '../store-view-settings/viewSettingsReducer';\nimport {\n isUIFilterTree,\n isUIFilterThrough,\n isUIFilterValueList,\n type UIFilter,\n isUIFilterWithSmartFilter,\n} from '_ui/components/Filters/_types';\n\nexport const prepareViewForRequest = (\n view: IViewSettingsState,\n filters: UIFilter[],\n label: Record<string, string>,\n): ViewInput => ({\n library: view.libraryId,\n shared: false,\n display: {\n type: mapViewTypeFromExplorerToLegacy[view.viewType],\n },\n filters: filters.map((filter): RecordFilterInput => {\n if (isUIFilterTree(filter)) {\n return {\n // TODO save filter.field, but need to handle Through an other way in useTransformFilters.toValidFilters to keep that field as saved\n field: filter.attribute.id,\n // TODO : save filter values as string[] when tree filter and handle fields with libraries\n value: filter.value?.[0],\n condition: filter.condition,\n withEmptyValues: filter.withEmptyValues,\n };\n }\n\n if (isUIFilterValueList(filter)) {\n return {\n // TODO save filter.field, but need to handle Through an other way in useTransformFilters.toValidFilters to keep that field as saved\n field: filter.attribute.id,\n // TODO : save filter values as string[] when filter and handle fields with libraries\n value: filter.value?.[0],\n condition: filter.condition,\n withEmptyValues: filter.withEmptyValues,\n };\n }\n\n if (isUIFilterWithSmartFilter(filter)) {\n return {\n field: filter.field, // We use the field here because we want to keep the full path to the attribute (ex: link_attribute.id)\n // TODO : save filter values as string[] when filter and handle fields with libraries\n value: filter.value?.[0],\n condition: filter.condition,\n withEmptyValues: filter.withEmptyValues,\n };\n }\n\n if (isUIFilterThrough(filter)) {\n return {\n field: `${filter.field}.${filter.subField}`,\n value: filter.value,\n condition: filter.subCondition,\n };\n }\n\n return {\n field: filter.field,\n value: filter.value,\n condition: filter.condition,\n withEmptyValues: filter.withEmptyValues,\n };\n }),\n sort: view.sort.map(({field, order}) => ({field, order})),\n attributes: view.attributesIds,\n label,\n});\n"]}
1
+ {"version":3,"file":"prepareViewForRequest.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/manage-view-settings/save-view/prepareViewForRequest.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,+BAA+B,EAAC,MAAM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,QAAQ,EAAE;oBAClF,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,uGAAuG;gBAC3H,KAAK,EAAE,IAAI,EAAE,uEAAuE;gBACpF,SAAS,EAAE,cAAc,CAAC,CAAC,CAAE,MAA2B,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS;gBACxF,eAAe,EAAE,MAAM,CAAC,eAAe;aAC1C,CAAC;QACN,CAAC;QAED,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,OAAO;gBACH,KAAK,EAAE,GAAG,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,QAAQ,EAAE;gBAC3C,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,SAAS,EAAE,MAAM,CAAC,YAAY;aACjC,CAAC;QACN,CAAC;QAED,OAAO;YACH,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,eAAe,EAAE,MAAM,CAAC,eAAe;SAC1C,CAAC;IACN,CAAC,CAAC;IACF,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAC,KAAK,EAAE,KAAK,EAAC,EAAE,EAAE,CAAC,CAAC,EAAC,KAAK,EAAE,KAAK,EAAC,CAAC,CAAC;IACzD,UAAU,EAAE,IAAI,CAAC,aAAa;IAC9B,KAAK;CACR,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type RecordFilterInput, type ViewInput} from '_ui/_gqlTypes';\nimport {mapViewTypeFromExplorerToLegacy} from '../../_constants';\nimport {type IViewSettingsState} from '../store-view-settings/viewSettingsReducer';\nimport {\n isUIFilterTree,\n isUIFilterThrough,\n isUIFilterValueList,\n type UIFilter,\n isUIFilterWithSmartFilter,\n type IUIFilterThrough,\n} from '_ui/components/Filters/_types';\n\nexport const prepareViewForRequest = (\n view: IViewSettingsState,\n filters: UIFilter[],\n label: Record<string, string>,\n): ViewInput => ({\n library: view.libraryId,\n shared: false,\n display: {\n type: mapViewTypeFromExplorerToLegacy[view.viewType],\n },\n filters: filters.map((filter): RecordFilterInput => {\n if (isUIFilterTree(filter)) {\n return {\n // TODO save filter.field, but need to handle Through an other way in useTransformFilters.toValidFilters to keep that field as saved\n field: filter.attribute.id,\n // TODO : save filter values as string[] when tree filter and handle fields with libraries\n value: filter.value?.[0],\n condition: filter.condition,\n withEmptyValues: filter.withEmptyValues,\n };\n }\n\n if (isUIFilterValueList(filter)) {\n return {\n // TODO save filter.field, but need to handle Through an other way in useTransformFilters.toValidFilters to keep that field as saved\n field: filter.attribute.id,\n // TODO : save filter values as string[] when filter and handle fields with libraries\n value: filter.value?.[0],\n condition: filter.condition,\n withEmptyValues: filter.withEmptyValues,\n };\n }\n\n if (isUIFilterWithSmartFilter(filter)) {\n const isThoughFilter = isUIFilterThrough(filter);\n return {\n field: isThoughFilter\n ? `${(filter as IUIFilterThrough).field}.${(filter as IUIFilterThrough).subField}`\n : filter.field, // We use the field here because we want to keep the full path to the attribute (ex: link_attribute.id)\n value: null, // Force no value to avoid broken load view, may be fix after LEAVC-569\n condition: isThoughFilter ? (filter as IUIFilterThrough).subCondition : filter.condition,\n withEmptyValues: filter.withEmptyValues,\n };\n }\n\n if (isUIFilterThrough(filter)) {\n return {\n field: `${filter.field}.${filter.subField}`,\n value: filter.value,\n condition: filter.subCondition,\n };\n }\n\n return {\n field: filter.field,\n value: filter.value,\n condition: filter.condition,\n withEmptyValues: filter.withEmptyValues,\n };\n }),\n sort: view.sort.map(({field, order}) => ({field, order})),\n attributes: view.attributesIds,\n label,\n});\n"]}
@@ -26,6 +26,9 @@ export interface IUIFilterLinkAttribute extends IUIFilterBaseAttribute {
26
26
  };
27
27
  smartFilter?: {
28
28
  enable?: boolean;
29
+ through?: {
30
+ id: string;
31
+ } | null;
29
32
  };
30
33
  }
31
34
  export interface IUIFilterTreeAttribute extends IUIFilterBaseAttribute {
@@ -76,6 +79,14 @@ export interface IUIFilterTree extends Omit<IUIFilterBase, 'value' | 'formattedV
76
79
  libraryId: string;
77
80
  }>;
78
81
  field: string[];
82
+ includeHiddenOptions?: boolean;
83
+ /** Nodes explicitly selected by the user. Null/undefined = no user selection (use initial filter). */
84
+ userNodes?: null | Array<{
85
+ nodeId: string;
86
+ libraryId: string;
87
+ }>;
88
+ /** Labels for user-selected nodes (used for display in CommonFilterItem). */
89
+ userFormattedValue?: string[] | null;
79
90
  }
80
91
  export interface IUIFilterSmartFiler extends Omit<IUIFilterBase, 'value' | 'formattedValue'> {
81
92
  attribute: IUIFilterLinkAttribute;
@@ -1 +1 @@
1
- {"version":3,"file":"_types.js","sourceRoot":"","sources":["../../../src/components/Filters/_types.ts"],"names":[],"mappings":"AAIA,OAAO,EAEH,aAAa,GAKhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AAsIxD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAgB,EAA+B,EAAE,CAChF,CAAC,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAEnF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAgB,EAA2B,EAAE,CACxE,CAAC,aAAa,CAAC,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;IACxF,MAAM,CAAC,SAAS,KAAK,sBAAsB,CAAC,OAAO,CAAC;AAExD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAgB,EAA8B,EAAE,CAC9E,CAAC,aAAa,CAAC,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC,QAAQ,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MAAgB,EAAmE,EAAE,CACtG,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,IAAI,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type Override} from '@leav/utils';\nimport {\n type AttributeFormat,\n AttributeType,\n type LinkAttributeDetailsFragment,\n type RecordFilterCondition,\n type StandardAttributeDetailsFragment,\n type ViewDetailsFilterFragment,\n} from '_ui/_gqlTypes';\nimport {ThroughConditionFilter} from '_ui/types/search';\n\nexport type FiltersOperator = 'AND' | 'OR';\n\nexport interface IUIFilterBaseAttribute {\n type: AttributeType;\n /**\n * Used to display the label of the filter.\n *\n * > Not displayed when filter is hidden\n */\n label: string;\n /**\n * Used to verify unicity: one filter per attribute\n */\n id: string;\n format?: AttributeFormat | null | undefined;\n valuesList?:\n | NonNullable<StandardAttributeDetailsFragment['valuesList']>\n | NonNullable<LinkAttributeDetailsFragment['valuesList']>;\n}\n\nexport interface IUIFilterStandardAttribute extends IUIFilterBaseAttribute {\n format: AttributeFormat;\n}\n\nexport interface IUIFilterLinkAttribute extends IUIFilterBaseAttribute {\n linkedLibrary?: {\n id: string;\n };\n smartFilter?: {\n enable?: boolean;\n };\n}\n\nexport interface IUIFilterTreeAttribute extends IUIFilterBaseAttribute {\n linkedTree?: {\n id: string;\n };\n}\n\ninterface IUIFilterBase {\n id: string;\n attribute: IUIFilterBaseAttribute;\n condition: RecordFilterCondition | ThroughConditionFilter | null;\n /**\n * Used to build filter field.\n *\n * - ex: `campaigns_id_pac`\n * - ex with **subField**: `campaigns_id_pac.id`\n */\n field: any;\n value: string | null;\n formattedValue?: string | null;\n hidden?: boolean | undefined;\n withEmptyValues?: boolean;\n}\n\nexport interface IUIFilterStandard extends Omit<IUIFilterBase, 'field'> {\n attribute: IUIFilterStandardAttribute;\n condition: RecordFilterCondition | null;\n field: string;\n}\n\nexport interface IUIFilterLink extends Omit<IUIFilterBase, 'field'> {\n attribute: IUIFilterLinkAttribute;\n condition: RecordFilterCondition | null;\n field: string;\n}\n\nexport interface IUIFilterThrough extends Omit<IUIFilterBase, 'field'> {\n attribute: IUIFilterLinkAttribute;\n condition: ThroughConditionFilter.THROUGH | null;\n subCondition: RecordFilterCondition | null;\n subField: string | null;\n field: string;\n}\n\nexport interface IUIFilterTree extends Omit<IUIFilterBase, 'value' | 'formattedValue' | 'field'> {\n attribute: IUIFilterTreeAttribute;\n condition: RecordFilterCondition | null;\n value: string[] | null;\n formattedValue?: string[] | null;\n nodes?: null | Array<{nodeId: string; libraryId: string}>;\n field: string[];\n}\n\nexport interface IUIFilterSmartFiler extends Omit<IUIFilterBase, 'value' | 'formattedValue'> {\n attribute: IUIFilterLinkAttribute;\n value: string[] | null;\n formattedValue?: string[] | null;\n condition: RecordFilterCondition | null;\n field: string;\n}\n\nexport interface IUIFilterValueList extends Omit<IUIFilterBase, 'value' | 'formattedValue'> {\n attribute: (IUIFilterStandardAttribute | IUIFilterLinkAttribute) & {\n valuesList:\n | NonNullable<StandardAttributeDetailsFragment['valuesList']>\n | NonNullable<LinkAttributeDetailsFragment['valuesList']>;\n };\n value: string[] | null;\n condition: RecordFilterCondition | null;\n field: string | string[];\n}\n\nexport interface IUIFilterStandardValueList extends Omit<IUIFilterStandard, 'attribute' | 'value'>, IUIFilterValueList {\n attribute: IUIFilterStandardAttribute & {\n valuesList: NonNullable<StandardAttributeDetailsFragment['valuesList']>;\n };\n field: string;\n}\n\nexport interface IUIFilterLinkValueList extends Omit<IUIFilterLink, 'attribute' | 'value'>, IUIFilterValueList {\n attribute: IUIFilterLinkAttribute & {\n valuesList: NonNullable<LinkAttributeDetailsFragment['valuesList']>;\n };\n field: string;\n}\nexport interface IUIFilterTreeValueList extends Omit<IUIFilterTree, 'attribute' | 'value'>, IUIFilterValueList {\n attribute: IUIFilterLinkAttribute & {\n valuesList: NonNullable<LinkAttributeDetailsFragment['valuesList']>;\n };\n field: string[];\n}\n\nexport type UIFilter =\n | IUIFilterStandard\n | IUIFilterLink\n | IUIFilterThrough\n | IUIFilterValueList\n | IUIFilterTree\n | IUIFilterSmartFiler;\n\nexport const isUIFilterStandard = (filter: UIFilter): filter is IUIFilterStandard =>\n [AttributeType.simple, AttributeType.advanced].includes(filter.attribute.type);\n\nexport const isUIFilterLink = (filter: UIFilter): filter is IUIFilterLink =>\n [AttributeType.simple_link, AttributeType.advanced_link].includes(filter.attribute.type) &&\n filter.condition !== ThroughConditionFilter.THROUGH;\n\nexport const isUIFilterThrough = (filter: UIFilter): filter is IUIFilterThrough =>\n [AttributeType.simple_link, AttributeType.advanced_link].includes(filter.attribute.type) &&\n filter.condition === ThroughConditionFilter.THROUGH;\n\nexport const isUIFilterValueList = (filter: UIFilter): filter is IUIFilterValueList =>\n (isUIFilterStandard(filter) || isUIFilterLink(filter) || isUIFilterWithSmartFilter(filter)) && isValueList(filter);\n\nexport const isUIFilterStandardWithValueList = (filter: UIFilter): filter is IUIFilterStandardValueList =>\n [AttributeType.simple, AttributeType.advanced].includes(filter.attribute.type) && isValueList(filter);\n\nexport const isUIFilterLinkWithValueList = (filter: UIFilter): filter is IUIFilterLinkValueList =>\n [AttributeType.simple_link, AttributeType.advanced_link].includes(filter.attribute.type) && isValueList(filter);\n\nexport const isUIFilterTree = (filter: UIFilter): filter is IUIFilterTree =>\n filter.attribute.type === AttributeType.tree;\n\nexport const isUIFilterTreeWithValueList = (filter: UIFilter): filter is IUIFilterTreeValueList =>\n isUIFilterTree(filter) && isValueList(filter);\n\nexport const isUIFilterWithSmartFilter = (filter: UIFilter): filter is IUIFilterSmartFiler =>\n (isUIFilterLink(filter) || isUIFilterThrough(filter)) && filter.attribute.smartFilter?.enable;\n\nconst isValueList = (filter: UIFilter): filter is UIFilter & {attribute: {valuesList: {enabled: true}}} =>\n !!filter.attribute?.valuesList && filter.attribute?.valuesList.enable;\n\nexport interface IUIFilterDropDownProps {\n filter: UIFilter;\n canReset: boolean;\n canRemove: boolean;\n}\n\nexport type ValidFieldFilter = Override<\n ViewDetailsFilterFragment,\n {\n field: NonNullable<ViewDetailsFilterFragment['field']>;\n condition: NonNullable<ViewDetailsFilterFragment['condition']>;\n hidden: boolean;\n withEmptyValues?: boolean;\n }\n>;\n\nexport type ValidFieldFilterStandardValuesList = Override<\n ValidFieldFilter,\n {\n valuesList: StandardAttributeDetailsFragment['valuesList'];\n }\n>;\n\nexport type ValidFieldFilterLinkValuesList = Override<\n ValidFieldFilter,\n {\n valuesList: LinkAttributeDetailsFragment['valuesList'];\n }\n>;\n\nexport type ValidFieldFilterThrough = Override<\n ValidFieldFilter,\n {\n condition: ThroughConditionFilter.THROUGH;\n hidden: boolean;\n }\n> & {\n subField: NonNullable<ViewDetailsFilterFragment['field']>;\n subCondition?: ViewDetailsFilterFragment['condition'];\n};\n\nexport type ValidFilter =\n | ValidFieldFilter\n | ValidFieldFilterThrough\n | ValidFieldFilterStandardValuesList\n | ValidFieldFilterLinkValuesList;\n"]}
1
+ {"version":3,"file":"_types.js","sourceRoot":"","sources":["../../../src/components/Filters/_types.ts"],"names":[],"mappings":"AAIA,OAAO,EAEH,aAAa,GAKhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AA8IxD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAgB,EAA+B,EAAE,CAChF,CAAC,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAEnF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAgB,EAA2B,EAAE,CACxE,CAAC,aAAa,CAAC,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;IACxF,MAAM,CAA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,MAAgB,EAAiC,EAAE,CACzF,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC;AAElG,MAAM,WAAW,GAAG,CAAC,MAAgB,EAAmE,EAAE,CACtG,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,IAAI,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type Override} from '@leav/utils';\nimport {\n type AttributeFormat,\n AttributeType,\n type LinkAttributeDetailsFragment,\n type RecordFilterCondition,\n type StandardAttributeDetailsFragment,\n type ViewDetailsFilterFragment,\n} from '_ui/_gqlTypes';\nimport {ThroughConditionFilter} from '_ui/types/search';\n\nexport type FiltersOperator = 'AND' | 'OR';\n\nexport interface IUIFilterBaseAttribute {\n type: AttributeType;\n /**\n * Used to display the label of the filter.\n *\n * > Not displayed when filter is hidden\n */\n label: string;\n /**\n * Used to verify unicity: one filter per attribute\n */\n id: string;\n format?: AttributeFormat | null | undefined;\n valuesList?:\n | NonNullable<StandardAttributeDetailsFragment['valuesList']>\n | NonNullable<LinkAttributeDetailsFragment['valuesList']>;\n}\n\nexport interface IUIFilterStandardAttribute extends IUIFilterBaseAttribute {\n format: AttributeFormat;\n}\n\nexport interface IUIFilterLinkAttribute extends IUIFilterBaseAttribute {\n linkedLibrary?: {\n id: string;\n };\n smartFilter?: {\n enable?: boolean;\n through?: {\n id: string;\n } | null;\n };\n}\n\nexport interface IUIFilterTreeAttribute extends IUIFilterBaseAttribute {\n linkedTree?: {\n id: string;\n };\n}\n\ninterface IUIFilterBase {\n id: string;\n attribute: IUIFilterBaseAttribute;\n condition: RecordFilterCondition | ThroughConditionFilter | null;\n /**\n * Used to build filter field.\n *\n * - ex: `campaigns_id_pac`\n * - ex with **subField**: `campaigns_id_pac.id`\n */\n field: any;\n value: string | null;\n formattedValue?: string | null;\n hidden?: boolean | undefined;\n withEmptyValues?: boolean;\n}\n\nexport interface IUIFilterStandard extends Omit<IUIFilterBase, 'field'> {\n attribute: IUIFilterStandardAttribute;\n condition: RecordFilterCondition | null;\n field: string;\n}\n\nexport interface IUIFilterLink extends Omit<IUIFilterBase, 'field'> {\n attribute: IUIFilterLinkAttribute;\n condition: RecordFilterCondition | null;\n field: string;\n}\n\nexport interface IUIFilterThrough extends Omit<IUIFilterBase, 'field'> {\n attribute: IUIFilterLinkAttribute;\n condition: ThroughConditionFilter.THROUGH | null;\n subCondition: RecordFilterCondition | null;\n subField: string | null;\n field: string;\n}\n\nexport interface IUIFilterTree extends Omit<IUIFilterBase, 'value' | 'formattedValue' | 'field'> {\n attribute: IUIFilterTreeAttribute;\n condition: RecordFilterCondition | null;\n value: string[] | null;\n formattedValue?: string[] | null;\n nodes?: null | Array<{nodeId: string; libraryId: string}>;\n field: string[];\n includeHiddenOptions?: boolean;\n /** Nodes explicitly selected by the user. Null/undefined = no user selection (use initial filter). */\n userNodes?: null | Array<{nodeId: string; libraryId: string}>;\n /** Labels for user-selected nodes (used for display in CommonFilterItem). */\n userFormattedValue?: string[] | null;\n}\n\nexport interface IUIFilterSmartFiler extends Omit<IUIFilterBase, 'value' | 'formattedValue'> {\n attribute: IUIFilterLinkAttribute;\n value: string[] | null;\n formattedValue?: string[] | null;\n condition: RecordFilterCondition | null;\n field: string;\n}\n\nexport interface IUIFilterValueList extends Omit<IUIFilterBase, 'value' | 'formattedValue'> {\n attribute: (IUIFilterStandardAttribute | IUIFilterLinkAttribute) & {\n valuesList:\n | NonNullable<StandardAttributeDetailsFragment['valuesList']>\n | NonNullable<LinkAttributeDetailsFragment['valuesList']>;\n };\n value: string[] | null;\n condition: RecordFilterCondition | null;\n field: string | string[];\n}\n\nexport interface IUIFilterStandardValueList extends Omit<IUIFilterStandard, 'attribute' | 'value'>, IUIFilterValueList {\n attribute: IUIFilterStandardAttribute & {\n valuesList: NonNullable<StandardAttributeDetailsFragment['valuesList']>;\n };\n field: string;\n}\n\nexport interface IUIFilterLinkValueList extends Omit<IUIFilterLink, 'attribute' | 'value'>, IUIFilterValueList {\n attribute: IUIFilterLinkAttribute & {\n valuesList: NonNullable<LinkAttributeDetailsFragment['valuesList']>;\n };\n field: string;\n}\nexport interface IUIFilterTreeValueList extends Omit<IUIFilterTree, 'attribute' | 'value'>, IUIFilterValueList {\n attribute: IUIFilterLinkAttribute & {\n valuesList: NonNullable<LinkAttributeDetailsFragment['valuesList']>;\n };\n field: string[];\n}\n\nexport type UIFilter =\n | IUIFilterStandard\n | IUIFilterLink\n | IUIFilterThrough\n | IUIFilterValueList\n | IUIFilterTree\n | IUIFilterSmartFiler;\n\nexport const isUIFilterStandard = (filter: UIFilter): filter is IUIFilterStandard =>\n [AttributeType.simple, AttributeType.advanced].includes(filter.attribute.type);\n\nexport const isUIFilterLink = (filter: UIFilter): filter is IUIFilterLink =>\n [AttributeType.simple_link, AttributeType.advanced_link].includes(filter.attribute.type) &&\n filter.condition !== ThroughConditionFilter.THROUGH;\n\nexport const isUIFilterThrough = (filter: UIFilter): filter is IUIFilterThrough =>\n [AttributeType.simple_link, AttributeType.advanced_link].includes(filter.attribute.type) &&\n filter.condition === ThroughConditionFilter.THROUGH;\n\nexport const isUIFilterValueList = (filter: UIFilter): filter is IUIFilterValueList =>\n (isUIFilterStandard(filter) || isUIFilterLink(filter) || isUIFilterWithSmartFilter(filter)) && isValueList(filter);\n\nexport const isUIFilterStandardWithValueList = (filter: UIFilter): filter is IUIFilterStandardValueList =>\n [AttributeType.simple, AttributeType.advanced].includes(filter.attribute.type) && isValueList(filter);\n\nexport const isUIFilterLinkWithValueList = (filter: UIFilter): filter is IUIFilterLinkValueList =>\n [AttributeType.simple_link, AttributeType.advanced_link].includes(filter.attribute.type) && isValueList(filter);\n\nexport const isUIFilterTree = (filter: UIFilter): filter is IUIFilterTree =>\n filter.attribute.type === AttributeType.tree;\n\nexport const isUIFilterTreeWithValueList = (filter: UIFilter): filter is IUIFilterTreeValueList =>\n isUIFilterTree(filter) && isValueList(filter);\n\nexport const isUIFilterWithSmartFilter = (filter: UIFilter): filter is IUIFilterSmartFiler =>\n (isUIFilterLink(filter) || isUIFilterThrough(filter)) && filter.attribute.smartFilter?.enable;\n\nconst isValueList = (filter: UIFilter): filter is UIFilter & {attribute: {valuesList: {enabled: true}}} =>\n !!filter.attribute?.valuesList && filter.attribute?.valuesList.enable;\n\nexport interface IUIFilterDropDownProps {\n filter: UIFilter;\n canReset: boolean;\n canRemove: boolean;\n}\n\nexport type ValidFieldFilter = Override<\n ViewDetailsFilterFragment,\n {\n field: NonNullable<ViewDetailsFilterFragment['field']>;\n condition: NonNullable<ViewDetailsFilterFragment['condition']>;\n hidden: boolean;\n withEmptyValues?: boolean;\n }\n>;\n\nexport type ValidFieldFilterStandardValuesList = Override<\n ValidFieldFilter,\n {\n valuesList: StandardAttributeDetailsFragment['valuesList'];\n }\n>;\n\nexport type ValidFieldFilterLinkValuesList = Override<\n ValidFieldFilter,\n {\n valuesList: LinkAttributeDetailsFragment['valuesList'];\n }\n>;\n\nexport type ValidFieldFilterThrough = Override<\n ValidFieldFilter,\n {\n condition: ThroughConditionFilter.THROUGH;\n hidden: boolean;\n }\n> & {\n subField: NonNullable<ViewDetailsFilterFragment['field']>;\n subCondition?: ViewDetailsFilterFragment['condition'];\n};\n\nexport type ValidFilter =\n | ValidFieldFilter\n | ValidFieldFilterThrough\n | ValidFieldFilterStandardValuesList\n | ValidFieldFilterLinkValuesList;\n"]}
@@ -1,2 +1,3 @@
1
- export declare const hasOnlyNoValueConditions: (attributeFormat: string) => boolean;
1
+ import { AttributeFormat } from '../../_gqlTypes';
2
+ export declare const hasOnlyNoValueConditions: (attributeFormat: AttributeFormat) => boolean;
2
3
  export declare const nullValueConditions: import("../../_gqlTypes").RecordFilterCondition[];
@@ -1 +1 @@
1
- {"version":3,"file":"conditionsHelper.js","sourceRoot":"","sources":["../../../src/components/Filters/conditionsHelper.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,wBAAwB,EAAC,MAAM,WAAW,CAAC;AAEnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,eAAuB,EAAW,EAAE,CACzE,CAAC,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,UAAU,EAAE,eAAe,CAAC,SAAS,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAC7G,eAAe,CAClB,CAAC;AAEN,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,wBAAwB,CAAC,QAAQ;IACjC,wBAAwB,CAAC,YAAY;IACrC,wBAAwB,CAAC,KAAK;IAC9B,wBAAwB,CAAC,QAAQ;IACjC,wBAAwB,CAAC,SAAS;IAClC,wBAAwB,CAAC,UAAU;IACnC,wBAAwB,CAAC,UAAU;CACtC,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 {AttributeFormat} from '_ui/_gqlTypes';\nimport {AttributeConditionFilter} from '_ui/types';\n\nexport const hasOnlyNoValueConditions = (attributeFormat: string): boolean =>\n [AttributeFormat.color, AttributeFormat.date_range, AttributeFormat.encrypted, AttributeFormat.extended].includes(\n attributeFormat,\n );\n\nexport const nullValueConditions = [\n AttributeConditionFilter.IS_EMPTY,\n AttributeConditionFilter.IS_NOT_EMPTY,\n AttributeConditionFilter.TODAY,\n AttributeConditionFilter.TOMORROW,\n AttributeConditionFilter.YESTERDAY,\n AttributeConditionFilter.LAST_MONTH,\n AttributeConditionFilter.NEXT_MONTH,\n];\n"]}
1
+ {"version":3,"file":"conditionsHelper.js","sourceRoot":"","sources":["../../../src/components/Filters/conditionsHelper.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,wBAAwB,EAAC,MAAM,WAAW,CAAC;AAEnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,eAAgC,EAAW,EAAE,CAClF,CAAC,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,UAAU,EAAE,eAAe,CAAC,SAAS,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAC7G,eAAe,CAClB,CAAC;AAEN,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,wBAAwB,CAAC,QAAQ;IACjC,wBAAwB,CAAC,YAAY;IACrC,wBAAwB,CAAC,KAAK;IAC9B,wBAAwB,CAAC,QAAQ;IACjC,wBAAwB,CAAC,SAAS;IAClC,wBAAwB,CAAC,UAAU;IACnC,wBAAwB,CAAC,UAAU;CACtC,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 {AttributeFormat} from '_ui/_gqlTypes';\nimport {AttributeConditionFilter} from '_ui/types';\n\nexport const hasOnlyNoValueConditions = (attributeFormat: AttributeFormat): boolean =>\n [AttributeFormat.color, AttributeFormat.date_range, AttributeFormat.encrypted, AttributeFormat.extended].includes(\n attributeFormat,\n );\n\nexport const nullValueConditions = [\n AttributeConditionFilter.IS_EMPTY,\n AttributeConditionFilter.IS_NOT_EMPTY,\n AttributeConditionFilter.TODAY,\n AttributeConditionFilter.TOMORROW,\n AttributeConditionFilter.YESTERDAY,\n AttributeConditionFilter.LAST_MONTH,\n AttributeConditionFilter.NEXT_MONTH,\n];\n"]}