Skip to content

Commit

Permalink
UIIN-3162 update call numbers browse results list
Browse files Browse the repository at this point in the history
  • Loading branch information
BogdanDenis committed Jan 14, 2025
1 parent 7a10026 commit 5bdfaa5
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 41 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* React 19: refactor away from react-dom/test-utils. Refs UIIN-2888.
* Add call number browse settings. Refs UIIN-3116.
* 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.
* *BREAKING* Use `browse` `1.5` interface that provides new Call Number Browse endpoints. Refs UIIN-3162.

## [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
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
6 changes: 0 additions & 6 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,16 @@ const defaultProps = {
browseData: [
{
fullCallNumber: 'Aaa',
shelfKey: 'Aa 1',
isAnchor: true,
totalRecords: 0,
},
{
fullCallNumber: 'A 1958 A 8050',
shelfKey: '41958 A 48050',
totalRecords: 1,
instance,
},
{
fullCallNumber: 'ABBA',
shelfKey: '41918 A 64243',
totalRecords: 2,
instance,
},
],
isEmptyMessage: 'Empty Message',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ const getBrowseResultsFormatter = ({
const commonTargetRecordArgs = [browseOption, filters, namespace, data];

return {
title: r => getFullMatchRecord(r.instance?.title, r.isAnchor),
subject: r => {
if (!r?.totalRecords && r?.isAnchor) {
return <MissedMatchItem query={r?.value} />;
Expand All @@ -138,7 +137,7 @@ const getBrowseResultsFormatter = ({
return typeName || <NoValue />;
},
callNumber: r => {
if (r?.instance || r?.totalRecords) {
if (r?.totalRecords) {
return getTargetRecord(r?.fullCallNumber, r, ...commonTargetRecordArgs);
}
return <MissedMatchItem query={r.fullCallNumber} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,9 @@ describe('getBrowseResultsFormatter', () => {
// 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');
// Default row
expect(screen.getByText(nonAnchorRecord.fullCallNumber).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', () => {
Expand Down
37 changes: 22 additions & 15 deletions src/components/BrowseResultsList/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
browseClassificationIndexToId,
FACETS,
queryIndexes,
segments,
} from '@folio/stripes-inventory-components';

export const isRowPreventsClick = (row, browseOption) => {
Expand All @@ -21,7 +22,6 @@ export const isRowPreventsClick = (row, browseOption) => {
const isItemHasNoRecords = row.totalRecords === 0;

return isItemHasNoRecords || (
(browseOption === browseModeOptions.CALL_NUMBERS && !row.shelfKey) ||
(browseOption === browseModeOptions.CONTRIBUTORS && !row.contributorNameTypeId) ||
(browseOption === browseModeOptions.SUBJECTS && !row.totalRecords)
);
Expand Down Expand Up @@ -109,38 +109,45 @@ export const getSearchParams = (row, qindex, allFilters, data) => {

const optionsMap = {
[browseModeOptions.CALL_NUMBERS]: {
qindex: queryIndexes.CALL_NUMBER,
query: row.shelfKey,
qindex: queryIndexes.ITEM_NORMALIZED_CALL_NUMBERS,
query: row.fullCallNumber,
segment: segments.items,
...filters,
},
[browseModeOptions.DEWEY]: {
qindex: queryIndexes.CALL_NUMBER,
query: row.shelfKey,
qindex: queryIndexes.ITEM_NORMALIZED_CALL_NUMBERS,
query: row.fullCallNumber,
segment: segments.items,
...filters,
},
[browseModeOptions.LIBRARY_OF_CONGRESS]: {
qindex: queryIndexes.CALL_NUMBER,
query: row.shelfKey,
qindex: queryIndexes.ITEM_NORMALIZED_CALL_NUMBERS,
query: row.fullCallNumber,
segment: segments.items,
...filters,
},
[browseModeOptions.LOCAL]: {
qindex: queryIndexes.CALL_NUMBER,
query: row.shelfKey,
qindex: queryIndexes.ITEM_NORMALIZED_CALL_NUMBERS,
query: row.fullCallNumber,
segment: segments.items,
...filters,
},
[browseModeOptions.NATIONAL_LIBRARY_OF_MEDICINE]: {
qindex: queryIndexes.CALL_NUMBER,
query: row.shelfKey,
qindex: queryIndexes.ITEM_NORMALIZED_CALL_NUMBERS,
query: row.fullCallNumber,
segment: segments.items,
...filters,
},
[browseModeOptions.OTHER]: {
qindex: queryIndexes.CALL_NUMBER,
query: row.shelfKey,
qindex: queryIndexes.ITEM_NORMALIZED_CALL_NUMBERS,
query: row.fullCallNumber,
segment: segments.items,
...filters,
},
[browseModeOptions.SUPERINTENDENT]: {
qindex: queryIndexes.CALL_NUMBER,
query: row.shelfKey,
qindex: queryIndexes.ITEM_NORMALIZED_CALL_NUMBERS,
query: row.fullCallNumber,
segment: segments.items,
...filters,
},
[browseModeOptions.CLASSIFICATION_ALL]: classificationOption,
Expand Down
16 changes: 8 additions & 8 deletions src/hooks/useInventoryBrowse/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { browseModeOptions } from '@folio/stripes-inventory-components';
// [pageNumber, direction, anchor] - E.g. [1, 'prev', 'Fizz Buzz'];
export const INIT_PAGE_CONFIG = [0, null, null];

export const regExp = /^((callNumber|subject|name|itemEffectiveShelvingOrder) [<|>])/i;
export const regExp = /^((callNumber|subject|name|fullCallNumber) [<|>])/i;
export const PRECEDING_RECORDS_COUNT = 5;
export const FIVE_MINUTES = 5 * 60 * 1000;

Expand Down Expand Up @@ -39,13 +39,13 @@ export const INITIAL_SEARCH_PARAMS_MAP = {

export const PAGINATION_SEARCH_PARAMS_MAP = {
[browseModeOptions.SUBJECTS]: INITIAL_SEARCH_PARAMS_MAP[browseModeOptions.SUBJECTS],
[browseModeOptions.CALL_NUMBERS]: 'itemEffectiveShelvingOrder',
[browseModeOptions.DEWEY]: 'itemEffectiveShelvingOrder',
[browseModeOptions.LIBRARY_OF_CONGRESS]: 'itemEffectiveShelvingOrder',
[browseModeOptions.LOCAL]: 'itemEffectiveShelvingOrder',
[browseModeOptions.NATIONAL_LIBRARY_OF_MEDICINE]: 'itemEffectiveShelvingOrder',
[browseModeOptions.OTHER]: 'itemEffectiveShelvingOrder',
[browseModeOptions.SUPERINTENDENT]: 'itemEffectiveShelvingOrder',
[browseModeOptions.CALL_NUMBERS]: 'fullCallNumber',
[browseModeOptions.DEWEY]: 'fullCallNumber',
[browseModeOptions.LIBRARY_OF_CONGRESS]: 'fullCallNumber',
[browseModeOptions.LOCAL]: 'fullCallNumber',
[browseModeOptions.NATIONAL_LIBRARY_OF_MEDICINE]: 'fullCallNumber',
[browseModeOptions.OTHER]: 'fullCallNumber',
[browseModeOptions.SUPERINTENDENT]: 'fullCallNumber',
[browseModeOptions.CLASSIFICATION_ALL]: INITIAL_SEARCH_PARAMS_MAP[browseModeOptions.CLASSIFICATION_ALL],
[browseModeOptions.DEWEY_CLASSIFICATION]: INITIAL_SEARCH_PARAMS_MAP[browseModeOptions.DEWEY_CLASSIFICATION],
[browseModeOptions.LC_CLASSIFICATION]: INITIAL_SEARCH_PARAMS_MAP[browseModeOptions.LC_CLASSIFICATION],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const useSearchForShadowInstanceTenants = ({ instanceId } = {}) => {

const { isLoading, data = {} } = useQuery({
queryKey: [namespace, consortium, instanceId],
queryFn: () => ky.get('search/instances/facets',
queryFn: () => ky.get('search/call-numbers/facets',
{
searchParams: {
facet: 'holdings.tenantId',
Expand Down

0 comments on commit 5bdfaa5

Please sign in to comment.