Skip to content

Commit

Permalink
Merge branch 'master' into UXPROD-4125
Browse files Browse the repository at this point in the history
  • Loading branch information
mariia-aloshyna authored Feb 12, 2025
2 parents d055df8 + 99ed763 commit ab8b708
Show file tree
Hide file tree
Showing 19 changed files with 294 additions and 111 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* Sort holdings by location name and call number. Refs UIIN-3207.
* Remove hover-over text next to "Shelving order" on the Item record detail view. Refs UIIN-3210.
* CI: Switch to centralized/shared workflow from https://github.com/folio-org/.github. Fixes UIIN-3218.
* Set correct widths for Call number browse results columns. Fixes UIIN-3229.
* Display actual instance state (shared or local) when user is using "Drag and drop" to move inventory records. Fixes UIIN-3185.
* Add Version history button and Version history pane to details view of Item. Refs UIIN-3172.
* Add Version history button and Version history pane to details view of Holdings. Refs UIIN-3171.
* Add Version history button and Version history pane to details view of Instance. Refs UIIN-3170.
Expand Down Expand Up @@ -49,6 +51,8 @@

* Display holdings names in `Consortial holdings` accordion for user without inventory permissions in member tenants. Fixes UIIN-3159.
* Remove the ability to share local instance when `Inventory: View, create instances` permission is assigned. Fixes UIIN-3166.
* *BREAKING* Use `browse` `1.5` interface that provides new Call Number Browse endpoints. Refs UIIN-3162.
* Add `getCallNumberQuery` function to build a query string based on the call number and its type. Refs UIIN-3205.

## [12.0.7](https://github.com/folio-org/ui-inventory/tree/v12.0.7) (2024-12-17)
[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v12.0.6...v12.0.7)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@folio/inventory",
"version": "13.0.0",
"version": "13.1.0",
"description": "Inventory manager",
"repository": "folio-org/ui-inventory",
"publishConfig": {
Expand Down Expand Up @@ -54,7 +54,7 @@
"okapiInterfaces": {
"alternative-title-types": "1.0",
"call-number-types": "1.0",
"browse": "0.6 1.0",
"browse": "1.5",
"circulation": "9.0 10.0 11.0 12.0 13.0 14.0",
"classification-types": "1.1",
"configuration": "2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const InstanceMovementDetails = ({
onClose={closeInstance}
actionMenu={getActionMenu}
data-test-instance-movement-details={instance.id}
isShared={instance.shared}
id={id}
>
<Droppable
Expand Down
8 changes: 2 additions & 6 deletions src/components/BrowseResultsList/BrowseResultsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@ import {
MCLPagingTypes,
MultiColumnList,
} from '@folio/stripes/components';
import {
useItemToView,
} from '@folio/stripes-acq-components';
import { useItemToView } from '@folio/stripes-acq-components';

import {
BROWSE_RESULTS_COUNT,
} from '../../constants';
import { BROWSE_RESULTS_COUNT } from '../../constants';
import { DataContext } from '../../contexts';
import {
COLUMNS_MAPPING,
Expand Down
21 changes: 12 additions & 9 deletions src/components/BrowseResultsList/BrowseResultsList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import { createMemoryHistory } from 'history';
import { Router } from 'react-router-dom';

import { instance } from '../../../test/fixtures/instance';
import {
renderWithIntl,
translationsProperties,
Expand All @@ -37,21 +36,19 @@ const defaultProps = {
browseData: [
{
fullCallNumber: 'Aaa',
shelfKey: 'Aa 1',
callNumber: 'Aaa',
isAnchor: true,
totalRecords: 0,
},
{
fullCallNumber: 'A 1958 A 8050',
shelfKey: '41958 A 48050',
callNumber: 'A 1958 A 8050',
totalRecords: 1,
instance,
},
{
fullCallNumber: 'ABBA',
shelfKey: '41918 A 64243',
callNumber: 'ABBA',
totalRecords: 2,
instance,
},
],
isEmptyMessage: 'Empty Message',
Expand Down Expand Up @@ -93,6 +90,12 @@ const mockContext = {
],
},
],
callNumberBrowseConfig: [
{
id: 'dewey',
typeIds: ['dewey-id', 'lc-id'],
},
],
subjectSources: [{ id: 'sourceId', name: 'sourceName' }],
subjectTypes: [{ id: 'typeId', name: 'typeName' }],
};
Expand Down Expand Up @@ -133,13 +136,13 @@ describe('BrowseResultsList', () => {
it('should render browse data', () => {
renderBrowseResultsList();

expect(screen.getByText(defaultProps.browseData[1].fullCallNumber)).toBeInTheDocument();
expect(screen.getByText(defaultProps.browseData[1].callNumber)).toBeInTheDocument();
});

it('should navigate to instance Search page and show related instances', async () => {
renderBrowseResultsList();

await act(async () => fireEvent.click(screen.getByText(defaultProps.browseData[2].fullCallNumber)));
await act(async () => fireEvent.click(screen.getByText(defaultProps.browseData[2].callNumber)));

const { pathname, search } = history.location;

Expand Down Expand Up @@ -180,7 +183,7 @@ describe('BrowseResultsList', () => {
},
});

fireEvent.click(screen.getByText(defaultProps.browseData[2].fullCallNumber));
fireEvent.click(screen.getByText(defaultProps.browseData[2].callNumber));

expect(history.location.search).toContain('?filters=shared.true%2Cshared.false%2CtenantId.college');
});
Expand Down
33 changes: 32 additions & 1 deletion src/components/BrowseResultsList/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,38 @@ export const COLUMNS_MAPPING = {
export const COLUMNS_WIDTHS = {
[browseModeOptions.CALL_NUMBERS]: {
callNumber: '15%',
title: '40%',
title: '70%',
numberOfTitles: '15%',
},
[browseModeOptions.DEWEY]: {
callNumber: '15%',
title: '70%',
numberOfTitles: '15%',
},
[browseModeOptions.LIBRARY_OF_CONGRESS]: {
callNumber: '15%',
title: '70%',
numberOfTitles: '15%',
},
[browseModeOptions.NATIONAL_LIBRARY_OF_MEDICINE]: {
callNumber: '15%',
title: '70%',
numberOfTitles: '15%',
},
[browseModeOptions.LOCAL]: {
callNumber: '15%',
title: '70%',
numberOfTitles: '15%',
},
[browseModeOptions.OTHER]: {
callNumber: '15%',
title: '70%',
numberOfTitles: '15%',
},
[browseModeOptions.SUPERINTENDENT]: {
callNumber: '15%',
title: '70%',
numberOfTitles: '15%',
},
[browseModeOptions.CLASSIFICATION_ALL]: {
classificationNumber: '50%',
Expand Down
9 changes: 6 additions & 3 deletions src/components/BrowseResultsList/getBrowseResultsFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
INVENTORY_ROUTE,
} from '../../constants';
import {
getFullCallNumber,
getSearchParams,
isRowPreventsClick,
} from './utils';
Expand Down Expand Up @@ -112,7 +113,7 @@ const getBrowseResultsFormatter = ({
const commonTargetRecordArgs = [browseOption, filters, namespace, data];

return {
title: r => getFullMatchRecord(r.instance?.title, r.isAnchor),
title: r => getFullMatchRecord(r.instanceTitle, r.isAnchor),
subject: r => {
if (!r?.totalRecords && r?.isAnchor) {
return <MissedMatchItem query={r?.value} />;
Expand All @@ -138,8 +139,10 @@ const getBrowseResultsFormatter = ({
return typeName || <NoValue />;
},
callNumber: r => {
if (r?.instance || r?.totalRecords) {
return getTargetRecord(r?.fullCallNumber, r, ...commonTargetRecordArgs);
const fullCallNumber = getFullCallNumber(r);

if (r?.totalRecords) {
return getTargetRecord(fullCallNumber, r, ...commonTargetRecordArgs);
}
return <MissedMatchItem query={r.fullCallNumber} />;
},
Expand Down
61 changes: 45 additions & 16 deletions src/components/BrowseResultsList/getBrowseResultsFormatter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ import '../../../test/jest/__mock__';
import { act, screen, fireEvent } from '@folio/jest-config-stripes/testing-library/react';
import { createMemoryHistory } from 'history';
import { Router } from 'react-router-dom';
import queryString from 'query-string';

import { MultiColumnList } from '@folio/stripes-components';
import { browseModeOptions } from '@folio/stripes-inventory-components';
import {
browseCallNumberOptions,
browseModeOptions,
queryIndexes,
} from '@folio/stripes-inventory-components';

import {
renderWithIntl,
Expand Down Expand Up @@ -47,6 +52,13 @@ const data = {
],
},
],
callNumberBrowseConfig: [
{
id: 'dewey',
shelvingAlgorithm: 'dewey',
typeIds: ['dewey-id', 'lc-id'],
},
],
subjectSources: [{ id: 'sourceId1', name: 'sourceName1' }, { id: 'sourceId2', name: 'sourceName2' }],
subjectTypes: [{ id: 'typeId1', name: 'typeName1' }, { id: 'typeId2', name: 'typeName2' }],
};
Expand Down Expand Up @@ -87,21 +99,21 @@ describe('getBrowseResultsFormatter', () => {
const missedMatchRecord = {
isAnchor: true,
fullCallNumber: 'bla bla',
callNumber: 'bla bla',
totalRecords: 0,
};
const contentData = [
{
fullCallNumber: 'A 1958 A 8050',
shelfKey: '41958 A 48050',
fullCallNumber: 'CALL',
isAnchor: true,
totalRecords: 1,
instance: { id: 'ce9dd893-c812-49d5-8973-d55d018894c4', title: 'Test title' },
totalRecords: 0,
},
{
fullCallNumber: 'AAA',
shelfKey: '123456',
fullCallNumber: 'CALL SUF',
callNumber: 'CALL',
callNumberPrefix: 'PRE',
callNumberSuffix: 'SUF',
totalRecords: 2,
instance: { id: 'ce9dd893-c812-49d5-8973-d55d018894c4', title: 'Test title 2' },
},
];
const [anchorRecord, nonAnchorRecord] = contentData;
Expand All @@ -117,30 +129,47 @@ describe('getBrowseResultsFormatter', () => {
renderCallNumberList();

// Anchor row
expect(screen.getByText(anchorRecord.fullCallNumber).tagName.toLowerCase()).toBe('strong');
expect(screen.getByText(anchorRecord.totalRecords).tagName.toLowerCase()).toBe('strong');
expect(screen.getByText(anchorRecord.instance.title).tagName.toLowerCase()).toBe('strong');
expect(screen.getByText('would be here').tagName.toLowerCase()).toBe('strong');
expect(screen.getByText('CALL').tagName.toLowerCase()).not.toBe('strong');
// Default row
expect(screen.getByText(nonAnchorRecord.fullCallNumber).tagName.toLowerCase()).not.toBe('strong');
expect(screen.getByText('PRE CALL SUF').tagName.toLowerCase()).not.toBe('strong');
expect(screen.getByText(nonAnchorRecord.totalRecords).tagName.toLowerCase()).not.toBe('strong');
expect(screen.getByText(nonAnchorRecord.instance.title).tagName.toLowerCase()).not.toBe('strong');
});

it('should render \'Missed match item\' row', () => {
renderCallNumberList({ contentData: [missedMatchRecord] });

expect(screen.getByText(missedMatchRecord.fullCallNumber)).toBeInTheDocument();
expect(screen.getByText(missedMatchRecord.callNumber)).toBeInTheDocument();
expect(screen.getByText(missedMatchText)).toBeInTheDocument();
});

it('should navigate to instance "Search" page when target column was clicked', async () => {
it('should not navigate to any page when anchor is clicked', async () => {
renderCallNumberList();

expect(history.location.pathname).toEqual(BROWSE_INVENTORY_ROUTE);

await act(async () => fireEvent.click(screen.getByText(anchorRecord.fullCallNumber)));

expect(history.location.pathname).toEqual(INVENTORY_ROUTE);
expect(history.location.pathname).toEqual(BROWSE_INVENTORY_ROUTE);
});

describe('when call number title is clicked', () => {
it('should navigate to the instance "Search" page', async () => {
const { getByText } = renderCallNumberList({
formatter: getBrowseResultsFormatter({
data,
browseOption: browseCallNumberOptions.DEWEY,
}),
});

const query = queryString.stringify({
selectedBrowseResult: true,
qindex: queryIndexes.QUERY_SEARCH,
query: 'itemNormalizedCallNumbers="PRE CALL SUF" and (item.effectiveCallNumberComponents.typeId=="dewey-id" or item.effectiveCallNumberComponents.typeId=="lc-id")',
});

expect(getByText('PRE CALL SUF').href).toContain(`${INVENTORY_ROUTE}?${query}`);
});
});
});

Expand Down
Loading

0 comments on commit ab8b708

Please sign in to comment.