Browse Source

fix handling of zero-weight items. They're not counted in goals/compositon, but project progress count them as 1.

main
Gisle Aune 4 years ago
parent
commit
173158a514
  1. 5
      svelte-ui/src/components/Composition.svelte
  2. 2
      svelte-ui/src/components/GoalEntry.svelte
  3. 6
      svelte-ui/src/components/ProjectProgress.svelte

5
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,15 +21,18 @@
for (const log of logs) {
if (log.itemCounted !== false) {
const item = log.item;
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 (!ignoreZeroWeight || item.groupWeight > 0) {
if (!map[item.id]) {
map[item.id] = {name: item.name, amount: log.secondaryItemAmount, link: `/items#${item.id}`};
} else {
@ -36,6 +40,7 @@
}
}
}
}
} else {
for (const log of logs) {
const task = log.task;

2
svelte-ui/src/components/GoalEntry.svelte

@ -49,7 +49,7 @@
<Progress count={goal.completedAmount} target={goal.amount} />
<TimeProgress startTime={goal.startTime} endTime={goal.endTime} />
</div>
<Composition logs={goal.logs} mode={goal.compositionMode} />
<Composition ignoreZeroWeight logs={goal.logs} mode={goal.compositionMode} />
</ParentEntry>
<style>

6
svelte-ui/src/components/ProjectProgress.svelte

@ -13,10 +13,10 @@
let progressTarget: number;
$: progressAmount = (project.tasks||[]).map(t => (t.active || t.statusTag === "to do" || t.statusTag === "on hold")
? Math.min(t.completedAmount, t.itemAmount) * t.item.groupWeight
: t.itemAmount * t.item.groupWeight
? Math.min(t.completedAmount, t.itemAmount) * (t.item.groupWeight || 1)
: t.itemAmount * (t.item.groupWeight || 1)
).reduce((n,m) => n+m, 0);
$: progressTarget = Math.max((project.tasks||[]).map(t => t.itemAmount * t.item.groupWeight).reduce((n,m) => n+m, 0), 1);
$: progressTarget = Math.max((project.tasks||[]).map(t => t.itemAmount * (t.item.groupWeight || 1)).reduce((n,m) => n+m, 0), 1);
</script>
<Progress thin contextColor count={progressAmount} target={progressTarget} />
Loading…
Cancel
Save