|
@ -1,5 +1,6 @@ |
|
|
<script lang="ts"> |
|
|
<script lang="ts"> |
|
|
import type Item from "../models/item"; |
|
|
import type Item from "../models/item"; |
|
|
|
|
|
import type { LogResult } from "../models/log"; |
|
|
import type { ProjectResult } from "../models/project"; |
|
|
import type { ProjectResult } from "../models/project"; |
|
|
import Icon from "./Icon.svelte"; |
|
|
import Icon from "./Icon.svelte"; |
|
|
|
|
|
|
|
@ -8,14 +9,20 @@ |
|
|
amount: number |
|
|
amount: number |
|
|
target: number |
|
|
target: number |
|
|
extras: number |
|
|
extras: number |
|
|
|
|
|
noTarget?: boolean |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export let project: ProjectResult; |
|
|
|
|
|
|
|
|
export let project: ProjectResult = null; |
|
|
|
|
|
export let logs: LogResult[] = []; |
|
|
|
|
|
export let centered = false; |
|
|
|
|
|
export let vertical = false; |
|
|
|
|
|
|
|
|
let list: ListEntry[] = []; |
|
|
let list: ListEntry[] = []; |
|
|
|
|
|
|
|
|
$: { |
|
|
$: { |
|
|
list = []; |
|
|
list = []; |
|
|
|
|
|
|
|
|
|
|
|
if (project != null) { |
|
|
for (const task of project.tasks) { |
|
|
for (const task of project.tasks) { |
|
|
let entry = list.find(e => e.item.id === task.item.id); |
|
|
let entry = list.find(e => e.item.id === task.item.id); |
|
|
if (entry == null) { |
|
|
if (entry == null) { |
|
@ -48,23 +55,54 @@ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (const log of logs) { |
|
|
|
|
|
const items: [Item, number][] = [ |
|
|
|
|
|
[log.item, log.itemAmount], |
|
|
|
|
|
[log.secondaryItem, log.secondaryItemAmount] |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
for (const [item, count] of items) { |
|
|
|
|
|
if (item != null) { |
|
|
|
|
|
let entry = list.find(e => e.item.id === item.id); |
|
|
|
|
|
if (entry == null) { |
|
|
|
|
|
entry = {item, amount: 0, target: 0, extras: 0, noTarget: true}; |
|
|
|
|
|
list.push(entry); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
entry.amount += count; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
list = list.sort((a,b) => { |
|
|
list = list.sort((a,b) => { |
|
|
|
|
|
if (a.noTarget && b.noTarget) { |
|
|
|
|
|
return a.amount - b.amount; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (a.target === b.target) { |
|
|
if (a.target === b.target) { |
|
|
return a.item.name.localeCompare(b.item.name); |
|
|
return a.item.name.localeCompare(b.item.name); |
|
|
} else { |
|
|
} else { |
|
|
return b.target - a.target; |
|
|
return b.target - a.target; |
|
|
} |
|
|
} |
|
|
}).filter(l => l.extras > 0 || l.target > 0); |
|
|
|
|
|
|
|
|
}).filter(l => l.extras > 0 || (l.target > 0 || l.noTarget)); |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<div class="ItemProgress"> |
|
|
<div class="ItemProgress"> |
|
|
|
|
|
<div class="wrapper" class:centered class:vertical={vertical || list.length > 3}> |
|
|
{#each list as entry (entry.item.id)} |
|
|
{#each list as entry (entry.item.id)} |
|
|
<div class="entry"> |
|
|
<div class="entry"> |
|
|
|
|
|
{#if entry.noTarget} |
|
|
|
|
|
<div class="amount"> |
|
|
|
|
|
<span>{entry.amount}× </span> |
|
|
|
|
|
</div> |
|
|
|
|
|
{:else} |
|
|
<div class="icon"> |
|
|
<div class="icon"> |
|
|
<Icon name={entry.item.icon} /> |
|
|
<Icon name={entry.item.icon} /> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
{/if} |
|
|
<div class="name"> |
|
|
<div class="name"> |
|
|
{entry.item.name} |
|
|
{entry.item.name} |
|
|
</div> |
|
|
</div> |
|
@ -77,26 +115,44 @@ |
|
|
<span class="extras">+ {entry.extras}</span> |
|
|
<span class="extras">+ {entry.extras}</span> |
|
|
{/if} |
|
|
{/if} |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
{:else} |
|
|
|
|
|
|
|
|
{:else if !entry.noTarget} |
|
|
<div class="extras"> |
|
|
<div class="extras"> |
|
|
×{entry.extras} |
|
|
×{entry.extras} |
|
|
</div> |
|
|
</div> |
|
|
{/if} |
|
|
{/if} |
|
|
</div> |
|
|
</div> |
|
|
{/each} |
|
|
{/each} |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<style> |
|
|
<style> |
|
|
div.ItemProgress { |
|
|
div.ItemProgress { |
|
|
display: inline-block; |
|
|
|
|
|
|
|
|
display: flex; |
|
|
|
|
|
flex-direction: row; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
div.ItemProgress div.wrapper { |
|
|
|
|
|
display: flex; |
|
|
|
|
|
flex-direction: row; |
|
|
|
|
|
flex-wrap: wrap; |
|
|
padding: 0.25em; |
|
|
padding: 0.25em; |
|
|
font-size: 0.8em; |
|
|
font-size: 0.8em; |
|
|
} |
|
|
} |
|
|
|
|
|
div.ItemProgress div.wrapper.centered { |
|
|
|
|
|
margin: 0 auto; |
|
|
|
|
|
} |
|
|
|
|
|
div.ItemProgress div.wrapper.vertical { |
|
|
|
|
|
flex-direction: column; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
div.ItemProgress div.entry { |
|
|
div.ItemProgress div.entry { |
|
|
display: flex; |
|
|
display: flex; |
|
|
flex-direction: row; |
|
|
flex-direction: row; |
|
|
color: #777; |
|
|
color: #777; |
|
|
|
|
|
padding-right: 1ch; |
|
|
|
|
|
} |
|
|
|
|
|
div.ItemProgress div.wrapper.vertical div.entry { |
|
|
|
|
|
padding-right: 0; |
|
|
} |
|
|
} |
|
|
div.ItemProgress div.entry div { |
|
|
div.ItemProgress div.entry div { |
|
|
padding: 0.1em 0.25em; |
|
|
padding: 0.1em 0.25em; |
|
@ -105,7 +161,7 @@ |
|
|
color: #555; |
|
|
color: #555; |
|
|
} |
|
|
} |
|
|
div.ItemProgress div.entry .icon { |
|
|
div.ItemProgress div.entry .icon { |
|
|
padding: 0.20em; |
|
|
|
|
|
|
|
|
padding: 0.20em 0.5ch; |
|
|
} |
|
|
} |
|
|
div.ItemProgress div.entry .extras { |
|
|
div.ItemProgress div.entry .extras { |
|
|
color: #484; |
|
|
color: #484; |
|
|