From 4cbe77b12610ae2f209a3e486c522efd7a16f89c Mon Sep 17 00:00:00 2001 From: John Cross Date: Sun, 22 Jan 2023 17:40:16 +0000 Subject: [PATCH 001/136] Disabled a lint rule Else it would not build Added .env.local (as per README) Fixed a typo in README --- README.md | 2 +- ui/.env.local | 2 ++ ui/.eslintrc.js | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 ui/.env.local diff --git a/README.md b/README.md index 0f27dde6..f40053ca 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Create a `.env` file containing the following content: ``` touch .env.local -echo "CKAN_URL=https://manage.test.standards.nhs.uk/api/action\nPAGES_CKAN_URL=https://manage.test.standards.nhs.uk/api/action" >> .env.local +echo "CKAN_URL=https://manage.test.standards.nhs.uk/api/action\nPAGES_CKAN_URL=https://manage.standards.nhs.uk/api/action" >> .env.local ``` ### Running the server diff --git a/ui/.env.local b/ui/.env.local new file mode 100644 index 00000000..eac18220 --- /dev/null +++ b/ui/.env.local @@ -0,0 +1,2 @@ +CKAN_URL=https://manage.test.standards.nhs.uk/api/action +PAGES_CKAN_URL=https://manage.standards.nhs.uk/api/action diff --git a/ui/.eslintrc.js b/ui/.eslintrc.js index 452480b5..3e68cc3f 100644 --- a/ui/.eslintrc.js +++ b/ui/.eslintrc.js @@ -19,6 +19,7 @@ module.exports = { }, plugins: ['react'], rules: { + '@next/next/no-document-import-in-page': 'off', 'react/prop-types': [0], 'react/react-in-jsx-scope': [0], // next puts react in global scope 'no-console': [2, { allow: ['warn', 'error'] }], From 0d7f3403310440a5e824b61aa40a4dd03bc94fe5 Mon Sep 17 00:00:00 2001 From: Stuart Last Date: Wed, 12 Apr 2023 14:43:02 +0100 Subject: [PATCH 002/136] NSDV-110 - IMPLEMENTS order by name asc by default --- .gitignore | 1 + ui/components/Dataset/index.js | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index a7c1a580..8c675561 100644 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,7 @@ typings/ # dotenv environment variables file .env +.env.local # OSX .DS_Store diff --git a/ui/components/Dataset/index.js b/ui/components/Dataset/index.js index f17f83ea..50a9e7fc 100644 --- a/ui/components/Dataset/index.js +++ b/ui/components/Dataset/index.js @@ -69,22 +69,23 @@ function SortMenu({ searchTerm }) { label: 'Relevance', value: 'score desc', }, - { - label: 'Added (newest)', - value: 'metadata_created desc', - }, - { - label: 'Added (oldest)', - value: 'metadata_created asc', - }, { label: 'Name (A to Z)', value: 'name asc', + selected: 'selected', }, { label: 'Name (Z to A)', value: 'name desc', }, + { + label: 'Added (newest)', + value: 'metadata_created desc', + }, + { + label: 'Added (oldest)', + value: 'metadata_created asc', + }, ]; const value = `${query.orderBy} ${query.order}`; @@ -165,7 +166,7 @@ export default function Dataset({ includeType, schema, }) { - const { query } = useQueryContext(); + const { query, updateQuery } = useQueryContext(); const searchTerm = query.q; const [data, setData] = useState(initialData); const [loading, setLoading] = useState(false); @@ -185,15 +186,22 @@ export default function Dataset({ setLoading(false); } } + // we dont want to fetch data on initial load. if (pageLoaded) { getData(); } + // we don't want pageLoaded in the dependency array // eslint-disable-next-line react-hooks/exhaustive-deps }, [query]); - useEffect(() => setPageLoaded(true), []); + useEffect(() => { + const orderBy = 'name'; + const order = 'asc'; + updateQuery({ orderBy, order }); + setPageLoaded(true); + }, []); return ( <> From 46e1ef39f8ba241a099e1e611b65d95eb915a2d2 Mon Sep 17 00:00:00 2001 From: Stuart Last Date: Wed, 12 Apr 2023 14:48:55 +0100 Subject: [PATCH 003/136] NSDV-110 - FIXES search term in query string --- ui/components/Dataset/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/components/Dataset/index.js b/ui/components/Dataset/index.js index 50a9e7fc..f89479d2 100644 --- a/ui/components/Dataset/index.js +++ b/ui/components/Dataset/index.js @@ -199,7 +199,7 @@ export default function Dataset({ useEffect(() => { const orderBy = 'name'; const order = 'asc'; - updateQuery({ orderBy, order }); + updateQuery({ ...query, orderBy, order }); setPageLoaded(true); }, []); From bc19d35471950932f517b4c2915883c59f8a3344 Mon Sep 17 00:00:00 2001 From: Stuart Last Date: Wed, 12 Apr 2023 16:19:47 +0100 Subject: [PATCH 004/136] NSDV-112 - FIX hide number of filters selected when there are no filter --- ui/components/Filters/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/components/Filters/index.js b/ui/components/Filters/index.js index 2ace467e..217e2ead 100644 --- a/ui/components/Filters/index.js +++ b/ui/components/Filters/index.js @@ -30,7 +30,7 @@ export function Filter({ {label} - {{numActive} selected} + {numActive > 0 ? {numActive} selected : null} ); From 14ef9f213807c9d63e050a610bd5512e9173f609 Mon Sep 17 00:00:00 2001 From: Stuart Last Date: Thu, 13 Apr 2023 08:26:08 +0100 Subject: [PATCH 005/136] NSDV-111 - Conforms action link to NHS design standard --- ui/components/ActionLink/index.js | 41 ++++++++++++++++++++++ ui/components/ActionLink/style.module.scss | 3 ++ ui/schema/index.js | 4 ++- 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 ui/components/ActionLink/index.js create mode 100644 ui/components/ActionLink/style.module.scss diff --git a/ui/components/ActionLink/index.js b/ui/components/ActionLink/index.js new file mode 100644 index 00000000..e2b26703 --- /dev/null +++ b/ui/components/ActionLink/index.js @@ -0,0 +1,41 @@ +import styles from './style.module.scss'; + +const ActionLink = ({ link = false, title = '' }) => { + return !link ? ( + 'Not available' + ) : ( + <> + +
+ opens in a new tab +
+ (opens in new tab) +
+ + ); +}; + +export default ActionLink; diff --git a/ui/components/ActionLink/style.module.scss b/ui/components/ActionLink/style.module.scss new file mode 100644 index 00000000..e158dc11 --- /dev/null +++ b/ui/components/ActionLink/style.module.scss @@ -0,0 +1,3 @@ +.linkText { + font-size: 1.2em; +} diff --git a/ui/schema/index.js b/ui/schema/index.js index 763bd315..9b33f95c 100644 --- a/ui/schema/index.js +++ b/ui/schema/index.js @@ -10,6 +10,7 @@ import { Dt, } from '../components'; import format from 'date-fns/format'; +import ActionLink from '../components/ActionLink'; // `!!val?.length` => check whether empty array or unset val @@ -155,7 +156,8 @@ const schema = [ <> {val && } {data.documentation_link && ( - From 7b197815605a140879f737f0e2e7620398bbdfe9 Mon Sep 17 00:00:00 2001 From: Stuart Last Date: Mon, 17 Apr 2023 08:57:54 +0100 Subject: [PATCH 006/136] NSDV-101 : Implements badges in search --- ui/components/Dataset/index.js | 24 +++++++++++++++++++++++- ui/components/Tag/index.js | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ui/components/Dataset/index.js b/ui/components/Dataset/index.js index f17f83ea..ec9aa116 100644 --- a/ui/components/Dataset/index.js +++ b/ui/components/Dataset/index.js @@ -28,11 +28,33 @@ function Embolden({ children }) { } function Model({ model }) { - const { name, status, title, metadata_created, description } = model; + const { + name, + status, + title, + metadata_created, + description, + is_published_standard, + } = model; const target = `/published-standards/${name}`; + + {status} + ; + return ( <> +
+ {is_published_standard ? ( + + Published standard + + ) : ( + + Future standard + + )} +
{title} diff --git a/ui/components/Tag/index.js b/ui/components/Tag/index.js index c494af4d..73ed153e 100644 --- a/ui/components/Tag/index.js +++ b/ui/components/Tag/index.js @@ -15,6 +15,7 @@ const colorMap = { 'in-development': 'nhsuk-tag--grey', deprecated: 'nhsuk-tag--orange', retired: 'nhsuk-tag--red', + future: 'nhsuk-tag--blue', }; export default function TypeTag({ children, classes, type }) { From 57b748edd211bb3c811b01e027bc434796560ea7 Mon Sep 17 00:00:00 2001 From: Stuart Last Date: Mon, 17 Apr 2023 09:14:16 +0100 Subject: [PATCH 007/136] NSDV-101 abstract badge logic into function --- ui/components/Dataset/index.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/ui/components/Dataset/index.js b/ui/components/Dataset/index.js index ec9aa116..59ba3d45 100644 --- a/ui/components/Dataset/index.js +++ b/ui/components/Dataset/index.js @@ -27,6 +27,22 @@ function Embolden({ children }) { ); } +function StandardTypeBadge({ isPublishedStandard }) { + return ( +
+ {isPublishedStandard ? ( + + Published standard + + ) : ( + + Future standard + + )} +
+ ); +} + function Model({ model }) { const { name, @@ -44,17 +60,7 @@ function Model({ model }) { return ( <> -
- {is_published_standard ? ( - - Published standard - - ) : ( - - Future standard - - )} -
+
{title} From e1caf51f073217bfead0dab37da296ebfcd56b4f Mon Sep 17 00:00:00 2001 From: Stuart Last Date: Mon, 17 Apr 2023 16:46:18 +0100 Subject: [PATCH 008/136] NSDV-106 - shows radio buttons for 'standard types' on LHS filters --- ui/components/Filters/index.js | 166 +++++++++++++++++++++++++-------- ui/components/Radio/index.js | 27 ++++++ ui/components/Select/index.js | 1 - 3 files changed, 156 insertions(+), 38 deletions(-) create mode 100644 ui/components/Radio/index.js diff --git a/ui/components/Filters/index.js b/ui/components/Filters/index.js index 2ace467e..dacc4ebe 100644 --- a/ui/components/Filters/index.js +++ b/ui/components/Filters/index.js @@ -6,6 +6,7 @@ import pick from 'lodash/pick'; import { CheckboxGroup, OptionSelect, Expander, Select } from '../'; import styles from './Filters.module.scss'; +import { Radio } from '../Radio'; export function Filter({ label, @@ -14,6 +15,7 @@ export function Filter({ field_name: fieldName, open, useSelect, + useRadio, numActive = 0, onlyChild, fullHeight, @@ -38,18 +40,68 @@ export function Filter({ updateQuery({ ...query, [fieldName]: val || [] }); } - return useSelect ? ( - + {clearAll && ( + + Clear all + + )} + + ); + } + + if (useRadio) { + return ( + + + {clearAll && ( + + Clear all + + )} + + ); + } + + return ( - item.field_name === 'status' ? mapStatus(item) : item - ); - - function mapStatus(item) { - return { - ...item, - label: 'Status', - choices: ['in-development', 'active', 'deprecated', 'retired'].map( - (value) => { - const choice = item.choices.find((c) => c.value === value); - if (value === 'in-development') { - return { - ...choice, - value, - label: 'In development (APIs only)', - }; - } - return choice; - } - ), - }; - } const setItem = (name) => (event) => { const { checked, value } = event.target; @@ -144,6 +173,66 @@ export function Filters({ }); }; + const setSingleItem = (name) => (event) => { + const { checked, value } = event.target; + console.log(checked, value); + + if (value === 'all') { + console.log('Selected All'); + return; + } + + let filter = query[name]; + + if (filter && !Array.isArray(filter)) { + filter = [filter]; + } + + if (checked) { + return updateQuery({ + [name]: filter ? [...filter, value] : [value], + }); + } + + if (!filter || !filter.includes(value)) { + return; + } + + const newVal = filter.filter((val) => val !== value); + return updateQuery({ + [name]: newVal.length ? newVal : null, + }); + }; + + const filters = select(categories, fields).map((item) => { + switch (item.field_name) { + case 'status': + return mapStatus(item); + default: + return item; + } + }); + + function mapStatus(item) { + return { + ...item, + label: 'Status', + choices: ['in-development', 'active', 'deprecated', 'retired'].map( + (value) => { + const choice = item.choices.find((c) => c.value === value); + if (value === 'in-development') { + return { + ...choice, + value, + label: 'In development (APIs only)', + }; + } + return choice; + } + ), + }; + } + function onClearAllClick(e) { e.preventDefault(); updateQuery(pick(query, 'q', 'page', 'orderBy', 'order'), { @@ -177,10 +266,13 @@ export function Filters({ key={filter.field_name} {...filter} open={expanded || openFilters.includes(filter.field_name)} - onChange={setItem(filter.field_name)} + onChange={ + filter.onChange ? filter.onChange : setItem(filter.field_name) + } numActive={numActive} // TODO: this should be configured in schema - useSelect={filter.field_name === 'standard_category'} + //useSelect={filter.field_name === 'standard_category'} + useRadio={filter.field_name === 'standard_category'} onlyChild={filters.length === 1} fullHeight={fullHeight} onClearAllClick={onClearAllClick} diff --git a/ui/components/Radio/index.js b/ui/components/Radio/index.js new file mode 100644 index 00000000..c7f1d591 --- /dev/null +++ b/ui/components/Radio/index.js @@ -0,0 +1,27 @@ +export function Radio({ options, onChange, id, value, name }) { + return ( + <> +
onChange(e.target.value)} + value={value} + > + {options.filter(Boolean).map((option) => ( +
+ + + {option.label} + +
+ ))} +
+ + ); +} diff --git a/ui/components/Select/index.js b/ui/components/Select/index.js index 2582cba4..b166c1cd 100644 --- a/ui/components/Select/index.js +++ b/ui/components/Select/index.js @@ -1,6 +1,5 @@ export function Select({ options, onChange, id, value, label, showAll, name }) { return ( - //
<> {' '} {label && ( From 1607f9d797e270a09af5151d4b7754941a96c9f8 Mon Sep 17 00:00:00 2001 From: Stuart Last Date: Tue, 18 Apr 2023 11:17:44 +0100 Subject: [PATCH 009/136] NSDV-107 - Implements future and published standards showing in search results --- ui/helpers/api.js | 19 +++++++++---------- ui/helpers/getPageProps.js | 8 ++++++-- ui/pages/search-results.js | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/ui/helpers/api.js b/ui/helpers/api.js index e6702b27..e141a83a 100644 --- a/ui/helpers/api.js +++ b/ui/helpers/api.js @@ -98,15 +98,10 @@ export async function getPages() { return callApi(`${PAGES_CKAN_URL}/ckanext_pages_list`); } -export async function list({ - page = 1, - q, - sort, - inactive, - orderBy, - order, - ...filters -}) { +export async function list( + { page = 1, q, sort, inactive, orderBy, order, ...filters }, + futureAndPublished = false +) { if (!sort) { if (orderBy) { sort = { @@ -131,12 +126,16 @@ export async function list({ .join(', '); } - filters.is_published_standard = !inactive; + if (!futureAndPublished) { + filters.is_published_standard = !inactive; + } fq = serialise(queriseSelections(filters)); const query = getSearchQuery(q); const ckanQuery = stringify({ q: query, fq, rows, start, sort: sortstring }); + console.log('Filters', filters); + console.log('ckanQuery', ckanQuery); return callApi(`${CKAN_URL}/package_search?${ckanQuery}`); } diff --git a/ui/helpers/getPageProps.js b/ui/helpers/getPageProps.js index d2e8cf84..2e443dc2 100644 --- a/ui/helpers/getPageProps.js +++ b/ui/helpers/getPageProps.js @@ -1,10 +1,14 @@ import { list, schema, getPages } from './api'; import { getHost } from './getHost'; -export async function getPageProps({ req, query }, options = {}) { +export async function getPageProps( + { req, query }, + options = {}, + futureAndPublished = false +) { return { props: { host: await getHost(req), - data: await list(query), + data: await list(query, futureAndPublished), schemaData: await schema(), pages: await getPages(), searchTerm: query.q || '', diff --git a/ui/pages/search-results.js b/ui/pages/search-results.js index d8267079..d1f2fa64 100644 --- a/ui/pages/search-results.js +++ b/ui/pages/search-results.js @@ -65,5 +65,5 @@ SearchResults.Layout = function SearchResults({ children }) { }; export async function getServerSideProps(context) { - return await getPageProps(context, { content }); + return await getPageProps(context, { content }, true); } From 85c7d570c960400c038ac200ad3be25aaec9d3db Mon Sep 17 00:00:00 2001 From: Stuart Last Date: Tue, 18 Apr 2023 11:22:20 +0100 Subject: [PATCH 010/136] NSDV-107 cleanup console.logs --- ui/helpers/api.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/ui/helpers/api.js b/ui/helpers/api.js index e141a83a..25f2fd26 100644 --- a/ui/helpers/api.js +++ b/ui/helpers/api.js @@ -134,8 +134,6 @@ export async function list( const query = getSearchQuery(q); const ckanQuery = stringify({ q: query, fq, rows, start, sort: sortstring }); - console.log('Filters', filters); - console.log('ckanQuery', ckanQuery); return callApi(`${CKAN_URL}/package_search?${ckanQuery}`); } From 9b1db72fe02ad88888826910df27247375fff826 Mon Sep 17 00:00:00 2001 From: Stuart Last Date: Tue, 18 Apr 2023 12:07:02 +0100 Subject: [PATCH 011/136] NSDV-107 - remove 'published' from placeholder text in search-results page --- ui/pages/search-results.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/pages/search-results.js b/ui/pages/search-results.js index d1f2fa64..3cf1d864 100644 --- a/ui/pages/search-results.js +++ b/ui/pages/search-results.js @@ -42,7 +42,7 @@ export default function SearchResults({ data, schemaData, host }) {
From f4561814b71f1d1c5ba60da5f1c565683fc07d06 Mon Sep 17 00:00:00 2001 From: Stuart Last Date: Tue, 18 Apr 2023 13:55:37 +0100 Subject: [PATCH 012/136] FIX build errors --- ui/components/Dataset/index.js | 2 +- ui/components/Filters/index.js | 31 ------------------------------- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/ui/components/Dataset/index.js b/ui/components/Dataset/index.js index e139d496..7f066574 100644 --- a/ui/components/Dataset/index.js +++ b/ui/components/Dataset/index.js @@ -229,7 +229,7 @@ export default function Dataset({ const order = 'asc'; updateQuery({ ...query, orderBy, order }); setPageLoaded(true); - }, []); + }, [updateQuery, query]); return ( <> diff --git a/ui/components/Filters/index.js b/ui/components/Filters/index.js index bf90f3d4..cf9e69d9 100644 --- a/ui/components/Filters/index.js +++ b/ui/components/Filters/index.js @@ -173,37 +173,6 @@ export function Filters({ }); }; - const setSingleItem = (name) => (event) => { - const { checked, value } = event.target; - console.log(checked, value); - - if (value === 'all') { - console.log('Selected All'); - return; - } - - let filter = query[name]; - - if (filter && !Array.isArray(filter)) { - filter = [filter]; - } - - if (checked) { - return updateQuery({ - [name]: filter ? [...filter, value] : [value], - }); - } - - if (!filter || !filter.includes(value)) { - return; - } - - const newVal = filter.filter((val) => val !== value); - return updateQuery({ - [name]: newVal.length ? newVal : null, - }); - }; - const filters = select(categories, fields).map((item) => { switch (item.field_name) { case 'status': From f8b85415795337ec831f1e602ab395a681a1878a Mon Sep 17 00:00:00 2001 From: Stuart Last Date: Tue, 18 Apr 2023 14:21:26 +0100 Subject: [PATCH 013/136] FIX - remove useEffect missing dependencies warning --- ui/components/Dataset/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/components/Dataset/index.js b/ui/components/Dataset/index.js index 7f066574..d0f8e9d2 100644 --- a/ui/components/Dataset/index.js +++ b/ui/components/Dataset/index.js @@ -229,7 +229,7 @@ export default function Dataset({ const order = 'asc'; updateQuery({ ...query, orderBy, order }); setPageLoaded(true); - }, [updateQuery, query]); + }, []); // eslint-disable-line react-hooks/exhaustive-deps return ( <> From 64732faddde95c34dd05dae5e08c24f0fa12337d Mon Sep 17 00:00:00 2001 From: Stuart Last Date: Thu, 20 Apr 2023 10:34:22 +0100 Subject: [PATCH 014/136] NSDV-107 - FIXES 'future standards' not showing in search results --- ui/components/Dataset/index.js | 6 +++++- ui/helpers/api.js | 2 +- ui/pages/api/refresh-list.js | 4 +++- ui/pages/search-results.js | 7 ++++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ui/components/Dataset/index.js b/ui/components/Dataset/index.js index d0f8e9d2..75145593 100644 --- a/ui/components/Dataset/index.js +++ b/ui/components/Dataset/index.js @@ -193,6 +193,7 @@ export default function Dataset({ data: initialData = {}, includeType, schema, + futureAndPublished = false, }) { const { query, updateQuery } = useQueryContext(); const searchTerm = query.q; @@ -206,7 +207,10 @@ export default function Dataset({ async function getData() { try { setLoading(true); - const res = await axios.post('/api/refresh-list', query); + const res = await axios.post('/api/refresh-list', { + ...query, + futureAndPublished, + }); setData(res.data); } catch (err) { console.error(err); diff --git a/ui/helpers/api.js b/ui/helpers/api.js index 25f2fd26..3111bbb0 100644 --- a/ui/helpers/api.js +++ b/ui/helpers/api.js @@ -99,7 +99,7 @@ export async function getPages() { } export async function list( - { page = 1, q, sort, inactive, orderBy, order, ...filters }, + { page = 1, q, sort, inactive = false, orderBy, order, ...filters }, futureAndPublished = false ) { if (!sort) { diff --git a/ui/pages/api/refresh-list.js b/ui/pages/api/refresh-list.js index f98e767e..318eb96d 100644 --- a/ui/pages/api/refresh-list.js +++ b/ui/pages/api/refresh-list.js @@ -1,7 +1,9 @@ import { list } from '../../helpers/api'; export default async function handler(req, res) { - const data = await list(req.body); + const futureAndPublished = req.body.futureAndPublished || false; + delete req.body.futureAndPublished; + const data = await list(req.body, futureAndPublished); res.status(200).json(data); } diff --git a/ui/pages/search-results.js b/ui/pages/search-results.js index 3cf1d864..5ae77a42 100644 --- a/ui/pages/search-results.js +++ b/ui/pages/search-results.js @@ -52,7 +52,12 @@ export default function SearchResults({ data, schemaData, host }) { - + From 3ae042b56621971c90e9521e288519b3a5c687b4 Mon Sep 17 00:00:00 2001 From: Stuart Last Date: Thu, 20 Apr 2023 11:47:35 +0100 Subject: [PATCH 015/136] NSDV-109 WIP moved 'National Requriement' to left-hand filters --- ui/components/Dataset/index.js | 40 --------------------- ui/components/Filters/index.js | 65 +++++++++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 41 deletions(-) diff --git a/ui/components/Dataset/index.js b/ui/components/Dataset/index.js index d0f8e9d2..2d088533 100644 --- a/ui/components/Dataset/index.js +++ b/ui/components/Dataset/index.js @@ -129,43 +129,6 @@ function SortMenu({ searchTerm }) { ); } -const CheckBox = () => { - const { getSelections, updateQuery } = useQueryContext(); - const toggleMandated = (event) => { - const selections = getSelections(); - const { name, checked } = event.target; - delete selections[name]; - if (checked) { - selections[name] = checked; - } - updateQuery(selections, { replace: true }); - }; - - return ( -
- - -
- ); -}; - const NoResultsSummary = ({ searchTerm }) => ( <>

@@ -245,9 +208,6 @@ export default function Dataset({
-
- -

{count > 0 ? (
    diff --git a/ui/components/Filters/index.js b/ui/components/Filters/index.js index cf9e69d9..98685531 100644 --- a/ui/components/Filters/index.js +++ b/ui/components/Filters/index.js @@ -8,6 +8,69 @@ import { CheckboxGroup, OptionSelect, Expander, Select } from '../'; import styles from './Filters.module.scss'; import { Radio } from '../Radio'; +const CheckBox = () => { + const { getSelections, updateQuery } = useQueryContext(); + + const selections = getSelections(); + + useEffect(() => { + const name = 'mandated'; + delete selections[name]; + selections[name] = true; + updateQuery(selections, { replace: true }); + }, []); // eslint-disable-line react-hooks/exhaustive-deps + + const toggleMandated = (event) => { + const { name, checked } = event.target; + delete selections[name]; + if (checked) { + selections[name] = checked; + } + updateQuery(selections, { replace: true }); + }; + + return ( + +
    + {/* + + */} + + +
    +
    + ); +}; + export function Filter({ label, choices, @@ -240,7 +303,6 @@ export function Filters({ } numActive={numActive} // TODO: this should be configured in schema - //useSelect={filter.field_name === 'standard_category'} useRadio={filter.field_name === 'standard_category'} onlyChild={filters.length === 1} fullHeight={fullHeight} @@ -251,6 +313,7 @@ export function Filters({ /> ); })} + ); From 9da17b8052d558f1a5ed54b1750f39625b25a4d1 Mon Sep 17 00:00:00 2001 From: Stuart Last Date: Thu, 20 Apr 2023 12:22:09 +0100 Subject: [PATCH 016/136] NSDV-109 - Show mandated standards by default --- ui/components/Dataset/index.js | 3 ++- ui/components/Filters/index.js | 9 --------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/ui/components/Dataset/index.js b/ui/components/Dataset/index.js index 2d088533..96068609 100644 --- a/ui/components/Dataset/index.js +++ b/ui/components/Dataset/index.js @@ -190,7 +190,8 @@ export default function Dataset({ useEffect(() => { const orderBy = 'name'; const order = 'asc'; - updateQuery({ ...query, orderBy, order }); + const mandated = 'true'; + updateQuery({ ...query, orderBy, order, mandated }); setPageLoaded(true); }, []); // eslint-disable-line react-hooks/exhaustive-deps diff --git a/ui/components/Filters/index.js b/ui/components/Filters/index.js index 98685531..55075d7a 100644 --- a/ui/components/Filters/index.js +++ b/ui/components/Filters/index.js @@ -42,15 +42,6 @@ const CheckBox = () => { styles.checkboxItem )} > - {/* - - */} Date: Thu, 20 Apr 2023 15:42:27 +0100 Subject: [PATCH 017/136] NSDV-101 - move 'published' flag to right of standard title --- ui/components/Dataset/index.js | 18 ++++++++++++------ ui/components/Dataset/style.module.scss | 13 +++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/ui/components/Dataset/index.js b/ui/components/Dataset/index.js index 75145593..5cae58cf 100644 --- a/ui/components/Dataset/index.js +++ b/ui/components/Dataset/index.js @@ -60,12 +60,18 @@ function Model({ model }) { return ( <> - - - - {title} - - +
    + +
    + +
    +

    {description}

    diff --git a/ui/components/Dataset/style.module.scss b/ui/components/Dataset/style.module.scss index 16facf81..823283db 100644 --- a/ui/components/Dataset/style.module.scss +++ b/ui/components/Dataset/style.module.scss @@ -25,3 +25,16 @@ .right { text-align: right; } + +.standardHeader { + display: flex; + justify-content: space-between; +} + +.standardTitle { + flex: 6; +} + +.standardFlag { + flex: 2; +} From bd902e2fa9a384d12ba789db8cc565edfbcef42d Mon Sep 17 00:00:00 2001 From: Stuart Last Date: Thu, 20 Apr 2023 15:50:44 +0100 Subject: [PATCH 018/136] NSDV-101 Clean up standard result header spacing --- ui/components/Dataset/style.module.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/components/Dataset/style.module.scss b/ui/components/Dataset/style.module.scss index 823283db..4c170c4a 100644 --- a/ui/components/Dataset/style.module.scss +++ b/ui/components/Dataset/style.module.scss @@ -33,8 +33,10 @@ .standardTitle { flex: 6; + margin-bottom: 1.4em; } .standardFlag { flex: 2; + text-align: right; } From 095f0236c1bf33b7c1423ebeccc04e8866d77bf6 Mon Sep 17 00:00:00 2001 From: Stuart Last Date: Fri, 21 Apr 2023 16:21:18 +0100 Subject: [PATCH 019/136] NSDV-109 - styling alignment corrections --- ui/components/Filters/Filters.module.scss | 19 +++++++++++++++++++ ui/components/Filters/index.js | 7 ++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ui/components/Filters/Filters.module.scss b/ui/components/Filters/Filters.module.scss index c17cb270..623b08ef 100644 --- a/ui/components/Filters/Filters.module.scss +++ b/ui/components/Filters/Filters.module.scss @@ -34,3 +34,22 @@ .clear { clear: both; } + +.requirementLabel { + margin-left: -8px; +} + +.requirementLabel::before { + margin-top: 10px !important; + margin-left: 4px !important; + height: 24px !important; + width: 24px !important; +} + +.requirementLabel::after { + left: 9px !important; + top: 17px !important; + width: 9px !important; + height: 3.5px !important; + border-width: 0 0 3px 3px !important; +} diff --git a/ui/components/Filters/index.js b/ui/components/Filters/index.js index 55075d7a..d7780727 100644 --- a/ui/components/Filters/index.js +++ b/ui/components/Filters/index.js @@ -52,7 +52,12 @@ const CheckBox = () => { onChange={toggleMandated} />