From aa05d11a6041b60755eccab71d11ae84e4374e43 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Tue, 24 Dec 2024 10:30:58 -0500 Subject: [PATCH 1/2] replace formatType with recordType --- __test__/fixtures/bibFixtures.ts | 18 +-- __test__/fixtures/rawSierraAccountData.ts | 20 ++-- .../searchResultElectronicResources.ts | 6 +- .../fixtures/searchResultManyPhysicalItems.ts | 2 +- .../fixtures/searchResultPhysicalItems.ts | 2 +- __test__/fixtures/searchResultsManyBibs.ts | 112 +++++++++--------- .../pages/search/advancedSearchForm.test.tsx | 6 +- discoveryApiResearchNowMapping.md | 8 +- pages/search/advanced.tsx | 8 +- .../RefineSearch/RefineSearch.test.tsx | 12 +- src/components/RefineSearch/RefineSearch.tsx | 2 +- .../RefineSearch/sampleFilters.json | 10 +- .../SearchFilters/AppliedFilters.test.tsx | 10 +- .../SearchFilters/appliedFilterUtils.test.ts | 6 +- src/components/SearchResults/SearchResult.tsx | 2 +- src/config/aggregations.tsx | 90 +++++++++++--- src/models/Bib.ts | 6 +- src/models/Item.ts | 2 +- src/models/modelTests/Bib.test.ts | 4 +- .../modelTests/SearchResultsBib.test.ts | 2 +- src/types/bibTypes.ts | 4 +- src/types/myAccountTypes.ts | 2 +- src/types/searchTypes.ts | 6 +- src/utils/advancedSearchUtils.ts | 6 +- src/utils/refineSearchUtils.ts | 2 +- src/utils/searchUtils.ts | 4 +- src/utils/utilsTests/searchUtils.test.ts | 4 +- 27 files changed, 205 insertions(+), 151 deletions(-) diff --git a/__test__/fixtures/bibFixtures.ts b/__test__/fixtures/bibFixtures.ts index 294842e95..0ba51f9b1 100644 --- a/__test__/fixtures/bibFixtures.ts +++ b/__test__/fixtures/bibFixtures.ts @@ -435,7 +435,7 @@ export const bibWithItems = { }, ], lccClassification: ["IN PROCESS"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -903,7 +903,7 @@ export const bibNoItems = { }, ], lccClassification: ["IN PROCESS"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -2655,7 +2655,7 @@ export const bibWithManyItems = { prefLabel: "Chinese", }, ], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -3127,7 +3127,7 @@ export const bibWithSupplementaryContent = { }, ], lccClassification: ["FICTION WAT"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -6525,7 +6525,7 @@ export const parallelsBib = { }, ], lccClassification: ["DR1932 .P68"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -7660,7 +7660,7 @@ export const noParallels = { }, ], lccClassification: ["PQ2663.O7223 Z46 2005"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -8217,7 +8217,7 @@ export const yiddishBib = { }, ], lccClassification: ["DS135.R93 K42 1968"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -11223,7 +11223,7 @@ export const bibManyEResources = { prefLabel: "French", }, ], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -11446,7 +11446,7 @@ export const bibWithSubjectHeadings = { }, ], lccClassification: ["PQ2663.O7223 Z46 2005"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", diff --git a/__test__/fixtures/rawSierraAccountData.ts b/__test__/fixtures/rawSierraAccountData.ts index 529d34a22..ce54e9a0e 100644 --- a/__test__/fixtures/rawSierraAccountData.ts +++ b/__test__/fixtures/rawSierraAccountData.ts @@ -599,7 +599,7 @@ export const checkoutBibs = { }, title: "Good night, Little Fish", author: "Cousins, Lucy, author.", - materialType: { + recordType: { code: "a ", value: "BOOK/TEXT", }, @@ -1499,7 +1499,7 @@ export const checkoutBibs = { }, title: "Fish, fish, fish", author: "Adams, Georgie.", - materialType: { + recordType: { code: "a ", value: "BOOK/TEXT", }, @@ -1852,7 +1852,7 @@ export const checkoutBibs = { }, title: "test 5/6 01", author: "Spaghetti Monster", - materialType: { + recordType: { code: "- ", value: "MISC", }, @@ -1904,7 +1904,7 @@ export const checkoutBibs = { title: "[Standard NYPL restrictions apply] HOF HA-KELAVIM HA-MESHUHRARIM = THE BEACH OF FREE DOGS / AVRON POLAKOW. [RECAP]", author: "Polakow, Avron, author.", - materialType: { + recordType: { code: "- ", value: "MISC", }, @@ -1983,7 +1983,7 @@ export const holdBibs = { }, title: "Spaghetti!", author: "Cortanze, GĂ©rard de.", - materialType: { + recordType: { code: "a ", value: "BOOK/TEXT", }, @@ -2466,7 +2466,7 @@ export const holdBibs = { }, title: "The house of mirth : large print", author: "Wharton, Edith, 1862-1937.", - materialType: { + recordType: { code: "l ", value: "LARGE PRINT", }, @@ -3154,7 +3154,7 @@ export const holdBibs = { }, title: "I want to be spaghetti!", author: "Wright-Ruiz, Kiera, author.", - materialType: { + recordType: { code: "a ", value: "BOOK/TEXT", }, @@ -3862,7 +3862,7 @@ export const holdBibs = { }, title: "Partner record", author: "Spaghetti Monster", - materialType: { + recordType: { code: "- ", value: "MISC", }, @@ -3912,7 +3912,7 @@ export const holdBibs = { lang: { code: "eng", name: "English" }, title: "Pasta every day : make it, shape it, sauce it, eat it", author: "Feinstein, Meryl, author.", - materialType: { code: "a ", value: "BOOK/TEXT" }, + recordType: { code: "a ", value: "BOOK/TEXT" }, bibLevel: { code: "m", value: "MONOGRAPH" }, publishYear: 2023, catalogDate: "2023-11-22", @@ -3975,7 +3975,7 @@ export const holds = { }, title: "Pasta every day : make it, shape it, sauce it, eat it", author: "Feinstein, Meryl, author.", - materialType: { + recordType: { code: "a ", value: "BOOK/TEXT", }, diff --git a/__test__/fixtures/searchResultElectronicResources.ts b/__test__/fixtures/searchResultElectronicResources.ts index 0343d3337..0d52f05e8 100644 --- a/__test__/fixtures/searchResultElectronicResources.ts +++ b/__test__/fixtures/searchResultElectronicResources.ts @@ -73,7 +73,7 @@ export const searchResultElectronicResources = { }, ], lccClassification: ["PQ4916.E778 S63 2019"], - materialType: [ + recordType: [ { "@id": "resourcetypes:aud", prefLabel: "Audio", @@ -189,7 +189,7 @@ export const searchResultElectronicResourcesNoLabel = { }, ], lccClassification: ["PQ4916.E778 S63 2019"], - materialType: [ + recordType: [ { "@id": "resourcetypes:aud", prefLabel: "Audio", @@ -311,7 +311,7 @@ export const searchResultMultipleElectronicResources = { }, ], lccClassification: ["PQ4916.E778 S63 2019"], - materialType: [ + recordType: [ { "@id": "resourcetypes:aud", prefLabel: "Audio", diff --git a/__test__/fixtures/searchResultManyPhysicalItems.ts b/__test__/fixtures/searchResultManyPhysicalItems.ts index 0d7ac0a19..8366bf301 100644 --- a/__test__/fixtures/searchResultManyPhysicalItems.ts +++ b/__test__/fixtures/searchResultManyPhysicalItems.ts @@ -257,7 +257,7 @@ export const searchResultManyPhysicalItems = { prefLabel: "English", }, ], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", diff --git a/__test__/fixtures/searchResultPhysicalItems.ts b/__test__/fixtures/searchResultPhysicalItems.ts index 3c5538b7f..acdf60253 100644 --- a/__test__/fixtures/searchResultPhysicalItems.ts +++ b/__test__/fixtures/searchResultPhysicalItems.ts @@ -174,7 +174,7 @@ export const searchResultPhysicalItems = { }, ], lccClassification: ["TS2157 .P7"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Material", diff --git a/__test__/fixtures/searchResultsManyBibs.ts b/__test__/fixtures/searchResultsManyBibs.ts index 3dd9b598c..bd23baa8f 100644 --- a/__test__/fixtures/searchResultsManyBibs.ts +++ b/__test__/fixtures/searchResultsManyBibs.ts @@ -118,7 +118,7 @@ export const results = { }, ], lccClassification: ["PQ2663.O7223 Z46 2005"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -252,7 +252,7 @@ export const results = { prefLabel: "English", }, ], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -466,7 +466,7 @@ export const results = { }, ], lccClassification: ["TS2157 .P7"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -610,7 +610,7 @@ export const results = { }, ], lccClassification: ["D763.I8 W3"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -733,7 +733,7 @@ export const results = { }, ], lccClassification: ["PQ4916.E778 S63 2019"], - materialType: [ + recordType: [ { "@id": "resourcetypes:aud", prefLabel: "Audio", @@ -880,7 +880,7 @@ export const results = { }, ], lccClassification: ["PZ7.F8596 Ed 1978"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -1075,7 +1075,7 @@ export const results = { }, ], lccClassification: ["PZ8.3.G427 On 1982"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -1231,7 +1231,7 @@ export const results = { prefLabel: "No linguistic content", }, ], - materialType: [ + recordType: [ { "@id": "resourcetypes:not", prefLabel: "Notated music", @@ -1417,7 +1417,7 @@ export const results = { }, ], lccClassification: ["PZ7.D6224 Sp 2002"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -1563,7 +1563,7 @@ export const results = { prefLabel: "English", }, ], - materialType: [ + recordType: [ { "@id": "resourcetypes:aud", prefLabel: "Audio", @@ -1733,7 +1733,7 @@ export const results = { prefLabel: "English", }, ], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -1893,7 +1893,7 @@ export const results = { prefLabel: "English", }, ], - materialType: [ + recordType: [ { "@id": "resourcetypes:aud", prefLabel: "Audio", @@ -2133,7 +2133,7 @@ export const results = { prefLabel: "Italian", }, ], - materialType: [ + recordType: [ { "@id": "resourcetypes:aud", prefLabel: "Audio", @@ -2316,7 +2316,7 @@ export const results = { }, ], lccClassification: ["PQ4916.E778 S63 2013"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -2474,7 +2474,7 @@ export const results = { }, ], lccClassification: ["PQ4907.E54 S63 2015"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -2629,7 +2629,7 @@ export const results = { prefLabel: "English", }, ], - materialType: [ + recordType: [ { "@id": "resourcetypes:mov", prefLabel: "Moving image", @@ -2799,7 +2799,7 @@ export const results = { }, ], lccClassification: ["D763.I8 W3"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -2967,7 +2967,7 @@ export const results = { }, ], lccClassification: ["PZ7.J6354 Onat 2006"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -3575,7 +3575,7 @@ export const results = { }, ], lccClassification: ["IN PROCESS"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -3753,7 +3753,7 @@ export const results = { prefLabel: "English", }, ], - materialType: [ + recordType: [ { "@id": "resourcetypes:not", prefLabel: "Notated music", @@ -4148,7 +4148,7 @@ export const results = { }, ], lccClassification: ["PN1995.9.W4 M325 2012"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -4303,7 +4303,7 @@ export const results = { }, ], lccClassification: ["PZ40.O74 E85 2017"], - materialType: [ + recordType: [ { "@id": "resourcetypes:aud", prefLabel: "Audio", @@ -4418,7 +4418,7 @@ export const results = { }, ], lccClassification: ["FICTION WAT"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -4583,7 +4583,7 @@ export const results = { }, ], lccClassification: ["PQ4916.E668 L33 2011"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -4672,7 +4672,7 @@ export const results = { }, ], lccClassification: ["PQ2722.A734 S96 2020"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -4814,7 +4814,7 @@ export const results = { prefLabel: "German", }, ], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -4983,7 +4983,7 @@ export const results = { }, ], lccClassification: ["PN1995.9.W4 F75 2006"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -5179,7 +5179,7 @@ export const results = { }, ], lccClassification: ["M1035.E5 D38 2006"], - materialType: [ + recordType: [ { "@id": "resourcetypes:not", prefLabel: "Notated music", @@ -5377,7 +5377,7 @@ export const results = { prefLabel: "English", }, ], - materialType: [ + recordType: [ { "@id": "resourcetypes:aud", prefLabel: "Audio", @@ -5704,7 +5704,7 @@ export const results = { }, ], lccClassification: ["PN1995.9.W4 M325 2012"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -5881,7 +5881,7 @@ export const results = { }, ], lccClassification: ["PQ2668.A569 S63 1994"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -6024,7 +6024,7 @@ export const results = { }, ], lccClassification: ["TX809.M17 W3"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -6186,7 +6186,7 @@ export const results = { }, ], lccClassification: ["D805.I8"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -6345,7 +6345,7 @@ export const results = { }, ], lccClassification: ["PZ44.9 .P58 2015"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -6500,7 +6500,7 @@ export const results = { }, ], lccClassification: ["M1630.2.L96 S63 1950"], - materialType: [ + recordType: [ { "@id": "resourcetypes:not", prefLabel: "Notated music", @@ -6662,7 +6662,7 @@ export const results = { }, ], lccClassification: ["PZ7.K8585 Fl"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -6850,7 +6850,7 @@ export const results = { }, ], lccClassification: ["PZ7.H572 Dad 1986"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -6972,7 +6972,7 @@ export const results = { }, ], lccClassification: ["PZ7.1.N342 On 2017eb"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -7136,7 +7136,7 @@ export const results = { prefLabel: "German", }, ], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -7241,7 +7241,7 @@ export const results = { }, ], lccClassification: ["PZ7.W3298 Sts 2016ab"], - materialType: [ + recordType: [ { "@id": "resourcetypes:aud", prefLabel: "Audio", @@ -7397,7 +7397,7 @@ export const results = { prefLabel: "German", }, ], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -7541,7 +7541,7 @@ export const results = { }, ], lccClassification: ["HF5415 .P57 1998"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -7696,7 +7696,7 @@ export const results = { }, ], lccClassification: ["PZ7.K7877 Mar 1991"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -7842,7 +7842,7 @@ export const results = { }, ], lccClassification: ["PZ7.F8596 Eg 1983"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -7976,7 +7976,7 @@ export const results = { }, }, ], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -8175,7 +8175,7 @@ export const results = { }, ], lccClassification: ["M1035.E5 D38 2006"], - materialType: [ + recordType: [ { "@id": "resourcetypes:not", prefLabel: "Notated music", @@ -8373,7 +8373,7 @@ export const results = { }, ], lccClassification: ["PQ7798.23.A657 C8"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -8536,7 +8536,7 @@ export const results = { }, ], lccClassification: ["PT2708.E4878 M36 2017"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -8693,7 +8693,7 @@ export const results = { }, ], lccClassification: ["GT2868.68 .M66 2021"], - materialType: [ + recordType: [ { "@id": "resourcetypes:txt", prefLabel: "Text", @@ -8936,7 +8936,7 @@ export const results = { }, ], lccClassification: ["M1630.2 .S63 2007"], - materialType: [ + recordType: [ { "@id": "resourcetypes:aud", prefLabel: "Audio", @@ -9017,9 +9017,9 @@ export const emptyAggregationsResults = { }, { "@type": "nypl:Aggregation", - "@id": "res:materialType", - id: "materialType", - field: "materialType", + "@id": "res:recordType", + id: "recordType", + field: "recordType", values: [], }, { @@ -9102,9 +9102,9 @@ export const aggregationsResults = { }, { "@type": "nypl:Aggregation", - "@id": "res:materialType", - id: "materialType", - field: "materialType", + "@id": "res:recordType", + id: "recordType", + field: "recordType", values: [ { value: "resourcetypes:txt", diff --git a/__test__/pages/search/advancedSearchForm.test.tsx b/__test__/pages/search/advancedSearchForm.test.tsx index b07ec4842..29e8c7767 100644 --- a/__test__/pages/search/advancedSearchForm.test.tsx +++ b/__test__/pages/search/advancedSearchForm.test.tsx @@ -69,12 +69,12 @@ describe("Advanced Search Form", () => { it("can check material checkboxes", async () => { render() await userEvent.click(screen.getByLabelText("Notated music")) - await userEvent.click(screen.getByLabelText("Cartographic")) + await userEvent.click(screen.getByLabelText("Map")) submit() // expect the label for notated music and cartographic // ("resourcetypes:not", "resourcetypes:car") to be in url expect(mockRouter.asPath).toBe( - "/search?q=&filters%5BmaterialType%5D%5B0%5D=resourcetypes%3Anot&filters%5BmaterialType%5D%5B1%5D=resourcetypes%3Acar" + "/search?q=&filters%5BrecordType%5D%5B0%5D=c&filters%5BrecordType%5D%5B1%5D=e" ) }) it("can check location checkboxes", async () => { @@ -91,7 +91,7 @@ describe("Advanced Search Form", () => { render() const notatedMusic = screen.getByLabelText("Notated music") await userEvent.click(notatedMusic) - const cartographic = screen.getByLabelText("Cartographic") + const cartographic = screen.getByLabelText("Map") await userEvent.click(cartographic) const selector = screen.getByLabelText("Language") await userEvent.selectOptions(selector, "Azerbaijani") diff --git a/discoveryApiResearchNowMapping.md b/discoveryApiResearchNowMapping.md index 6bb2b868f..06d7fce10 100644 --- a/discoveryApiResearchNowMapping.md +++ b/discoveryApiResearchNowMapping.md @@ -19,7 +19,7 @@ - `search_scope` string - "all", "title", "contributor", "subject", "series", "callnumber", "standard_number" - `filters` string - - "owner", "subjectLiteral", "holdingLocation", "deliveryLocation", "language", "materialType", "mediaType", " + - "owner", "subjectLiteral", "holdingLocation", "deliveryLocation", "language", "recordType", "mediaType", " carrierType", "publisher", "contributor", "creator", "issuance", "createdYear", "dateAfter"', or "dateBefore" - Specify a hash of filters to apply, where keys are from terms above @@ -126,7 +126,7 @@ e.g. `filters`) is used for the parameters the respective APIs except. |
    'Author/Contributor' |
      "contributor" |
        "author" | |
          'Standard Number' |
            "standard_number" |
              "standardNumber" | | _Search page filters_ | `filters` | | -|
                'Format' |
                  `filters[materialType]` |
                    N/A\* | +|
                      'Format' |
                        `filters[recordType]` |
                          N/A\* | |
                            'Date':
                            • 'Start Year'
                            • 'End Year' |

                                `filters[dateAfter]`
                                `filters[dateBefore]` | `filters`
                                  `years[start]`
                                  `years[end]` | |
                                    'Language' |
                                      `filters[language]` |
                                        `filters` `language` | | _Filters linked to from a bib page_ | @@ -138,7 +138,7 @@ e.g. `filters`) is used for the parameters the respective APIs except. | _Sorting_ | `sort` | `sort[field]` | | | `sort_direction` | `sort[direction]` | -\* ResearchNow's `format` parameter does not correspond to the `materialType` in Discovery API. The former relates to +\* ResearchNow's `format` parameter does not correspond to the `recordType` in Discovery API. The former relates to digital formats (pdf, epub, and html). The latter to physical material type. ## API Response Structure @@ -233,7 +233,7 @@ digital formats (pdf, epub, and html). The latter to physical material type. "prefLabel": "string" } ], - "materialType": [ + "recordType": [ { "@type": "string", "@id": "string", diff --git a/pages/search/advanced.tsx b/pages/search/advanced.tsx index d1d4130aa..a36c2361d 100644 --- a/pages/search/advanced.tsx +++ b/pages/search/advanced.tsx @@ -37,7 +37,7 @@ import { useDateForm } from "../../src/hooks/useDateForm" import DateForm from "../../src/components/SearchFilters/DateForm" import SearchFilterCheckboxField from "../../src/components/RefineSearch/SearchFilterCheckboxField" import CancelSubmitButtonGroup from "../../src/components/RefineSearch/CancelSubmitButtonGroup" -import { materialTypeOptions } from "../../src/utils/advancedSearchUtils" +import { recordTypeOptions } from "../../src/utils/advancedSearchUtils" import { searchAggregations } from "../../src/config/aggregations" import RCLink from "../../src/components/Links/RCLink/RCLink" @@ -213,13 +213,13 @@ export default function AdvancedSearch({ gridOptions={{ min: 1, max: 1 }} /> - handleCheckboxChange("materialType", e) + handleCheckboxChange("recordType", e) } - searchFormState={searchFormState["filters"].materialType} + searchFormState={searchFormState["filters"].recordType} /> diff --git a/src/components/RefineSearch/RefineSearch.test.tsx b/src/components/RefineSearch/RefineSearch.test.tsx index acc5f3521..693e478ee 100644 --- a/src/components/RefineSearch/RefineSearch.test.tsx +++ b/src/components/RefineSearch/RefineSearch.test.tsx @@ -78,7 +78,7 @@ describe("RefineSearch", () => { await selectSomeFilters() await apply() expect(mockRouter.asPath).toBe( - "/search?filters%5BcreatorLiteral%5D%5B0%5D=Gaberscek%2C+Carlo.&filters%5Blanguage%5D%5B0%5D=lang%3Apor&filters%5BmaterialType%5D%5B0%5D=resourcetypes%3Aaud&filters%5BsubjectLiteral%5D%5B0%5D=Cooking%2C+Italian." + "/search?filters%5BcreatorLiteral%5D%5B0%5D=Gaberscek%2C+Carlo.&filters%5Blanguage%5D%5B0%5D=lang%3Apor&filters%5BrecordType%5D%5B0%5D=resourcetypes%3Aaud&filters%5BsubjectLiteral%5D%5B0%5D=Cooking%2C+Italian." ) }) it("should clear refinement filters and creatorliteral filter", async () => { @@ -116,7 +116,7 @@ describe("RefineSearch", () => { expect(mockRouter.query.q).toBe("spaghetti") expect(mockRouter.query).toStrictEqual({ "filters[language][0]": "lang:por", - "filters[materialType][0]": "resourcetypes:aud", + "filters[recordType][0]": "resourcetypes:aud", "filters[subjectLiteral][0]": "Cooking, Italian.", q: "spaghetti", }) @@ -169,7 +169,7 @@ describe("RefineSearch", () => { await apply() expect(mockRouter.query).toStrictEqual({ "filters[language][0]": "lang:por", - "filters[materialType][0]": "resourcetypes:aud", + "filters[recordType][0]": "resourcetypes:aud", "filters[subjectLiteral][0]": "Cooking, Italian.", }) }) @@ -217,8 +217,8 @@ describe("RefineSearch", () => { "filters[language][0]": "lang:fre", "filters[language][1]": "lang:dut", "filters[language][2]": "lang:ita", - "filters[materialType][0]": "resourcetypes:aud", - "filters[materialType][1]": "resourcetypes:mov", + "filters[recordType][0]": "resourcetypes:aud", + "filters[recordType][1]": "resourcetypes:mov", }) }) it("deselecting and applying removes filters", async () => { @@ -227,7 +227,7 @@ describe("RefineSearch", () => { query: { "filters[language][0]": "lang:por", "filters[language][1]": "lang:ita", - "filters[materialType][0]": "resourcetypes:aud", + "filters[recordType][0]": "resourcetypes:aud", "filters[subjectLiteral][0]": "Cooking, Italian.", }, }) diff --git a/src/components/RefineSearch/RefineSearch.tsx b/src/components/RefineSearch/RefineSearch.tsx index 69c9178ae..3ca0c63ce 100644 --- a/src/components/RefineSearch/RefineSearch.tsx +++ b/src/components/RefineSearch/RefineSearch.tsx @@ -29,7 +29,7 @@ import SearchFilterCheckboxField from "./SearchFilterCheckboxField" const fields = [ { value: "buildingLocation", label: "Item location" }, - { value: "materialType", label: "Format" }, + { value: "recordType", label: "Format" }, { value: "language", label: "Language" }, { value: "dateAfter", label: "Start Year" }, { value: "dateBefore", label: "End Year" }, diff --git a/src/components/RefineSearch/sampleFilters.json b/src/components/RefineSearch/sampleFilters.json index 68dc4ba06..fb4d6e563 100644 --- a/src/components/RefineSearch/sampleFilters.json +++ b/src/components/RefineSearch/sampleFilters.json @@ -1,6 +1,6 @@ { "selectedFilters": { - "materialType": [], + "recordType": [], "language": [], "dateAfter": "", "dateBefore": "", @@ -320,9 +320,9 @@ }, { "@type": "nypl:Aggregation", - "@id": "res:materialType", - "id": "materialType", - "field": "materialType", + "@id": "res:recordType", + "id": "recordType", + "field": "recordType", "values": [ { "value": "resourcetypes:txt", @@ -1247,4 +1247,4 @@ ], "totalResults": 428 } -} +} \ No newline at end of file diff --git a/src/components/SearchFilters/AppliedFilters.test.tsx b/src/components/SearchFilters/AppliedFilters.test.tsx index f061c1957..637985f68 100644 --- a/src/components/SearchFilters/AppliedFilters.test.tsx +++ b/src/components/SearchFilters/AppliedFilters.test.tsx @@ -14,7 +14,7 @@ describe("Applied Filters", () => { describe("tagset click handler", () => { it("can remove one filter", async () => { mockRouter.push( - "/search?q=spaghetti&filters[materialType][0]=resourcetypes%3Amov&filters[language][0]=lang%3Afre" + "/search?q=spaghetti&filters[recordType][0]=resourcetypes%3Amov&filters[language][0]=lang%3Afre" ) render( { }) it("can remove all filters", async () => { mockRouter.push( - "/search?q=spaghetti&filters[materialType][0]=resourcetypes%3Atxt&filters[language][0]=lang%3Afre" + "/search?q=spaghetti&filters[recordType][0]=resourcetypes%3Atxt&filters[language][0]=lang%3Afre" ) render( { }) it("can remove one of many field filters", async () => { mockRouter.push( - "/search?q=spaghetti&filters[materialType][0]=resourcetypes%3Atxt&filters[materialType][1]=resourcetypes%3Aaud&filters[materialType][2]=resourcetypes%3Amov&filters[language][0]=lang%3Afre" + "/search?q=spaghetti&filters[recordType][0]=resourcetypes%3Atxt&filters[recordType][1]=resourcetypes%3Aaud&filters[recordType][2]=resourcetypes%3Amov&filters[language][0]=lang%3Afre" ) render( { ) await userEvent.click(screen.getAllByTestId("filter-tags")[0]) expect(decodeURI(mockRouter.asPath)).toBe( - "/search?q=spaghetti&filters[materialType][0]=resourcetypes%3Aaud&filters[materialType][1]=resourcetypes%3Amov&filters[language][0]=lang%3Afre" + "/search?q=spaghetti&filters[recordType][0]=resourcetypes%3Aaud&filters[recordType][1]=resourcetypes%3Amov&filters[language][0]=lang%3Afre" ) }) }) @@ -92,7 +92,7 @@ describe("Applied Filters", () => { }) it("can handle a combination of filters with no results", () => { mockRouter.push( - "/search?q=spaghetti&filters[materialType][0]=resourcetypes%3Amix&filters[language][0]=lang%3Apol&filters[subjectLiteral][0]=Community life." + "/search?q=spaghetti&filters[recordType][0]=resourcetypes%3Amix&filters[language][0]=lang%3Apol&filters[subjectLiteral][0]=Community life." ) render( { it("takes applied filter values and adds the appropriate label", () => { const appliedFilterValues = { - materialType: ["resourcetypes:txt"], + recordType: ["resourcetypes:txt"], language: ["lang:ita"], subjectLiteral: ["Spaghetti Westerns -- History and criticism."], } @@ -92,9 +92,7 @@ describe("Applied Filter utils", () => { appliedFilterValues ) expect(parsed).toStrictEqual({ - materialType: [ - { value: "resourcetypes:txt", count: 371, label: "Text" }, - ], + recordType: [{ value: "resourcetypes:txt", count: 371, label: "Text" }], language: [{ value: "lang:ita", count: 59, label: "Italian" }], subjectLiteral: [ { diff --git a/src/components/SearchResults/SearchResult.tsx b/src/components/SearchResults/SearchResult.tsx index c54139ff3..47533a502 100644 --- a/src/components/SearchResults/SearchResult.tsx +++ b/src/components/SearchResults/SearchResult.tsx @@ -42,7 +42,7 @@ const SearchResult = ({ bib }: SearchResultProps) => { p: { display: "inline-block", marginRight: "s", marginBottom: "s" }, }} > - {bib.materialType && {bib.materialType}} + {bib.recordType && {bib.recordType}} {bib.publicationStatement && {bib.publicationStatement}} {bib.yearPublished && {bib.yearPublished}} {bib.getNumItemsMessage()} diff --git a/src/config/aggregations.tsx b/src/config/aggregations.tsx index 4746bb921..86f6e5e9c 100644 --- a/src/config/aggregations.tsx +++ b/src/config/aggregations.tsx @@ -21,39 +21,95 @@ export const searchAggregations = { ), }, ], - materialType: [ + recordType: [ { - value: "resourcetypes:txt", - label: "Text", + value: "b", + label: "Blu-ray", }, { - value: "resourcetypes:aud", - label: "Audio", + value: "c", + label: "Notated music", }, { - value: "resourcetypes:not", - label: "Notated music", + value: "i", + label: "Spoken word recording", + }, + { + value: "z", + label: "E-Book", + }, + { + label: "DVD", + }, + { + value: "u", + label: "Audiobook", + }, + { + value: "d", + label: "Manuscript notated music", + }, + { + value: "m", + label: "Computer file", + }, + { + label: "Kit", + }, + { + value: "p", + label: "Archival Mix", + }, + { + value: "a", + label: "Book/Text", + }, + { + value: "3", + label: "E-Video", + }, + { + value: "l", + label: "Large print", + }, + { + value: "e", + label: "Map", + }, + { + value: "n", + label: "E-Audiobook", + }, + { + value: "k", + label: "Picture", + }, + { + value: "t", + label: "Manuscript", }, + { value: "s", label: "VHS" }, { - value: "resourcetypes:mov", - label: "Moving image", + value: "j", + label: "Musical recording", }, { - value: "resourcetypes:img", - label: "Still image", + value: "y", + label: "Music CD", }, { - value: "resourcetypes:car", - label: "Cartographic", + value: "h", + label: "Microform", }, { - value: "resourcetypes:mix", - label: "Mixed material", + value: "r", + label: "3-D Object", }, { - value: "resourcetypes:mul", - label: "Multimedia", + value: "g", + label: "Film, Slide, etc.", }, + { value: "f", label: "Manuscript map" }, ], language: [ { diff --git a/src/models/Bib.ts b/src/models/Bib.ts index a7fc54cd9..c80817627 100644 --- a/src/models/Bib.ts +++ b/src/models/Bib.ts @@ -24,7 +24,7 @@ export default class Bib { electronicResources?: ElectronicResource[] numPhysicalItems: number numItemsMatched: number - materialType?: string + recordType?: string issuance?: JSONLDValue[] items?: Item[] itemAggregations?: Aggregation[] @@ -38,8 +38,8 @@ export default class Bib { this.electronicResources = result.electronicResources || null this.numPhysicalItems = result.numItemsTotal || 0 this.numItemsMatched = result.numItemsMatched || 0 - this.materialType = - (result.materialType?.length && result.materialType[0]?.prefLabel) || null + this.recordType = + (result.recordType?.length && result.recordType[0]?.prefLabel) || null this.issuance = (result.issuance?.length && result.issuance) || null this.items = this.getItemsFromResult(result) this.itemAggregations = result.itemAggregations || null diff --git a/src/models/Item.ts b/src/models/Item.ts index 436ee500a..72b135e97 100644 --- a/src/models/Item.ts +++ b/src/models/Item.ts @@ -49,7 +49,7 @@ export default class Item { : null this.format = item.formatLiteral?.length ? item.formatLiteral[0] - : bib.materialType + : bib.recordType this.barcode = item.idBarcode?.length ? item.idBarcode[0] : null this.location = this.getLocationFromItem(item) this.aeonUrl = item.aeonUrl?.length ? item.aeonUrl[0] : null diff --git a/src/models/modelTests/Bib.test.ts b/src/models/modelTests/Bib.test.ts index 592572f40..3a310781a 100644 --- a/src/models/modelTests/Bib.test.ts +++ b/src/models/modelTests/Bib.test.ts @@ -30,8 +30,8 @@ describe("Bib model", () => { expect(bib.numPhysicalItems).toBe(4) }) - it("initializes materialType with the Bib's materialType field", () => { - expect(bib.materialType).toBe("Text") + it("initializes recordType with the Bib's recordType field", () => { + expect(bib.recordType).toBe("Text") }) it("initializes issuance with the Bib's issuance field", () => { diff --git a/src/models/modelTests/SearchResultsBib.test.ts b/src/models/modelTests/SearchResultsBib.test.ts index 7df9ccd86..59f231d86 100644 --- a/src/models/modelTests/SearchResultsBib.test.ts +++ b/src/models/modelTests/SearchResultsBib.test.ts @@ -19,7 +19,7 @@ describe("SearchResultsBib model", () => { expect(searchResultsBib.title).toBe("Urban spaghetti.") expect(searchResultsBib.electronicResources).toStrictEqual([]) expect(searchResultsBib.numPhysicalItems).toBe(4) - expect(searchResultsBib.materialType).toBe("Text") + expect(searchResultsBib.recordType).toBe("Text") expect(searchResultsBib.issuance).toStrictEqual([ { "@id": "urn:biblevel:s", prefLabel: "serial" }, ]) diff --git a/src/types/bibTypes.ts b/src/types/bibTypes.ts index 8ff0297ca..3b569bf04 100644 --- a/src/types/bibTypes.ts +++ b/src/types/bibTypes.ts @@ -15,7 +15,7 @@ export interface DiscoveryBibResult { titleDisplay?: string[] creatorLiteral?: string[] title?: string[] - materialType?: MaterialType[] + recordType?: recordType[] publicationStatement?: string[] dateStartYear?: number dateEndYear?: number @@ -52,7 +52,7 @@ export interface DiscoveryBibResult { // uri: string // } -type MaterialType = { +type recordType = { value?: string prefLabel?: string } diff --git a/src/types/myAccountTypes.ts b/src/types/myAccountTypes.ts index bbac892a8..be3604f6e 100644 --- a/src/types/myAccountTypes.ts +++ b/src/types/myAccountTypes.ts @@ -154,7 +154,7 @@ export interface SierraBibEntry { lang: SierraCodeName title: string author: string - materialType: { + recordType: { code: string value: string } diff --git a/src/types/searchTypes.ts b/src/types/searchTypes.ts index 2cf22674e..daa1377dd 100644 --- a/src/types/searchTypes.ts +++ b/src/types/searchTypes.ts @@ -7,11 +7,11 @@ type SubjectLiteral = string type ContributorLiteral = string type CreatorLiteral = string type Issuance = string -type MaterialTypeFilter = string +type recordTypeFilter = string type BuildingLocationFilter = string export interface SearchFilters { - materialType?: MaterialTypeFilter | MaterialTypeFilter[] + recordType?: recordTypeFilter | recordTypeFilter[] language?: Language | Language[] subjectLiteral?: SubjectLiteral | SubjectLiteral[] contributorLiteral?: ContributorLiteral | ContributorLiteral[] @@ -108,5 +108,5 @@ export interface SearchFormEvent { language?: SearchFormField dateBefore?: SearchFormField dateAfter?: SearchFormField - materialType?: SearchFormField + recordType?: SearchFormField } diff --git a/src/utils/advancedSearchUtils.ts b/src/utils/advancedSearchUtils.ts index 0ab01474e..f03afc0dc 100644 --- a/src/utils/advancedSearchUtils.ts +++ b/src/utils/advancedSearchUtils.ts @@ -18,7 +18,7 @@ export const initialSearchFormState: SearchParams = { language: "", dateBefore: "", dateAfter: "", - materialType: [], + recordType: [], buildingLocation: [], }, } @@ -35,8 +35,8 @@ export const languageOptions = [ ) // Returns an array of objects of Material Type options derived from the aggregations sorted by label text -export const materialTypeOptions = searchAggregations.materialType.sort( - (a, b) => (a.label > b.label ? 1 : -1) +export const recordTypeOptions = searchAggregations.recordType.sort((a, b) => + a.label > b.label ? 1 : -1 ) export const buildGoBackHref = (referer) => { diff --git a/src/utils/refineSearchUtils.ts b/src/utils/refineSearchUtils.ts index d792b04ee..59e3179a3 100644 --- a/src/utils/refineSearchUtils.ts +++ b/src/utils/refineSearchUtils.ts @@ -1,7 +1,7 @@ import type { CollapsedMultiValueAppliedFilters } from "../types/filterTypes" // Filters are always multivalue query params in the form -// filters[field][index]=value eg filters[materialType][0]=resourcetypes:aud. +// filters[field][index]=value eg filters[recordType][0]=resourcetypes:aud. // This method returns an object that maps a field to an array of the values // provided in the query string with that field called out. export const collapseMultiValueQueryParams = ( diff --git a/src/utils/searchUtils.ts b/src/utils/searchUtils.ts index 1f2605b98..92dfbcbb4 100644 --- a/src/utils/searchUtils.ts +++ b/src/utils/searchUtils.ts @@ -242,7 +242,7 @@ export function mapRequestBodyToSearchParams( title, subject, language, - materialType, + recordType, dateAfter, dateBefore, } = reqBody @@ -253,7 +253,7 @@ export function mapRequestBodyToSearchParams( title, subject, filters: { - materialType, + recordType, language, dateAfter, dateBefore, diff --git a/src/utils/utilsTests/searchUtils.test.ts b/src/utils/utilsTests/searchUtils.test.ts index f185499b9..b7348873c 100644 --- a/src/utils/utilsTests/searchUtils.test.ts +++ b/src/utils/utilsTests/searchUtils.test.ts @@ -152,7 +152,7 @@ describe("searchUtils", () => { const params = mapRequestBodyToSearchParams({ q: "spaghetti", language: "igbo", - materialType: "scroll", + recordType: "scroll", dateAfter: "1900", dateBefore: "1902", }) @@ -161,7 +161,7 @@ describe("searchUtils", () => { page: 1, filters: { language: "igbo", - materialType: "scroll", + recordType: "scroll", dateAfter: "1900", dateBefore: "1902", }, From 5fa7b3a1f98afff206eb2d92497dc46813521051 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Tue, 24 Dec 2024 10:36:46 -0500 Subject: [PATCH 2/2] replace values --- src/components/RefineSearch/sampleFilters.json | 2 +- src/config/aggregations.tsx | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/RefineSearch/sampleFilters.json b/src/components/RefineSearch/sampleFilters.json index fb4d6e563..c15d8e9c1 100644 --- a/src/components/RefineSearch/sampleFilters.json +++ b/src/components/RefineSearch/sampleFilters.json @@ -1247,4 +1247,4 @@ ], "totalResults": 428 } -} \ No newline at end of file +} diff --git a/src/config/aggregations.tsx b/src/config/aggregations.tsx index 86f6e5e9c..b7b60d6a9 100644 --- a/src/config/aggregations.tsx +++ b/src/config/aggregations.tsx @@ -39,6 +39,7 @@ export const searchAggregations = { label: "E-Book", }, { + value: "v", label: "DVD", }, { @@ -54,6 +55,7 @@ export const searchAggregations = { label: "Computer file", }, { + value: "o", label: "Kit", }, {