@leav/ui 0.4.0-c10dd58e → 0.4.0-c3ee29dd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__mocks__/common/form.d.ts +0 -632
- package/dist/__mocks__/common/form.js +22 -27
- package/dist/__mocks__/common/form.js.map +1 -1
- package/dist/_gqlTypes/index.d.ts +1636 -1778
- package/dist/_gqlTypes/index.js +1303 -1378
- package/dist/_gqlTypes/index.js.map +1 -1
- package/dist/_queries/records/getRecordFormQuery.js +5 -1
- package/dist/_queries/records/getRecordFormQuery.js.map +1 -1
- package/dist/_utils/attributeType.d.ts +2 -1
- package/dist/_utils/attributeType.js +2 -1
- package/dist/_utils/attributeType.js.map +1 -1
- package/dist/components/Explorer/Explorer.d.ts +1 -0
- package/dist/components/Explorer/Explorer.js +11 -3
- package/dist/components/Explorer/Explorer.js.map +1 -1
- package/dist/components/Explorer/_queries/prepareFiltersForRequest.d.ts +1 -1
- package/dist/components/Explorer/_queries/prepareFiltersForRequest.js +82 -31
- package/dist/components/Explorer/_queries/prepareFiltersForRequest.js.map +1 -1
- package/dist/components/Explorer/_queries/useExplorerData.js +32 -27
- package/dist/components/Explorer/_queries/useExplorerData.js.map +1 -1
- package/dist/components/Explorer/_types.d.ts +32 -2
- package/dist/components/Explorer/_types.js +1 -0
- package/dist/components/Explorer/_types.js.map +1 -1
- package/dist/components/Explorer/actions-item/useReplaceItemAction.d.ts +2 -1
- package/dist/components/Explorer/actions-item/useReplaceItemAction.js +2 -2
- package/dist/components/Explorer/actions-item/useReplaceItemAction.js.map +1 -1
- package/dist/components/Explorer/actions-primary/useCreatePrimaryAction.d.ts +3 -1
- package/dist/components/Explorer/actions-primary/useCreatePrimaryAction.js +9 -19
- package/dist/components/Explorer/actions-primary/useCreatePrimaryAction.js.map +1 -1
- package/dist/components/Explorer/actions-primary/useLinkPrimaryAction.d.ts +6 -3
- package/dist/components/Explorer/actions-primary/useLinkPrimaryAction.js +5 -19
- package/dist/components/Explorer/actions-primary/useLinkPrimaryAction.js.map +1 -1
- package/dist/components/Explorer/link-item/LinkModal.d.ts +3 -0
- package/dist/components/Explorer/link-item/LinkModal.js +44 -4
- package/dist/components/Explorer/link-item/LinkModal.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/_shared/CommonFilterItem.js +1 -1
- package/dist/components/Explorer/manage-view-settings/_shared/CommonFilterItem.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/_shared/useTransformFilters.js +22 -2
- package/dist/components/Explorer/manage-view-settings/_shared/useTransformFilters.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/filter-items/FilterItems.js +10 -7
- package/dist/components/Explorer/manage-view-settings/filter-items/FilterItems.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/FilterDropdownContent.js +5 -1
- package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/FilterDropdownContent.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/TreeAttributeDropDown.d.ts +3 -0
- package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/TreeAttributeDropDown.js +69 -0
- package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/TreeAttributeDropDown.js.map +1 -0
- package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/_types.d.ts +6 -1
- package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/useConditionOptionsByType.d.ts +2 -0
- package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/useConditionOptionsByType.js +31 -4
- package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/useConditionOptionsByType.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/prepareViewForRequest.js +19 -8
- package/dist/components/Explorer/manage-view-settings/save-view/prepareViewForRequest.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/store-view-settings/viewSettingsInitialState.js +1 -1
- package/dist/components/Explorer/manage-view-settings/store-view-settings/viewSettingsInitialState.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/store-view-settings/viewSettingsReducer.d.ts +2 -2
- package/dist/components/Explorer/manage-view-settings/store-view-settings/viewSettingsReducer.js +38 -12
- package/dist/components/Explorer/manage-view-settings/store-view-settings/viewSettingsReducer.js.map +1 -1
- package/dist/components/Explorer/useLoadView.d.ts +1 -1
- package/dist/components/Explorer/useLoadView.js +32 -38
- package/dist/components/Explorer/useLoadView.js.map +1 -1
- package/dist/components/Explorer/useSearchInput.js +2 -0
- package/dist/components/Explorer/useSearchInput.js.map +1 -1
- package/dist/components/RecordEdition/EditRecord/EditRecord.d.ts +2 -1
- package/dist/components/RecordEdition/EditRecord/EditRecord.js +72 -224
- package/dist/components/RecordEdition/EditRecord/EditRecord.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/EditRecordContent.d.ts +2 -2
- package/dist/components/RecordEdition/EditRecordContent/EditRecordContent.js +29 -68
- package/dist/components/RecordEdition/EditRecordContent/EditRecordContent.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/_types.d.ts +9 -18
- package/dist/components/RecordEdition/EditRecordContent/_types.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/antdUtils.d.ts +0 -6
- package/dist/components/RecordEdition/EditRecordContent/antdUtils.js +1 -7
- package/dist/components/RecordEdition/EditRecordContent/antdUtils.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/helpers/extractFormElements/extractFormElements.d.ts +2 -15
- package/dist/components/RecordEdition/EditRecordContent/helpers/extractFormElements/extractFormElements.js +24 -47
- package/dist/components/RecordEdition/EditRecordContent/helpers/extractFormElements/extractFormElements.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/hooks/useCreateEmptyRecordMutation.d.ts +5 -0
- package/dist/components/RecordEdition/EditRecordContent/hooks/useCreateEmptyRecordMutation.js +28 -0
- package/dist/components/RecordEdition/EditRecordContent/hooks/useCreateEmptyRecordMutation.js.map +1 -0
- package/dist/components/RecordEdition/EditRecordContent/hooks/useRecordEditionContext.d.ts +3 -0
- package/dist/components/RecordEdition/EditRecordContent/hooks/useRecordEditionContext.js +7 -0
- package/dist/components/RecordEdition/EditRecordContent/hooks/useRecordEditionContext.js.map +1 -0
- package/dist/components/RecordEdition/EditRecordContent/hooks/useTabManagement.d.ts +0 -1
- package/dist/components/RecordEdition/EditRecordContent/hooks/useTabManagement.js +0 -4
- package/dist/components/RecordEdition/EditRecordContent/hooks/useTabManagement.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/Container/Container.d.ts +2 -2
- package/dist/components/RecordEdition/EditRecordContent/uiElements/Container/Container.js +5 -3
- package/dist/components/RecordEdition/EditRecordContent/uiElements/Container/Container.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/FormDivider/FormDivider.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/FormTabs/FormTabs.js +5 -25
- package/dist/components/RecordEdition/EditRecordContent/uiElements/FormTabs/FormTabs.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/Frame/Frame.d.ts +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/Frame/Frame.js +3 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/Frame/Frame.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/LinkField.js +7 -34
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/LinkField.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/ActionButton.d.ts +3 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/ActionButton.js +9 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/ActionButton.js.map +1 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/{link-record-in-edition/useLinkRecords.d.ts → link-record/useExplorerLinkRecords.d.ts} +2 -2
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/{link-record-in-edition/useLinkRecords.js → link-record/useExplorerLinkRecords.js} +3 -3
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/useExplorerLinkRecords.js.map +1 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/{link-record-in-edition/useLinkRecordsInEdition.d.ts → link-record/useLinkRecords.d.ts} +5 -9
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/useLinkRecords.js +76 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/useLinkRecords.js.map +1 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/utils.js +1 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/utils.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardField.d.ts +2 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardField.js +85 -72
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardField.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSInputWrapper.js +1 -2
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSInputWrapper.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValue.d.ts +1 -2
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValue.js +1 -2
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValue.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/_types.d.ts +0 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TextBlock/TextBlock.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/TreeField.js +4 -14
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/TreeField.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/useManageTreeNodeSelection.d.ts +2 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/useManageTreeNodeSelection.js +5 -9
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/useManageTreeNodeSelection.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/calculatedInheritedFlags.js +4 -4
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/calculatedInheritedFlags.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/useOutsideInteractionDetector.d.ts +2 -4
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/useOutsideInteractionDetector.js +6 -10
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/useOutsideInteractionDetector.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js +22 -4
- package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordPage/EditRecordPage.js +23 -5
- package/dist/components/RecordEdition/EditRecordPage/EditRecordPage.js.map +1 -1
- package/dist/components/RecordEdition/editRecordReducer/editRecordReducer.d.ts +1 -6
- package/dist/components/RecordEdition/editRecordReducer/editRecordReducer.js +1 -5
- package/dist/components/RecordEdition/editRecordReducer/editRecordReducer.js.map +1 -1
- package/dist/components/RecordEdition/index.d.ts +1 -1
- package/dist/components/RecordEdition/index.js +1 -1
- package/dist/components/RecordEdition/index.js.map +1 -1
- package/dist/components/SelectRecordForLinkModal/SelectRecordForLinkModal.d.ts +2 -0
- package/dist/components/SelectRecordForLinkModal/SelectRecordForLinkModal.js +6 -4
- package/dist/components/SelectRecordForLinkModal/SelectRecordForLinkModal.js.map +1 -1
- package/dist/components/SelectTreeNode/SelectTreeNode.d.ts +2 -0
- package/dist/components/SelectTreeNode/SelectTreeNode.js +2 -2
- package/dist/components/SelectTreeNode/SelectTreeNode.js.map +1 -1
- package/dist/components/SelectTreeNode/SelectTreeNodeContent.d.ts +2 -0
- package/dist/components/SelectTreeNode/SelectTreeNodeContent.js +58 -39
- package/dist/components/SelectTreeNode/SelectTreeNodeContent.js.map +1 -1
- package/dist/components/SelectTreeNode/_types.d.ts +1 -0
- package/dist/components/SelectTreeNode/_types.js.map +1 -1
- package/dist/hooks/useGetRecordForm/useGetRecordForm.d.ts +1 -2
- package/dist/hooks/useGetRecordForm/useGetRecordForm.js +13 -2
- package/dist/hooks/useGetRecordForm/useGetRecordForm.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/types.d.ts +2 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.d.ts +3 -3
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.js +5 -1
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.js.map +1 -1
- package/dist/locales/en/shared.json +2 -1
- package/dist/locales/fr/shared.json +1 -0
- package/package.json +3 -3
- package/dist/components/LinkSelect/LinkSelect.d.ts +0 -15
- package/dist/components/LinkSelect/LinkSelect.js +0 -88
- package/dist/components/LinkSelect/LinkSelect.js.map +0 -1
- package/dist/components/LinkSelect/index.d.ts +0 -2
- package/dist/components/LinkSelect/index.js +0 -6
- package/dist/components/LinkSelect/index.js.map +0 -1
- package/dist/components/RecordEdition/EditRecord/creationErrorContext.d.ts +0 -6
- package/dist/components/RecordEdition/EditRecord/creationErrorContext.js +0 -7
- package/dist/components/RecordEdition/EditRecord/creationErrorContext.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/hooks/useCreateRecordMutation.d.ts +0 -5
- package/dist/components/RecordEdition/EditRecordContent/hooks/useCreateRecordMutation.js +0 -28
- package/dist/components/RecordEdition/EditRecordContent/hooks/useCreateRecordMutation.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/hooks/useFetchVisibleFormValue.d.ts +0 -13
- package/dist/components/RecordEdition/EditRecordContent/hooks/useFetchVisibleFormValue.js +0 -119
- package/dist/components/RecordEdition/EditRecordContent/hooks/useFetchVisibleFormValue.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/hooks/useRunActionsListAndFormatOnValue.d.ts +0 -121
- package/dist/components/RecordEdition/EditRecordContent/hooks/useRunActionsListAndFormatOnValue.js +0 -31
- package/dist/components/RecordEdition/EditRecordContent/hooks/useRunActionsListAndFormatOnValue.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/action-item/useEditRecord.d.ts +0 -5
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/action-item/useEditRecord.js +0 -39
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/action-item/useEditRecord.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/action-item/useUnselectRecord.d.ts +0 -8
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/action-item/useUnselectRecord.js +0 -23
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/action-item/useUnselectRecord.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/action-mass/useUnselectAllRecords.d.ts +0 -9
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/action-mass/useUnselectAllRecords.js +0 -23
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/action-mass/useUnselectAllRecords.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/action-primary/useCreateRecord.d.ts +0 -8
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/action-primary/useCreateRecord.js +0 -26
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/action-primary/useCreateRecord.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/action-primary/useRecordSelector.d.ts +0 -12
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/action-primary/useRecordSelector.js +0 -24
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/action-primary/useRecordSelector.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record-in-creation/useLinkRecords.d.ts +0 -19
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record-in-creation/useLinkRecords.js +0 -103
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record-in-creation/useLinkRecords.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record-in-creation/useLinkRecordsInCreation.d.ts +0 -22
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record-in-creation/useLinkRecordsInCreation.js +0 -104
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record-in-creation/useLinkRecordsInCreation.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record-in-edition/useLinkRecords.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record-in-edition/useLinkRecordsInEdition.js +0 -311
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record-in-edition/useLinkRecordsInEdition.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/LinkActionsButtons.d.ts +0 -9
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/LinkActionsButtons.js +0 -15
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/LinkActionsButtons.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/ValuesList/ValuesList.d.ts +0 -16
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/ValuesList/ValuesList.js +0 -35
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/ValuesList/ValuesList.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/ValuesList/index.d.ts +0 -2
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/ValuesList/index.js +0 -6
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/ValuesList/index.js.map +0 -1
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
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 { localizedTranslation } from '@leav/utils';
|
|
6
|
-
import {
|
|
6
|
+
import { useState } from 'react';
|
|
7
7
|
import { useEditRecordReducer } from '../../../../../components/RecordEdition/editRecordReducer/useEditRecordReducer';
|
|
8
8
|
import { AntForm, KitInputWrapper } from 'aristid-ds';
|
|
9
9
|
import { useLang } from '../../../../../hooks';
|
|
@@ -12,8 +12,7 @@ import { LINK_FIELD_ID_PREFIX } from '../../../../../constants';
|
|
|
12
12
|
import { computeCalculatedFlags, computeInheritedFlags } from '../shared/calculatedInheritedFlags';
|
|
13
13
|
import { ComputeIndicator } from '../shared/ComputeIndicator';
|
|
14
14
|
import { useOutsideInteractionDetector } from '../shared/useOutsideInteractionDetector';
|
|
15
|
-
import {
|
|
16
|
-
import { useLinkRecordsInEdition } from './link-record-in-edition/useLinkRecordsInEdition';
|
|
15
|
+
import { useLinkRecords } from './link-record/useLinkRecords';
|
|
17
16
|
import { CREATE_RECORD_MODAL_CLASSNAME, EDIT_RECORD_MODAL_CLASSNAME, LINK_RECORDS_MODAL_CLASSNAME } from '../../../../../components/Explorer/_constants';
|
|
18
17
|
const Wrapper = styled.div `
|
|
19
18
|
margin-bottom: ${props => (props.$metadataEdit ? 0 : '1.5em')};
|
|
@@ -40,14 +39,10 @@ const KitInputWrapperStyled = styled(KitInputWrapper) `
|
|
|
40
39
|
display: none;
|
|
41
40
|
}
|
|
42
41
|
`;
|
|
43
|
-
const LinkField = ({ element, readonly,
|
|
42
|
+
const LinkField = ({ element, readonly, isFormCreationMode, onDeleteMultipleValues, metadataEdit = false }) => {
|
|
44
43
|
const { state, dispatch } = useEditRecordReducer();
|
|
45
44
|
const { lang } = useLang();
|
|
46
45
|
const { settings, attribute, joinLibraryContext } = element;
|
|
47
|
-
const attributesPendingDefaultValues = pendingValues?.[attribute.id]
|
|
48
|
-
? Object.values(pendingValues?.[attribute.id])
|
|
49
|
-
: [];
|
|
50
|
-
const [attributePendingValues, setAttributePendingValues] = useState(attributesPendingDefaultValues);
|
|
51
46
|
const [backendValues, setBackendValues] = useState(element.values);
|
|
52
47
|
const calculatedFlags = computeCalculatedFlags(backendValues);
|
|
53
48
|
const inheritedFlags = computeInheritedFlags(backendValues);
|
|
@@ -57,19 +52,12 @@ const LinkField = ({ element, readonly, isCreationForm, pendingValues, onDeleteM
|
|
|
57
52
|
const columnsToDisplay = settings.columns?.map(({ id }) => id);
|
|
58
53
|
const isReadOnly = attribute.readonly || !attribute.permissions.edit_value || readonly;
|
|
59
54
|
const isFieldInError = fieldErrors.length > 0;
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
setAttributePendingValues(pendingValues?.[attribute.id]
|
|
62
|
-
? Object.values(pendingValues?.[attribute.id])
|
|
63
|
-
: []);
|
|
64
|
-
}, [pendingValues, attribute.id]);
|
|
65
55
|
useOutsideInteractionDetector({
|
|
66
56
|
attribute,
|
|
67
57
|
activeAttribute: state.activeAttribute,
|
|
68
58
|
attributePrefix: LINK_FIELD_ID_PREFIX,
|
|
69
59
|
dispatch,
|
|
70
|
-
|
|
71
|
-
elementValues: backendValues,
|
|
72
|
-
pendingValues: attributePendingValues,
|
|
60
|
+
backendValues,
|
|
73
61
|
allowedSelectors: [
|
|
74
62
|
'div[role="status"]:has(.kit-snackbar-message)',
|
|
75
63
|
'.kit-modal-wrapper',
|
|
@@ -79,36 +67,21 @@ const LinkField = ({ element, readonly, isCreationForm, pendingValues, onDeleteM
|
|
|
79
67
|
'.kit-select-dropdown-content'
|
|
80
68
|
]
|
|
81
69
|
});
|
|
82
|
-
const {
|
|
83
|
-
attribute,
|
|
84
|
-
libraryId: attribute.linked_library.id,
|
|
85
|
-
pendingValues: attributePendingValues,
|
|
86
|
-
activeAttribute: state.activeAttribute,
|
|
87
|
-
dispatch,
|
|
88
|
-
isHookUsed: isCreationForm,
|
|
89
|
-
isReadOnly,
|
|
90
|
-
isFieldInError,
|
|
91
|
-
onValueSubmit,
|
|
92
|
-
onValueDelete
|
|
93
|
-
});
|
|
94
|
-
const { UnlinkAllRecordsInEdition, LinkRecordsInEditionExplorer } = useLinkRecordsInEdition({
|
|
70
|
+
const { UnlinkAllRecords, LinkRecordsExplorer } = useLinkRecords({
|
|
95
71
|
libraryId: state.libraryId,
|
|
96
72
|
recordId: state.record?.id,
|
|
73
|
+
isFormCreationMode,
|
|
97
74
|
attribute,
|
|
98
75
|
joinLibraryContext,
|
|
99
76
|
columnsToDisplay,
|
|
100
77
|
backendValues,
|
|
101
78
|
setBackendValues,
|
|
102
|
-
activeAttribute: state.activeAttribute,
|
|
103
|
-
dispatch,
|
|
104
|
-
isHookUsed: !isCreationForm,
|
|
105
79
|
isReadOnly,
|
|
106
80
|
isFieldInError,
|
|
107
|
-
tagDisplayMode: settings.tagDisplayMode,
|
|
108
81
|
hasNoValue: backendValues.length === 0,
|
|
109
82
|
onDeleteMultipleValues
|
|
110
83
|
});
|
|
111
|
-
return (_jsx(Wrapper, { "$metadataEdit": metadataEdit, children: _jsx(AntForm.Item, { name: attribute.id, noStyle: true, children: _jsx(KitInputWrapperStyled, { id: LINK_FIELD_ID_PREFIX + attribute.id, "data-testid": "link-field", label: label, required: attribute.required, bordered: true, disabled: isReadOnly, status: isFieldInError ? 'error' : undefined, helper: isFieldInError ? String(fieldErrors[0]) : undefined, extra: _jsxs(_Fragment, { children: [_jsx(KitInputExtraAlignLeft, { children: _jsx(ComputeIndicator, { calculatedFlags: calculatedFlags, inheritedFlags: inheritedFlags }) }),
|
|
84
|
+
return (_jsx(Wrapper, { "$metadataEdit": metadataEdit, children: _jsx(AntForm.Item, { name: attribute.id, noStyle: true, children: _jsx(KitInputWrapperStyled, { id: LINK_FIELD_ID_PREFIX + attribute.id, "data-testid": "link-field", label: label, required: attribute.required, bordered: true, disabled: isReadOnly, status: isFieldInError ? 'error' : undefined, helper: isFieldInError ? String(fieldErrors[0]) : undefined, extra: _jsxs(_Fragment, { children: [_jsx(KitInputExtraAlignLeft, { children: _jsx(ComputeIndicator, { calculatedFlags: calculatedFlags, inheritedFlags: inheritedFlags }) }), UnlinkAllRecords] }), children: LinkRecordsExplorer }) }) }));
|
|
112
85
|
};
|
|
113
86
|
export default LinkField;
|
|
114
87
|
//# sourceMappingURL=LinkField.js.map
|
package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/LinkField.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkField.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/LinkField.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,
|
|
1
|
+
{"version":3,"file":"LinkField.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/LinkField.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAA+B,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAC,oBAAoB,EAAC,MAAM,qEAAqE,CAAC;AAKzG,OAAO,EAAC,OAAO,EAAE,eAAe,EAAC,MAAM,YAAY,CAAC;AACpD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,oBAAoB,EAAC,MAAM,eAAe,CAAC;AACnD,OAAO,EAAC,sBAAsB,EAAE,qBAAqB,EAAC,MAAM,oCAAoC,CAAC;AACjG,OAAO,EAAC,gBAAgB,EAAC,MAAM,4BAA4B,CA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Q,QACR,QAAQ,EAAE,UAAU,EACpB,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAC5C,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAC3D,KAAK,EACD,8BACI,KAAC,sBAAsB,cACnB,KAAC,gBAAgB,IAAC,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,GAAI,GACjE,EACxB,gBAAgB,IAClB,YAGN,mBAAmB,GACA,GACb,GACT,CACb,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const ActionButton: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("aristid-ds/dist/Kit/General/Button/types").IKitButton & import("react").RefAttributes<HTMLElement>, {
|
|
2
|
+
$hasNoValue: boolean;
|
|
3
|
+
}>> & import("aristid-ds/dist/Kit/General/Button/types").KitButtonCompoundedComponent;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
2
|
+
// This file is released under LGPL V3
|
|
3
|
+
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
4
|
+
import { KitButton } from 'aristid-ds';
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
export const ActionButton = styled(KitButton) `
|
|
7
|
+
margin-top: ${props => (props.$hasNoValue ? 0 : 'calc((var(--general-spacing-xs)) * 1px)')};
|
|
8
|
+
`;
|
|
9
|
+
//# sourceMappingURL=ActionButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionButton.js","sourceRoot":"","sources":["../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/ActionButton.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AACrC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,CAAwB;kBACnD,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,yCAAyC,CAAC;CAC7F,CAAC"}
|
|
@@ -3,13 +3,13 @@ import { DeleteMultipleValuesFunc, ISubmitMultipleResult } from '../../../_types
|
|
|
3
3
|
import { Dispatch, SetStateAction } from 'react';
|
|
4
4
|
import { IItemData, MassSelection } from '../../../../../../components/Explorer/_types';
|
|
5
5
|
import { RecordFormElementsValueLinkValue } from '../../../../../../hooks/useGetRecordForm';
|
|
6
|
-
interface
|
|
6
|
+
interface IUseExplorerLinkRecordsProps {
|
|
7
7
|
attribute: RecordFormAttributeLinkAttributeFragment;
|
|
8
8
|
backendValues: RecordFormElementsValueLinkValue[];
|
|
9
9
|
setBackendValues: Dispatch<SetStateAction<RecordFormElementsValueLinkValue[]>>;
|
|
10
10
|
onDeleteMultipleValues: DeleteMultipleValuesFunc;
|
|
11
11
|
}
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const useExplorerLinkRecords: ({ attribute, backendValues, setBackendValues, onDeleteMultipleValues }: IUseExplorerLinkRecordsProps) => {
|
|
13
13
|
handleDeleteAllValues: () => Promise<void>;
|
|
14
14
|
handleExplorerRemoveValue: (item: IItemData) => void;
|
|
15
15
|
handleExplorerMassDeactivateValues: (_massSelectedFilter: RecordFilterInput[], massSelection: MassSelection) => void;
|
|
@@ -2,7 +2,7 @@ import { APICallStatus } from '../../../_types';
|
|
|
2
2
|
import { AntForm } from 'aristid-ds';
|
|
3
3
|
import { useSharedTranslation } from '../../../../../../hooks/useSharedTranslation';
|
|
4
4
|
import { ErrorTypes } from '@leav/utils';
|
|
5
|
-
export const
|
|
5
|
+
export const useExplorerLinkRecords = ({ attribute, backendValues, setBackendValues, onDeleteMultipleValues }) => {
|
|
6
6
|
const { t } = useSharedTranslation();
|
|
7
7
|
const form = AntForm.useFormInstance();
|
|
8
8
|
const removeValues = (filterFn, useIdValue = false) => {
|
|
@@ -52,7 +52,7 @@ export const useLinkRecords = ({ attribute, backendValues, setBackendValues, onD
|
|
|
52
52
|
errors: []
|
|
53
53
|
}
|
|
54
54
|
]);
|
|
55
|
-
setBackendValues([...
|
|
55
|
+
setBackendValues(previousBackendValues => [...previousBackendValues, ...saveLinkValues]);
|
|
56
56
|
}
|
|
57
57
|
if (saveValuesResult.status === APICallStatus.ERROR && saveValuesResult.errors) {
|
|
58
58
|
const attributeError = saveValuesResult.errors.filter(err => err.attribute === attribute.id)?.[0];
|
|
@@ -82,4 +82,4 @@ export const useLinkRecords = ({ attribute, backendValues, setBackendValues, onD
|
|
|
82
82
|
handleExplorerCreateValue
|
|
83
83
|
};
|
|
84
84
|
};
|
|
85
|
-
//# sourceMappingURL=
|
|
85
|
+
//# sourceMappingURL=useExplorerLinkRecords.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExplorerLinkRecords.js","sourceRoot":"","sources":["../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/useExplorerLinkRecords.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAC,aAAa,EAAkD,MAAM,iBAAiB,CAAC;AAG/F,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AACnC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AASvC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EACnC,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACK,EAAE,EAAE;IAC/B,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM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ComponentProps, Dispatch, SetStateAction } from 'react';
|
|
|
3
3
|
import { DeleteMultipleValuesFunc } from '../../../_types';
|
|
4
4
|
import { JoinLibraryContextFragment, RecordFormAttributeLinkAttributeFragment } from '../../../../../../_gqlTypes';
|
|
5
5
|
import { RecordFormElementsValueLinkValue } from '../../../../../../hooks/useGetRecordForm';
|
|
6
|
-
|
|
7
|
-
interface ILinkRecordsInCreationProps {
|
|
6
|
+
interface ILinkRecords {
|
|
8
7
|
libraryId: string;
|
|
9
8
|
recordId: string;
|
|
9
|
+
isFormCreationMode: boolean;
|
|
10
10
|
attribute: RecordFormAttributeLinkAttributeFragment;
|
|
11
11
|
joinLibraryContext: JoinLibraryContextFragment;
|
|
12
12
|
columnsToDisplay: ComponentProps<typeof Explorer>['defaultViewSettings']['attributesIds'];
|
|
13
13
|
backendValues: RecordFormElementsValueLinkValue[];
|
|
14
14
|
setBackendValues: Dispatch<SetStateAction<RecordFormElementsValueLinkValue[]>>;
|
|
15
|
-
activeAttribute: IRecordPropertyWithAttribute | null;
|
|
16
|
-
dispatch: Dispatch<IEditRecordReducerActions>;
|
|
17
|
-
isHookUsed: boolean;
|
|
18
15
|
isReadOnly: boolean;
|
|
19
16
|
isFieldInError: boolean;
|
|
20
|
-
tagDisplayMode: boolean;
|
|
21
17
|
hasNoValue: boolean;
|
|
22
18
|
onDeleteMultipleValues: DeleteMultipleValuesFunc;
|
|
23
19
|
}
|
|
24
|
-
export declare const
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
export declare const useLinkRecords: ({ libraryId, recordId, isFormCreationMode, attribute, joinLibraryContext, columnsToDisplay, backendValues, setBackendValues, isReadOnly, isFieldInError, hasNoValue, onDeleteMultipleValues }: ILinkRecords) => {
|
|
21
|
+
UnlinkAllRecords: JSX.Element;
|
|
22
|
+
LinkRecordsExplorer: JSX.Element;
|
|
27
23
|
};
|
|
28
24
|
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
3
|
+
// This file is released under LGPL V3
|
|
4
|
+
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
5
|
+
import { Explorer } from '../../../../../../components/Explorer';
|
|
6
|
+
import { useEffect, useState } from 'react';
|
|
7
|
+
import { ExplorerWrapper } from '../shared/ExplorerWrapper';
|
|
8
|
+
import { DeleteAllValuesButton } from '../../shared/DeleteAllValuesButton';
|
|
9
|
+
import { AntForm, KitSpace } from 'aristid-ds';
|
|
10
|
+
import { useExplorerLinkRecords } from './useExplorerLinkRecords';
|
|
11
|
+
import { FaList } from 'react-icons/fa';
|
|
12
|
+
import { ActionButton } from './ActionButton';
|
|
13
|
+
import { useSharedTranslation } from '../../../../../../hooks/useSharedTranslation';
|
|
14
|
+
const _shouldUpdateExplorerActions = (ref, explorerActions) => ref?.createAction?.disabled !== explorerActions?.createAction?.disabled ||
|
|
15
|
+
ref?.linkAction?.disabled !== explorerActions?.linkAction?.disabled ||
|
|
16
|
+
ref?.totalCount !== explorerActions?.totalCount;
|
|
17
|
+
export const useLinkRecords = ({ libraryId, recordId, isFormCreationMode, attribute, joinLibraryContext, columnsToDisplay, backendValues, setBackendValues, isReadOnly, isFieldInError, hasNoValue, onDeleteMultipleValues }) => {
|
|
18
|
+
const { t } = useSharedTranslation();
|
|
19
|
+
const form = AntForm.useFormInstance();
|
|
20
|
+
const [explorerActions, setExplorerActions] = useState(null);
|
|
21
|
+
const { handleDeleteAllValues, handleExplorerCreateValue, handleExplorerLinkValue, handleExplorerMassDeactivateValues, handleExplorerRemoveValue } = useExplorerLinkRecords({
|
|
22
|
+
attribute,
|
|
23
|
+
backendValues,
|
|
24
|
+
setBackendValues,
|
|
25
|
+
onDeleteMultipleValues
|
|
26
|
+
});
|
|
27
|
+
const _handleExplorerRef = (ref) => {
|
|
28
|
+
if (_shouldUpdateExplorerActions(ref, explorerActions)) {
|
|
29
|
+
setExplorerActions({
|
|
30
|
+
createAction: ref?.createAction,
|
|
31
|
+
linkAction: ref?.linkAction,
|
|
32
|
+
totalCount: ref?.totalCount
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const _getExplorerItemActions = () => {
|
|
37
|
+
if (isReadOnly) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
if ((!attribute.multiple_values && attribute.required) ||
|
|
41
|
+
(attribute.multiple_values && backendValues.length === 1 && attribute.required)) {
|
|
42
|
+
return ['edit'];
|
|
43
|
+
}
|
|
44
|
+
return ['edit', 'remove'];
|
|
45
|
+
};
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!isFormCreationMode && backendValues.length === 0 && attribute.required) {
|
|
48
|
+
form.setFields([{ name: attribute.id, errors: [t('errors.standard_field_required')] }]);
|
|
49
|
+
}
|
|
50
|
+
}, []);
|
|
51
|
+
return {
|
|
52
|
+
UnlinkAllRecords: backendValues.length > 1 && attribute.multiple_values && !attribute.required && (_jsx(DeleteAllValuesButton, { handleDelete: handleDeleteAllValues, disabled: isReadOnly, danger: isFieldInError })),
|
|
53
|
+
LinkRecordsExplorer: recordId && (_jsxs(_Fragment, { children: [_jsx(ExplorerWrapper, { children: _jsx(Explorer, { ref: _handleExplorerRef, defaultViewSettings: {
|
|
54
|
+
attributesIds: columnsToDisplay
|
|
55
|
+
}, entrypoint: {
|
|
56
|
+
type: 'link',
|
|
57
|
+
parentLibraryId: libraryId,
|
|
58
|
+
parentRecordId: recordId,
|
|
59
|
+
linkAttributeId: attribute.id
|
|
60
|
+
}, defaultCallbacks: {
|
|
61
|
+
item: {
|
|
62
|
+
remove: handleExplorerRemoveValue
|
|
63
|
+
},
|
|
64
|
+
mass: {
|
|
65
|
+
deactivate: handleExplorerMassDeactivateValues
|
|
66
|
+
},
|
|
67
|
+
primary: {
|
|
68
|
+
link: handleExplorerLinkValue,
|
|
69
|
+
create: handleExplorerCreateValue
|
|
70
|
+
}
|
|
71
|
+
}, showTitle: false, showSearch: false, selectionMode: attribute.multiple_values ? 'multiple' : 'simple', disableSelection: isReadOnly ||
|
|
72
|
+
!attribute.multiple_values ||
|
|
73
|
+
(attribute.required && attribute.multiple_values && backendValues.length === 1), defaultActionsForItem: _getExplorerItemActions(), joinLibraryContext: joinLibraryContext, hidePrimaryActions: true, hideTableHeader: true, iconsOnlyItemActions: true }) }), _jsxs(KitSpace, { size: "xs", style: { padding: '1rem' }, children: [_jsx(ActionButton, { type: "secondary", size: "m", "$hasNoValue": hasNoValue, icon: explorerActions?.createAction?.icon, disabled: isReadOnly || explorerActions?.createAction?.disabled, onClick: explorerActions?.createAction?.callback, children: explorerActions?.createAction?.label }), _jsx(ActionButton, { type: "secondary", size: "m", "$hasNoValue": hasNoValue, icon: _jsx(FaList, {}), disabled: isReadOnly || (attribute.multiple_values && explorerActions?.linkAction?.disabled), onClick: explorerActions?.linkAction?.callback, children: explorerActions?.linkAction?.label })] })] }))
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=useLinkRecords.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLinkRecords.js","sourceRoot":"","sources":["../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/useLinkRecords.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,QAAQ,EAAC,MAAM,yBAAyB,CAAC;AAEjD,OAAO,EAA2C,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACpF,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAC,qBAAqB,EAAC,MAAM,oCAAoC,CAAC;AAIzE,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;A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AAC,SAAS,CAAC,eAAe,IAAI,eAAe,EAAE,UAAU,EAAE,QAAQ,CAAC,EAC5F,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,QAAQ,YAE7C,eAAe,EAAE,UAAU,EAAE,KAAK,GACxB,IACR,IACZ,CACN;KACJ,CAAC;AACN,CAAC,CAAC"}
|
package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/utils.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,eAAe,EAAE,aAAa,EAAE,qBAAqB,EAAC,MAAM,eAAe,CAAC;AAGpF,MAAM,CAAC,MAAM,2BAA2B,GAA2C;IAC/E,EAAE,EAAE,EAAE;IACN,SAAS,EAAE;QACP,MAAM,EAAE,eAAe,CAAC,IAAI;QAC5B,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,aAAa,CAAC,MAAM;KAC7B;IACD,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,qBAAqB,CAAC,KAAK;CACzC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAA8B;IACxD;QACI,GAAG,2BAA2B;QAC9B,KAAK,EAAE,WAAW;KACrB;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/utils.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,eAAe,EAAE,aAAa,EAAE,qBAAqB,EAAC,MAAM,eAAe,CAAC;AAGpF,MAAM,CAAC,MAAM,2BAA2B,GAA2C;IAC/E,EAAE,EAAE,EAAE;IACN,SAAS,EAAE;QACP,MAAM,EAAE,eAAe,CAAC,IAAI;QAC5B,KAAK,EAAE,IAAI;QACX,EAAE,EAAE,IAAI;QACR,IAAI,EAAE,aAAa,CAAC,MAAM;KAC7B;IACD,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,qBAAqB,CAAC,KAAK;CACzC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAA8B;IACxD;QACI,GAAG,2BAA2B;QAC9B,KAAK,EAAE,WAAW;KACrB;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC"}
|
package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardField.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ import { FunctionComponent } from 'react';
|
|
|
3
3
|
import { RecordFormElementsValueStandardValue } from '../../../../../hooks/useGetRecordForm/useGetRecordForm';
|
|
4
4
|
import { IFormElementProps } from '../../_types';
|
|
5
5
|
import { FormInstance } from 'antd';
|
|
6
|
+
import { GetRecordColumnsValuesRecord, IRecordColumnValueStandard } from '../../../../../_queries/records/getRecordColumnsValues';
|
|
6
7
|
declare const StandardField: FunctionComponent<IFormElementProps<IRequiredFieldsSettings, RecordFormElementsValueStandardValue> & {
|
|
7
8
|
antdForm?: FormInstance;
|
|
9
|
+
computedValues?: GetRecordColumnsValuesRecord<IRecordColumnValueStandard>;
|
|
8
10
|
}>;
|
|
9
11
|
export default StandardField;
|
package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardField.js
CHANGED
|
@@ -58,97 +58,115 @@ const KitAddValueButton = styled(KitButton) `
|
|
|
58
58
|
margin-top: calc((var(--general-spacing-xs) - 3) * 1px);
|
|
59
59
|
margin-bottom: 3px;
|
|
60
60
|
`;
|
|
61
|
-
const StandardField = ({ element,
|
|
61
|
+
const StandardField = ({ element, computedValues, isFormCreationMode, antdForm, readonly, onValueSubmit, onValueDelete, onDeleteMultipleValues, metadataEdit = false }) => {
|
|
62
62
|
const { t } = useSharedTranslation();
|
|
63
63
|
const { lang } = useLang();
|
|
64
|
-
const [elementValuesWithoutCalculatedOrInherited, setElementValuesWithoutCalculatedOrInherited] = useState([]);
|
|
65
64
|
const antdListFieldsRef = useRef(null);
|
|
66
65
|
const { attribute } = element;
|
|
67
66
|
useEffect(() => {
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
.sort((a, b) => Number(a.id_value) - Number(b.id_value))
|
|
72
|
-
.map(v => getAntdDisplayedValue([v], attribute));
|
|
73
|
-
antdForm.setFieldValue(attribute.id, antdDisplayedValues);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
antdForm.setFieldValue(attribute.id, getAntdDisplayedValue(element.values, attribute));
|
|
77
|
-
}
|
|
67
|
+
if (computedValues && computedValues[attribute.id]) {
|
|
68
|
+
setBackendValues(computedValues[attribute.id]);
|
|
69
|
+
antdForm.setFieldValue(attribute.id, getAntdDisplayedValue(computedValues[attribute.id], attribute));
|
|
78
70
|
}
|
|
79
|
-
}, [
|
|
71
|
+
}, [computedValues]);
|
|
80
72
|
if (!attribute) {
|
|
81
73
|
return _jsx(ErrorDisplay, { message: t('record_edition.missing_attribute') });
|
|
82
74
|
}
|
|
83
75
|
const { state, dispatch } = useEditRecordReducer();
|
|
84
|
-
const
|
|
85
|
-
const
|
|
76
|
+
const [backendValues, setBackendValues] = useState(element.values);
|
|
77
|
+
const calculatedFlags = computeCalculatedFlags(backendValues);
|
|
78
|
+
const inheritedFlags = computeInheritedFlags(backendValues);
|
|
86
79
|
const defaultValueToAddInAntdForm = getEmptyInitialValue(attribute);
|
|
87
|
-
const [attributePendingValues, setAttributePendingValues] = useState([]);
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
setAttributePendingValues(pendingValues?.[attribute.id]
|
|
90
|
-
? Object.values(pendingValues?.[attribute.id])
|
|
91
|
-
: []);
|
|
92
|
-
}, [pendingValues, attribute.id]);
|
|
93
80
|
useEffect(() => {
|
|
94
81
|
if (state.activeAttribute?.attribute.id === attribute.id) {
|
|
95
82
|
dispatch({
|
|
96
83
|
type: EditRecordReducerActionsTypes.SET_ACTIVE_VALUE,
|
|
97
|
-
values:
|
|
84
|
+
values: backendValues
|
|
98
85
|
});
|
|
99
86
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
.sort((a, b) => Number(a.id_value) - Number(b.id_value)));
|
|
107
|
-
}, [element.values]);
|
|
87
|
+
}, [backendValues]);
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (!isFormCreationMode && backendValues.length === 0 && attribute.required) {
|
|
90
|
+
antdForm.setFields([{ name: attribute.id, errors: [t('errors.standard_field_required')] }]);
|
|
91
|
+
}
|
|
92
|
+
}, []);
|
|
108
93
|
useOutsideInteractionDetector({
|
|
109
94
|
attribute,
|
|
110
95
|
activeAttribute: state.activeAttribute,
|
|
111
96
|
attributePrefix: STANDARD_FIELD_ID_PREFIX,
|
|
112
97
|
dispatch,
|
|
113
|
-
|
|
114
|
-
elementValues: element.values ?? [],
|
|
115
|
-
pendingValues: attributePendingValues,
|
|
98
|
+
backendValues,
|
|
116
99
|
allowedSelectors: ['.ant-popover.ant-color-picker', '.ant-picker-dropdown', '.kit-modal-wrapper.link-modal']
|
|
117
100
|
});
|
|
101
|
+
const backendWithoutCalculatedOrInheritedValues = backendValues
|
|
102
|
+
.filter(backendValue => !backendValue.isCalculated && !backendValue.isInherited)
|
|
103
|
+
.sort((a, b) => Number(a.id_value) - Number(b.id_value));
|
|
118
104
|
const { presentationValues } = useGetPresentationValues({
|
|
119
105
|
//TODO fix type
|
|
120
|
-
values:
|
|
106
|
+
values: backendWithoutCalculatedOrInheritedValues,
|
|
121
107
|
format: attribute.format,
|
|
122
108
|
calculatedValue: calculatedFlags.calculatedValue,
|
|
123
109
|
inheritedValue: inheritedFlags.inheritedValue
|
|
124
110
|
});
|
|
125
|
-
const _handleSubmit = (idValue, fieldName) => async (valueToSave) => {
|
|
111
|
+
const _handleSubmit = (idValue, fieldName, submittedFieldIndex) => async (valueToSave) => {
|
|
126
112
|
const shouldSpecifyFieldName = attribute.multiple_values && fieldName !== undefined;
|
|
127
113
|
const name = shouldSpecifyFieldName ? [attribute.id, fieldName] : attribute.id;
|
|
128
|
-
// Clear error on the input
|
|
129
114
|
if (antdForm) {
|
|
130
|
-
antdForm.setFields([
|
|
115
|
+
antdForm.setFields([
|
|
116
|
+
{
|
|
117
|
+
name,
|
|
118
|
+
errors: null
|
|
119
|
+
}
|
|
120
|
+
]);
|
|
131
121
|
}
|
|
132
|
-
// Send request to api
|
|
133
122
|
let submitRes;
|
|
134
123
|
if (attribute.multiple_values) {
|
|
124
|
+
if (valueToSave === '') {
|
|
125
|
+
_handleDeleteValue(idValue, submittedFieldIndex);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
135
128
|
submitRes = await onValueSubmit([{ value: valueToSave, idValue: idValue ?? null, attribute }], null);
|
|
129
|
+
if (submitRes.status === APICallStatus.SUCCESS) {
|
|
130
|
+
setBackendValues(previousBackendValues => {
|
|
131
|
+
const newBackendValues = [...previousBackendValues, ...submitRes.values].reduce((acc, backendValue) => {
|
|
132
|
+
const existingValue = acc.find(o => o.id_value === backendValue.id_value &&
|
|
133
|
+
o.isCalculated === backendValue.isCalculated &&
|
|
134
|
+
o.isInherited === backendValue.isInherited);
|
|
135
|
+
if (existingValue) {
|
|
136
|
+
Object.assign(existingValue, backendValue);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
acc.push(backendValue);
|
|
140
|
+
}
|
|
141
|
+
return acc;
|
|
142
|
+
}, []);
|
|
143
|
+
return newBackendValues;
|
|
144
|
+
});
|
|
145
|
+
return submitRes;
|
|
146
|
+
}
|
|
136
147
|
}
|
|
137
148
|
else {
|
|
138
|
-
if (
|
|
139
|
-
submitRes = await
|
|
149
|
+
if (valueToSave) {
|
|
150
|
+
submitRes = await onValueSubmit([{ value: valueToSave, idValue: idValue ?? null, attribute }], null);
|
|
151
|
+
if (submitRes.status === APICallStatus.SUCCESS) {
|
|
152
|
+
setBackendValues(submitRes.values ?? []);
|
|
153
|
+
return submitRes;
|
|
154
|
+
}
|
|
140
155
|
}
|
|
141
156
|
else {
|
|
142
|
-
|
|
157
|
+
if (backendWithoutCalculatedOrInheritedValues.length > 0) {
|
|
158
|
+
submitRes = await onValueDelete({ id_value: idValue, payload: null }, attribute.id);
|
|
159
|
+
if (submitRes.status === APICallStatus.SUCCESS) {
|
|
160
|
+
setBackendValues(previousBackendValues => previousBackendValues.filter(value => (value.isCalculated !== null && value.isCalculated !== undefined) ||
|
|
161
|
+
(value.isInherited !== null && value.isInherited !== undefined)));
|
|
162
|
+
return submitRes;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
143
165
|
}
|
|
144
166
|
}
|
|
145
167
|
if (!submitRes) {
|
|
146
168
|
return;
|
|
147
169
|
}
|
|
148
|
-
if (submitRes.status === APICallStatus.SUCCESS) {
|
|
149
|
-
return submitRes;
|
|
150
|
-
}
|
|
151
|
-
// Parse errors from api response
|
|
152
170
|
if (!submitRes.error && submitRes.errors) {
|
|
153
171
|
const attributeError = submitRes.errors.filter(err => err.attribute === attribute.id)?.[0];
|
|
154
172
|
if (attributeError) {
|
|
@@ -158,43 +176,38 @@ const StandardField = ({ element, antdForm, readonly, isCreationForm, pendingVal
|
|
|
158
176
|
: t(`errors.${attributeError.type}`);
|
|
159
177
|
}
|
|
160
178
|
}
|
|
161
|
-
// Display errors on input if found
|
|
162
179
|
if (submitRes.error && antdForm) {
|
|
163
|
-
antdForm.setFields([
|
|
180
|
+
antdForm.setFields([
|
|
181
|
+
{
|
|
182
|
+
name,
|
|
183
|
+
errors: [submitRes.error]
|
|
184
|
+
}
|
|
185
|
+
]);
|
|
164
186
|
}
|
|
165
187
|
return submitRes;
|
|
166
188
|
};
|
|
167
|
-
const
|
|
168
|
-
// Re check error if we click in the input
|
|
169
|
-
if (attribute.multiple_values && fieldName !== undefined) {
|
|
170
|
-
antdForm?.setFields([{ name: [attribute.id, fieldName], errors: undefined }]);
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
antdForm?.setFields([{ name: attribute.id, errors: undefined }]);
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
const _handleDeleteValue = async (idValue, antdRemove, deletedFieldIndex) => {
|
|
189
|
+
const _handleDeleteValue = async (idValue, deletedFieldIndex) => {
|
|
177
190
|
if (idValue) {
|
|
178
191
|
await onValueDelete({ id_value: idValue }, attribute.id);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
192
|
+
setBackendValues(previousBackendValues => previousBackendValues.filter(backendValue => backendValue.id_value !== idValue));
|
|
193
|
+
}
|
|
194
|
+
antdListFieldsRef.current.remove(deletedFieldIndex);
|
|
195
|
+
if (backendWithoutCalculatedOrInheritedValues.length === 1) {
|
|
196
|
+
antdListFieldsRef.current.add(defaultValueToAddInAntdForm);
|
|
183
197
|
}
|
|
184
|
-
antdRemove(deletedFieldIndex);
|
|
185
198
|
};
|
|
186
199
|
const _handleDeleteAllValues = async () => {
|
|
187
|
-
const deleteRes = await onDeleteMultipleValues(attribute.id,
|
|
200
|
+
const deleteRes = await onDeleteMultipleValues(attribute.id, backendValues.filter(b => b.id_value), null);
|
|
188
201
|
if (deleteRes.status === APICallStatus.SUCCESS) {
|
|
189
202
|
antdListFieldsRef.current.remove(antdListFieldsRef.current.indexes);
|
|
190
203
|
antdListFieldsRef.current.add(defaultValueToAddInAntdForm);
|
|
191
|
-
|
|
204
|
+
setBackendValues(previousBackendValues => previousBackendValues.filter(backendValue => !backendValue.id_value));
|
|
192
205
|
return;
|
|
193
206
|
}
|
|
194
207
|
};
|
|
195
208
|
let isFieldInError = false;
|
|
196
209
|
if (antdForm) {
|
|
197
|
-
const hasErrorsInFormList =
|
|
210
|
+
const hasErrorsInFormList = backendValues.some((_, index) => {
|
|
198
211
|
const errors = antdForm.getFieldError([attribute.id, index]);
|
|
199
212
|
return errors.length > 0;
|
|
200
213
|
});
|
|
@@ -202,21 +215,21 @@ const StandardField = ({ element, antdForm, readonly, isCreationForm, pendingVal
|
|
|
202
215
|
isFieldInError =
|
|
203
216
|
antdForm.getFieldError(attribute.id).length > 0 || hasErrorsInFormList || multipleFieldRequiredInError;
|
|
204
217
|
}
|
|
205
|
-
const isMultipleValues = element.attribute
|
|
206
|
-
const hasValue = isMultipleValues &&
|
|
218
|
+
const isMultipleValues = element.attribute.multiple_values;
|
|
219
|
+
const hasValue = isMultipleValues && backendValues.length > 0;
|
|
207
220
|
const canAddAnotherValue = !readonly &&
|
|
208
221
|
isMultipleValues &&
|
|
209
222
|
!isFieldInError &&
|
|
210
223
|
attribute.format !== AttributeFormat.boolean &&
|
|
211
224
|
attribute.format !== AttributeFormat.encrypted;
|
|
212
|
-
const canDeleteAllValues = hasValue &&
|
|
225
|
+
const canDeleteAllValues = hasValue && backendValues.length > 1 && !attribute.required;
|
|
213
226
|
const label = localizedTranslation(element.settings.label, lang);
|
|
214
227
|
const isReadOnly = attribute.readonly || !attribute.permissions.edit_value || readonly;
|
|
215
|
-
return (_jsx(Wrapper, { "$metadataEdit": metadataEdit, children: _jsxs(KitInputWrapperStyled, { id: STANDARD_FIELD_ID_PREFIX + attribute.id, label: label, required: attribute.required, disabled: isReadOnly, bordered: attribute.multiple_values, status: isFieldInError ? 'error' : undefined, extra: _jsxs(_Fragment, { children: [_jsx(KitInputExtraAlignLeft, { children: _jsx(ComputeIndicator, { calculatedFlags: calculatedFlags, inheritedFlags: inheritedFlags }) }), canDeleteAllValues && (_jsx(DeleteAllValuesButton, { handleDelete: _handleDeleteAllValues, disabled: isReadOnly, danger: isFieldInError }))] }), htmlFor: attribute.id, children: [!attribute.multiple_values && (_jsx(StandardFieldValue, { presentationValue: presentationValues[0] ?? '', handleSubmit: _handleSubmit(
|
|
228
|
+
return (_jsx(Wrapper, { "$metadataEdit": metadataEdit, children: _jsxs(KitInputWrapperStyled, { id: STANDARD_FIELD_ID_PREFIX + attribute.id, label: label, required: attribute.required, disabled: isReadOnly, bordered: attribute.multiple_values, status: isFieldInError ? 'error' : undefined, extra: _jsxs(_Fragment, { children: [_jsx(KitInputExtraAlignLeft, { children: _jsx(ComputeIndicator, { calculatedFlags: calculatedFlags, inheritedFlags: inheritedFlags }) }), canDeleteAllValues && (_jsx(DeleteAllValuesButton, { handleDelete: _handleDeleteAllValues, disabled: isReadOnly, danger: isFieldInError }))] }), htmlFor: attribute.id, children: [!attribute.multiple_values && (_jsx(StandardFieldValue, { presentationValue: presentationValues[0] ?? '', handleSubmit: _handleSubmit(backendWithoutCalculatedOrInheritedValues[0]?.id_value), attribute: attribute, readonly: isReadOnly, label: label, calculatedFlags: calculatedFlags, inheritedFlags: inheritedFlags })), attribute.multiple_values && (_jsx(Form.List, { name: attribute.id, children: (fields, { add, remove }) => {
|
|
216
229
|
antdListFieldsRef.current = { add, remove, indexes: fields.map((_, index) => index) };
|
|
217
|
-
const shouldDisabledAddValueButton = fields.length >
|
|
218
|
-
return (_jsxs(_Fragment, { children: [_jsx(KitFieldsWrapper, { children: fields.map((field, index) => (_jsxs(RowValueWrapper, { children: [_jsx(StandardFieldValueWrapper, { children: _jsx(StandardFieldValue, { listField: field, presentationValue: presentationValues[index] ?? '', handleSubmit: _handleSubmit(
|
|
219
|
-
|
|
230
|
+
const shouldDisabledAddValueButton = fields.length > backendWithoutCalculatedOrInheritedValues.length;
|
|
231
|
+
return (_jsxs(_Fragment, { children: [_jsx(KitFieldsWrapper, { children: fields.map((field, index) => (_jsxs(RowValueWrapper, { children: [_jsx(StandardFieldValueWrapper, { children: _jsx(StandardFieldValue, { listField: field, presentationValue: presentationValues[index] ?? '', handleSubmit: _handleSubmit(backendWithoutCalculatedOrInheritedValues[index]?.id_value, field.name, index), attribute: attribute, label: label, readonly: isReadOnly, calculatedFlags: calculatedFlags, inheritedFlags: inheritedFlags, isLastValueOfMultivalues: index === fields.length - 1 && index !== 0, removeLastValueOfMultivalues: () => remove(index) }) }), backendWithoutCalculatedOrInheritedValues.length > 0 && (_jsx(KitDeleteValueButton, { type: "tertiary", title: t('record_edition.delete_value'), icon: _jsx(FaTrash, {}), onClick: () => _handleDeleteValue(backendWithoutCalculatedOrInheritedValues[index]
|
|
232
|
+
?.id_value, index), disabled: isReadOnly }))] }, field.key))) }), canAddAnotherValue && (_jsx(KitTooltip, { title: shouldDisabledAddValueButton
|
|
220
233
|
? t('record_edition.please_select_value_before_adding')
|
|
221
234
|
: undefined, children: _jsx(KitAddValueButton, { type: "secondary", size: "m", icon: _jsx(FaPlus, {}), onClick: () => add(defaultValueToAddInAntdForm), disabled: isReadOnly || shouldDisabledAddValueButton, children: t('record_edition.add_value') }) }))] }));
|
|
222
235
|
} }))] }) }));
|