@leav/ui 1.6.0-fb9dc9ec → 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/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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExplorerLinkRecords.js","sourceRoot":"","sources":["../../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/explorer/link-record/useExplorerLinkRecords.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAC,aAAa,EAA6B,MAAM,oBAAoB,CAAC;AAG7E,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AACnC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAQvC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EAAC,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAA+B,EAAE,EAAE;IACjH,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,IAAI,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAEvC,MAAM,YAAY,GAAG,CAAC,QAAkC,EAAE,aAAsB,KAAK,EAAE,EAAE;QACrF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACZ,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,CAA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AE;wBAClB,MAAM,EAAE,CAAC,YAAY,CAAC;qBACzB;iBACJ,CAAC,CAAC;YACP,CAAC;QACL,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,yBAAyB,GAAG,CAAC,EAC/B,eAAe,EACf,sBAAsB,GAIzB,EAAE,EAAE;QACD,IAAI,sBAAsB,EAAE,CAAC;YACzB,uBAAuB,CAAC,sBAAsB,CAAC,CAAC;QACpD,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACH,yBAAyB;QACzB,kCAAkC;QAClC,uBAAuB;QACvB,yBAAyB;KAC5B,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 RecordFilterInput, type RecordFormAttributeLinkAttributeFragment} from '_ui/_gqlTypes';\nimport {APICallStatus, type ISubmitMultipleResult} from '../../../../_types';\nimport {type Dispatch, type SetStateAction} from 'react';\nimport {type IItemData, type MassSelection} from '_ui/components/Explorer/_types';\nimport {AntForm} from 'aristid-ds';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type RecordFormElementsValueLinkValue} from '_ui/hooks/useGetRecordForm';\nimport {ErrorTypes} from '@leav/utils';\n\ninterface IUseExplorerLinkRecordsProps {\n attribute: RecordFormAttributeLinkAttributeFragment;\n backendValues: RecordFormElementsValueLinkValue[];\n setBackendValues: Dispatch<SetStateAction<RecordFormElementsValueLinkValue[]>>;\n}\n\nexport const useExplorerLinkRecords = ({attribute, backendValues, setBackendValues}: IUseExplorerLinkRecordsProps) => {\n const {t} = useSharedTranslation();\n\n const form = AntForm.useFormInstance();\n\n const removeValues = (filterFn?: (id: string) => boolean, useIdValue: boolean = false) => {\n if (!filterFn) {\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 return;\n }\n\n const newBackendValues = backendValues.filter(backendValue =>\n filterFn(useIdValue ? backendValue.id_value : backendValue.linkValue.id),\n );\n\n form.setFieldValue(\n attribute.id,\n newBackendValues.map(({linkValue}) => linkValue.id),\n );\n\n form.setFields([\n {\n name: attribute.id,\n errors:\n attribute.required && newBackendValues.length === 0 ? [t('errors.standard_field_required')] : [],\n },\n ]);\n\n setBackendValues(previousBackendValues =>\n previousBackendValues.filter(backendValue =>\n filterFn(useIdValue ? backendValue.id_value : backendValue.linkValue.id),\n ),\n );\n };\n\n const handleExplorerRemoveValue = (item: IItemData) => {\n removeValues(id => id !== item.itemId);\n };\n\n const handleExplorerMassDeactivateValues = (\n _massSelectedFilter: RecordFilterInput[],\n massSelection: MassSelection,\n ) => {\n removeValues(idValue => !massSelection.includes(idValue), true);\n };\n\n const handleExplorerLinkValue = (saveValuesResult: ISubmitMultipleResult) => {\n if (saveValuesResult.status === APICallStatus.SUCCESS) {\n const saveLinkValues = saveValuesResult.values as unknown as RecordFormElementsValueLinkValue[];\n\n form.setFieldValue(attribute.id, [\n ...backendValues.map(({linkValue}) => linkValue.id),\n ...saveLinkValues.map(({linkValue}) => linkValue.id),\n ]);\n\n form.setFields([\n {\n name: attribute.id,\n errors: [],\n },\n ]);\n\n setBackendValues(previousBackendValues => [...previousBackendValues, ...saveLinkValues]);\n }\n\n if (saveValuesResult.status === APICallStatus.ERROR && saveValuesResult.errors) {\n const attributeError = saveValuesResult.errors.filter(err => err.attribute === attribute.id)?.[0];\n\n if (attributeError) {\n const errorMessage =\n attributeError.type === ErrorTypes.VALIDATION_ERROR\n ? attributeError.message\n : t(`errors.${attributeError.type}`);\n\n form.setFields([\n {\n name: attribute.id,\n errors: [errorMessage],\n },\n ]);\n }\n }\n };\n\n const handleExplorerCreateValue = ({\n recordIdCreated,\n saveValuesResultOnLink,\n }: {\n recordIdCreated: string;\n saveValuesResultOnLink?: ISubmitMultipleResult;\n }) => {\n if (saveValuesResultOnLink) {\n handleExplorerLinkValue(saveValuesResultOnLink);\n }\n };\n\n return {\n handleExplorerRemoveValue,\n handleExplorerMassDeactivateValues,\n handleExplorerLinkValue,\n handleExplorerCreateValue,\n };\n};\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Explorer } from '
|
|
1
|
+
import { Explorer } from '../../../../../../../components/Explorer';
|
|
2
2
|
import { type ComponentProps, type Dispatch, type SetStateAction } from 'react';
|
|
3
|
-
import { type DeleteMultipleValuesFunc } from '
|
|
4
|
-
import { type JoinLibraryContextFragment, type RecordFormAttributeLinkAttributeFragment } from '
|
|
5
|
-
import { type RecordFormElementsValueLinkValue } from '
|
|
3
|
+
import { type DeleteMultipleValuesFunc } from '../../../../_types';
|
|
4
|
+
import { type JoinLibraryContextFragment, type RecordFormAttributeLinkAttributeFragment } from '../../../../../../../_gqlTypes';
|
|
5
|
+
import { type RecordFormElementsValueLinkValue } from '../../../../../../../hooks/useGetRecordForm';
|
|
6
6
|
interface ILinkRecords {
|
|
7
7
|
libraryId: string;
|
|
8
8
|
recordId: string;
|
|
@@ -18,8 +18,7 @@ interface ILinkRecords {
|
|
|
18
18
|
hasNoValue: boolean;
|
|
19
19
|
onDeleteMultipleValues: DeleteMultipleValuesFunc;
|
|
20
20
|
}
|
|
21
|
-
export declare const useLinkRecords: ({ libraryId, recordId, editionFormId, isFormCreationMode, attribute, joinLibraryContext, columnsToDisplay, backendValues, setBackendValues, isReadOnly,
|
|
22
|
-
UnlinkAllRecords: JSX.Element;
|
|
21
|
+
export declare const useLinkRecords: ({ libraryId, recordId, editionFormId, isFormCreationMode, attribute, joinLibraryContext, columnsToDisplay, backendValues, setBackendValues, isReadOnly, hasNoValue, }: ILinkRecords) => {
|
|
23
22
|
LinkRecordsExplorer: JSX.Element;
|
|
24
23
|
};
|
|
25
24
|
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
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 { Explorer } from '../../../../../../../components/Explorer';
|
|
6
|
+
import { useEffect, useState } from 'react';
|
|
7
|
+
import { AntForm, KitButton, KitSpace, KitTooltip } from 'aristid-ds';
|
|
8
|
+
import { useExplorerLinkRecords } from './useExplorerLinkRecords';
|
|
9
|
+
import { useSharedTranslation } from '../../../../../../../hooks/useSharedTranslation';
|
|
10
|
+
import { useEditRecordModal } from '../../../../../../../components/RecordEdition/EditRecordModal/useEditRecordModal';
|
|
11
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
12
|
+
import { faEye, faPlus } from '@fortawesome/free-solid-svg-icons';
|
|
13
|
+
import { INPUT_MAX_HEIGHT } from '../../../../formConstants';
|
|
14
|
+
import styled from 'styled-components';
|
|
15
|
+
const _shouldUpdateExplorerActions = (ref, explorerActions) => ref?.createAction?.disabled !== explorerActions?.createAction?.disabled ||
|
|
16
|
+
ref?.linkAction?.disabled !== explorerActions?.linkAction?.disabled ||
|
|
17
|
+
ref?.totalCount !== explorerActions?.totalCount;
|
|
18
|
+
const ActionButton = styled(KitButton) `
|
|
19
|
+
margin-top: ${props => (props.$hasNoValue ? 0 : 'calc((var(--general-spacing-xs)) * 1px)')};
|
|
20
|
+
`;
|
|
21
|
+
export const useLinkRecords = ({ libraryId, recordId, editionFormId, isFormCreationMode, attribute, joinLibraryContext, columnsToDisplay, backendValues, setBackendValues, isReadOnly, hasNoValue, }) => {
|
|
22
|
+
const { t } = useSharedTranslation();
|
|
23
|
+
const form = AntForm.useFormInstance();
|
|
24
|
+
const [explorerActions, setExplorerActions] = useState(null);
|
|
25
|
+
const { handleExplorerCreateValue, handleExplorerLinkValue, handleExplorerMassDeactivateValues, handleExplorerRemoveValue, } = useExplorerLinkRecords({
|
|
26
|
+
attribute,
|
|
27
|
+
backendValues,
|
|
28
|
+
setBackendValues,
|
|
29
|
+
});
|
|
30
|
+
const _handleExplorerRef = (ref) => {
|
|
31
|
+
if (_shouldUpdateExplorerActions(ref, explorerActions)) {
|
|
32
|
+
setExplorerActions({
|
|
33
|
+
createAction: ref?.createAction,
|
|
34
|
+
linkAction: ref?.linkAction,
|
|
35
|
+
totalCount: ref?.totalCount,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const _getExplorerItemActions = () => {
|
|
40
|
+
if (isReadOnly) {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
if ((!attribute.multiple_values && attribute.required) ||
|
|
44
|
+
(attribute.multiple_values && backendValues.length === 1 && attribute.required)) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
return ['remove'];
|
|
48
|
+
};
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (!isFormCreationMode && backendValues.length === 0 && attribute.required) {
|
|
51
|
+
form.setFields([{ name: attribute.id, errors: [t('errors.standard_field_required')] }]);
|
|
52
|
+
}
|
|
53
|
+
}, []);
|
|
54
|
+
const { EditRecordModal, openEditRecordModal } = useEditRecordModal();
|
|
55
|
+
return {
|
|
56
|
+
LinkRecordsExplorer: recordId && (_jsxs(_Fragment, { children: [_jsx(Explorer, { ref: _handleExplorerRef, defaultViewSettings: {
|
|
57
|
+
attributesIds: columnsToDisplay,
|
|
58
|
+
}, entrypoint: {
|
|
59
|
+
type: 'link',
|
|
60
|
+
parentLibraryId: libraryId,
|
|
61
|
+
parentRecordId: recordId,
|
|
62
|
+
linkAttributeId: attribute.id,
|
|
63
|
+
}, defaultCallbacks: {
|
|
64
|
+
item: {
|
|
65
|
+
remove: handleExplorerRemoveValue,
|
|
66
|
+
},
|
|
67
|
+
mass: {
|
|
68
|
+
deactivate: handleExplorerMassDeactivateValues,
|
|
69
|
+
},
|
|
70
|
+
primary: {
|
|
71
|
+
link: handleExplorerLinkValue,
|
|
72
|
+
create: handleExplorerCreateValue,
|
|
73
|
+
},
|
|
74
|
+
}, showTitle: false, showSearch: false, selectionMode: attribute.multiple_values ? 'multiple' : 'simple', disableSelection: isReadOnly ||
|
|
75
|
+
!attribute.multiple_values ||
|
|
76
|
+
(attribute.required && attribute.multiple_values && backendValues.length === 1), defaultActionsForItem: _getExplorerItemActions(), itemActions: [
|
|
77
|
+
{
|
|
78
|
+
label: t('explorer.edit-item'),
|
|
79
|
+
icon: _jsx(FontAwesomeIcon, { icon: faEye }),
|
|
80
|
+
useItemActionOnRowClick: true,
|
|
81
|
+
callback: item => {
|
|
82
|
+
openEditRecordModal({
|
|
83
|
+
library: item.libraryId,
|
|
84
|
+
record: {
|
|
85
|
+
id: item.itemId,
|
|
86
|
+
label: item.whoAmI?.label,
|
|
87
|
+
subLabel: item.whoAmI?.subLabel,
|
|
88
|
+
color: item.whoAmI?.color,
|
|
89
|
+
library: { id: item.libraryId },
|
|
90
|
+
},
|
|
91
|
+
editionFormId,
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
], joinLibraryContext: joinLibraryContext, hidePrimaryActions: true, hideTableHeader: !columnsToDisplay?.length, useSmallHeaderSize: true, tableBodyHeight: INPUT_MAX_HEIGHT }), !isReadOnly && (_jsx(KitSpace, { size: "xs", style: { padding: '1rem' }, children: _jsx(KitTooltip, { title: explorerActions?.linkAction?.label, children: _jsx(ActionButton, { type: "secondary", size: "m", "$hasNoValue": hasNoValue, icon: _jsx(FontAwesomeIcon, { icon: faPlus }), disabled: isReadOnly || (attribute.multiple_values && explorerActions?.linkAction?.disabled), onClick: explorerActions?.linkAction?.callback, "aria-label": explorerActions?.linkAction?.label }) }) })), EditRecordModal] })),
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=useLinkRecords.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLinkRecords.js","sourceRoot":"","sources":["../../../../../../../../src/components/RecordEdition/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,uBAAuB,EAAE,IAAI;4BAC7B,QAAQ,EAAE,IAAI,CAAC,EAAE;gCACb,mBAAmB,CAAC;oCAChB,OAAO,EAAE,IAAI,CAAC,SAAS;oCACvB,MAAM,EAAE;wCACJ,EAAE,EAAE,IAAI,CAAC,MAAM;wCACf,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK;wCACzB,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ;wCAC/B,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK;wCACzB,OAAO,EAAE,EAAC,EAAE,EAAE,IAAI,CAAC,SAAS,EAAC;qCAChC;oCACD,aAAa;iCAChB,CAAC,CAAC;4BACP,CAAC;yBACJ;qBACJ,EACD,kBAAkB,EAAE,kBAAkB,EACtC,kBAAkB,QAClB,eAAe,EAAE,CAAC,gBAAgB,EAAE,MAAM,EAC1C,kBAAkB,QAClB,eAAe,EAAE,gBAAgB,GACnC,EACD,CAAC,UAAU,IAAI,CACZ,KAAC,QAAQ,IAAC,IAAI,EAAC,IAAI,EAAC,KAAK,EAAE,EAAC,OAAO,EAAE,MAAM,EAAC,YACxC,KAAC,UAAU,IAAC,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,KAAK,YACjD,KAAC,YAAY,IACT,IAAI,EAAC,WAAW,EAChB,IAAI,EAAC,GAAG,iBACK,UAAU,EACvB,IAAI,EAAE,KAAC,eAAe,IAAC,IAAI,EAAE,MAAM,GAAI,EACvC,QAAQ,EACJ,UAAU,IAAI,CAAC,SAAS,CAAC,eAAe,IAAI,eAAe,EAAE,UAAU,EAAE,QAAQ,CAAC,EAEtF,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,QAAQ,gBAClC,eAAe,EAAE,UAAU,EAAE,KAAK,GAChD,GACO,GACN,CACd,EACA,eAAe,IACjB,CACN;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 {Explorer} from '_ui/components/Explorer';\nimport {type IExplorerRef} from '_ui/components/Explorer/Explorer';\nimport {type ComponentProps, type Dispatch, type SetStateAction, useEffect, useState} from 'react';\nimport {type DeleteMultipleValuesFunc} from '../../../../_types';\nimport {type JoinLibraryContextFragment, type RecordFormAttributeLinkAttributeFragment} from '_ui/_gqlTypes';\nimport {type RecordFormElementsValueLinkValue} from '_ui/hooks/useGetRecordForm';\nimport {AntForm, KitButton, KitSpace, KitTooltip} from 'aristid-ds';\nimport {useExplorerLinkRecords} from './useExplorerLinkRecords';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {useEditRecordModal} from '_ui/components/RecordEdition/EditRecordModal/useEditRecordModal';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faEye, faPlus} from '@fortawesome/free-solid-svg-icons';\nimport {INPUT_MAX_HEIGHT} from '../../../../formConstants';\nimport styled from 'styled-components';\n\ninterface ILinkRecords {\n libraryId: string;\n recordId: string;\n editionFormId: string;\n isFormCreationMode: boolean;\n attribute: RecordFormAttributeLinkAttributeFragment;\n joinLibraryContext: JoinLibraryContextFragment;\n columnsToDisplay: ComponentProps<typeof Explorer>['defaultViewSettings']['attributesIds'];\n backendValues: RecordFormElementsValueLinkValue[];\n setBackendValues: Dispatch<SetStateAction<RecordFormElementsValueLinkValue[]>>;\n isReadOnly: boolean;\n isFieldInError: boolean;\n hasNoValue: boolean;\n onDeleteMultipleValues: DeleteMultipleValuesFunc;\n}\n\nconst _shouldUpdateExplorerActions = (ref: IExplorerRef, explorerActions: IExplorerRef) =>\n ref?.createAction?.disabled !== explorerActions?.createAction?.disabled ||\n ref?.linkAction?.disabled !== explorerActions?.linkAction?.disabled ||\n ref?.totalCount !== explorerActions?.totalCount;\n\nconst ActionButton = styled(KitButton)<{$hasNoValue: boolean}>`\n margin-top: ${props => (props.$hasNoValue ? 0 : 'calc((var(--general-spacing-xs)) * 1px)')};\n`;\n\nexport const useLinkRecords = ({\n libraryId,\n recordId,\n editionFormId,\n isFormCreationMode,\n attribute,\n joinLibraryContext,\n columnsToDisplay,\n backendValues,\n setBackendValues,\n isReadOnly,\n hasNoValue,\n}: ILinkRecords) => {\n const {t} = useSharedTranslation();\n const form = AntForm.useFormInstance();\n const [explorerActions, setExplorerActions] = useState<IExplorerRef | null>(null);\n\n const {\n handleExplorerCreateValue,\n handleExplorerLinkValue,\n handleExplorerMassDeactivateValues,\n handleExplorerRemoveValue,\n } = useExplorerLinkRecords({\n attribute,\n backendValues,\n setBackendValues,\n });\n\n const _handleExplorerRef = (ref: IExplorerRef) => {\n if (_shouldUpdateExplorerActions(ref, explorerActions)) {\n setExplorerActions({\n createAction: ref?.createAction,\n linkAction: ref?.linkAction,\n totalCount: ref?.totalCount,\n });\n }\n };\n\n const _getExplorerItemActions = (): Array<'remove'> => {\n if (isReadOnly) {\n return [];\n }\n\n if (\n (!attribute.multiple_values && attribute.required) ||\n (attribute.multiple_values && backendValues.length === 1 && attribute.required)\n ) {\n return [];\n }\n\n return ['remove'];\n };\n\n useEffect(() => {\n if (!isFormCreationMode && backendValues.length === 0 && attribute.required) {\n form.setFields([{name: attribute.id, errors: [t('errors.standard_field_required')]}]);\n }\n }, []);\n\n const {EditRecordModal, openEditRecordModal} = useEditRecordModal();\n\n return {\n LinkRecordsExplorer: recordId && (\n <>\n <Explorer\n ref={_handleExplorerRef}\n defaultViewSettings={{\n attributesIds: columnsToDisplay,\n }}\n entrypoint={{\n type: 'link',\n parentLibraryId: libraryId,\n parentRecordId: recordId,\n linkAttributeId: attribute.id,\n }}\n defaultCallbacks={{\n item: {\n remove: handleExplorerRemoveValue,\n },\n mass: {\n deactivate: handleExplorerMassDeactivateValues,\n },\n primary: {\n link: handleExplorerLinkValue,\n create: handleExplorerCreateValue,\n },\n }}\n showTitle={false}\n showSearch={false}\n selectionMode={attribute.multiple_values ? 'multiple' : 'simple'}\n disableSelection={\n isReadOnly ||\n !attribute.multiple_values ||\n (attribute.required && attribute.multiple_values && backendValues.length === 1)\n }\n defaultActionsForItem={_getExplorerItemActions()}\n itemActions={[\n {\n label: t('explorer.edit-item'),\n icon: <FontAwesomeIcon icon={faEye} />,\n useItemActionOnRowClick: true,\n callback: item => {\n openEditRecordModal({\n library: item.libraryId,\n record: {\n id: item.itemId,\n label: item.whoAmI?.label,\n subLabel: item.whoAmI?.subLabel,\n color: item.whoAmI?.color,\n library: {id: item.libraryId},\n },\n editionFormId,\n });\n },\n },\n ]}\n joinLibraryContext={joinLibraryContext}\n hidePrimaryActions\n hideTableHeader={!columnsToDisplay?.length}\n useSmallHeaderSize\n tableBodyHeight={INPUT_MAX_HEIGHT} // In a form we want the table body height at 320px\n />\n {!isReadOnly && (\n <KitSpace size=\"xs\" style={{padding: '1rem'}}>\n <KitTooltip title={explorerActions?.linkAction?.label}>\n <ActionButton\n type=\"secondary\"\n size=\"m\"\n $hasNoValue={hasNoValue}\n icon={<FontAwesomeIcon icon={faPlus} />}\n disabled={\n isReadOnly || (attribute.multiple_values && explorerActions?.linkAction?.disabled)\n }\n onClick={explorerActions?.linkAction?.callback}\n aria-label={explorerActions?.linkAction?.label}\n />\n </KitTooltip>\n </KitSpace>\n )}\n {EditRecordModal}\n </>\n ),\n };\n};\n"]}
|
|
@@ -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,E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8BACI,KAAC,mBAAmB,cAChB,KAAC,gBAAgB,IAAC,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,GAAI,GACpE,EACrB,sBAAsB,IACxB,yBAEc,UAAU,YAE/B,MAAC,QAAQ,IAAC,SAAS,EAAC,UAAU,aAC1B,KAAC,QAAQ,IAAC,SAAS,EAAC,YAAY,EAAC,IAAI,EAAC,KAAK,EAAC,IAAI,kBAC3C,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CACxB,KAAC,MAAM,IAEH,IAAI,EAAC,WAAW,EAChB,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,YAEzE,KAAC,SAAS,IAAC,WAAW,EAAE,KAAK,CAAC,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
|