diff --git a/CHANGELOG.md b/CHANGELOG.md index 12320b11e..777f5413d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change history for ui-inventory +## [10.0.1](IN PROGRESS) +* If Shared & Held by facets were selected in the Browse search, then retain them in the Search lookup after clicking the record. Refs UIIN-2608. + ## [10.0.0](https://github.com/folio-org/ui-inventory/tree/v10.0.0) (2023-10-13) [Full Changelog](https://github.com/folio-org/ui-inventory/compare/v9.4.12...v10.0.0) @@ -107,7 +110,6 @@ * Bump @folio/stripes-acq-components dependency version to 5.0.0. Refs UIIN-2620. * ECS: Check when sharing instance with source=MARC is complete before re-fetching it. Refs UIIN-2605. * Update all facets after changing a term or selecting a facet option. Refs UIIN-2610. -* If Shared & Held by facets were selected in the Browse search, then retain them in the Search lookup after clicking the record. Refs UIIN-2608. ## [9.4.12](https://github.com/folio-org/ui-inventory/tree/v9.4.12) (2023-09-21) [Full Changelog](https://github.com/folio-org/ui-inventory/compare/v9.4.11...v9.4.12) diff --git a/src/components/BrowseResultsList/BrowseResultsList.test.js b/src/components/BrowseResultsList/BrowseResultsList.test.js index f90c2d3b8..6a6a0cca9 100644 --- a/src/components/BrowseResultsList/BrowseResultsList.test.js +++ b/src/components/BrowseResultsList/BrowseResultsList.test.js @@ -76,19 +76,19 @@ const mockContext = { const contributorsData = [ { - "name": "Toth, Josh", - "contributorTypeId": [ - "6e09d47d-95e2-4d8a-831b-f777b8ef6d81" + 'name': 'Toth, Josh', + 'contributorTypeId': [ + '6e09d47d-95e2-4d8a-831b-f777b8ef6d81' ], - "contributorNameTypeId": "2b94c631-fca9-4892-a730-03ee529ffe2a", - "isAnchor": false, - "totalRecords": 1 + 'contributorNameTypeId': '2b94c631-fca9-4892-a730-03ee529ffe2a', + 'isAnchor': false, + 'totalRecords': 1 }, ]; const subjectsData = [ { - "value": "Trivia and miscellanea", - "totalRecords": 8 + 'value': 'Trivia and miscellanea', + 'totalRecords': 8 }, ]; @@ -129,7 +129,7 @@ describe('BrowseResultsList', () => { }); describe.each([ - { searchOption: browseCallNumberOptions.CALL_NUMBERS, shared: FACETS.SHARED, heldBy: FACETS.CALL_NUMBERS_HELD_BY }, + { searchOption: browseCallNumberOptions.CALL_NUMBERS, shared: FACETS.SHARED, heldBy: FACETS.CALL_NUMBERS_HELD_BY }, { searchOption: browseCallNumberOptions.DEWEY, shared: FACETS.SHARED, heldBy: FACETS.CALL_NUMBERS_HELD_BY }, { searchOption: browseCallNumberOptions.LIBRARY_OF_CONGRESS, shared: FACETS.SHARED, heldBy: FACETS.CALL_NUMBERS_HELD_BY }, { searchOption: browseCallNumberOptions.LOCAL, shared: FACETS.SHARED, heldBy: FACETS.CALL_NUMBERS_HELD_BY }, @@ -151,16 +151,16 @@ describe('BrowseResultsList', () => { qindex: searchOption, query: 'a', [shared]: ['true', 'false'], - [heldBy]: ["college"], + [heldBy]: ['college'], }, }); await act(async () => fireEvent.click(screen.getByText(defaultProps.browseData[2].fullCallNumber))); expect(history.location.search).toContain('?filters=shared.true%2Cshared.false%2CtenantId.college'); - }) - }) - }) + }); + }); + }); describe('when the search option is Contributors and the Shared and/or HeldBy facets are selected', () => { describe('and the user clicks on a record in the list', () => { @@ -176,7 +176,7 @@ describe('BrowseResultsList', () => { filters: { qindex: 'contributors', contributorsShared: ['true', 'false'], - contributorsTenantId: ["college"], + contributorsTenantId: ['college'], }, browseData: contributorsData, }); @@ -186,11 +186,11 @@ describe('BrowseResultsList', () => { expect(history.location.search).toContain( '?filters=searchContributors.2b94c631-fca9-4892-a730-03ee529ffe2a%2Cshared.true%2Cshared.false%2CtenantId.college' ); - }) - }) - }) + }); + }); + }); - describe(`when the search option is Subjects and the Shared and/or HeldBy facets are selected`, () => { + describe('when the search option is Subjects and the Shared and/or HeldBy facets are selected', () => { describe('and the user clicks on a record in the list', () => { it('should be navigated to the Search lookup with those filters', async () => { history = createMemoryHistory({ @@ -204,7 +204,7 @@ describe('BrowseResultsList', () => { filters: { qindex: 'browseSubjects', subjectsShared: ['true', 'false'], - subjectsTenantId: ["college"], + subjectsTenantId: ['college'], }, browseData: subjectsData, }); @@ -212,9 +212,9 @@ describe('BrowseResultsList', () => { await act(async () => fireEvent.click(screen.getByText(subjectsData[0].value))); expect(history.location.search).toContain('?filters=shared.true%2Cshared.false%2CtenantId.college'); - }) - }) - }) + }); + }); + }); describe('when Instance record is linked to an authority record', () => { describe('by clicking on the icon of an authority app', () => { diff --git a/src/components/BrowseResultsList/utils.js b/src/components/BrowseResultsList/utils.js index aed6f0ec5..6a38054ee 100644 --- a/src/components/BrowseResultsList/utils.js +++ b/src/components/BrowseResultsList/utils.js @@ -17,10 +17,9 @@ export const isRowPreventsClick = (row, browseOption) => { ); }; -// [true, false] => 'shared.true,shared.false' const facetsToString = (filters, facetNameInBrowse, facetNameInSearch) => { return filters[facetNameInBrowse]?.map(value => `${facetNameInSearch}.${value}`).join(','); -} +}; const getExtraFilters = (row, qindex, allFilters) => { const filtersOnly = omit(allFilters, 'qindex', 'query'); @@ -51,7 +50,7 @@ const getExtraFilters = (row, qindex, allFilters) => { const extraFacetsString = [...extraFacets, sharedExtraFacets, heldByExtraFacets].filter(Boolean).join(','); return extraFacetsString ? { filters: extraFacetsString } : {}; -} +}; export const getSearchParams = (row, qindex, allFilters) => { const filters = getExtraFilters(row, qindex, allFilters);