From 16cd64e89b4507bf825b09ac5ee956865aa03352 Mon Sep 17 00:00:00 2001 From: vashjs <86330150+vashjs@users.noreply.github.com> Date: Tue, 14 Nov 2023 15:23:49 +0100 Subject: [PATCH] UIBULKED-349 Update Electronic access - URL relationship (#409) --- CHANGELOG.md | 1 + .../ContentUpdatesForm/ActionsRow.js | 8 +- .../ContentUpdatesForm/ValuesColumn.js | 36 +- .../ContentUpdatesForm/ValuesColumn.test.js | 66 +- .../ContentUpdatesForm/helpers.js | 32 +- .../ContentUpdatesForm/helpers.test.js | 849 +++++++++++------- src/constants/core.js | 1 + src/constants/inAppActions.js | 16 +- src/constants/selectOptions.js | 22 +- src/hooks/api/useElectronicAccess.js | 26 + translations/ui-bulk-edit/en.json | 3 + 11 files changed, 683 insertions(+), 377 deletions(-) create mode 100644 src/hooks/api/useElectronicAccess.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 73e0afe4..96c17dfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ * [UIBULKED-371](https://issues.folio.org/browse/UIBULKED-371) Bulk edit - Grouped form controls missing accessible name. * [UIBULKED-353](https://issues.folio.org/browse/UIBULKED-353) Update Electronic access - URI. * [UIBULKED-356](https://issues.folio.org/browse/UIBULKED-356) Separate holdings notes by note type +* [UIBULKED-349](https://issues.folio.org/browse/UIBULKED-349) Update Electronic access - URL relationship ## [4.0.0](https://github.com/folio-org/ui-bulk-edit/tree/v4.0.0) (2023-10-12) diff --git a/src/components/BulkEditList/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/ActionsRow.js b/src/components/BulkEditList/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/ActionsRow.js index db6ad9f2..2bb736e6 100644 --- a/src/components/BulkEditList/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/ActionsRow.js +++ b/src/components/BulkEditList/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/ActionsRow.js @@ -36,7 +36,13 @@ export const ActionsRow = ({ option, actions, onChange }) => { {/* Render value fields only in case if actions selected AND action is not from FINAL_ACTIONS */} {action.name && !FINAL_ACTIONS.includes(action.name) && ( - + )} {/* Render additional actions */} diff --git a/src/components/BulkEditList/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/ValuesColumn.js b/src/components/BulkEditList/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/ValuesColumn.js index 393fb0b6..28a2b0ad 100644 --- a/src/components/BulkEditList/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/ValuesColumn.js +++ b/src/components/BulkEditList/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/ValuesColumn.js @@ -15,8 +15,10 @@ import { BASE_DATE_FORMAT, CAPABILITIES, CONTROL_TYPES, - getDuplicateNoteOptions, getHoldingsNotes, + getDuplicateNoteOptions, + getHoldingsNotes, getItemStatusOptions, + getItemsWithPlaceholder, getNotesOptions, } from '../../../../../constants'; import { FIELD_VALUE_KEY, TEMPORARY_LOCATIONS } from './helpers'; @@ -24,8 +26,9 @@ import { useLoanTypes, usePatronGroup } from '../../../../../hooks/api'; import { useItemNotes } from '../../../../../hooks/api/useItemNotes'; import { usePreselectedValue } from '../../../../../hooks/usePreselectedValue'; import { useHoldingsNotes } from '../../../../../hooks/api/useHoldingsNotes'; +import { useElectronicAccessRelationships } from '../../../../../hooks/api/useElectronicAccess'; -export const ValuesColumn = ({ action, actionIndex, onChange, option }) => { +export const ValuesColumn = ({ action, allActions, actionIndex, onChange, option }) => { const { formatMessage } = useIntl(); const location = useLocation(); const search = new URLSearchParams(location.search); @@ -38,6 +41,12 @@ export const ValuesColumn = ({ action, actionIndex, onChange, option }) => { const { userGroups } = usePatronGroup({ enabled: isUserCapability }); const { loanTypes, isLoanTypesLoading } = useLoanTypes({ enabled: isItemCapability }); const { itemNotes, usItemNotesLoading } = useItemNotes({ enabled: isItemCapability }); + + const { electronicAccessRelationships, isElectronicAccessLoading } = useElectronicAccessRelationships({ enabled: isHoldingsCapability }); + // exclude from second action the first action value + const filteredElectronicAccessRelationships = electronicAccessRelationships.filter(item => actionIndex === 0 || item.value !== allActions[0]?.value); + const accessRelationshipsWithPlaceholder = getItemsWithPlaceholder(filteredElectronicAccessRelationships); + const { holdingsNotes, isHoldingsNotesLoading } = useHoldingsNotes({ enabled: isHoldingsCapability }); const duplicateNoteOptions = getDuplicateNoteOptions(formatMessage).filter(el => el.value !== option); @@ -130,7 +139,7 @@ export const ValuesColumn = ({ action, actionIndex, onChange, option }) => { <> onChange({ actionIndex, value: location.id, fieldName: FIELD_VALUE_KEY })} + onSelect={loc => onChange({ actionIndex, value: loc.id, fieldName: FIELD_VALUE_KEY })} placeholder={formatMessage({ id: 'ui-bulk-edit.layer.selectLocation' })} data-test-id={`textField-${actionIndex}`} aria-label={formatMessage({ id: 'ui-bulk-edit.ariaLabel.location' })} @@ -138,8 +147,8 @@ export const ValuesColumn = ({ action, actionIndex, onChange, option }) => { onChange({ - actionIndex, value: location.id, fieldName: FIELD_VALUE_KEY, + onLocationSelected={(loc) => onChange({ + actionIndex, value: loc.id, fieldName: FIELD_VALUE_KEY, })} data-testid={`locationLookup-${actionIndex}`} /> @@ -204,6 +213,17 @@ export const ValuesColumn = ({ action, actionIndex, onChange, option }) => { /> ); + const renderElectronicAccessRelationshipSelect = () => controlType === CONTROL_TYPES.ELECTRONIC_ACCESS_RELATIONSHIP_SELECT && ( +