Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIBULKED-599 Change Administrative note type is not supported for MARC instances #671

Merged
merged 4 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* [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-543](https://folio-org.atlassian.net/browse/UIBULKED-543) Rename Find (full field search) to Find.
* [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,
electronicAccessWithFindFullField,
} from '../../../../../constants';
import { getActionParameters } from '../../../../../constants/actionParameters';
Expand Down Expand Up @@ -83,6 +85,7 @@ export const getDefaultActions = ({
option,
options,
capability,
approach,
}) => {
const replaceClearDefaultActions = replaceClearActions();
const emailDefaultFindActions = emailActionsFind();
Expand All @@ -95,6 +98,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 @@ -274,7 +278,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 @@ -500,7 +506,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 @@ -509,6 +515,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 @@ -5,6 +5,7 @@ import {
OPTIONS,
commonAdditionalActions,
CAPABILITIES,
APPROACHES,
PARAMETERS_KEYS,
} from '../../../../../constants';

Expand Down Expand Up @@ -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: <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.find" />,
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(),
getFindAction(),
];

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

Expand Down
Loading