From a8aa3d57462294e3f8d6d13e2dd131c4424137b7 Mon Sep 17 00:00:00 2001 From: "Erin E. Sullivan" Date: Tue, 27 Aug 2024 10:06:59 -0400 Subject: [PATCH 1/6] Updating `View HathiTrust search-only materials`. --- src/config.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/config.js b/src/config.js index e4779757..13e4d91c 100644 --- a/src/config.js +++ b/src/config.js @@ -65,19 +65,11 @@ const config = { filters: [ { conditions: { - checked: true - }, - groupBy: 'Access Options', - type: 'checkbox', - uid: 'available_online' - }, - { - conditions: { - default: 'checked', - unchecked: false + checked: true, + unchecked: undefined }, groupBy: 'Access Options', - name: 'Remove Search Only HathiTrust Materials', + name: 'View HathiTrust search-only materials', type: 'checkbox', uid: 'search_only' }, From 990ff3eeab2a33e3bdb6ef3d9d3c17ad46515b48 Mon Sep 17 00:00:00 2001 From: "Erin E. Sullivan" Date: Tue, 27 Aug 2024 10:21:08 -0400 Subject: [PATCH 2/6] Uncommenting `Search only (no full text)` filtering. --- .../resource-acccess/components/Holders/index.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/modules/resource-acccess/components/Holders/index.js b/src/modules/resource-acccess/components/Holders/index.js index 9aa28dbb..7033b251 100644 --- a/src/modules/resource-acccess/components/Holders/index.js +++ b/src/modules/resource-acccess/components/Holders/index.js @@ -10,7 +10,7 @@ const Holders = ({ context, record }) => { return state.filters.active; }); /* - * - Check if the record is under 'Catalog', and the 'Remove search-only HathiTrust materials' is checked + * - Check if the record is under 'Catalog', and the 'View search-only HathiTrust materials' is checked * - If true, remove all 'Search only (no full text)' holdings */ if ( @@ -20,14 +20,11 @@ const Holders = ({ context, record }) => { || (Object.keys(mirlyn).includes('search_only') && mirlyn.search_only.includes('true')) ) ) { - // UNCOMMENT THE BLOCK BELOW WHEN READY TO LAUNCH - /* - * Record.resourceAccess.forEach((resource) => { - * resource.rows = resource.rows.filter((row) => { - * return row[0].text !== 'Search only (no full text)'; - * }); - * }); - */ + record.resourceAccess.forEach((resource) => { + resource.rows = resource.rows.filter((row) => { + return row[0].text !== 'Search only (no full text)'; + }); + }); } return ( <> From f0c758f705b92de656a2fb638db2302d2bac37fb Mon Sep 17 00:00:00 2001 From: "Erin E. Sullivan" Date: Tue, 27 Aug 2024 10:56:39 -0400 Subject: [PATCH 3/6] Reversing logic for hiding `Search only (no full text)`. --- src/config.js | 2 +- src/modules/resource-acccess/components/Holders/index.js | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/config.js b/src/config.js index 13e4d91c..112fdc2b 100644 --- a/src/config.js +++ b/src/config.js @@ -66,7 +66,7 @@ const config = { { conditions: { checked: true, - unchecked: undefined + unchecked: null }, groupBy: 'Access Options', name: 'View HathiTrust search-only materials', diff --git a/src/modules/resource-acccess/components/Holders/index.js b/src/modules/resource-acccess/components/Holders/index.js index 7033b251..d74d180f 100644 --- a/src/modules/resource-acccess/components/Holders/index.js +++ b/src/modules/resource-acccess/components/Holders/index.js @@ -10,15 +10,12 @@ const Holders = ({ context, record }) => { return state.filters.active; }); /* - * - Check if the record is under 'Catalog', and the 'View search-only HathiTrust materials' is checked + * - Check if the record is under 'Catalog', and the 'View search-only HathiTrust materials' is unchecked * - If true, remove all 'Search only (no full text)' holdings */ if ( record.datastore === 'mirlyn' - && ( - !mirlyn - || (Object.keys(mirlyn).includes('search_only') && mirlyn.search_only.includes('true')) - ) + && (!mirlyn || !mirlyn.search_only || mirlyn.search_only.includes('false')) ) { record.resourceAccess.forEach((resource) => { resource.rows = resource.rows.filter((row) => { From 800a0551f8c54f8f1cd921c36b7e0f188d4c75d7 Mon Sep 17 00:00:00 2001 From: "Erin E. Sullivan" Date: Tue, 27 Aug 2024 11:43:04 -0400 Subject: [PATCH 4/6] Simplifying `CheckboxFilters` and adding styles. --- .../components/CheckboxFilters/index.js | 26 ++++++++++--------- .../components/CheckboxFilters/styles.css | 3 +++ 2 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 src/modules/filters/components/CheckboxFilters/styles.css diff --git a/src/modules/filters/components/CheckboxFilters/index.js b/src/modules/filters/components/CheckboxFilters/index.js index f9693676..7aa9b1da 100644 --- a/src/modules/filters/components/CheckboxFilters/index.js +++ b/src/modules/filters/components/CheckboxFilters/index.js @@ -1,28 +1,30 @@ +import './styles.css'; import { Anchor, Icon } from '../../../reusable'; import { getURLWithFiltersRemoved, newSearch } from '../../utilities'; import React from 'react'; import { useSelector } from 'react-redux'; -const CheckBoxFiltersContainer = () => { +const CheckBoxFilters = () => { const { active: activeFilters, groups, order } = useSelector((state) => { return state.filters; }); - const activeDatastore = useSelector((state) => { - return state.datastores.active; + const { active: activeDatastore } = useSelector((state) => { + return state.datastores; }); - const checkboxes = order.reduce((acc, id) => { - if (groups[id]?.type === 'checkbox') { - return acc.concat(groups[id]); - } - return acc; - }, []); + const checkboxes = order + .filter((id) => { + return groups[id]?.type === 'checkbox'; + }) + .map((id) => { + return groups[id]; + }); if (!checkboxes.length) { return null; } return ( -
    +
      {checkboxes.map((checkbox) => { const { uid } = checkbox; const { metadata, preSelected } = groups[uid]; @@ -36,7 +38,7 @@ const CheckBoxFiltersContainer = () => { ? `${document.location.pathname}?${newSearch({ filter: { [uid]: String(!isChecked) }, page: 1 })}` : getURLWithFiltersRemoved({ group: uid, value: isActive }) } - className={`padding-y__2xs padding-x__m flex underline__hover ${isChecked ? 'active-checkbox' : 'inactive-checkbox'}`} + className={`flex underline__hover ${isChecked ? '' : 'in'}active-checkbox`} > {metadata.name} @@ -48,4 +50,4 @@ const CheckBoxFiltersContainer = () => { ); }; -export default CheckBoxFiltersContainer; +export default CheckBoxFilters; diff --git a/src/modules/filters/components/CheckboxFilters/styles.css b/src/modules/filters/components/CheckboxFilters/styles.css new file mode 100644 index 00000000..c15df043 --- /dev/null +++ b/src/modules/filters/components/CheckboxFilters/styles.css @@ -0,0 +1,3 @@ +ul.active-filters { + padding: var(--search-spacing-s) var(--search-spacing-m); +} \ No newline at end of file From c32b9d1d7ad3bcaafede4b4649423c9d7582db6c Mon Sep 17 00:00:00 2001 From: "Erin E. Sullivan" Date: Tue, 27 Aug 2024 12:20:47 -0400 Subject: [PATCH 5/6] Simplifying CheckboxFilters logic. --- .../filters/components/CheckboxFilters/index.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/modules/filters/components/CheckboxFilters/index.js b/src/modules/filters/components/CheckboxFilters/index.js index 7aa9b1da..c4b42017 100644 --- a/src/modules/filters/components/CheckboxFilters/index.js +++ b/src/modules/filters/components/CheckboxFilters/index.js @@ -25,13 +25,11 @@ const CheckBoxFilters = () => { return (
        - {checkboxes.map((checkbox) => { - const { uid } = checkbox; - const { metadata, preSelected } = groups[uid]; - const isActive = activeFilters[activeDatastore]?.[uid]?.[0]; - const isChecked = isActive ? isActive === 'true' : preSelected; + {checkboxes.map(({ uid, metadata, preSelected }, index) => { + const [isActive] = activeFilters[activeDatastore]?.[uid] || []; + const isChecked = isActive === 'true' || preSelected; return ( -
      • +
      • Date: Wed, 28 Aug 2024 10:02:18 -0400 Subject: [PATCH 6/6] Bug: Filtering out holdings with empty rows. --- src/modules/resource-acccess/components/Holders/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules/resource-acccess/components/Holders/index.js b/src/modules/resource-acccess/components/Holders/index.js index d74d180f..9006e0a3 100644 --- a/src/modules/resource-acccess/components/Holders/index.js +++ b/src/modules/resource-acccess/components/Holders/index.js @@ -22,6 +22,9 @@ const Holders = ({ context, record }) => { return row[0].text !== 'Search only (no full text)'; }); }); + record.resourceAccess = record.resourceAccess.filter((resource) => { + return resource.rows.length > 0; + }); } return ( <>