add task and item filters to goals.
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-01-19 22:12:10 +01:00
parent 99cc6fac3c
commit a187e91c3c
8 changed files with 122 additions and 21 deletions
+10 -9
View File
@@ -1,7 +1,6 @@
<script lang="ts">
import type { GoalCompositionMode } from "../models/goal";
import type { GoalCompositionMode, GoalLogResult } from "../models/goal";
import type { LogResult } from "../models/log";
import type { TaskResult } from "../models/task";
interface CompositionItem {
link: string
@@ -19,14 +18,16 @@ import type { TaskResult } from "../models/task";
if (mode === "item") {
for (const log of logs) {
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 (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 (log.secondaryItem) {
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}`};
@@ -49,7 +50,7 @@ import type { TaskResult } from "../models/task";
}
}
list = Object.keys(map).sort((a, b) => map[b].amount - map[a].amount).map(k => map[k]);
list = Object.keys(map).sort((a, b) => map[b].amount - map[a].amount).map(k => map[k]).filter(e => e.amount > 0);
}
</script>