From ec513fc362272cef660be7647ea675a91c1579b5 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sat, 15 Nov 2025 09:13:37 +0200 Subject: [PATCH 01/25] Add basic filter --- frontend/src/html/popups.html | 7 ++++++ frontend/src/ts/modals/quote-filter.ts | 32 ++++++++++++++++++++++++++ frontend/src/ts/modals/quote-search.ts | 30 +++++++++++++++++++----- 3 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 frontend/src/ts/modals/quote-filter.ts diff --git a/frontend/src/html/popups.html b/frontend/src/html/popups.html index 2b51f5751973..8e98fdd2101b 100644 --- a/frontend/src/html/popups.html +++ b/frontend/src/html/popups.html @@ -944,6 +944,13 @@ + diff --git a/frontend/src/ts/modals/quote-filter.ts b/frontend/src/ts/modals/quote-filter.ts index e9fb3b969df7..9873f0814626 100644 --- a/frontend/src/ts/modals/quote-filter.ts +++ b/frontend/src/ts/modals/quote-filter.ts @@ -1,10 +1,7 @@ import AnimatedModal from "../utils/animated-modal"; -export let filterLength = 0; - -function handleLengthFilter(customFilterLength: number): void { - filterLength = customFilterLength; -} +export let minFilterLength: number = 0; +export let maxFilterLength: number = 0; export function show(): void { void modal.show(); @@ -19,9 +16,10 @@ function hide(clearModalChain: boolean): void { async function setup(modalEl: HTMLElement): Promise { let submitButton = modalEl.querySelector("button"); submitButton?.addEventListener("click", () => { - let inputEl = modalEl.querySelector(".filterLength") as HTMLInputElement; - let customFilterLength = +inputEl.value; - handleLengthFilter(customFilterLength); + let minEl = modalEl.querySelector(".minFilterLength") as HTMLInputElement; + let maxEl = modalEl.querySelector(".maxFilterLength") as HTMLInputElement; + minFilterLength = +minEl?.value; + maxFilterLength = +maxEl?.value; hide(true); let refreshButton = document.querySelector( ".refreshQuotes" diff --git a/frontend/src/ts/modals/quote-search.ts b/frontend/src/ts/modals/quote-search.ts index 829a0bad9667..99f30da55e44 100644 --- a/frontend/src/ts/modals/quote-search.ts +++ b/frontend/src/ts/modals/quote-search.ts @@ -54,19 +54,24 @@ function applyQuoteLengthFilter(quotes: Quote[]): Quote[] { return quotes; } - let filterLength = QuoteFilterPopup.filterLength; + let minFilterLength = QuoteFilterPopup.minFilterLength; + let maxFilterLength = QuoteFilterPopup.maxFilterLength; if (quoteLengthFilterValue.includes("4")) { if (usingCustomLength) { QuoteFilterPopup.show(); } } else { - filterLength = 0; + minFilterLength = 0; + maxFilterLength = 0; } let filteredQuotes = quotes; - if (filterLength > 0) { - filteredQuotes = quotes.filter((quote) => quote.length <= filterLength); + if (minFilterLength > 0) { + filteredQuotes = quotes.filter( + (quote) => + quote.length >= minFilterLength && quote.length <= maxFilterLength + ); } else { const quoteLengthFilter = new Set( quoteLengthFilterValue.map((filterValue) => parseInt(filterValue, 10)) From 52fd99dbc5df5e35e9ce187768449c55ab6efdd3 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sat, 15 Nov 2025 12:40:45 +0200 Subject: [PATCH 05/25] refactor --- frontend/src/ts/modals/quote-filter.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/frontend/src/ts/modals/quote-filter.ts b/frontend/src/ts/modals/quote-filter.ts index 9873f0814626..e9e91cc26f88 100644 --- a/frontend/src/ts/modals/quote-filter.ts +++ b/frontend/src/ts/modals/quote-filter.ts @@ -3,6 +3,13 @@ import AnimatedModal from "../utils/animated-modal"; export let minFilterLength: number = 0; export let maxFilterLength: number = 0; +function handleFilterLength(modalEl: HTMLElement): void { + let minEl = modalEl.querySelector(".minFilterLength") as HTMLInputElement; + let maxEl = modalEl.querySelector(".maxFilterLength") as HTMLInputElement; + minFilterLength = +minEl?.value; + maxFilterLength = +maxEl?.value; +} + export function show(): void { void modal.show(); } @@ -16,19 +23,20 @@ function hide(clearModalChain: boolean): void { async function setup(modalEl: HTMLElement): Promise { let submitButton = modalEl.querySelector("button"); submitButton?.addEventListener("click", () => { - let minEl = modalEl.querySelector(".minFilterLength") as HTMLInputElement; - let maxEl = modalEl.querySelector(".maxFilterLength") as HTMLInputElement; - minFilterLength = +minEl?.value; - maxFilterLength = +maxEl?.value; + handleFilterLength(modalEl); hide(true); - let refreshButton = document.querySelector( - ".refreshQuotes" - ) as HTMLButtonElement; - refreshButton.click(); }); } +async function cleanup(): Promise { + let refreshButton = document.querySelector( + ".refreshQuotes" + ) as HTMLButtonElement; + refreshButton.click(); +} + const modal = new AnimatedModal({ dialogId: "quoteFilterModal", setup, + cleanup, }); From 02754cdb126b20dace035948cf3e767da0cea992 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sat, 15 Nov 2025 12:42:34 +0200 Subject: [PATCH 06/25] Remove unnecessary parameter --- frontend/src/ts/modals/quote-filter.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/frontend/src/ts/modals/quote-filter.ts b/frontend/src/ts/modals/quote-filter.ts index e9e91cc26f88..553f26938847 100644 --- a/frontend/src/ts/modals/quote-filter.ts +++ b/frontend/src/ts/modals/quote-filter.ts @@ -14,17 +14,15 @@ export function show(): void { void modal.show(); } -function hide(clearModalChain: boolean): void { - void modal.hide({ - clearModalChain, - }); +function hide(): void { + void modal.hide(); } async function setup(modalEl: HTMLElement): Promise { let submitButton = modalEl.querySelector("button"); submitButton?.addEventListener("click", () => { handleFilterLength(modalEl); - hide(true); + hide(); }); } From b40f0c320d3fc1cb5e08ebe30b3486dc7ffc4269 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sat, 15 Nov 2025 12:47:31 +0200 Subject: [PATCH 07/25] Ignore custom when others are present --- frontend/src/ts/modals/quote-search.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/ts/modals/quote-search.ts b/frontend/src/ts/modals/quote-search.ts index 99f30da55e44..f7cfeb1cbe2b 100644 --- a/frontend/src/ts/modals/quote-search.ts +++ b/frontend/src/ts/modals/quote-search.ts @@ -57,13 +57,17 @@ function applyQuoteLengthFilter(quotes: Quote[]): Quote[] { let minFilterLength = QuoteFilterPopup.minFilterLength; let maxFilterLength = QuoteFilterPopup.maxFilterLength; - if (quoteLengthFilterValue.includes("4")) { + if ( + quoteLengthFilterValue[0] === "4" && + quoteLengthFilterValue.length === 1 + ) { if (usingCustomLength) { QuoteFilterPopup.show(); } } else { minFilterLength = 0; maxFilterLength = 0; + usingCustomLength = false; } let filteredQuotes = quotes; From a9a3a0e9a3ad8b0252da8697b067b024d54475b2 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sat, 15 Nov 2025 15:07:36 +0200 Subject: [PATCH 08/25] Don't show popup when removing other filters --- frontend/src/ts/modals/quote-search.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/ts/modals/quote-search.ts b/frontend/src/ts/modals/quote-search.ts index f7cfeb1cbe2b..5b15d868d1f7 100644 --- a/frontend/src/ts/modals/quote-search.ts +++ b/frontend/src/ts/modals/quote-search.ts @@ -51,6 +51,7 @@ function applyQuoteLengthFilter(quotes: Quote[]): Quote[] { "#quoteSearchModal .quoteLengthFilter" ).val() as string[]; if (quoteLengthFilterValue.length === 0) { + usingCustomLength = true; return quotes; } @@ -354,7 +355,6 @@ const searchForQuotes = debounce(250, (): void => { const searchText = (document.getElementById("searchBox") as HTMLInputElement) .value; currentPageNumber = 1; - usingCustomLength = true; void updateResults(searchText); }); From 7b7422466cde2097511937ac48dc4b7635bc0449 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sat, 15 Nov 2025 15:15:33 +0200 Subject: [PATCH 09/25] Make popup show when first option isn't custom --- frontend/src/ts/modals/quote-search.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/frontend/src/ts/modals/quote-search.ts b/frontend/src/ts/modals/quote-search.ts index 5b15d868d1f7..94aa891b9e90 100644 --- a/frontend/src/ts/modals/quote-search.ts +++ b/frontend/src/ts/modals/quote-search.ts @@ -27,7 +27,7 @@ const searchServiceCache: Record> = {}; const pageSize = 100; let currentPageNumber = 1; -let usingCustomLength = false; +let usingCustomLength = true; function getSearchService( language: string, @@ -58,21 +58,18 @@ function applyQuoteLengthFilter(quotes: Quote[]): Quote[] { let minFilterLength = QuoteFilterPopup.minFilterLength; let maxFilterLength = QuoteFilterPopup.maxFilterLength; - if ( - quoteLengthFilterValue[0] === "4" && - quoteLengthFilterValue.length === 1 - ) { + if (quoteLengthFilterValue.includes("4")) { if (usingCustomLength) { QuoteFilterPopup.show(); } } else { minFilterLength = 0; maxFilterLength = 0; - usingCustomLength = false; + usingCustomLength = true; } let filteredQuotes = quotes; - if (minFilterLength > 0) { + if (minFilterLength > 0 && quoteLengthFilterValue.length === 1) { filteredQuotes = quotes.filter( (quote) => quote.length >= minFilterLength && quote.length <= maxFilterLength From 076da52de6021517c0d711486a35fb17ac8d3126 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sat, 15 Nov 2025 15:35:36 +0200 Subject: [PATCH 10/25] Make quotes change after each input change --- frontend/src/ts/modals/quote-filter.ts | 30 ++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/frontend/src/ts/modals/quote-filter.ts b/frontend/src/ts/modals/quote-filter.ts index 553f26938847..5cdf2f86482a 100644 --- a/frontend/src/ts/modals/quote-filter.ts +++ b/frontend/src/ts/modals/quote-filter.ts @@ -3,11 +3,17 @@ import AnimatedModal from "../utils/animated-modal"; export let minFilterLength: number = 0; export let maxFilterLength: number = 0; -function handleFilterLength(modalEl: HTMLElement): void { - let minEl = modalEl.querySelector(".minFilterLength") as HTMLInputElement; - let maxEl = modalEl.querySelector(".maxFilterLength") as HTMLInputElement; +function handleFilterLength( + modalEl: HTMLElement, + minEl: HTMLInputElement, + maxEl: HTMLInputElement +): void { minFilterLength = +minEl?.value; maxFilterLength = +maxEl?.value; + let refreshButton = document.querySelector( + ".refreshQuotes" + ) as HTMLButtonElement; + refreshButton.click(); } export function show(): void { @@ -20,21 +26,23 @@ function hide(): void { async function setup(modalEl: HTMLElement): Promise { let submitButton = modalEl.querySelector("button"); + let minEl = modalEl.querySelector(".minFilterLength") as HTMLInputElement; + let maxEl = modalEl.querySelector(".maxFilterLength") as HTMLInputElement; submitButton?.addEventListener("click", () => { - handleFilterLength(modalEl); + handleFilterLength(modalEl, minEl, maxEl); hide(); }); -} -async function cleanup(): Promise { - let refreshButton = document.querySelector( - ".refreshQuotes" - ) as HTMLButtonElement; - refreshButton.click(); + minEl?.addEventListener("input", function () { + handleFilterLength(modalEl, minEl, maxEl); + }); + + maxEl?.addEventListener("input", () => { + handleFilterLength(modalEl, minEl, maxEl); + }); } const modal = new AnimatedModal({ dialogId: "quoteFilterModal", setup, - cleanup, }); From 6edba5f24cdfe112039382a86f077e44d147949b Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sat, 15 Nov 2025 15:59:02 +0200 Subject: [PATCH 11/25] refactor --- frontend/src/ts/modals/quote-filter.ts | 10 ++++++++++ frontend/src/ts/modals/quote-search.ts | 7 +++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/frontend/src/ts/modals/quote-filter.ts b/frontend/src/ts/modals/quote-filter.ts index 5cdf2f86482a..2d5479b22f0f 100644 --- a/frontend/src/ts/modals/quote-filter.ts +++ b/frontend/src/ts/modals/quote-filter.ts @@ -2,6 +2,7 @@ import AnimatedModal from "../utils/animated-modal"; export let minFilterLength: number = 0; export let maxFilterLength: number = 0; +export let usingCustomLength = true; function handleFilterLength( modalEl: HTMLElement, @@ -16,6 +17,10 @@ function handleFilterLength( refreshButton.click(); } +export function setUsingCustomLength(value: boolean): void { + usingCustomLength = value; +} + export function show(): void { void modal.show(); } @@ -42,7 +47,12 @@ async function setup(modalEl: HTMLElement): Promise { }); } +async function cleanup(): Promise { + setUsingCustomLength(false); +} + const modal = new AnimatedModal({ dialogId: "quoteFilterModal", setup, + cleanup, }); diff --git a/frontend/src/ts/modals/quote-search.ts b/frontend/src/ts/modals/quote-search.ts index 94aa891b9e90..927822ed46d4 100644 --- a/frontend/src/ts/modals/quote-search.ts +++ b/frontend/src/ts/modals/quote-search.ts @@ -27,7 +27,6 @@ const searchServiceCache: Record> = {}; const pageSize = 100; let currentPageNumber = 1; -let usingCustomLength = true; function getSearchService( language: string, @@ -50,8 +49,10 @@ function applyQuoteLengthFilter(quotes: Quote[]): Quote[] { const quoteLengthFilterValue = $( "#quoteSearchModal .quoteLengthFilter" ).val() as string[]; + + let usingCustomLength = QuoteFilterPopup.usingCustomLength; if (quoteLengthFilterValue.length === 0) { - usingCustomLength = true; + QuoteFilterPopup.setUsingCustomLength(true); return quotes; } @@ -65,7 +66,6 @@ function applyQuoteLengthFilter(quotes: Quote[]): Quote[] { } else { minFilterLength = 0; maxFilterLength = 0; - usingCustomLength = true; } let filteredQuotes = quotes; @@ -470,7 +470,6 @@ async function setup(modalEl: HTMLElement): Promise { const searchText = ( document.getElementById("searchBox") as HTMLInputElement ).value; - usingCustomLength = false; void updateResults(searchText); }); } From 8c44ed35bd9292d4a6798284e511334aef0a44f0 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sat, 15 Nov 2025 16:08:31 +0200 Subject: [PATCH 12/25] Allow min to be 0 --- frontend/src/ts/modals/quote-search.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/src/ts/modals/quote-search.ts b/frontend/src/ts/modals/quote-search.ts index 927822ed46d4..288faa535657 100644 --- a/frontend/src/ts/modals/quote-search.ts +++ b/frontend/src/ts/modals/quote-search.ts @@ -50,7 +50,6 @@ function applyQuoteLengthFilter(quotes: Quote[]): Quote[] { "#quoteSearchModal .quoteLengthFilter" ).val() as string[]; - let usingCustomLength = QuoteFilterPopup.usingCustomLength; if (quoteLengthFilterValue.length === 0) { QuoteFilterPopup.setUsingCustomLength(true); return quotes; @@ -60,8 +59,9 @@ function applyQuoteLengthFilter(quotes: Quote[]): Quote[] { let maxFilterLength = QuoteFilterPopup.maxFilterLength; if (quoteLengthFilterValue.includes("4")) { - if (usingCustomLength) { + if (QuoteFilterPopup.usingCustomLength) { QuoteFilterPopup.show(); + QuoteFilterPopup.setUsingCustomLength(false); } } else { minFilterLength = 0; @@ -69,7 +69,10 @@ function applyQuoteLengthFilter(quotes: Quote[]): Quote[] { } let filteredQuotes = quotes; - if (minFilterLength > 0 && quoteLengthFilterValue.length === 1) { + if ( + !QuoteFilterPopup.usingCustomLength && + quoteLengthFilterValue.length === 1 + ) { filteredQuotes = quotes.filter( (quote) => quote.length >= minFilterLength && quote.length <= maxFilterLength From 5c0889d64658e558e55fd6e7b3e584f40d14ad34 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sat, 15 Nov 2025 16:12:48 +0200 Subject: [PATCH 13/25] Remove else block --- frontend/src/ts/modals/quote-search.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/frontend/src/ts/modals/quote-search.ts b/frontend/src/ts/modals/quote-search.ts index 288faa535657..f2a7d87f0f9d 100644 --- a/frontend/src/ts/modals/quote-search.ts +++ b/frontend/src/ts/modals/quote-search.ts @@ -55,17 +55,11 @@ function applyQuoteLengthFilter(quotes: Quote[]): Quote[] { return quotes; } - let minFilterLength = QuoteFilterPopup.minFilterLength; - let maxFilterLength = QuoteFilterPopup.maxFilterLength; - if (quoteLengthFilterValue.includes("4")) { if (QuoteFilterPopup.usingCustomLength) { QuoteFilterPopup.show(); QuoteFilterPopup.setUsingCustomLength(false); } - } else { - minFilterLength = 0; - maxFilterLength = 0; } let filteredQuotes = quotes; @@ -75,7 +69,8 @@ function applyQuoteLengthFilter(quotes: Quote[]): Quote[] { ) { filteredQuotes = quotes.filter( (quote) => - quote.length >= minFilterLength && quote.length <= maxFilterLength + quote.length >= QuoteFilterPopup.minFilterLength && + quote.length <= QuoteFilterPopup.maxFilterLength ); } else { const quoteLengthFilter = new Set( From a2805ee006770952bad201acdbdf3fa505a50b7a Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sat, 15 Nov 2025 16:54:33 +0200 Subject: [PATCH 14/25] Make custom work with other filters --- frontend/src/ts/modals/quote-search.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/frontend/src/ts/modals/quote-search.ts b/frontend/src/ts/modals/quote-search.ts index f2a7d87f0f9d..c3b484ae0fd8 100644 --- a/frontend/src/ts/modals/quote-search.ts +++ b/frontend/src/ts/modals/quote-search.ts @@ -55,27 +55,25 @@ function applyQuoteLengthFilter(quotes: Quote[]): Quote[] { return quotes; } + let filteredQuotes = quotes; + const quoteLengthFilter = new Set( + quoteLengthFilterValue.map((filterValue) => parseInt(filterValue, 10)) + ); + if (quoteLengthFilterValue.includes("4")) { if (QuoteFilterPopup.usingCustomLength) { QuoteFilterPopup.show(); QuoteFilterPopup.setUsingCustomLength(false); } - } - let filteredQuotes = quotes; - if ( - !QuoteFilterPopup.usingCustomLength && - quoteLengthFilterValue.length === 1 - ) { filteredQuotes = quotes.filter( (quote) => - quote.length >= QuoteFilterPopup.minFilterLength && - quote.length <= QuoteFilterPopup.maxFilterLength + (quote.length >= QuoteFilterPopup.minFilterLength && + quote.length <= QuoteFilterPopup.maxFilterLength) || + quoteLengthFilter.has(quote.group) ); } else { - const quoteLengthFilter = new Set( - quoteLengthFilterValue.map((filterValue) => parseInt(filterValue, 10)) - ); + QuoteFilterPopup.setUsingCustomLength(true); filteredQuotes = quotes.filter((quote) => quoteLengthFilter.has(quote.group) ); From cec251e618ab63bd136cc28a9e49ed073ee791f3 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sat, 15 Nov 2025 17:53:52 +0200 Subject: [PATCH 15/25] convert to simple modal --- frontend/src/ts/modals/quote-filter.ts | 76 ++++++++++++-------------- frontend/src/ts/modals/quote-search.ts | 2 +- 2 files changed, 35 insertions(+), 43 deletions(-) diff --git a/frontend/src/ts/modals/quote-filter.ts b/frontend/src/ts/modals/quote-filter.ts index 2d5479b22f0f..3ef183ce0a2f 100644 --- a/frontend/src/ts/modals/quote-filter.ts +++ b/frontend/src/ts/modals/quote-filter.ts @@ -1,16 +1,10 @@ -import AnimatedModal from "../utils/animated-modal"; +import { SimpleModal } from "../utils/simple-modal"; export let minFilterLength: number = 0; export let maxFilterLength: number = 0; export let usingCustomLength = true; -function handleFilterLength( - modalEl: HTMLElement, - minEl: HTMLInputElement, - maxEl: HTMLInputElement -): void { - minFilterLength = +minEl?.value; - maxFilterLength = +maxEl?.value; +function refresh(): void { let refreshButton = document.querySelector( ".refreshQuotes" ) as HTMLButtonElement; @@ -21,38 +15,36 @@ export function setUsingCustomLength(value: boolean): void { usingCustomLength = value; } -export function show(): void { - void modal.show(); -} - -function hide(): void { - void modal.hide(); -} - -async function setup(modalEl: HTMLElement): Promise { - let submitButton = modalEl.querySelector("button"); - let minEl = modalEl.querySelector(".minFilterLength") as HTMLInputElement; - let maxEl = modalEl.querySelector(".maxFilterLength") as HTMLInputElement; - submitButton?.addEventListener("click", () => { - handleFilterLength(modalEl, minEl, maxEl); - hide(); - }); - - minEl?.addEventListener("input", function () { - handleFilterLength(modalEl, minEl, maxEl); - }); - - maxEl?.addEventListener("input", () => { - handleFilterLength(modalEl, minEl, maxEl); - }); -} - -async function cleanup(): Promise { - setUsingCustomLength(false); -} - -const modal = new AnimatedModal({ - dialogId: "quoteFilterModal", - setup, - cleanup, +export const quoteFilterModal = new SimpleModal({ + id: "quoteFilter", + title: "Enter minimum and maximum values", + inputs: [ + { + placeholder: "1", + type: "number", + }, + { + placeholder: "100", + type: "number", + }, + ], + buttonText: "save", + onlineOnly: true, + execFn: async (_thisPopup, min, max) => { + const minNum = parseInt(min, 10); + const maxNum = parseInt(max, 10); + if (isNaN(minNum) || isNaN(maxNum)) { + return { + status: 0, + message: "Invalid min/max values", + }; + } + + minFilterLength = minNum; + maxFilterLength = maxNum; + refresh(); + + let message: string = "saved custom filter"; + return { status: 1, message }; + }, }); diff --git a/frontend/src/ts/modals/quote-search.ts b/frontend/src/ts/modals/quote-search.ts index c3b484ae0fd8..56b94a6378bd 100644 --- a/frontend/src/ts/modals/quote-search.ts +++ b/frontend/src/ts/modals/quote-search.ts @@ -62,7 +62,7 @@ function applyQuoteLengthFilter(quotes: Quote[]): Quote[] { if (quoteLengthFilterValue.includes("4")) { if (QuoteFilterPopup.usingCustomLength) { - QuoteFilterPopup.show(); + QuoteFilterPopup.quoteFilterModal.show(undefined, {}); QuoteFilterPopup.setUsingCustomLength(false); } From 5778104d9320810f4b896ae4025bebdb7d7b3a87 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sat, 15 Nov 2025 17:57:27 +0200 Subject: [PATCH 16/25] Move usingCustomLength to quote-search --- frontend/src/ts/modals/quote-filter.ts | 5 ----- frontend/src/ts/modals/quote-search.ts | 9 +++++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/frontend/src/ts/modals/quote-filter.ts b/frontend/src/ts/modals/quote-filter.ts index 3ef183ce0a2f..11df98fd4fec 100644 --- a/frontend/src/ts/modals/quote-filter.ts +++ b/frontend/src/ts/modals/quote-filter.ts @@ -2,7 +2,6 @@ import { SimpleModal } from "../utils/simple-modal"; export let minFilterLength: number = 0; export let maxFilterLength: number = 0; -export let usingCustomLength = true; function refresh(): void { let refreshButton = document.querySelector( @@ -11,10 +10,6 @@ function refresh(): void { refreshButton.click(); } -export function setUsingCustomLength(value: boolean): void { - usingCustomLength = value; -} - export const quoteFilterModal = new SimpleModal({ id: "quoteFilter", title: "Enter minimum and maximum values", diff --git a/frontend/src/ts/modals/quote-search.ts b/frontend/src/ts/modals/quote-search.ts index 56b94a6378bd..d1b215a36d27 100644 --- a/frontend/src/ts/modals/quote-search.ts +++ b/frontend/src/ts/modals/quote-search.ts @@ -27,6 +27,7 @@ const searchServiceCache: Record> = {}; const pageSize = 100; let currentPageNumber = 1; +let usingCustomLength = true; function getSearchService( language: string, @@ -51,7 +52,7 @@ function applyQuoteLengthFilter(quotes: Quote[]): Quote[] { ).val() as string[]; if (quoteLengthFilterValue.length === 0) { - QuoteFilterPopup.setUsingCustomLength(true); + usingCustomLength = true; return quotes; } @@ -61,9 +62,9 @@ function applyQuoteLengthFilter(quotes: Quote[]): Quote[] { ); if (quoteLengthFilterValue.includes("4")) { - if (QuoteFilterPopup.usingCustomLength) { + if (usingCustomLength) { QuoteFilterPopup.quoteFilterModal.show(undefined, {}); - QuoteFilterPopup.setUsingCustomLength(false); + usingCustomLength = false; } filteredQuotes = quotes.filter( @@ -73,7 +74,7 @@ function applyQuoteLengthFilter(quotes: Quote[]): Quote[] { quoteLengthFilter.has(quote.group) ); } else { - QuoteFilterPopup.setUsingCustomLength(true); + usingCustomLength = true; filteredQuotes = quotes.filter((quote) => quoteLengthFilter.has(quote.group) ); From 96eb8ea26980285b6073bdc3ddcdcf3aca2e2053 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sat, 15 Nov 2025 18:00:33 +0200 Subject: [PATCH 17/25] Remove old modal --- frontend/src/html/popups.html | 9 --------- 1 file changed, 9 deletions(-) diff --git a/frontend/src/html/popups.html b/frontend/src/html/popups.html index 65d9f7f3e9ed..74f3aeda5222 100644 --- a/frontend/src/html/popups.html +++ b/frontend/src/html/popups.html @@ -948,15 +948,6 @@ -