From 20a3e1c4379f09401baaca5aea3787fa5e86c1e8 Mon Sep 17 00:00:00 2001 From: vashjs Date: Wed, 15 Jan 2025 17:54:08 +0100 Subject: [PATCH 1/2] UIBULKED-599 Change Administrative note type is not supported for MARC instances --- CHANGELOG.md | 1 + .../ContentUpdatesForm/ContentUpdatesForm.js | 8 ++-- .../ContentUpdatesForm/helpers.js | 11 ++++- .../ContentUpdatesForm/helpers.test.js | 46 +++++++++++++++++++ src/constants/inAppActions.js | 6 ++- 5 files changed, 66 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5885f86..93d792f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * [UIBULKED-574](https://folio-org.atlassian.net/browse/UIBULKED-574) Updates to Errors component. * [UIBULKED-571](https://folio-org.atlassian.net/browse/UIBULKED-571) Errors in response to UI calls. * [UIBULKED-568](https://folio-org.atlassian.net/browse/UIBULKED-568) Populating Are you sure? form +* [UIBULKED-599](https://folio-org.atlassian.net/browse/UIBULKED-599) Change Administrative note type is not supported for MARC instances. ## [4.2.2](https://github.com/folio-org/ui-bulk-edit/tree/v4.2.2) (2024-11-15) diff --git a/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/ContentUpdatesForm.js b/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/ContentUpdatesForm.js index 5dd9e67e..4c6d4235 100644 --- a/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/ContentUpdatesForm.js +++ b/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/ContentUpdatesForm.js @@ -34,10 +34,10 @@ import css from '../../../BulkEditPane.css'; export const ContentUpdatesForm = ({ fields, setFields, options }) => { const { formatMessage } = useIntl(); - const { currentRecordType } = useSearchParams(); + const { currentRecordType, approach } = useSearchParams(); useEffect(() => { - setFields([getFieldTemplate(options, currentRecordType)]); + setFields([getFieldTemplate(options, currentRecordType, approach)]); // eslint-disable-next-line }, []); @@ -56,6 +56,7 @@ export const ContentUpdatesForm = ({ fields, setFields, options }) => { capability: currentRecordType, option, options, + approach, }), }; } @@ -171,7 +172,7 @@ export const ContentUpdatesForm = ({ fields, setFields, options }) => { const handleAdd = () => { const filteredFields = getFilteredFields([...fields, { - ...getFieldTemplate(options, currentRecordType), + ...getFieldTemplate(options, currentRecordType, approach), id: uniqueId(), actionsDetails: { type: null, @@ -191,6 +192,7 @@ export const ContentUpdatesForm = ({ fields, setFields, options }) => { capability: currentRecordType, option, options, + approach, }), }) : f; diff --git a/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/helpers.js b/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/helpers.js index 9dd8a644..3bd91c3a 100644 --- a/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/helpers.js +++ b/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/helpers.js @@ -3,6 +3,7 @@ import uniqueId from 'lodash/uniqueId'; import { CONTROL_TYPES, OPTIONS, + APPROACHES, BASE_DATE_FORMAT, FINAL_ACTIONS, ACTIONS, @@ -22,6 +23,7 @@ import { noteActionsWithDuplicate, electronicAccess, statisticalCodeActions, + noteActionsMarc, } from '../../../../../constants'; import { getActionParameters } from '../../../../../constants/actionParameters'; @@ -82,6 +84,7 @@ export const getDefaultActions = ({ option, options, capability, + approach, }) => { const replaceClearDefaultActions = replaceClearActions(); const emailDefaultFindActions = emailActionsFind(); @@ -94,6 +97,7 @@ export const getDefaultActions = ({ const statusDefaultActions = statusActions(); const loanDefaultActions = permanentLoanTypeActions(); const noteDefaultActions = noteActions(); + const noteDefaultActionsMarc = noteActionsMarc(); const noteWithMarcDefaultActions = noteActionsWithMarc(); const noteDuplicateDefaultActions = noteActionsWithDuplicate(); const electronicAccessActions = electronicAccess(); @@ -272,7 +276,9 @@ export const getDefaultActions = ({ actions: [ null, { - actionsList: noteDefaultActions, + actionsList: approach === APPROACHES.MARC + ? noteDefaultActionsMarc + : noteDefaultActions, controlType: (action) => { return action === ACTIONS.CHANGE_TYPE ? CONTROL_TYPES.NOTE_SELECT @@ -498,7 +504,7 @@ export const getMappedContentUpdates = (fields, options) => fields.map(({ }; }); -export const getFieldTemplate = (options, capability) => { +export const getFieldTemplate = (options, capability, approach) => { return ({ id: uniqueId(), options, @@ -507,6 +513,7 @@ export const getFieldTemplate = (options, capability) => { actionsDetails: getDefaultActions({ option: '', capability, + approach, options, }), }); diff --git a/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/helpers.test.js b/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/helpers.test.js index ce8fbf5b..39029b0b 100644 --- a/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/helpers.test.js +++ b/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/helpers.test.js @@ -5,6 +5,7 @@ import { OPTIONS, commonAdditionalActions, CAPABILITIES, + APPROACHES, PARAMETERS_KEYS, } from '../../../../../constants'; @@ -835,6 +836,51 @@ describe('ContentUpdatesForm helpers', () => { )); }); + it('returns the correct object for the ADMINISTRATIVE_NOTE option using instance marc', () => { + expect(JSON.stringify(getDefaultActions({ + option: OPTIONS.ADMINISTRATIVE_NOTE, + options: [], + formatMessage, + capability: CAPABILITIES.INSTANCE, + approach: APPROACHES.MARC + }))) + .toEqual( + JSON.stringify({ + type: '', + actions: [ + null, + { + actionsList: [ + { + value: '', + label: , + disabled: true, + }, + { + value: ACTIONS.ADD_TO_EXISTING, + label: , + disabled: false, + }, + { + value: ACTIONS.REMOVE_ALL, + label: , + disabled: false, + }, + { + value: ACTIONS.FIND, + label: , + disabled: false, + }, + ], + controlType: () => CONTROL_TYPES.TEXTAREA, + [ACTION_VALUE_KEY]: '', + [FIELD_VALUE_KEY]: '', + }, + ], + }) + ); + }); + it('returns the correct object for the ELECTRONIC_ACCESS_MATERIALS_SPECIFIED option', () => { expect(JSON.stringify(getDefaultActions({ option: OPTIONS.ELECTRONIC_ACCESS_MATERIALS_SPECIFIED, diff --git a/src/constants/inAppActions.js b/src/constants/inAppActions.js index 18d7c32b..1cfebae7 100644 --- a/src/constants/inAppActions.js +++ b/src/constants/inAppActions.js @@ -157,11 +157,15 @@ export const statisticalCodeActions = () => [ getRemoveAllAction(), ]; -export const noteActions = () => [ +export const noteActionsMarc = () => [ getPlaceholder(), getAddToExistingAction(), getRemoveAllAction(), getFindFullFieldAction(), +]; + +export const noteActions = () => [ + ...noteActionsMarc(), getChangeNoteTypeAction(), ]; From 58fb045d98869a915fe7b17ab2a0d0b1167e0eed Mon Sep 17 00:00:00 2001 From: vashjs Date: Fri, 17 Jan 2025 13:14:51 +0100 Subject: [PATCH 2/2] update test after conflict resolving --- .../BulkEditInApp/ContentUpdatesForm/helpers.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/helpers.test.js b/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/helpers.test.js index 4a63dfd1..b8c6285a 100644 --- a/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/helpers.test.js +++ b/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/helpers.test.js @@ -868,7 +868,7 @@ describe('ContentUpdatesForm helpers', () => { }, { value: ACTIONS.FIND, - label: , + label: , disabled: false, }, ],