From bdf0f9f15ed2ae97c59a8660c9181526348fe394 Mon Sep 17 00:00:00 2001 From: Bram Tweedegolf Date: Fri, 1 Nov 2024 14:01:29 +0100 Subject: [PATCH 1/3] Combined text search and sorting --- frontend/src/lib/CrateList.svelte | 19 +++++++++++++++++- frontend/src/lib/SortFilter.svelte | 4 ++++ frontend/src/lib/TextFilter.svelte | 29 ++++++++++++++++++++------- frontend/src/store/FilterStore.svelte | 3 +++ 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/frontend/src/lib/CrateList.svelte b/frontend/src/lib/CrateList.svelte index 5a5de57..1939351 100644 --- a/frontend/src/lib/CrateList.svelte +++ b/frontend/src/lib/CrateList.svelte @@ -1,7 +1,7 @@
    diff --git a/frontend/src/lib/SortFilter.svelte b/frontend/src/lib/SortFilter.svelte index efafcbf..241d650 100644 --- a/frontend/src/lib/SortFilter.svelte +++ b/frontend/src/lib/SortFilter.svelte @@ -41,6 +41,7 @@ $: recent_downloads_open = $sort_by == 'recent_downloads'; $: newly_added_open = $sort_by == 'newly_added'; $: recently_updated_open = $sort_by == 'recently_updated'; + $: text_score = $sort_by == 'score'; @@ -68,6 +69,9 @@ + diff --git a/frontend/src/lib/TextFilter.svelte b/frontend/src/lib/TextFilter.svelte index d5ef970..141b154 100644 --- a/frontend/src/lib/TextFilter.svelte +++ b/frontend/src/lib/TextFilter.svelte @@ -1,5 +1,6 @@
    -
    \ No newline at end of file + diff --git a/frontend/src/store/FilterStore.svelte b/frontend/src/store/FilterStore.svelte index b8e6df1..9d6be8e 100644 --- a/frontend/src/store/FilterStore.svelte +++ b/frontend/src/store/FilterStore.svelte @@ -8,4 +8,7 @@ // The results are sorted by export let sort_by = writable("alphanumeric"); + // Results of text search + export let scores = writable([]); + From cddec5abf417af0b9d96b7c007a526a7fc0d1295 Mon Sep 17 00:00:00 2001 From: Bram Tweedegolf Date: Fri, 1 Nov 2024 14:38:11 +0100 Subject: [PATCH 2/3] Fixed type issuse --- frontend/src/App.svelte | 2 +- frontend/src/app.css | 5 +++++ frontend/src/lib/CrateList.svelte | 11 ++++++++--- frontend/src/lib/Filter.svelte | 2 +- frontend/src/lib/SortFilter.svelte | 2 +- frontend/src/lib/TextFilter.svelte | 11 ++++++++--- frontend/src/store/FilterStore.svelte | 14 -------------- frontend/src/store/FilterStore.ts | 16 ++++++++++++++++ frontend/tsconfig.json | 3 ++- 9 files changed, 42 insertions(+), 24 deletions(-) delete mode 100644 frontend/src/store/FilterStore.svelte create mode 100644 frontend/src/store/FilterStore.ts diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index 50da466..a4d90b7 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -1,7 +1,7 @@
    - +
    diff --git a/frontend/src/store/FilterStore.svelte b/frontend/src/store/FilterStore.svelte deleted file mode 100644 index 9d6be8e..0000000 --- a/frontend/src/store/FilterStore.svelte +++ /dev/null @@ -1,14 +0,0 @@ - diff --git a/frontend/src/store/FilterStore.ts b/frontend/src/store/FilterStore.ts new file mode 100644 index 0000000..a611f1e --- /dev/null +++ b/frontend/src/store/FilterStore.ts @@ -0,0 +1,16 @@ +import {writable} from 'svelte/store'; + +export interface Score { + name: String; + score: number; +} + +// Which filter is currenly opened +export let open_filter = writable(""); + +// The results are sorted by +export let sort_by = writable("alphanumeric"); + +// Results of text search +export let scores = writable([]); + diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index a10ccc3..d449b61 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -13,7 +13,8 @@ */ "allowJs": true, "checkJs": true, - "isolatedModules": true + "isolatedModules": true, + "allowImportingTsExtensions": true }, "include": ["src/**/*.ts", "src/**/*.js", "src/**/*.svelte"], "references": [ From c6af90d0833e54a8197c92f1e9d599ab592f0150 Mon Sep 17 00:00:00 2001 From: Tamme Dittrich Date: Fri, 1 Nov 2024 14:41:58 +0100 Subject: [PATCH 3/3] run formatter --- frontend/src/app.css | 1 - frontend/src/store/FilterStore.ts | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/frontend/src/app.css b/frontend/src/app.css index 5d35c55..192c724 100644 --- a/frontend/src/app.css +++ b/frontend/src/app.css @@ -157,7 +157,6 @@ label { input[type="text"] { min-height: 54px; } - } .filter { diff --git a/frontend/src/store/FilterStore.ts b/frontend/src/store/FilterStore.ts index a611f1e..6d2c80e 100644 --- a/frontend/src/store/FilterStore.ts +++ b/frontend/src/store/FilterStore.ts @@ -1,4 +1,4 @@ -import {writable} from 'svelte/store'; +import { writable } from "svelte/store"; export interface Score { name: String; @@ -13,4 +13,3 @@ export let sort_by = writable("alphanumeric"); // Results of text search export let scores = writable([]); -