From 173158a514b5f7e5cc9d489bc198b53cc49331c3 Mon Sep 17 00:00:00 2001 From: Gisle Aune Date: Sun, 7 Feb 2021 12:47:11 +0100 Subject: [PATCH] fix handling of zero-weight items. They're not counted in goals/compositon, but project progress count them as 1. --- svelte-ui/src/components/Composition.svelte | 21 ++++++++++++------- svelte-ui/src/components/GoalEntry.svelte | 2 +- .../src/components/ProjectProgress.svelte | 6 +++--- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/svelte-ui/src/components/Composition.svelte b/svelte-ui/src/components/Composition.svelte index 1f4d855..72216d9 100644 --- a/svelte-ui/src/components/Composition.svelte +++ b/svelte-ui/src/components/Composition.svelte @@ -10,6 +10,7 @@ export let logs: LogResult[] = []; export let mode: GoalCompositionMode = "item"; + export let ignoreZeroWeight: boolean = false; let list: CompositionItem[] = []; @@ -20,19 +21,23 @@ for (const log of logs) { if (log.itemCounted !== false) { const item = log.item; - if (!map[item.id]) { - map[item.id] = {name: item.name, amount: log.itemAmount, link: `/items#${item.id}`}; - } else { - map[item.id].amount += log.itemAmount; + if (!ignoreZeroWeight || item.groupWeight > 0) { + if (!map[item.id]) { + map[item.id] = {name: item.name, amount: log.itemAmount, link: `/items#${item.id}`}; + } else { + map[item.id].amount += log.itemAmount; + } } } if (log.secondaryItem && log.secondaryItemCounted !== false) { const item = log.secondaryItem; - if (!map[item.id]) { - map[item.id] = {name: item.name, amount: log.secondaryItemAmount, link: `/items#${item.id}`}; - } else { - map[item.id].amount += log.secondaryItemAmount; + if (!ignoreZeroWeight || item.groupWeight > 0) { + if (!map[item.id]) { + map[item.id] = {name: item.name, amount: log.secondaryItemAmount, link: `/items#${item.id}`}; + } else { + map[item.id].amount += log.secondaryItemAmount; + } } } } diff --git a/svelte-ui/src/components/GoalEntry.svelte b/svelte-ui/src/components/GoalEntry.svelte index 2242c26..52c7849 100644 --- a/svelte-ui/src/components/GoalEntry.svelte +++ b/svelte-ui/src/components/GoalEntry.svelte @@ -49,7 +49,7 @@ - +