@leav/ui 1.6.0 → 1.7.0-178015c1
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/README.md +13 -12
- package/dist/__mocks__/react-i18next.d.ts +1 -1
- package/dist/_gqlTypes/index.d.ts +1006 -686
- package/dist/_gqlTypes/index.js +167 -43
- package/dist/_gqlTypes/index.js.map +1 -1
- package/dist/_queries/attributes/attributeDetailsFragment.js +5 -0
- package/dist/_queries/attributes/attributeDetailsFragment.js.map +1 -1
- package/dist/_queries/trees/treeNodeChildrenQuery.js +2 -0
- package/dist/_queries/trees/treeNodeChildrenQuery.js.map +1 -1
- package/dist/_queries/views/viewDetailsFragment.js +1 -0
- package/dist/_queries/views/viewDetailsFragment.js.map +1 -1
- package/dist/components/AttributesSelectionList/SelectedAttributesList/SelectedAttributesList.js +20 -12
- package/dist/components/AttributesSelectionList/SelectedAttributesList/SelectedAttributesList.js.map +1 -1
- package/dist/components/AttributesSelectionList/reducer/__mocks__/attributesSelectionListStateContext.d.ts +1 -1
- package/dist/components/AttributesSelectionList/sharedComponents.d.ts +159 -153
- package/dist/components/Explorer/DataView.d.ts +2 -0
- package/dist/components/Explorer/DataView.js +6 -3
- package/dist/components/Explorer/DataView.js.map +1 -1
- package/dist/components/Explorer/Explorer.d.ts +2 -0
- package/dist/components/Explorer/Explorer.js +7 -5
- package/dist/components/Explorer/Explorer.js.map +1 -1
- package/dist/components/Explorer/ExplorerFiltersAndSorts.js +1 -1
- package/dist/components/Explorer/ExplorerFiltersAndSorts.js.map +1 -1
- package/dist/components/Explorer/TableCell.js +6 -7
- package/dist/components/Explorer/TableCell.js.map +1 -1
- package/dist/components/Explorer/TableNameCell.js +3 -2
- package/dist/components/Explorer/TableNameCell.js.map +1 -1
- package/dist/components/Explorer/_queries/useExplorerData.d.ts +7 -7
- package/dist/components/Explorer/_queries/useExplorerData.js +19 -7
- package/dist/components/Explorer/_queries/useExplorerData.js.map +1 -1
- package/dist/components/Explorer/actions-item/useEditStatusItemAction.js +3 -2
- package/dist/components/Explorer/actions-item/useEditStatusItemAction.js.map +1 -1
- package/dist/components/Explorer/actions-item/useReplaceItemAction.d.ts +2 -1
- package/dist/components/Explorer/actions-item/useReplaceItemAction.js +5 -4
- package/dist/components/Explorer/actions-item/useReplaceItemAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.d.ts +2 -4
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js +18 -16
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js.map +1 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js +2 -2
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js.map +1 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js +9 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js.map +1 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.d.ts +10 -3
- package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js +16 -6
- package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js.map +1 -1
- package/dist/components/Explorer/actions-mass/export/ExportProfileSelectionModal.d.ts +10 -0
- package/dist/components/Explorer/actions-mass/export/ExportProfileSelectionModal.js +46 -0
- package/dist/components/Explorer/actions-mass/export/ExportProfileSelectionModal.js.map +1 -0
- package/dist/components/Explorer/actions-mass/export/content/NoProfiles.d.ts +1 -0
- package/dist/components/Explorer/actions-mass/export/content/NoProfiles.js +17 -0
- package/dist/components/Explorer/actions-mass/export/content/NoProfiles.js.map +1 -0
- package/dist/components/Explorer/actions-mass/export/content/ProfilesSelection.d.ts +8 -0
- package/dist/components/Explorer/actions-mass/export/content/ProfilesSelection.js +49 -0
- package/dist/components/Explorer/actions-mass/export/content/ProfilesSelection.js.map +1 -0
- package/dist/components/Explorer/actions-mass/export/useGetLibraryExportProfiles.d.ts +27 -0
- package/dist/components/Explorer/actions-mass/export/useGetLibraryExportProfiles.js +48 -0
- package/dist/components/Explorer/actions-mass/export/useGetLibraryExportProfiles.js.map +1 -0
- package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js +3 -2
- package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js +3 -2
- package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js +3 -2
- package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useExportMassAction.d.ts +7 -4
- package/dist/components/Explorer/actions-mass/useExportMassAction.js +80 -73
- package/dist/components/Explorer/actions-mass/useExportMassAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useMassActions.js +3 -2
- package/dist/components/Explorer/actions-mass/useMassActions.js.map +1 -1
- package/dist/components/Explorer/actions-primary/useCreatePrimaryAction.js +3 -2
- package/dist/components/Explorer/actions-primary/useCreatePrimaryAction.js.map +1 -1
- package/dist/components/Explorer/actions-primary/useLinkPrimaryAction.d.ts +2 -1
- package/dist/components/Explorer/actions-primary/useLinkPrimaryAction.js +5 -4
- package/dist/components/Explorer/actions-primary/useLinkPrimaryAction.js.map +1 -1
- package/dist/components/Explorer/link-item/LinkModal.d.ts +1 -0
- package/dist/components/Explorer/link-item/LinkModal.js +2 -2
- package/dist/components/Explorer/link-item/LinkModal.js.map +1 -1
- package/dist/components/Explorer/list-saved-views/SavedViews.js +4 -3
- package/dist/components/Explorer/list-saved-views/SavedViews.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/_shared/ColumnItem.js +5 -8
- package/dist/components/Explorer/manage-view-settings/_shared/ColumnItem.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/configure-display/attributes/SelectVisibleAttributes.js +3 -2
- package/dist/components/Explorer/manage-view-settings/configure-display/attributes/SelectVisibleAttributes.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/filter-items/FilterItems.js +7 -6
- package/dist/components/Explorer/manage-view-settings/filter-items/FilterItems.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/filter-items/FilterListItem.js +3 -2
- package/dist/components/Explorer/manage-view-settings/filter-items/FilterListItem.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/open-view-settings/useOpenViewSettings.js +4 -3
- package/dist/components/Explorer/manage-view-settings/open-view-settings/useOpenViewSettings.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/router-menu/SettingItem.js +3 -2
- package/dist/components/Explorer/manage-view-settings/router-menu/SettingItem.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/router-menu/SettingsPanel.js +3 -2
- package/dist/components/Explorer/manage-view-settings/router-menu/SettingsPanel.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/LabelViewFormModal.js +3 -2
- package/dist/components/Explorer/manage-view-settings/save-view/LabelViewFormModal.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/prepareViewForRequest.js +3 -0
- package/dist/components/Explorer/manage-view-settings/save-view/prepareViewForRequest.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/useCreateNewView.js +3 -2
- package/dist/components/Explorer/manage-view-settings/save-view/useCreateNewView.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/useDeleteView.js +4 -3
- package/dist/components/Explorer/manage-view-settings/save-view/useDeleteView.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/useEditLabelView.js +3 -2
- package/dist/components/Explorer/manage-view-settings/save-view/useEditLabelView.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/useResetView.js +3 -2
- package/dist/components/Explorer/manage-view-settings/save-view/useResetView.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/useShareView.js +3 -2
- package/dist/components/Explorer/manage-view-settings/save-view/useShareView.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/useUpdateView.js +3 -2
- package/dist/components/Explorer/manage-view-settings/save-view/useUpdateView.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/sort-items/SortItems.js +7 -6
- package/dist/components/Explorer/manage-view-settings/sort-items/SortItems.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/sort-items/SortListItem.js +3 -2
- package/dist/components/Explorer/manage-view-settings/sort-items/SortListItem.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/store-view-settings/viewSettingsReducer.js.map +1 -1
- package/dist/components/Explorer/useSearchInput.js +6 -2
- package/dist/components/Explorer/useSearchInput.js.map +1 -1
- package/dist/components/Filters/FiltersProvider.d.ts +2 -2
- package/dist/components/Filters/FiltersProvider.js.map +1 -1
- package/dist/components/Filters/_types.d.ts +3 -0
- package/dist/components/Filters/_types.js.map +1 -1
- package/dist/components/Filters/context/filtersReducer.js +7 -4
- package/dist/components/Filters/context/filtersReducer.js.map +1 -1
- package/dist/components/Filters/filter-items/CommonFilterItem.d.ts +1 -0
- package/dist/components/Filters/filter-items/CommonFilterItem.js +28 -8
- package/dist/components/Filters/filter-items/CommonFilterItem.js.map +1 -1
- package/dist/components/Filters/filter-items/EmptyValueCheckbox.d.ts +8 -0
- package/dist/components/Filters/filter-items/EmptyValueCheckbox.js +16 -0
- package/dist/components/Filters/filter-items/EmptyValueCheckbox.js.map +1 -0
- package/dist/components/Filters/filter-items/filter-type/BooleanAttributeDropdown.js +23 -9
- package/dist/components/Filters/filter-items/filter-type/BooleanAttributeDropdown.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/ColorAttributeDropDown.js +9 -8
- package/dist/components/Filters/filter-items/filter-type/ColorAttributeDropDown.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/FilterDropDown.js +4 -3
- package/dist/components/Filters/filter-items/filter-type/FilterDropDown.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/FilterDropdownContent.js +1 -1
- package/dist/components/Filters/filter-items/filter-type/FilterDropdownContent.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.d.ts +0 -1
- package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.js +17 -23
- package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/TreeAttributeDropDown.js +10 -12
- package/dist/components/Filters/filter-items/filter-type/TreeAttributeDropDown.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/useConditionOptionsByType.js +3 -13
- package/dist/components/Filters/filter-items/filter-type/useConditionOptionsByType.js.map +1 -1
- package/dist/components/Filters/index.d.ts +1 -0
- package/dist/components/Filters/index.js +1 -0
- package/dist/components/Filters/index.js.map +1 -1
- package/dist/components/Filters/prepareFiltersForRequest.js +36 -3
- package/dist/components/Filters/prepareFiltersForRequest.js.map +1 -1
- package/dist/components/Filters/useFilters.d.ts +5 -0
- package/dist/components/Filters/useTransformFilters.js +4 -0
- package/dist/components/Filters/useTransformFilters.js.map +1 -1
- package/dist/components/LibraryItemsList/FiltersPanel/Filter/Filter.d.ts +1 -3
- package/dist/components/LibraryItemsList/FiltersPanel/Filter/Filter.js +6 -2
- package/dist/components/LibraryItemsList/FiltersPanel/Filter/Filter.js.map +1 -1
- package/dist/components/LibraryItemsList/FiltersPanel/FiltersOptions.js +1 -8
- package/dist/components/LibraryItemsList/FiltersPanel/FiltersOptions.js.map +1 -1
- package/dist/components/LibraryItemsList/FiltersPanel/FiltersPanel.js +15 -17
- package/dist/components/LibraryItemsList/FiltersPanel/FiltersPanel.js.map +1 -1
- package/dist/components/LibraryItemsList/LibraryItemsListTable/ChooseTableColumns/ChooseTableColumns.js +0 -6
- package/dist/components/LibraryItemsList/LibraryItemsListTable/ChooseTableColumns/ChooseTableColumns.js.map +1 -1
- package/dist/components/LibraryItemsList/MenuView/MenuView.js +4 -4
- package/dist/components/LibraryItemsList/MenuView/MenuView.js.map +1 -1
- package/dist/components/LibraryItemsList/ViewPanel/View/View.d.ts +1 -3
- package/dist/components/LibraryItemsList/ViewPanel/View/View.js +9 -4
- package/dist/components/LibraryItemsList/ViewPanel/View/View.js.map +1 -1
- package/dist/components/LibraryItemsList/ViewPanel/ViewPanel.js +36 -14
- package/dist/components/LibraryItemsList/ViewPanel/ViewPanel.js.map +1 -1
- package/dist/components/Notifications/hooks/useNotificationSubscription.js +3 -2
- package/dist/components/Notifications/hooks/useNotificationSubscription.js.map +1 -1
- package/dist/components/RecordEdition/EditRecord/EditRecord.d.ts +1 -0
- package/dist/components/RecordEdition/EditRecord/EditRecord.js +3 -3
- package/dist/components/RecordEdition/EditRecord/EditRecord.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/antdUtils.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/hooks/__mocks__/useDeleteValueMutation.d.ts +1 -1
- package/dist/components/RecordEdition/EditRecordContent/hooks/__mocks__/useSaveValueMutation.d.ts +1 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/ValuesVersionBtn.js +5 -20
- package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/ValuesVersionBtn.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/LinkField.d.ts +1 -11
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/LinkField.js +8 -95
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/LinkField.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/_types.d.ts +8 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/_types.js +2 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/_types.js.map +1 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/explorer/LinkFieldExplorer.d.ts +6 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/explorer/LinkFieldExplorer.js +77 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/explorer/LinkFieldExplorer.js.map +1 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/{link-record → explorer/link-record}/useExplorerLinkRecords.d.ts +5 -7
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/{link-record → explorer/link-record}/useExplorerLinkRecords.js +3 -10
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/explorer/link-record/useExplorerLinkRecords.js.map +1 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/{link-record → explorer/link-record}/useLinkRecords.d.ts +5 -6
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/explorer/link-record/useLinkRecords.js +98 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/explorer/link-record/useLinkRecords.js.map +1 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/{ExplorerWrapper.d.ts → InputExtraAlignLeft.d.ts} +54 -52
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/{link-record/ActionButton.js → shared/InputExtraAlignLeft.js} +4 -4
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/InputExtraAlignLeft.js.map +1 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/InputWrapper.d.ts +3 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/InputWrapper.js +31 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/InputWrapper.js.map +1 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/Wrapper.d.ts +3 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/Wrapper.js +8 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/Wrapper.js.map +1 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/LinkFieldTags.d.ts +3 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/LinkFieldTags.js +57 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/LinkFieldTags.js.map +1 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/link-record/useLinkRecord.d.ts +16 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/link-record/useLinkRecord.js +82 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/link-record/useLinkRecord.js.map +1 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.d.ts +19 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.js +43 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.js.map +1 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/unlink-all-records/useUnlinkAllRecords.d.ts +16 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/unlink-all-records/useUnlinkAllRecords.js +27 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/unlink-all-records/useUnlinkAllRecords.js.map +1 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardField.js +4 -3
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardField.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/TreeField.js +9 -2
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/TreeField.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/display-tree-node/TreeFieldWrapper.d.ts +53 -51
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/display-tree-node/TreeNodeItem.js +3 -2
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/display-tree-node/TreeNodeItem.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/SelectTreeNodeModal.d.ts +2 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/SelectTreeNodeModal.js +4 -7
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/SelectTreeNodeModal.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/useManageTreeNodeSelection.d.ts +3 -2
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/useManageTreeNodeSelection.js +2 -2
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/useManageTreeNodeSelection.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/ComputeIndicator.js +3 -2
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/ComputeIndicator.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordPage/EditRecordPage.d.ts +1 -0
- package/dist/components/RecordEdition/EditRecordPage/EditRecordPage.js +2 -2
- package/dist/components/RecordEdition/EditRecordPage/EditRecordPage.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/RecordInformations.js +3 -2
- package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/RecordInformations.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordSidebar/ValuesSummary/ValuesSummary.js +4 -3
- package/dist/components/RecordEdition/EditRecordSidebar/ValuesSummary/ValuesSummary.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordSidebar/ValuesVersions/ValuesVersions.js +3 -2
- package/dist/components/RecordEdition/EditRecordSidebar/ValuesVersions/ValuesVersions.js.map +1 -1
- package/dist/components/RecordEdition/hooks/useGetSubmitButtons.js +2 -2
- package/dist/components/RecordEdition/hooks/useGetSubmitButtons.js.map +1 -1
- package/dist/components/SelectRecordForLinkModal/SelectRecordForLinkModal.d.ts +1 -0
- package/dist/components/SelectRecordForLinkModal/SelectRecordForLinkModal.js +7 -7
- package/dist/components/SelectRecordForLinkModal/SelectRecordForLinkModal.js.map +1 -1
- package/dist/components/SelectTreeNode/SelectTreeNode.d.ts +2 -1
- package/dist/components/SelectTreeNode/SelectTreeNode.js +3 -3
- package/dist/components/SelectTreeNode/SelectTreeNode.js.map +1 -1
- package/dist/components/SelectTreeNode/SelectTreeNodeContent.d.ts +2 -1
- package/dist/components/SelectTreeNode/SelectTreeNodeContent.js +6 -2
- package/dist/components/SelectTreeNode/SelectTreeNodeContent.js.map +1 -1
- package/dist/components/SelectTreeNode/TreeNodeTitle.js +3 -2
- package/dist/components/SelectTreeNode/TreeNodeTitle.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/messageHandlers.d.ts +3 -1
- package/dist/hooks/useIFrameMessenger/messageHandlers.js +16 -0
- package/dist/hooks/useIFrameMessenger/messageHandlers.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/schema.d.ts +6 -3
- package/dist/hooks/useIFrameMessenger/schema.js +2 -1
- package/dist/hooks/useIFrameMessenger/schema.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/types.d.ts +32 -2
- package/dist/hooks/useIFrameMessenger/types.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.d.ts +2 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.js +16 -2
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.js.map +1 -1
- package/dist/hooks/useIFrameMessengerClient/iFrameMessengerClientContext.d.ts +2 -0
- package/dist/hooks/useIFrameMessengerClient/useIFrameMessengerClient.d.ts +2 -0
- package/dist/locales/en/shared.json +18 -3
- package/dist/locales/fr/shared.json +18 -3
- package/package.json +40 -42
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/ActionButton.d.ts +0 -3
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/ActionButton.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/useExplorerLinkRecords.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/useLinkRecords.js +0 -100
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/useLinkRecords.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/ExplorerWrapper.js +0 -13
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/ExplorerWrapper.js.map +0 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const InputExtraAlignLeft: import("styled-components").IStyledComponent<"web", {
|
|
2
2
|
ref?: import("react").LegacyRef<HTMLDivElement>;
|
|
3
3
|
key?: import("react").Key | null | undefined;
|
|
4
4
|
defaultChecked?: boolean | undefined;
|
|
5
|
-
defaultValue?: string | number |
|
|
5
|
+
defaultValue?: string | number | readonly string[] | undefined;
|
|
6
6
|
suppressContentEditableWarning?: boolean | undefined;
|
|
7
7
|
suppressHydrationWarning?: boolean | undefined;
|
|
8
8
|
accessKey?: string | undefined;
|
|
9
|
+
autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {});
|
|
9
10
|
autoFocus?: boolean | undefined;
|
|
10
11
|
className?: string | undefined;
|
|
11
12
|
contentEditable?: (boolean | "true" | "false") | "inherit" | undefined;
|
|
@@ -36,7 +37,6 @@ export declare const ExplorerWrapper: import("styled-components").IStyledCompone
|
|
|
36
37
|
rev?: string | undefined;
|
|
37
38
|
typeof?: string | undefined;
|
|
38
39
|
vocab?: string | undefined;
|
|
39
|
-
autoCapitalize?: string | undefined;
|
|
40
40
|
autoCorrect?: string | undefined;
|
|
41
41
|
autoSave?: string | undefined;
|
|
42
42
|
color?: string | undefined;
|
|
@@ -50,55 +50,57 @@ export declare const ExplorerWrapper: import("styled-components").IStyledCompone
|
|
|
50
50
|
unselectable?: "on" | "off" | undefined;
|
|
51
51
|
inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined;
|
|
52
52
|
is?: string | undefined;
|
|
53
|
+
exportparts?: string | undefined;
|
|
54
|
+
part?: string | undefined;
|
|
53
55
|
children?: import("react").ReactNode;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
56
|
+
"aria-activedescendant"?: string | undefined;
|
|
57
|
+
"aria-atomic"?: boolean | "false" | "true" | undefined;
|
|
58
|
+
"aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;
|
|
59
|
+
"aria-busy"?: boolean | "false" | "true" | undefined;
|
|
60
|
+
"aria-checked"?: boolean | "false" | "mixed" | "true" | undefined;
|
|
61
|
+
"aria-colcount"?: number | undefined;
|
|
62
|
+
"aria-colindex"?: number | undefined;
|
|
63
|
+
"aria-colspan"?: number | undefined;
|
|
64
|
+
"aria-controls"?: string | undefined;
|
|
65
|
+
"aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined;
|
|
66
|
+
"aria-describedby"?: string | undefined;
|
|
67
|
+
"aria-details"?: string | undefined;
|
|
68
|
+
"aria-disabled"?: boolean | "false" | "true" | undefined;
|
|
69
|
+
"aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined;
|
|
70
|
+
"aria-errormessage"?: string | undefined;
|
|
71
|
+
"aria-expanded"?: boolean | "false" | "true" | undefined;
|
|
72
|
+
"aria-flowto"?: string | undefined;
|
|
73
|
+
"aria-grabbed"?: boolean | "false" | "true" | undefined;
|
|
74
|
+
"aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined;
|
|
75
|
+
"aria-hidden"?: boolean | "false" | "true" | undefined;
|
|
76
|
+
"aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
|
|
77
|
+
"aria-keyshortcuts"?: string | undefined;
|
|
78
|
+
"aria-label"?: string | undefined;
|
|
79
|
+
"aria-labelledby"?: string | undefined;
|
|
80
|
+
"aria-level"?: number | undefined;
|
|
81
|
+
"aria-live"?: "off" | "assertive" | "polite" | undefined;
|
|
82
|
+
"aria-modal"?: boolean | "false" | "true" | undefined;
|
|
83
|
+
"aria-multiline"?: boolean | "false" | "true" | undefined;
|
|
84
|
+
"aria-multiselectable"?: boolean | "false" | "true" | undefined;
|
|
85
|
+
"aria-orientation"?: "horizontal" | "vertical" | undefined;
|
|
86
|
+
"aria-owns"?: string | undefined;
|
|
87
|
+
"aria-placeholder"?: string | undefined;
|
|
88
|
+
"aria-posinset"?: number | undefined;
|
|
89
|
+
"aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined;
|
|
90
|
+
"aria-readonly"?: boolean | "false" | "true" | undefined;
|
|
91
|
+
"aria-relevant"?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined;
|
|
92
|
+
"aria-required"?: boolean | "false" | "true" | undefined;
|
|
93
|
+
"aria-roledescription"?: string | undefined;
|
|
94
|
+
"aria-rowcount"?: number | undefined;
|
|
95
|
+
"aria-rowindex"?: number | undefined;
|
|
96
|
+
"aria-rowspan"?: number | undefined;
|
|
97
|
+
"aria-selected"?: boolean | "false" | "true" | undefined;
|
|
98
|
+
"aria-setsize"?: number | undefined;
|
|
99
|
+
"aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
|
|
100
|
+
"aria-valuemax"?: number | undefined;
|
|
101
|
+
"aria-valuemin"?: number | undefined;
|
|
102
|
+
"aria-valuenow"?: number | undefined;
|
|
103
|
+
"aria-valuetext"?: string | undefined;
|
|
102
104
|
dangerouslySetInnerHTML?: {
|
|
103
105
|
__html: string | TrustedHTML;
|
|
104
106
|
} | undefined;
|
|
@@ -120,7 +122,7 @@ export declare const ExplorerWrapper: import("styled-components").IStyledCompone
|
|
|
120
122
|
onBlurCapture?: import("react").FocusEventHandler<HTMLDivElement>;
|
|
121
123
|
onChange?: import("react").FormEventHandler<HTMLDivElement>;
|
|
122
124
|
onChangeCapture?: import("react").FormEventHandler<HTMLDivElement>;
|
|
123
|
-
onBeforeInput?: import("react").
|
|
125
|
+
onBeforeInput?: import("react").InputEventHandler<HTMLDivElement>;
|
|
124
126
|
onBeforeInputCapture?: import("react").FormEventHandler<HTMLDivElement>;
|
|
125
127
|
onInput?: import("react").FormEventHandler<HTMLDivElement>;
|
|
126
128
|
onInputCapture?: import("react").FormEventHandler<HTMLDivElement>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
2
2
|
// This file is released under LGPL V3
|
|
3
3
|
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
4
|
-
import { KitButton } from 'aristid-ds';
|
|
5
4
|
import styled from 'styled-components';
|
|
6
|
-
export const
|
|
7
|
-
margin-
|
|
5
|
+
export const InputExtraAlignLeft = styled.div `
|
|
6
|
+
margin-right: auto;
|
|
7
|
+
line-height: 12px;
|
|
8
8
|
`;
|
|
9
|
-
//# sourceMappingURL=
|
|
9
|
+
//# sourceMappingURL=InputExtraAlignLeft.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InputExtraAlignLeft.js","sourceRoot":"","sources":["../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/InputExtraAlignLeft.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAG5C,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 styled from 'styled-components';\n\nexport const InputExtraAlignLeft = styled.div`\n margin-right: auto;\n line-height: 12px;\n`;\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const InputWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("aristid-ds/dist/Kit/DataEntry/InputWrapper/types").IKitInputWrapper & import("react").RefAttributes<HTMLDivElement>, {
|
|
2
|
+
$readonlyBackground: boolean;
|
|
3
|
+
}>> & import("react").ForwardRefExoticComponent<import("aristid-ds/dist/Kit/DataEntry/InputWrapper/types").IKitInputWrapper & import("react").RefAttributes<HTMLDivElement>>;
|
package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/InputWrapper.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
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 { KitInputWrapper } from 'aristid-ds';
|
|
5
|
+
import styled, { css } from 'styled-components';
|
|
6
|
+
export const InputWrapper = styled(KitInputWrapper) `
|
|
7
|
+
${props => props.$readonlyBackground &&
|
|
8
|
+
css `
|
|
9
|
+
.kit-input-wrapper-content {
|
|
10
|
+
background-color: var(--general-utilities-neutral-light);
|
|
11
|
+
}
|
|
12
|
+
`}
|
|
13
|
+
|
|
14
|
+
&.disabled {
|
|
15
|
+
.kit-input-wrapper-content {
|
|
16
|
+
background-color: var(--general-utilities-neutral-light);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&.error:not(.disabled) {
|
|
21
|
+
.kit-input-wrapper-content {
|
|
22
|
+
background-color: var(--general-utilities-error-light);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.ant-empty-image,
|
|
27
|
+
.ant-empty-description {
|
|
28
|
+
display: none;
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
//# sourceMappingURL=InputWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InputWrapper.js","sourceRoot":"","sources":["../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/InputWrapper.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAC3C,OAAO,MAAM,EAAE,EAAC,GAAG,EAAC,MAAM,mBAAmB,CAAC;AAE9C,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,eAAe,CAAC,CAAgC;MAC7E,KAAK,CAAC,EAAE,CACN,KAAK,CAAC,mBAAmB;IACzB,GAAG,CAAA;;;;SAIF;;;;;;;;;;;;;;;;;;CAkBR,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 {KitInputWrapper} from 'aristid-ds';\nimport styled, {css} from 'styled-components';\n\nexport const InputWrapper = styled(KitInputWrapper)<{$readonlyBackground: boolean}>`\n ${props =>\n props.$readonlyBackground &&\n css`\n .kit-input-wrapper-content {\n background-color: var(--general-utilities-neutral-light);\n }\n `}\n\n &.disabled {\n .kit-input-wrapper-content {\n background-color: var(--general-utilities-neutral-light);\n }\n }\n\n &.error:not(.disabled) {\n .kit-input-wrapper-content {\n background-color: var(--general-utilities-error-light);\n }\n }\n\n .ant-empty-image,\n .ant-empty-description {\n display: none;\n }\n`;\n"]}
|
package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/Wrapper.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
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 styled from 'styled-components';
|
|
5
|
+
export const Wrapper = styled.div `
|
|
6
|
+
margin-bottom: ${props => (props.$metadataEdit ? 0 : '1.5em')};
|
|
7
|
+
`;
|
|
8
|
+
//# sourceMappingURL=Wrapper.js.map
|
package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/Wrapper.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Wrapper.js","sourceRoot":"","sources":["../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/Wrapper.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAA0B;qBACtC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;CAChE,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 styled from 'styled-components';\n\nexport const Wrapper = styled.div<{$metadataEdit: boolean}>`\n margin-bottom: ${props => (props.$metadataEdit ? 0 : '1.5em')};\n`;\n"]}
|
package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/LinkFieldTags.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
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 { useState } from 'react';
|
|
6
|
+
import { AntForm, KitIdCard, KitSpace, KitTag } from 'aristid-ds';
|
|
7
|
+
import { LINK_FIELD_ID_PREFIX } from '../../../../../../constants';
|
|
8
|
+
import { localizedTranslation } from '@leav/utils';
|
|
9
|
+
import { useLang } from '../../../../../../hooks';
|
|
10
|
+
import { ComputeIndicator } from '../../shared/ComputeIndicator';
|
|
11
|
+
import { computeCalculatedFlags, computeInheritedFlags } from '../../shared/calculatedInheritedFlags';
|
|
12
|
+
import { useUnlinkAllRecords } from '../unlink-all-records/useUnlinkAllRecords';
|
|
13
|
+
import { useUnlinkRecord } from './unlink-record/useUnlinkRecord';
|
|
14
|
+
import { useLinkRecord } from './link-record/useLinkRecord';
|
|
15
|
+
import { Wrapper } from '../shared/Wrapper';
|
|
16
|
+
import { InputExtraAlignLeft } from '../shared/InputExtraAlignLeft';
|
|
17
|
+
import { InputWrapper } from '../shared/InputWrapper';
|
|
18
|
+
export const LinkFieldTags = ({ element, readonly, onValueSubmit, onValueDelete, onDeleteMultipleValues, metadataEdit = false, }) => {
|
|
19
|
+
const { lang } = useLang();
|
|
20
|
+
const { settings, attribute, joinLibraryContext, } = element;
|
|
21
|
+
const [backendValues, setBackendValues] = useState(element.values);
|
|
22
|
+
const calculatedFlags = computeCalculatedFlags(backendValues);
|
|
23
|
+
const inheritedFlags = computeInheritedFlags(backendValues);
|
|
24
|
+
const label = localizedTranslation(settings.label, lang);
|
|
25
|
+
const form = AntForm.useFormInstance();
|
|
26
|
+
const fieldErrors = form.getFieldError(attribute.id);
|
|
27
|
+
const isFieldInError = fieldErrors.length > 0;
|
|
28
|
+
// TODO: Temporary const that should be removed (and all it's usages) when we will have a proper way to override multiple values
|
|
29
|
+
const tmpCantOverrideValues = attribute.multiple_values &&
|
|
30
|
+
(calculatedFlags.calculatedValues?.length > 1 || inheritedFlags.inheritedValues?.length > 1);
|
|
31
|
+
const isReadOnly = attribute.readonly || !attribute.permissions.edit_value || readonly || tmpCantOverrideValues;
|
|
32
|
+
const { UnlinkAllRecordsButton } = useUnlinkAllRecords({
|
|
33
|
+
attribute,
|
|
34
|
+
backendValues,
|
|
35
|
+
setBackendValues,
|
|
36
|
+
onDeleteMultipleValues,
|
|
37
|
+
isReadOnly,
|
|
38
|
+
isFieldInError,
|
|
39
|
+
});
|
|
40
|
+
const { canUnlinkRecord, unlinkRecord } = useUnlinkRecord({
|
|
41
|
+
attribute,
|
|
42
|
+
backendValues,
|
|
43
|
+
isReadOnly,
|
|
44
|
+
setBackendValues,
|
|
45
|
+
onValueDelete,
|
|
46
|
+
});
|
|
47
|
+
const { LinkRecordButton } = useLinkRecord({
|
|
48
|
+
attribute,
|
|
49
|
+
isReadOnly,
|
|
50
|
+
onValueSubmit,
|
|
51
|
+
backendValues,
|
|
52
|
+
setBackendValues,
|
|
53
|
+
joinLibraryContext,
|
|
54
|
+
});
|
|
55
|
+
return (_jsx(Wrapper, { "$metadataEdit": metadataEdit, children: _jsx(AntForm.Item, { name: attribute.id, noStyle: true, children: _jsx(InputWrapper, { id: LINK_FIELD_ID_PREFIX + attribute.id, label: label, required: attribute.required, bordered: true, status: isFieldInError ? 'error' : undefined, helper: isFieldInError ? String(fieldErrors[0]) : undefined, extra: _jsxs(_Fragment, { children: [_jsx(InputExtraAlignLeft, { children: _jsx(ComputeIndicator, { calculatedFlags: calculatedFlags, inheritedFlags: inheritedFlags }) }), UnlinkAllRecordsButton] }), "$readonlyBackground": isReadOnly, children: _jsxs(KitSpace, { direction: "vertical", children: [_jsx(KitSpace, { direction: "horizontal", size: "xxs", wrap: true, children: backendValues.map(value => (_jsx(KitTag, { type: "secondary", onClose: canUnlinkRecord ? () => unlinkRecord(value.id_value) : undefined, children: _jsx(KitIdCard, { description: value.linkValue.whoAmI?.label }) }, value.id_value))) }), LinkRecordButton] }) }) }) }));
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=LinkFieldTags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkFieldTags.js","sourceRoot":"","sources":["../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/LinkFieldTags.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,QAAQ,EAAyB,MAAM,OAAO,CAAC;AAGvD,OAAO,EAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAC,MAAM,YAAY,CAAC;AAChE,OAAO,EAAC,oBAAoB,EAAC,MAAM,eAAe,CAAC;AACnD,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAC,sBAAsB,EAAE,qBAAqB,EAAC,MAAM,uCAAuC,CAAC;AACpG,OAAO,EAAC,mBAAmB,EAAC,MAAM,2CAA2C,CAAC;AAC9E,OAAO,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAC,aAAa,EAAC,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAC,mBAAmB,EAAC,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAEpD,M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C,SAAS,CAAC,MAAM,EAAE,KAAK,GAAI,IAJpD,KAAK,CAAC,QAAQ,CAKd,CACZ,CAAC,GACK,EACV,gBAAgB,IACV,GACA,GACJ,GACT,CACb,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {useState, type FunctionComponent} from 'react';\nimport {type LinkFieldProps} from '../_types';\nimport {type JoinLibraryContextFragment, type RecordFormAttributeLinkAttributeFragment} from '_ui/_gqlTypes';\nimport {AntForm, KitIdCard, KitSpace, KitTag} from 'aristid-ds';\nimport {LINK_FIELD_ID_PREFIX} from '_ui/constants';\nimport {localizedTranslation} from '@leav/utils';\nimport {useLang} from '_ui/hooks';\nimport {ComputeIndicator} from '../../shared/ComputeIndicator';\nimport {type RecordFormElementsValueLinkValue} from '_ui/hooks/useGetRecordForm';\nimport {computeCalculatedFlags, computeInheritedFlags} from '../../shared/calculatedInheritedFlags';\nimport {useUnlinkAllRecords} from '../unlink-all-records/useUnlinkAllRecords';\nimport {useUnlinkRecord} from './unlink-record/useUnlinkRecord';\nimport {useLinkRecord} from './link-record/useLinkRecord';\nimport {Wrapper} from '../shared/Wrapper';\nimport {InputExtraAlignLeft} from '../shared/InputExtraAlignLeft';\nimport {InputWrapper} from '../shared/InputWrapper';\n\nexport const LinkFieldTags: FunctionComponent<LinkFieldProps> = ({\n element,\n readonly,\n onValueSubmit,\n onValueDelete,\n onDeleteMultipleValues,\n metadataEdit = false,\n}) => {\n const {lang} = useLang();\n\n const {\n settings,\n attribute,\n joinLibraryContext,\n }: {\n settings: typeof element.settings;\n attribute?: RecordFormAttributeLinkAttributeFragment;\n joinLibraryContext?: JoinLibraryContextFragment;\n } = element;\n\n const [backendValues, setBackendValues] = useState<RecordFormElementsValueLinkValue[]>(element.values);\n\n const calculatedFlags = computeCalculatedFlags(backendValues);\n const inheritedFlags = computeInheritedFlags(backendValues);\n const label = localizedTranslation(settings.label, lang);\n const form = AntForm.useFormInstance();\n const fieldErrors = form.getFieldError(attribute.id);\n\n const isFieldInError = fieldErrors.length > 0;\n\n // TODO: Temporary const that should be removed (and all it's usages) when we will have a proper way to override multiple values\n const tmpCantOverrideValues =\n attribute.multiple_values &&\n (calculatedFlags.calculatedValues?.length > 1 || inheritedFlags.inheritedValues?.length > 1);\n const isReadOnly = attribute.readonly || !attribute.permissions.edit_value || readonly || tmpCantOverrideValues;\n\n const {UnlinkAllRecordsButton} = useUnlinkAllRecords({\n attribute,\n backendValues,\n setBackendValues,\n onDeleteMultipleValues,\n isReadOnly,\n isFieldInError,\n });\n\n const {canUnlinkRecord, unlinkRecord} = useUnlinkRecord({\n attribute,\n backendValues,\n isReadOnly,\n setBackendValues,\n onValueDelete,\n });\n\n const {LinkRecordButton} = useLinkRecord({\n attribute,\n isReadOnly,\n onValueSubmit,\n backendValues,\n setBackendValues,\n joinLibraryContext,\n });\n\n return (\n <Wrapper $metadataEdit={metadataEdit}>\n <AntForm.Item name={attribute.id} noStyle>\n <InputWrapper\n id={LINK_FIELD_ID_PREFIX + attribute.id}\n label={label}\n required={attribute.required}\n bordered\n status={isFieldInError ? 'error' : undefined}\n helper={isFieldInError ? String(fieldErrors[0]) : undefined}\n extra={\n <>\n <InputExtraAlignLeft>\n <ComputeIndicator calculatedFlags={calculatedFlags} inheritedFlags={inheritedFlags} />\n </InputExtraAlignLeft>\n {UnlinkAllRecordsButton}\n </>\n }\n $readonlyBackground={isReadOnly}\n >\n <KitSpace direction=\"vertical\">\n <KitSpace direction=\"horizontal\" size=\"xxs\" wrap>\n {backendValues.map(value => (\n <KitTag\n key={value.id_value}\n type=\"secondary\"\n onClose={canUnlinkRecord ? () => unlinkRecord(value.id_value) : undefined}\n >\n <KitIdCard description={value.linkValue.whoAmI?.label} />\n </KitTag>\n ))}\n </KitSpace>\n {LinkRecordButton}\n </KitSpace>\n </InputWrapper>\n </AntForm.Item>\n </Wrapper>\n );\n};\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type JoinLibraryContextFragment, type RecordFormAttributeLinkAttributeFragment } from '../../../../../../../_gqlTypes';
|
|
2
|
+
import { type SubmitValueFunc } from '../../../../../../../components/RecordEdition/EditRecordContent/_types';
|
|
3
|
+
import { type Dispatch, type SetStateAction } from 'react';
|
|
4
|
+
import { type RecordFormElementsValueLinkValue } from '../../../../../../../hooks/useGetRecordForm';
|
|
5
|
+
interface IUseLinkRecordProps {
|
|
6
|
+
attribute: RecordFormAttributeLinkAttributeFragment;
|
|
7
|
+
isReadOnly: boolean;
|
|
8
|
+
onValueSubmit: SubmitValueFunc;
|
|
9
|
+
backendValues: RecordFormElementsValueLinkValue[];
|
|
10
|
+
setBackendValues: Dispatch<SetStateAction<RecordFormElementsValueLinkValue[]>>;
|
|
11
|
+
joinLibraryContext?: JoinLibraryContextFragment;
|
|
12
|
+
}
|
|
13
|
+
export declare const useLinkRecord: ({ attribute, isReadOnly, onValueSubmit, backendValues, setBackendValues, joinLibraryContext, }: IUseLinkRecordProps) => {
|
|
14
|
+
LinkRecordButton: JSX.Element;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
3
|
+
// This file is released under LGPL V3
|
|
4
|
+
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
5
|
+
import { faPlus } from '@fortawesome/free-solid-svg-icons';
|
|
6
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
7
|
+
import { LINK_RECORDS_MODAL_CLASSNAME } from '../../../../../../../components/Explorer/_constants';
|
|
8
|
+
import { APICallStatus, } from '../../../../../../../components/RecordEdition/EditRecordContent/_types';
|
|
9
|
+
import { SelectRecordForLinkModal } from '../../../../../../../components/SelectRecordForLinkModal';
|
|
10
|
+
import { TOOLTIP_DEFAULT_DELAY_IN_SECONDS } from '../../../../../../../constants';
|
|
11
|
+
import { AntForm, KitButton, KitTooltip } from 'aristid-ds';
|
|
12
|
+
import { useState } from 'react';
|
|
13
|
+
import { useSharedTranslation } from '../../../../../../../hooks/useSharedTranslation';
|
|
14
|
+
import { SelectTreeNodeModal } from '../../../TreeField/manage-tree-node-selection/SelectTreeNodeModal';
|
|
15
|
+
export const useLinkRecord = ({ attribute, isReadOnly, onValueSubmit, backendValues, setBackendValues, joinLibraryContext, }) => {
|
|
16
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
17
|
+
const { t } = useSharedTranslation();
|
|
18
|
+
const antdForm = AntForm.useFormInstance();
|
|
19
|
+
const _buildValueToSubmit = (recordId) => ({
|
|
20
|
+
id: recordId,
|
|
21
|
+
whoAmI: { id: recordId, library: { id: attribute.linked_library?.id } },
|
|
22
|
+
});
|
|
23
|
+
const _handleLinkRecord = async (data) => {
|
|
24
|
+
let submitRes;
|
|
25
|
+
if (attribute.multiple_values) {
|
|
26
|
+
submitRes = await onValueSubmit(data.records.list.map(record => ({ value: _buildValueToSubmit(record.id), idValue: null, attribute })), null);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
submitRes = await onValueSubmit([
|
|
30
|
+
{
|
|
31
|
+
value: _buildValueToSubmit(data.records.list[0].id),
|
|
32
|
+
idValue: backendValues[0]?.id_value ?? null,
|
|
33
|
+
attribute,
|
|
34
|
+
},
|
|
35
|
+
], null);
|
|
36
|
+
}
|
|
37
|
+
if (submitRes.status === APICallStatus.SUCCESS) {
|
|
38
|
+
const linkValues = submitRes.values;
|
|
39
|
+
if (attribute.multiple_values) {
|
|
40
|
+
setBackendValues(previousBackendValues => [...previousBackendValues, ...linkValues]);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
setBackendValues([linkValues[0]]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (submitRes.status === APICallStatus.ERROR) {
|
|
47
|
+
antdForm.setFields([
|
|
48
|
+
{
|
|
49
|
+
name: attribute.id,
|
|
50
|
+
errors: [submitRes.error],
|
|
51
|
+
},
|
|
52
|
+
]);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const isReplacementMode = backendValues.length > 0 && !attribute.multiple_values;
|
|
56
|
+
const linkedLibraryId = joinLibraryContext &&
|
|
57
|
+
'linked_library' in joinLibraryContext.mandatoryAttribute &&
|
|
58
|
+
joinLibraryContext.mandatoryAttribute.linked_library?.id;
|
|
59
|
+
const linkedTreeId = joinLibraryContext &&
|
|
60
|
+
'linked_tree' in joinLibraryContext.mandatoryAttribute &&
|
|
61
|
+
joinLibraryContext.mandatoryAttribute.linked_tree?.id;
|
|
62
|
+
return {
|
|
63
|
+
LinkRecordButton: !isReadOnly ? (_jsxs(_Fragment, { children: [_jsx(KitTooltip, { title: isReplacementMode ? t('global.replace') : t('global.add'), mouseEnterDelay: TOOLTIP_DEFAULT_DELAY_IN_SECONDS, children: _jsx(KitButton, { type: "secondary", size: "m", icon: _jsx(FontAwesomeIcon, { icon: faPlus }), onClick: () => {
|
|
64
|
+
setIsModalOpen(true);
|
|
65
|
+
} }) }), linkedTreeId ? (_jsx(SelectTreeNodeModal, { open: isModalOpen, attribute: {
|
|
66
|
+
multiple_values: attribute.multiple_values,
|
|
67
|
+
linked_tree: {
|
|
68
|
+
id: linkedTreeId,
|
|
69
|
+
},
|
|
70
|
+
}, title: t(attribute.multiple_values ? 'tree-node-selection.title_many' : 'tree-node-selection.title'),
|
|
71
|
+
// We can select new node(s), ignoring current value(s).
|
|
72
|
+
// Selected element might be duplicated in link attribute in backend for now.
|
|
73
|
+
backendValues: [], onClose: () => setIsModalOpen(false), onConfirm: async (selectedNodes) => {
|
|
74
|
+
const nodeIds = selectedNodes.map(node => node.id);
|
|
75
|
+
await _handleLinkRecord({ records: { list: nodeIds.map(id => ({ id })) } });
|
|
76
|
+
} })) : (_jsx(SelectRecordForLinkModal, { className: LINK_RECORDS_MODAL_CLASSNAME, open: isModalOpen, childLibraryId: linkedLibraryId || attribute.linked_library?.id, onSelectionCompleted: async (data) => {
|
|
77
|
+
await _handleLinkRecord(data);
|
|
78
|
+
setIsModalOpen(false);
|
|
79
|
+
}, columnsToDisplay: [], replacementMode: isReplacementMode, selectionMode: !attribute.multiple_values ? 'simple' : 'multiple', hideSelectAllAction: !attribute.multiple_values, valuesList: attribute.linkValuesList?.values?.map(value => value.id), allowFreeEntry: attribute.linkValuesList?.allowFreeEntry, isMultivalue: attribute.multiple_values, onClose: () => setIsModalOpen(false), joinLibraryContext: joinLibraryContext }))] })) : undefined,
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=useLinkRecord.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLinkRecord.js","sourceRoot":"","sources":["../../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/link-record/useLinkRecord.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AACzD,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAM/D,OAAO,EAAC,4BAA4B,EAAC,MAAM,oCAAoC,CAAC;AAChF,OAAO,EACH,aAAa,GAGhB,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAC,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAC,gCAAgC,EAAC,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAC,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAqC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAEnE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,mBAAmB,EAAC,MAAM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AK,CAAC,CAAC;oBAC1B,CAAC,EACD,gBAAgB,EAAE,EAAE,EACpB,eAAe,EAAE,iBAAiB,EAClC,aAAa,EAAE,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,EACjE,mBAAmB,EAAE,CAAC,SAAS,CAAC,eAAe,EAC/C,UAAU,EAAE,SAAS,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,EACpE,cAAc,EAAE,SAAS,CAAC,cAAc,EAAE,cAAc,EACxD,YAAY,EAAE,SAAS,CAAC,eAAe,EACvC,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,EACpC,kBAAkB,EAAE,kBAAkB,GACxC,CACL,IACF,CACN,CAAC,CAAC,CAAC,SAAS;KAChB,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 {faPlus} from '@fortawesome/free-solid-svg-icons';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {\n type JoinLibraryContextFragment,\n type ExplorerSelectionIdsQuery,\n type RecordFormAttributeLinkAttributeFragment,\n} from '_ui/_gqlTypes';\nimport {LINK_RECORDS_MODAL_CLASSNAME} from '_ui/components/Explorer/_constants';\nimport {\n APICallStatus,\n type ISubmitMultipleResult,\n type SubmitValueFunc,\n} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {SelectRecordForLinkModal} from '_ui/components/SelectRecordForLinkModal';\nimport {TOOLTIP_DEFAULT_DELAY_IN_SECONDS} from '_ui/constants';\nimport {AntForm, KitButton, KitTooltip} from 'aristid-ds';\nimport {type Dispatch, type SetStateAction, useState} from 'react';\nimport {type RecordFormElementsValueLinkValue} from '_ui/hooks/useGetRecordForm';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {SelectTreeNodeModal} from '../../../TreeField/manage-tree-node-selection/SelectTreeNodeModal';\n\ninterface IUseLinkRecordProps {\n attribute: RecordFormAttributeLinkAttributeFragment;\n isReadOnly: boolean;\n onValueSubmit: SubmitValueFunc;\n backendValues: RecordFormElementsValueLinkValue[];\n setBackendValues: Dispatch<SetStateAction<RecordFormElementsValueLinkValue[]>>;\n joinLibraryContext?: JoinLibraryContextFragment;\n}\n\nexport const useLinkRecord = ({\n attribute,\n isReadOnly,\n onValueSubmit,\n backendValues,\n setBackendValues,\n joinLibraryContext,\n}: IUseLinkRecordProps) => {\n const [isModalOpen, setIsModalOpen] = useState(false);\n const {t} = useSharedTranslation();\n const antdForm = AntForm.useFormInstance();\n\n const _buildValueToSubmit = (recordId: string) => ({\n id: recordId,\n whoAmI: {id: recordId, library: {id: attribute.linked_library?.id}},\n });\n\n const _handleLinkRecord = async (data: ExplorerSelectionIdsQuery) => {\n let submitRes: ISubmitMultipleResult;\n\n if (attribute.multiple_values) {\n submitRes = await onValueSubmit(\n data.records.list.map(record => ({value: _buildValueToSubmit(record.id), idValue: null, attribute})),\n null,\n );\n } else {\n submitRes = await onValueSubmit(\n [\n {\n value: _buildValueToSubmit(data.records.list[0].id),\n idValue: backendValues[0]?.id_value ?? null,\n attribute,\n },\n ],\n null,\n );\n }\n\n if (submitRes.status === APICallStatus.SUCCESS) {\n const linkValues = submitRes.values as unknown as RecordFormElementsValueLinkValue[];\n\n if (attribute.multiple_values) {\n setBackendValues(previousBackendValues => [...previousBackendValues, ...linkValues]);\n } else {\n setBackendValues([linkValues[0]]);\n }\n }\n\n if (submitRes.status === APICallStatus.ERROR) {\n antdForm.setFields([\n {\n name: attribute.id,\n errors: [submitRes.error],\n },\n ]);\n }\n };\n\n const isReplacementMode = backendValues.length > 0 && !attribute.multiple_values;\n\n const linkedLibraryId =\n joinLibraryContext &&\n 'linked_library' in joinLibraryContext.mandatoryAttribute &&\n joinLibraryContext.mandatoryAttribute.linked_library?.id;\n\n const linkedTreeId =\n joinLibraryContext &&\n 'linked_tree' in joinLibraryContext.mandatoryAttribute &&\n joinLibraryContext.mandatoryAttribute.linked_tree?.id;\n\n return {\n LinkRecordButton: !isReadOnly ? (\n <>\n <KitTooltip\n title={isReplacementMode ? t('global.replace') : t('global.add')}\n mouseEnterDelay={TOOLTIP_DEFAULT_DELAY_IN_SECONDS}\n >\n <KitButton\n type=\"secondary\"\n size=\"m\"\n icon={<FontAwesomeIcon icon={faPlus} />}\n onClick={() => {\n setIsModalOpen(true);\n }}\n />\n </KitTooltip>\n {linkedTreeId ? (\n <SelectTreeNodeModal\n open={isModalOpen}\n attribute={{\n multiple_values: attribute.multiple_values,\n linked_tree: {\n id: linkedTreeId,\n },\n }}\n title={t(\n attribute.multiple_values ? 'tree-node-selection.title_many' : 'tree-node-selection.title',\n )}\n // We can select new node(s), ignoring current value(s).\n // Selected element might be duplicated in link attribute in backend for now.\n backendValues={[]}\n onClose={() => setIsModalOpen(false)}\n onConfirm={async selectedNodes => {\n const nodeIds = selectedNodes.map(node => node.id);\n await _handleLinkRecord({records: {list: nodeIds.map(id => ({id}))}});\n }}\n />\n ) : (\n <SelectRecordForLinkModal\n className={LINK_RECORDS_MODAL_CLASSNAME}\n open={isModalOpen}\n childLibraryId={linkedLibraryId || attribute.linked_library?.id}\n onSelectionCompleted={async data => {\n await _handleLinkRecord(data);\n setIsModalOpen(false);\n }}\n columnsToDisplay={[]} // TODO: One day, we should be able to choose the columns to display from a given viewId\n replacementMode={isReplacementMode}\n selectionMode={!attribute.multiple_values ? 'simple' : 'multiple'}\n hideSelectAllAction={!attribute.multiple_values}\n valuesList={attribute.linkValuesList?.values?.map(value => value.id)}\n allowFreeEntry={attribute.linkValuesList?.allowFreeEntry}\n isMultivalue={attribute.multiple_values}\n onClose={() => setIsModalOpen(false)}\n joinLibraryContext={joinLibraryContext}\n />\n )}\n </>\n ) : undefined,\n };\n};\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type DeleteValueFunc } from '../../../../../../../components/RecordEdition/EditRecordContent/_types';
|
|
2
|
+
import { type RecordFormAttributeLinkAttributeFragment } from '../../../../../../../_gqlTypes';
|
|
3
|
+
import { type RecordFormElementsValueLinkValue } from '../../../../../../../hooks/useGetRecordForm';
|
|
4
|
+
import { type Dispatch, type SetStateAction } from 'react';
|
|
5
|
+
interface IUseUnlinkRecordProps {
|
|
6
|
+
attribute: RecordFormAttributeLinkAttributeFragment;
|
|
7
|
+
backendValues: RecordFormElementsValueLinkValue[];
|
|
8
|
+
isReadOnly: boolean;
|
|
9
|
+
setBackendValues: Dispatch<SetStateAction<RecordFormElementsValueLinkValue[]>>;
|
|
10
|
+
onValueDelete: DeleteValueFunc;
|
|
11
|
+
}
|
|
12
|
+
export declare const useUnlinkRecord: ({ attribute, backendValues, isReadOnly, setBackendValues, onValueDelete, }: IUseUnlinkRecordProps) => {
|
|
13
|
+
canUnlinkRecord: boolean;
|
|
14
|
+
unlinkRecord: (idValue: string) => {
|
|
15
|
+
destroy: () => void;
|
|
16
|
+
update: (configUpdate: import("aristid-ds/dist/Kit/Feedback/Modal/types").ConfigUpdate) => void;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
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 { BREAK_TWO_LINES } from '../../../../../../../components/Explorer/_constants';
|
|
5
|
+
import { APICallStatus } from '../../../../../../../components/RecordEdition/EditRecordContent/_types';
|
|
6
|
+
import { useSharedTranslation } from '../../../../../../../hooks/useSharedTranslation';
|
|
7
|
+
import { AntForm, KitModal } from 'aristid-ds';
|
|
8
|
+
export const useUnlinkRecord = ({ attribute, backendValues, isReadOnly, setBackendValues, onValueDelete, }) => {
|
|
9
|
+
const { t } = useSharedTranslation();
|
|
10
|
+
const antdForm = AntForm.useFormInstance();
|
|
11
|
+
const handleUnlinkRecord = async (idValue) => {
|
|
12
|
+
const deleteRes = await onValueDelete({ id_value: idValue }, attribute.id);
|
|
13
|
+
if (deleteRes.status === APICallStatus.SUCCESS) {
|
|
14
|
+
setBackendValues(previousBackendValues => previousBackendValues.filter(backendValue => backendValue.id_value !== idValue));
|
|
15
|
+
}
|
|
16
|
+
if (deleteRes.status === APICallStatus.ERROR) {
|
|
17
|
+
antdForm.setFields([
|
|
18
|
+
{
|
|
19
|
+
name: attribute.id,
|
|
20
|
+
errors: [deleteRes.error],
|
|
21
|
+
},
|
|
22
|
+
]);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const canUnlinkRecord = !isReadOnly && (!attribute.required || (attribute.required && backendValues.length > 1));
|
|
26
|
+
return {
|
|
27
|
+
canUnlinkRecord,
|
|
28
|
+
unlinkRecord: (idValue) => KitModal.confirm({
|
|
29
|
+
width: '100%',
|
|
30
|
+
style: { content: { width: '90vw', maxWidth: '656px' } },
|
|
31
|
+
type: 'confirm',
|
|
32
|
+
icon: false,
|
|
33
|
+
title: t('record_edition.delete_link'),
|
|
34
|
+
content: t('record_edition.delete_link_description') + BREAK_TWO_LINES + t('global.are_you_sure'),
|
|
35
|
+
okText: t('global.confirm') ?? undefined,
|
|
36
|
+
cancelText: t('global.cancel') ?? undefined,
|
|
37
|
+
onOk: async () => {
|
|
38
|
+
await handleUnlinkRecord(idValue);
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=useUnlinkRecord.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUnlinkRecord.js","sourceRoot":"","sources":["../../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF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,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IAEjH,OAAO;QACH,eAAe;QACf,YAAY,EAAE,CAAC,OAAe,EAAE,EAAE,CAC9B,QAAQ,CAAC,OAAO,CAAC;YACb,KAAK,EAAE,MAAM;YACb,KAAK,EAAE,EAAC,OAAO,EAAE,EAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAC,EAAC;YACpD,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,KAAK;YACX,KAAK,EAAE,CAAC,CAAC,4BAA4B,CAAC;YACtC,OAAO,EAAE,CAAC,CAAC,wCAAwC,CAAC,GAAG,eAAe,GAAG,CAAC,CAAC,qBAAqB,CAAC;YACjG,MAAM,EAAE,CAAC,CAAC,gBAAgB,CAAC,IAAI,SAAS;YACxC,UAAU,EAAE,CAAC,CAAC,eAAe,CAAC,IAAI,SAAS;YAC3C,IAAI,EAAE,KAAK,IAAI,EAAE;gBACb,MAAM,kBAAkB,CAAC,OAAO,CAAC,CAAC;YACtC,CAAC;SACJ,CAAC;KACT,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 {BREAK_TWO_LINES} from '_ui/components/Explorer/_constants';\nimport {APICallStatus, type DeleteValueFunc} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {type RecordFormAttributeLinkAttributeFragment} from '_ui/_gqlTypes';\nimport {type RecordFormElementsValueLinkValue} from '_ui/hooks/useGetRecordForm';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {AntForm, KitModal} from 'aristid-ds';\nimport {type Dispatch, type SetStateAction} from 'react';\n\ninterface IUseUnlinkRecordProps {\n attribute: RecordFormAttributeLinkAttributeFragment;\n backendValues: RecordFormElementsValueLinkValue[];\n isReadOnly: boolean;\n setBackendValues: Dispatch<SetStateAction<RecordFormElementsValueLinkValue[]>>;\n onValueDelete: DeleteValueFunc;\n}\nexport const useUnlinkRecord = ({\n attribute,\n backendValues,\n isReadOnly,\n setBackendValues,\n onValueDelete,\n}: IUseUnlinkRecordProps) => {\n const {t} = useSharedTranslation();\n const antdForm = AntForm.useFormInstance();\n\n const handleUnlinkRecord = async (idValue: string) => {\n const deleteRes = await onValueDelete({id_value: idValue}, attribute.id);\n\n if (deleteRes.status === APICallStatus.SUCCESS) {\n setBackendValues(previousBackendValues =>\n previousBackendValues.filter(backendValue => backendValue.id_value !== idValue),\n );\n }\n\n if (deleteRes.status === APICallStatus.ERROR) {\n antdForm.setFields([\n {\n name: attribute.id,\n errors: [deleteRes.error],\n },\n ]);\n }\n };\n\n const canUnlinkRecord = !isReadOnly && (!attribute.required || (attribute.required && backendValues.length > 1));\n\n return {\n canUnlinkRecord,\n unlinkRecord: (idValue: string) =>\n KitModal.confirm({\n width: '100%',\n style: {content: {width: '90vw', maxWidth: '656px'}},\n type: 'confirm',\n icon: false,\n title: t('record_edition.delete_link'),\n content: t('record_edition.delete_link_description') + BREAK_TWO_LINES + t('global.are_you_sure'),\n okText: t('global.confirm') ?? undefined,\n cancelText: t('global.cancel') ?? undefined,\n onOk: async () => {\n await handleUnlinkRecord(idValue);\n },\n }),\n };\n};\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Dispatch, type SetStateAction } from 'react';
|
|
2
|
+
import { type RecordFormAttributeLinkAttributeFragment } from '../../../../../../_gqlTypes';
|
|
3
|
+
import { type RecordFormElementsValueLinkValue } from '../../../../../../hooks/useGetRecordForm';
|
|
4
|
+
import { type DeleteMultipleValuesFunc } from '../../../_types';
|
|
5
|
+
interface IUseUnlinkAllRecordsProps {
|
|
6
|
+
attribute: RecordFormAttributeLinkAttributeFragment;
|
|
7
|
+
backendValues: RecordFormElementsValueLinkValue[];
|
|
8
|
+
setBackendValues: Dispatch<SetStateAction<RecordFormElementsValueLinkValue[]>>;
|
|
9
|
+
onDeleteMultipleValues: DeleteMultipleValuesFunc;
|
|
10
|
+
isReadOnly: boolean;
|
|
11
|
+
isFieldInError: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare const useUnlinkAllRecords: ({ attribute, backendValues, setBackendValues, onDeleteMultipleValues, isReadOnly, isFieldInError, }: IUseUnlinkAllRecordsProps) => {
|
|
14
|
+
UnlinkAllRecordsButton: JSX.Element;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AntForm } from 'aristid-ds';
|
|
3
|
+
import { useSharedTranslation } from '../../../../../../hooks/useSharedTranslation';
|
|
4
|
+
import { APICallStatus } from '../../../_types';
|
|
5
|
+
import { DeleteAllValuesButton } from '../../shared/DeleteAllValuesButton';
|
|
6
|
+
export const useUnlinkAllRecords = ({ attribute, backendValues, setBackendValues, onDeleteMultipleValues, isReadOnly, isFieldInError, }) => {
|
|
7
|
+
const { t } = useSharedTranslation();
|
|
8
|
+
const form = AntForm.useFormInstance();
|
|
9
|
+
const handleDeleteAllValues = async () => {
|
|
10
|
+
const deleteRes = await onDeleteMultipleValues(attribute.id, backendValues.filter(backendValue => backendValue.id_value), null);
|
|
11
|
+
if (deleteRes.status === APICallStatus.SUCCESS) {
|
|
12
|
+
form.setFieldValue(attribute.id, []);
|
|
13
|
+
form.setFields([
|
|
14
|
+
{
|
|
15
|
+
name: attribute.id,
|
|
16
|
+
errors: attribute.required ? [t('errors.standard_field_required')] : [],
|
|
17
|
+
},
|
|
18
|
+
]);
|
|
19
|
+
setBackendValues([]);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const shouldDisplayUnlinkAll = !isReadOnly && backendValues.length > 1 && attribute.multiple_values && !attribute.required;
|
|
23
|
+
return {
|
|
24
|
+
UnlinkAllRecordsButton: shouldDisplayUnlinkAll && (_jsx(DeleteAllValuesButton, { handleDelete: handleDeleteAllValues, disabled: isReadOnly, danger: isFieldInError })),
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=useUnlinkAllRecords.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUnlinkAllRecords.js","sourceRoot":"","sources":["../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/unlink-all-records/useUnlinkAllRecords.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AACnC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAGpE,OAAO,EAAC,aAAa,EAAgC,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAC,qBAAqB,EAAC,MAAM,oCAAoC,CAAC;AAWzE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAChC,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,UAAU,EACV,cAAc,GACU,EAAE,EAAE;IAC5B,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,IAAI,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAEvC,MAAM,qBAAqB,GAAG,KAAK,IAAI,EAAE;QACrC,MAAM,SAAS,GAAG,MAAM,sBAAsB,CAC1C,SAAS,CAAC,EAAE,EACZ,aAAa,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,EAC3D,IAAI,CACP,CAAC;QAEF,IAAI,SAAS,CAAC,MAAM,KAAK,aAAa,CAAC,OAAO,EAAE,CAAC;YAC7C,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YACrC,IAAI,CAAC,SAAS,CAAC;gBACX;oBACI,IAAI,EAAE,SAAS,CAAC,EAAE;oBAClB,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;iBAC1E;aACJ,CAAC,CAAC;YACH,gBAAgB,CAAC,EAAE,CAAC,CAAC;QACzB,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,sBAAsB,GACxB,CAAC,UAAU,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,eAAe,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;IAEhG,OAAO;QACH,sBAAsB,EAAE,sBAAsB,IAAI,CAC9C,KAAC,qBAAqB,IAAC,YAAY,EAAE,qBAAqB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,GAAI,CAC/G;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 {type Dispatch, type SetStateAction} from 'react';\nimport {AntForm} from 'aristid-ds';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type RecordFormAttributeLinkAttributeFragment} from '_ui/_gqlTypes';\nimport {type RecordFormElementsValueLinkValue} from '_ui/hooks/useGetRecordForm';\nimport {APICallStatus, type DeleteMultipleValuesFunc} from '../../../_types';\nimport {DeleteAllValuesButton} from '../../shared/DeleteAllValuesButton';\n\ninterface IUseUnlinkAllRecordsProps {\n attribute: RecordFormAttributeLinkAttributeFragment;\n backendValues: RecordFormElementsValueLinkValue[];\n setBackendValues: Dispatch<SetStateAction<RecordFormElementsValueLinkValue[]>>;\n onDeleteMultipleValues: DeleteMultipleValuesFunc;\n isReadOnly: boolean;\n isFieldInError: boolean;\n}\n\nexport const useUnlinkAllRecords = ({\n attribute,\n backendValues,\n setBackendValues,\n onDeleteMultipleValues,\n isReadOnly,\n isFieldInError,\n}: IUseUnlinkAllRecordsProps) => {\n const {t} = useSharedTranslation();\n const form = AntForm.useFormInstance();\n\n const handleDeleteAllValues = async () => {\n const deleteRes = await onDeleteMultipleValues(\n attribute.id,\n backendValues.filter(backendValue => backendValue.id_value),\n null,\n );\n\n if (deleteRes.status === APICallStatus.SUCCESS) {\n form.setFieldValue(attribute.id, []);\n form.setFields([\n {\n name: attribute.id,\n errors: attribute.required ? [t('errors.standard_field_required')] : [],\n },\n ]);\n setBackendValues([]);\n }\n };\n\n const shouldDisplayUnlinkAll =\n !isReadOnly && backendValues.length > 1 && attribute.multiple_values && !attribute.required;\n\n return {\n UnlinkAllRecordsButton: shouldDisplayUnlinkAll && (\n <DeleteAllValuesButton handleDelete={handleDeleteAllValues} disabled={isReadOnly} danger={isFieldInError} />\n ),\n };\n};\n"]}
|