diff --git a/CHANGELOG b/CHANGELOG index 9c829bd..ac27f0d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,10 @@ Dates should be in`YYYY-MM-DD` format and versions are in [semantic versioning]( ## v0.7.5 2024-12-19 +### Added + +- Filter by lead on changes page. + ### Fixed - Prevented cycle in changes and processes URL navigation. diff --git a/src/lib/Changes.svelte b/src/lib/Changes.svelte index f6fd981..409c2b0 100644 --- a/src/lib/Changes.svelte +++ b/src/lib/Changes.svelte @@ -21,6 +21,7 @@ import Dialog from './Dialog.svelte'; import NewComment from './NewComment.svelte'; import Button from './Button.svelte'; + import Select from './Select.svelte'; interface Props { changes: ChangeRow[]; @@ -44,6 +45,7 @@ let filterText = $state(getInitialTextFilter()); let filterStatus = $state(getInitialStatusFilter()); + let filterLead = $state(getInitialLeadFilter()); let lowerFilter = $derived(filterText.toLocaleLowerCase().trim()); let textFilteredChanges = $derived( @@ -62,6 +64,14 @@ : textFilteredChanges.filter((change) => change.status === filterStatus) ); + let leadFilteredChanges = $derived( + filterLead === undefined + ? statusFilteredChanges + : statusFilteredChanges.filter((change) => change.lead === filterLead) + ); + + let filteredChanges = $derived(leadFilteredChanges); + /** The change for which a comment is being submitted */ let submittingComment: ChangeRow | undefined = $state(undefined); function hideNewComment() { @@ -78,6 +88,12 @@ return status !== null && status in Statuses ? (status as StatusType) : undefined; } + function getInitialLeadFilter() { + const params = $page.url.searchParams; + const lead = params.get('lead'); + return lead !== null ? lead : undefined; + } + // When the filters change, update the URL to match $effect(() => { const params = new URLSearchParams($page.url.searchParams.toString()); @@ -86,6 +102,8 @@ else params.set('words', encodeURI(filterText)); if (filterStatus === undefined) params.delete('status'); else params.set('status', filterStatus); + if (filterLead === undefined) params.delete('lead'); + else params.set('lead', filterLead); // Did the params change? Navigate. if (start !== params.toString()) goto(`?${params.toString()}`, { replaceState: true, keepFocus: true }); @@ -93,7 +111,7 @@ // The filtered list of comment IDs that we need to asynchronously load. let latestCommentIDs = $derived( - statusFilteredChanges.map((change) => change.comments.at(-1))?.filter((c) => c !== undefined) + filteredChanges.map((change) => change.comments.at(-1))?.filter((c) => c !== undefined) ); let latestComments = $state([]); @@ -120,6 +138,27 @@ value={filterStatus} /> + + +