add project to logs, project composition mode to goals and fix unweighted counts for other composition modes.
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-05-01 12:28:45 +02:00
parent 897f4aa358
commit 589f7a9132
10 changed files with 104 additions and 15 deletions
@@ -29,8 +29,11 @@
}
interface EntryCommonSub {
id?: string
name: string
icon: IconName
project?: EntryCommonSub
tags?: string[]
}
export let entry: EntryCommon = null;
@@ -64,6 +67,10 @@
<a href={`/questlog#${actualParent.id}`}>{actualParent.name}</a>
</div>
{/if}
{:else if (entry.task && entry.task.project != null)}
<div class="actual-parent">
<a href={`/questlog#${entry.task.project.id}`}>{entry.task.project.name}</a>
</div>
{/if}
<div class="name">{displayName}</div>
<div class="separator"></div>
+25 -1
View File
@@ -9,11 +9,24 @@
}
export let logs: LogResult[] = [];
export let unweighted: boolean = false;
export let mode: GoalCompositionMode = "item";
export let ignoreZeroWeight: boolean = false;
let list: CompositionItem[] = [];
function calculateAmount(log: LogResult, unweighted: boolean) {
let amount = 0;
if (log.itemCounted) {
amount += log.itemAmount * (unweighted ? 1 : log.item.groupWeight);
}
if (log.secondaryItemCounted) {
amount += log.secondaryItemAmount * (unweighted ? 1 : log.secondaryItem.groupWeight);
}
return amount;
}
$: {
const map: {[k: string]: CompositionItem} = {}
@@ -41,11 +54,22 @@
}
}
}
} else if (mode === "project") {
for (const log of logs) {
const project = log.task.project;
const amount = calculateAmount(log, unweighted);
if (!map[project.id]) {
map[project.id] = {name: project.name, amount, link: `/questlog#${project.id}`};
} else {
map[project.id].amount += amount;
}
}
} else {
for (const log of logs) {
const task = log.task;
const amount = log.secondaryItem ? log.secondaryItemAmount + log.itemAmount : log.itemAmount;
const amount = calculateAmount(log, unweighted);
if (!map[task.id]) {
map[task.id] = {name: task.name, amount, link: `/questlog#${task.projectId}`};