From 830c03b69823afdf1a16e83959e616ccd410ecc8 Mon Sep 17 00:00:00 2001 From: William Moore Date: Sun, 20 Oct 2024 22:43:31 +0100 Subject: [PATCH] Move all sort options under select --- ome2024-ngff-challenge/src/App.svelte | 118 ++++++------------- ome2024-ngff-challenge/src/ColumnSort.svelte | 23 ++-- ome2024-ngff-challenge/src/tableStore.js | 14 +-- 3 files changed, 47 insertions(+), 108 deletions(-) diff --git a/ome2024-ngff-challenge/src/App.svelte b/ome2024-ngff-challenge/src/App.svelte index 94373cb..5719419 100644 --- a/ome2024-ngff-challenge/src/App.svelte +++ b/ome2024-ngff-challenge/src/App.svelte @@ -73,16 +73,18 @@ } let sortedBy = ""; - let sortAscending = true; - function handleSort(colname) { - if (sortedBy === colname) { - sortAscending = !sortAscending; + let sortAscending = false; + function toggleSortAscending() { + sortAscending = !sortAscending; + ngffTable.sortTable(sortedBy, sortAscending); + } + function handleSort(event) { + sortedBy = event.target.value; + if (sortedBy === "") { + ngffTable.sortTable("index", true); } else { - // start by sorting descending (biggest first) - sortAscending = false; + ngffTable.sortTable(sortedBy, sortAscending); } - sortedBy = colname; - ngffTable.sortTable(colname, sortAscending); } // Main filtering function @@ -318,74 +320,29 @@
- - Sort by: -
- - - - - - -
-
- - - + +
Sort by:
+
+ +
+ +
+
@@ -553,13 +510,4 @@ .results h3 { margin: 10px; } - - .sortButtons { - display: flex; - flex-direction: row; - border: solid var(--border-color) 1px; - border-radius: 5px; - width: fit-content; - margin: 5px 0; - } diff --git a/ome2024-ngff-challenge/src/ColumnSort.svelte b/ome2024-ngff-challenge/src/ColumnSort.svelte index 84db378..30f0a12 100644 --- a/ome2024-ngff-challenge/src/ColumnSort.svelte +++ b/ome2024-ngff-challenge/src/ColumnSort.svelte @@ -1,32 +1,27 @@ -