Skip to content

Commit f7f75db

Browse files
committed
fix: unify backlog header and footer counts
1 parent 6be3651 commit f7f75db

3 files changed

Lines changed: 24 additions & 11 deletions

File tree

frontend/src/lib/features/collections/CollectionBacklog.svelte

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import { getIncompleteIterationItems } from './iterationCompletion.js';
2323
import CompleteIterationDialog from '../../dialogs/CompleteIterationDialog.svelte';
2424
import { workspacesStore } from '../../stores/workspaces.svelte.js';
25+
import { formatItemCount } from '../../utils/itemCount.js';
2526
import { isSystemFieldAvailableForItem } from '../../utils/screenFields.js';
2627
2728
let { workspaceId, collectionId = null } = $props();
@@ -246,6 +247,11 @@
246247
), collapsedSections.has('unassigned') ? 0 : unassignedItems.length)
247248
);
248249
250+
let backlogTotal = $derived(collectionStore.backlogPagination?.total_items ?? backlogItems.length);
251+
let backlogShownCount = $derived(collectionStore.loading ? null : shownItemCount);
252+
let backlogRemaining = $derived(Math.max(0, backlogTotal - backlogItems.length));
253+
let backlogCountSummary = $derived(formatItemCount(backlogTotal, backlogShownCount, t));
254+
249255
// Centralized gradient styling
250256
const styles = useGradientStyles();
251257
@@ -297,7 +303,7 @@
297303
298304
// Keep backlog count in sync
299305
$effect(() => {
300-
backlogStore.setCount(workspaceId, collectionStore.backlogPagination?.total_items ?? collectionStore.backlogItems.length);
306+
backlogStore.setCount(workspaceId, backlogTotal);
301307
});
302308
303309
// Adaptive polling for backlog items: use cheap deltas, falling back to full refresh only when needed.
@@ -716,8 +722,8 @@
716722
workspaceName={workspace?.name || ''}
717723
collection={currentCollectionName}
718724
viewName="Backlog"
719-
itemCount={collectionStore.collectionTotal}
720-
shownCount={collectionStore.loading ? null : shownItemCount}
725+
itemCount={backlogTotal}
726+
shownCount={backlogShownCount}
721727
>
722728
{#snippet actions()}
723729
<div class="flex items-center gap-2">
@@ -836,16 +842,16 @@
836842
>
837843
{collectionStore.backlogLoadingMore ? t('common.loading') : t('common.loadMore')}
838844
{#if collectionStore.backlogPagination?.total_items}
839-
({collectionStore.backlogPagination.total_items - collectionStore.backlogItems.length} {t('common.remaining')})
845+
({backlogRemaining} {t('common.remaining')})
840846
{/if}
841847
</button>
842848
</div>
843849
{/if}
844850
845851
<!-- Summary -->
846852
<div class="mt-8 text-center">
847-
<p class="text-sm" style="color: var(--ctx-text-subtle, var(--ds-text-subtle));">
848-
{t('collections.showingItemsFromBacklog', { count: collectionStore.backlogPagination?.total_items ?? backlogItems.length })}
853+
<p data-testid="backlog-count-summary" class="text-sm" style="color: var(--ctx-text-subtle, var(--ds-text-subtle));">
854+
{backlogCountSummary}
849855
</p>
850856
</div>
851857
</div>

frontend/src/lib/layout/ViewHeader.svelte

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script>
22
import { t } from '../stores/i18n.svelte.js';
3+
import { formatItemCount } from '../utils/itemCount.js';
34
import BaseHeader from './BaseHeader.svelte';
45
56
let {
@@ -15,11 +16,7 @@
1516
actions = null,
1617
} = $props();
1718
18-
let countText = $derived([
19-
itemCount !== null ? `${itemCount} ${t('layout.items')}` : '',
20-
shownCount !== null && shownCount !== itemCount
21-
? t('collections.itemsShown', { count: shownCount }) : '',
22-
].filter(Boolean).join(' · '));
19+
let countText = $derived(formatItemCount(itemCount, shownCount, t));
2320
let subtitle = $derived([workspaceName, countText].filter(Boolean).join(''));
2421
</script>
2522

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export function formatItemCount(itemCount, shownCount, t) {
2+
return [
3+
itemCount !== null ? `${itemCount} ${t('layout.items')}` : '',
4+
shownCount !== null && shownCount !== itemCount
5+
? t('collections.itemsShown', { count: shownCount })
6+
: '',
7+
]
8+
.filter(Boolean)
9+
.join(' · ');
10+
}

0 commit comments

Comments
 (0)