Skip to content

Commit

Permalink
UIBULKED-599 Change Administrative note type is not supported for MAR…
Browse files Browse the repository at this point in the history
…C instances
  • Loading branch information
vashjs committed Jan 15, 2025
1 parent 08fed89 commit 15f1098
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}, []);

Expand All @@ -56,6 +56,7 @@ export const ContentUpdatesForm = ({ fields, setFields, options }) => {
capability: currentRecordType,
option,
options,
approach,
}),
};
}
Expand Down Expand Up @@ -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,
Expand All @@ -191,6 +192,7 @@ export const ContentUpdatesForm = ({ fields, setFields, options }) => {
capability: currentRecordType,
option,
options,
approach,
}),
})
: f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import uniqueId from 'lodash/uniqueId';
import {
CONTROL_TYPES,
OPTIONS,
APPROACHES,
BASE_DATE_FORMAT,
FINAL_ACTIONS,
ACTIONS,
Expand All @@ -22,6 +23,7 @@ import {
noteActionsWithDuplicate,
electronicAccess,
statisticalCodeActions,
noteActionsMarc,
} from '../../../../../constants';
import { getActionParameters } from '../../../../../constants/actionParameters';

Expand Down Expand Up @@ -82,6 +84,7 @@ export const getDefaultActions = ({
option,
options,
capability,
approach,
}) => {
const replaceClearDefaultActions = replaceClearActions();
const emailDefaultFindActions = emailActionsFind();
Expand All @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -507,6 +513,7 @@ export const getFieldTemplate = (options, capability) => {
actionsDetails: getDefaultActions({
option: '',
capability,
approach,
options,
}),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,50 @@ 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_MARC
})))
.toEqual(
JSON.stringify({
type: '',
actions: [
null,
{
actionsList: [
{
value: '',
label: <FormattedMessage id="ui-bulk-edit.actions.placeholder" />,
disabled: true,
},
{
value: ACTIONS.ADD_TO_EXISTING,
label: <FormattedMessage id="ui-bulk-edit.layer.options.items.addNote" />,
disabled: false,
},
{
value: ACTIONS.REMOVE_ALL,
label: <FormattedMessage id="ui-bulk-edit.layer.options.items.removeAll" />,
disabled: false,
},
{
value: ACTIONS.FIND,
label: <FormattedMessage id="ui-bulk-edit.actions.findFullField" />,
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,
Expand Down
6 changes: 5 additions & 1 deletion src/constants/inAppActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,15 @@ export const statisticalCodeActions = () => [
getRemoveAllAction(),
];

export const noteActions = () => [
export const noteActionsMarc = () => [
getPlaceholder(),
getAddToExistingAction(),
getRemoveAllAction(),
getFindFullFieldAction(),
];

export const noteActions = () => [
...noteActionsMarc(),
getChangeNoteTypeAction(),
];

Expand Down

0 comments on commit 15f1098

Please sign in to comment.