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-353: Update Electronic access - URI #406

Merged
merged 4 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -10,6 +10,7 @@
* [UIBULKED-331](https://issues.folio.org/browse/UIBULKED-331) Bulk edit actions for holdings notes - add and remove notes.
* [UIBULKED-332](https://issues.folio.org/browse/UIBULKED-332) Bulk edit actions for holdings notes - find and replace or remove.
* [UIBULKED-333](https://issues.folio.org/browse/UIBULKED-333) Bulk edit actions for holdings notes - change note type.
* [UIBULKED-353](https://issues.folio.org/browse/UIBULKED-353) Update Electronic access - URI.

## [4.0.0](https://github.com/folio-org/ui-bulk-edit/tree/v4.0.0) (2023-10-12)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
noteActions,
noteActionsWithMark,
noteActionsWithDuplicate,
electronicAccess,
} from '../../../../../constants';

export const ACTION_VALUE_KEY = 'name';
Expand Down Expand Up @@ -91,6 +92,7 @@ export const getDefaultActions = (option, options, formatMessage) => {
const noteDefaultActions = noteActions(formatMessage);
const noteWithMarkDefaultActions = noteActionsWithMark(formatMessage);
const noteDuplicateDefaultActions = noteActionsWithDuplicate(formatMessage);
const electronicAccessActions = electronicAccess(formatMessage);

const replaceClearInitialVal = replaceClearDefaultActions[0].value;

Expand Down Expand Up @@ -291,6 +293,20 @@ export const getDefaultActions = (option, options, formatMessage) => {
],
};

case OPTIONS.URI:
return {
type: '',
actions: [
null,
{
actionsList: electronicAccessActions,
controlType: () => CONTROL_TYPES.TEXTAREA,
[ACTION_VALUE_KEY]: electronicAccessActions[0].value,
[FIELD_VALUE_KEY]: '',
},
],
};

default:
return {
type: null,
Expand Down Expand Up @@ -358,6 +374,7 @@ export const getExtraActions = (option, action, formattedMessage) => {
switch (`${option}-${action}`) {
case `${OPTIONS.ITEM_NOTE}-${ACTIONS.FIND}`:
case `${OPTIONS.ADMINISTRATIVE_NOTE}-${ACTIONS.FIND}`:
case `${OPTIONS.URI}-${ACTIONS.FIND}`:
case `${OPTIONS.CHECK_IN_NOTE}-${ACTIONS.FIND}`:
case `${OPTIONS.CHECK_OUT_NOTE}-${ACTIONS.FIND}`:
case `${OPTIONS.HOLDINGS_NOTE}-${ACTIONS.FIND}`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,37 @@ describe('ContentUpdatesForm helpers', () => {
);
});

it('returns the correct object for the URI option', () => {
expect(JSON.stringify(getDefaultActions(OPTIONS.URI, [], formatMessage))).toEqual(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toEqual already performs deep equality, so there's no need for JSON.stringify
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I know, but we use JSON stringify here because we need to check the string. Without it, our main function returns a slightly different string, with the same content, but the test is not passing. You can take a look at all tests in helpers.js, we are using the same approach.

JSON.stringify({
type: '',
actions: [
null,
{
actionsList: [{
value: '',
disabled: true,
label: undefined,
},
{ value: 'CLEAR_FIELD',
disabled: false,
label: undefined },
{ value: 'REPLACE_WITH',
disabled: false,
label: undefined },
{ value: 'FIND',
disabled: false,
label: undefined },
],
controlType: () => CONTROL_TYPES.TEXTAREA,
[ACTION_VALUE_KEY]: '',
[FIELD_VALUE_KEY]: '',
},
],
}),
);
});

it('returns the correct object for the default case', () => {
expect(getDefaultActions('unknown', [], formatMessage)).toEqual({
type: null,
Expand Down
6 changes: 6 additions & 0 deletions src/constants/inAppActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ export const noteActionsWithMark = (formatMessage) => [
getChangeNoteTypeAction(formatMessage),
];

export const electronicAccess = (formatMessage) => [
getPlaceholder(formatMessage),
getClearAction(formatMessage),
getReplaceAction(formatMessage),
getFindAction(formatMessage),
];
export const noteActionsWithDuplicate = (formatMessage) => [
getPlaceholder(formatMessage),
getMarkAsStuffOnlyAction(formatMessage),
Expand Down
9 changes: 8 additions & 1 deletion src/constants/selectOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const OPTIONS = {
ADMINISTRATIVE_NOTE: 'ADMINISTRATIVE_NOTE',
CHECK_IN_NOTE: 'CHECK_IN_NOTE',
CHECK_OUT_NOTE: 'CHECK_OUT_NOTE',
URI: 'URI'
};

export const PARAMETERS_KEYS = {
Expand Down Expand Up @@ -194,11 +195,17 @@ export const getHoldingsOptions = (formatMessage, holdingsNotes = []) => [
categoryName: formatMessage({ id: 'ui-bulk-edit.category.holdingsLocation' }),
},
...holdingsNotes,
{
value: OPTIONS.URI,
label: formatMessage({ id: 'ui-bulk-edit.layer.options.holdings.uri' }),
disabled: false,
categoryName: formatMessage({ id: 'ui-bulk-edit.category.electronicAccess' }),
},
{
value: OPTIONS.SUPPRESS_FROM_DISCOVERY,
label: formatMessage({ id: 'ui-bulk-edit.layer.options.holdings.suppress' }),
disabled: false,
},
}
];

export const getHoldingsNotes = (formatMessage, holdingsNotes) => [
Expand Down
2 changes: 2 additions & 0 deletions translations/ui-bulk-edit/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
"category.itemNotes": "Item notes",
"category.holdingsNotes": "Holdings notes",
"category.holdingsLocation": "Holdings location",
"category.electronicAccess": "Electronic access",

"columns.USER.User name": "Username",
"columns.USER.User id": "User id",
Expand Down Expand Up @@ -299,6 +300,7 @@
"layer.options.administrativeNote": "Administrative note",
"layer.options.checkInNote": "Check in note",
"layer.options.checkOutNote": "Check out note",
"layer.options.holdings.uri": "URI",

"previewModal.message": "{count, number} records will be changed if the Commit changes button is clicked. You may choose Download preview to review all changes prior to saving.",
"previewModal.previewToBeChanged": "Preview of records to be changed",
Expand Down
Loading