Skip to content

Commit

Permalink
Revert "UIBULKED-315 Group holdings record properties using optgroup …
Browse files Browse the repository at this point in the history
…component (#396)"

This reverts commit 988d3fb.
  • Loading branch information
vashjs authored Oct 16, 2023
1 parent 988d3fb commit cd33bd1
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 94 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
## In progress

* [UIBULKED-355](https://issues.folio.org/browse/UIBULKED-355) Remove reference to Query tab on the landing page.
* [UIBULKED-315](https://issues.folio.org/browse/UIBULKED-315) Group holdings record properties using optgroup component

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

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@
"subPermissions": [
"ui-bulk-edit.app-view",
"ui-bulk-edit.edit.base",
"inventory-storage.item-note-types.collection.get",
"inventory-storage.holdings-note-types.collection.get"
"inventory-storage.item-note-types.collection.get"
],
"visible": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
} from '../../../hooks/api';
import { useBulkPermissions, useLocationFilters } from '../../../hooks';
import { LogsFilters } from './LogsFilters/LogsFilters';
import { getCapabilityOptions, isCapabilityDisabled } from '../../../utils/helpers';
import { getCapabilityOptions, isCapabilityDisabled } from '../../../utils/filters';
import FilterTabs from './FilterTabs/FilterTabs';
import Capabilities from './Capabilities/Capabilities';
import { getIsDisabledByPerm } from './utils/getIsDisabledByPerm';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { BulkEditInAppTitle } from './BulkEditInAppTitle/BulkEditInAppTitle';
import { ContentUpdatesForm } from './ContentUpdatesForm/ContentUpdatesForm';
import { CAPABILITIES, getHoldingsOptions, getItemsOptions, getUserOptions } from '../../../../constants';
import { useItemNotes } from '../../../../hooks/api/useItemNotes';
import { useHoldingsNotes } from '../../../../hooks/api/useHoldingsNotes';

export const BulkEditInApp = ({
onContentUpdatesChanged,
Expand All @@ -25,19 +24,17 @@ export const BulkEditInApp = ({

const fileUploadedName = search.get('fileName');
const isItemCapability = capabilities === CAPABILITIES.ITEM;
const isHoldingsCapability = capabilities === CAPABILITIES.HOLDING;

const { itemNotes, isItemNotesLoading } = useItemNotes({ enabled: isItemCapability });
const { holdingNotes, isHoldingsNotesLoading } = useHoldingsNotes({ enabled: isHoldingsCapability });

const optionsMap = {
[CAPABILITIES.ITEM]: getItemsOptions(intl.formatMessage, itemNotes),
[CAPABILITIES.USER]: getUserOptions(intl.formatMessage),
[CAPABILITIES.HOLDING]: getHoldingsOptions(intl.formatMessage, holdingNotes),
[CAPABILITIES.HOLDING]: getHoldingsOptions(intl.formatMessage),
};

const options = optionsMap[capabilities];
const showContentUpdatesForm = options && !isItemNotesLoading && !isHoldingsNotesLoading;
const showContentUpdatesForm = options && !isItemNotesLoading;

return (
<>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MemoryRouter } from 'react-router-dom';
import { QueryClientProvider } from 'react-query';
import { act, render, screen, waitFor } from '@testing-library/react';
import { act, render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import { useOkapiKy } from '@folio/stripes/core';
Expand Down Expand Up @@ -256,16 +256,11 @@ describe('BulkEditInApp', () => {
expect(optionPatronGroup.selected).toBeTruthy();
});

it('should display holdings permanent location', async () => {
it('should display holdings permanent location', () => {
renderBulkEditInApp({ capability: CAPABILITIES.HOLDING });

let selectOption;
let optionStatus;

await waitFor(() => {
selectOption = screen.getByTestId('select-option-0');
optionStatus = screen.getByRole('option', { name: /layer.options.holdings.permanentLocation/ });
});
const selectOption = screen.getByTestId('select-option-0');
const optionStatus = screen.getByRole('option', { name: /layer.options.holdings.permanentLocation/ });

act(() => userEvent.selectOptions(selectOption, optionStatus));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
getFilteredFields,
getExtraActions,
} from './helpers';
import { groupByCategory } from '../../../../../utils/helpers';
import { groupByCategory } from '../../../../../utils/filters';

export const ContentUpdatesForm = ({
onContentUpdatesChanged,
Expand Down
18 changes: 3 additions & 15 deletions src/constants/selectOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ export const OPTIONS = {
TEMPORARY_HOLDINGS_LOCATION: 'TEMPORARY_HOLDINGS_LOCATION',
PERMANENT_HOLDINGS_LOCATION: 'PERMANENT_HOLDINGS_LOCATION',
ITEM_NOTE: 'ITEM_NOTE',
HOLDINGS_NOTE: 'HOLDINGS_NOTE',
ADMINISTRATIVE_NOTE: 'ADMINISTRATIVE_NOTE',
CHECK_IN_NOTE: 'CHECK_IN_NOTE',
CHECK_OUT_NOTE: 'CHECK_OUT_NOTE',
};

export const PARAMETERS_KEYS = {
ITEM_NOTE_TYPE_ID_KEY: 'ITEM_NOTE_TYPE_ID_KEY',
HOLDINGS_NOTE_TYPE_ID_KEY: 'HOLDINGS_NOTE_TYPE_ID_KEY',
};

export const OPTIONS_WITH_ADDITIONAL_PARAMETERS = [
Expand Down Expand Up @@ -170,30 +168,20 @@ export const getUserOptions = (formatMessage) => [
},
];

export const getHoldingsOptions = (formatMessage, holdingsNotes = []) => [
export const getHoldingsOptions = (formatMessage) => [
{
value: '',
label: formatMessage({ id: 'ui-bulk-edit.options.placeholder' }),
disabled: true,
},
{
value: OPTIONS.ADMINISTRATIVE_NOTE,
label: formatMessage({ id: 'ui-bulk-edit.layer.options.administrativeNote' }),
disabled: false,
},
{
value: OPTIONS.TEMPORARY_HOLDINGS_LOCATION,
{ value: OPTIONS.TEMPORARY_HOLDINGS_LOCATION,
label: formatMessage({ id: 'ui-bulk-edit.layer.options.holdings.temporaryLocation' }),
disabled: false,
categoryName: 'Holdings location'
},
disabled: false },
{
value: OPTIONS.PERMANENT_HOLDINGS_LOCATION,
label: formatMessage({ id: 'ui-bulk-edit.layer.options.holdings.permanentLocation' }),
disabled: false,
categoryName: 'Holdings location'
},
...holdingsNotes,
{
value: OPTIONS.SUPPRESS_FROM_DISCOVERY,
label: formatMessage({ id: 'ui-bulk-edit.layer.options.holdings.suppress' }),
Expand Down
File renamed without changes.
32 changes: 0 additions & 32 deletions src/hooks/api/useHoldingsNotes.js

This file was deleted.

18 changes: 12 additions & 6 deletions src/hooks/api/useItemNotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useOkapiKy } from '@folio/stripes/core';
import { useQuery } from 'react-query';
import { useIntl } from 'react-intl';
import { OPTIONS, PARAMETERS_KEYS } from '../../constants';
import { getMappedAndSortedNotes } from '../../utils/helpers';

export const useItemNotes = (options = {}) => {
const ky = useOkapiKy();
Expand All @@ -18,12 +17,19 @@ export const useItemNotes = (options = {}) => {
},
);

const itemNotes = getMappedAndSortedNotes({
notes: data?.itemNoteTypes,
categoryName: formatMessage({ id: 'ui-bulk-edit.category.itemNotes' }),
const mappedNotes = data?.itemNoteTypes?.map(type => ({
label: type.name,
value: type.id,
type: OPTIONS.ITEM_NOTE,
key: PARAMETERS_KEYS.ITEM_NOTE_TYPE_ID_KEY,
});
parameters: [{
key: PARAMETERS_KEYS.ITEM_NOTE_TYPE_ID_KEY,
value: type.id,
}],
disabled: false,
categoryName: formatMessage({ id: 'ui-bulk-edit.category.itemNotes' }),
})) || [];

const itemNotes = mappedNotes.sort((a, b) => a.label.localeCompare(b.label));

return {
itemNotes,
Expand Down
21 changes: 0 additions & 21 deletions src/utils/helpers.js → src/utils/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,4 @@ export const groupByCategory = (array) => {
}, {});
};

export const getMappedAndSortedNotes = ({
notes,
categoryName,
key,
type
}) => {
const mappedNotes = notes?.map(note => ({
label: note.name,
value: note.id,
type,
parameters: [{
key,
value: note.id,
}],
disabled: false,
categoryName,
})) || [];

return mappedNotes.sort((a, b) => a.label.localeCompare(b.label));
};


1 change: 0 additions & 1 deletion translations/ui-bulk-edit/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@
"category.loanType": "Loan type",
"category.location": "Location",
"category.itemNotes": "Item notes",
"category.holdingNotes": "Holdings notes",

"columns.USER.User name": "Username",
"columns.USER.User id": "User id",
Expand Down

0 comments on commit cd33bd1

Please sign in to comment.