From 8463ac43deda1efefc14b119fdceb92ed2e57592 Mon Sep 17 00:00:00 2001 From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com> Date: Mon, 7 Oct 2024 14:44:52 -0400 Subject: [PATCH 1/3] adding the npm config file to git ignore --- .gitignore | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 21d3b519..39eb7e66 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ dist node_modules - .env* -.DS_Store -src/.DS_Store +.npmrc From 7367dc1c3a06515dde63c9cb38347ef12039926c Mon Sep 17 00:00:00 2001 From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com> Date: Tue, 8 Oct 2024 13:19:09 -0400 Subject: [PATCH 2/3] adding the advisory/cycle number into the sort, also reversing sort order so latest runs are at the top --- src/components/trays/model-selection/catalogItems.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/trays/model-selection/catalogItems.js b/src/components/trays/model-selection/catalogItems.js index 87389881..afad8e07 100644 --- a/src/components/trays/model-selection/catalogItems.js +++ b/src/components/trays/model-selection/catalogItems.js @@ -146,6 +146,9 @@ export default function CatalogItems(data) { } // return all the data cards else { + // get the sorting parameter + const sortParam = (data.isTropical) ? 'advisory_number' : 'cycle'; + // render the results of the data query return ( @@ -172,7 +175,7 @@ export default function CatalogItems(data) { // filter by the group name, get the top 1 .filter((val, idx, self) => ( idx === self.findIndex((t)=> ( t['group'] === val['group']) ))) - .sort((a, b) => a.properties['product_name'] < b.properties['product_name'] ? -1 : 1) + .sort((a, b) => a.properties['product_name'] + a.properties[sortParam] < b.properties['product_name'] + b.properties[sortParam] ? 1 : -1) // output summarized details of each group member .map((mbr, mbrIdx) => ( // create the checkbox From d7eaa96925eee67a222d1ca8deb8abf7aa4c1308 Mon Sep 17 00:00:00 2001 From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com> Date: Thu, 10 Oct 2024 12:50:23 -0400 Subject: [PATCH 3/3] fixing the value used to sort by and the way of sorting --- src/components/trays/model-selection/catalogItems.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/trays/model-selection/catalogItems.js b/src/components/trays/model-selection/catalogItems.js index afad8e07..602a6393 100644 --- a/src/components/trays/model-selection/catalogItems.js +++ b/src/components/trays/model-selection/catalogItems.js @@ -149,6 +149,9 @@ export default function CatalogItems(data) { // get the sorting parameter const sortParam = (data.isTropical) ? 'advisory_number' : 'cycle'; + // simple sort comparer for more than 1 level of strings + const compare = (x, y) => (x > y) - (x < y); + // render the results of the data query return ( @@ -175,7 +178,8 @@ export default function CatalogItems(data) { // filter by the group name, get the top 1 .filter((val, idx, self) => ( idx === self.findIndex((t)=> ( t['group'] === val['group']) ))) - .sort((a, b) => a.properties['product_name'] + a.properties[sortParam] < b.properties['product_name'] + b.properties[sortParam] ? 1 : -1) + .sort((a, b) => compare(b.properties[sortParam], a.properties[sortParam]) || compare(a.properties['event_type'], b.properties['event_type'])) + //((b.properties[sortParam] + b.properties['event_type']).localeCompare(a.properties[sortParam] + a.properties['event_type']))) // output summarized details of each group member .map((mbr, mbrIdx) => ( // create the checkbox