|
|
@ -1,4 +1,6 @@ |
|
|
|
<script lang="ts"> |
|
|
|
import { significantDecimals } from "$lib/utils/numbers"; |
|
|
|
|
|
|
|
import { getItemMultiListContext } from "../contexts/ItemMultiListContext.svelte"; |
|
|
|
import Row from "../layout/Row.svelte"; |
|
|
|
import ItemSubSection from "../project/ItemSubSection.svelte"; |
|
|
@ -6,15 +8,33 @@ |
|
|
|
export let key: string; |
|
|
|
export let title: string; |
|
|
|
export let showAcquiredTime: boolean = false; |
|
|
|
export let useAcquiredTotal: boolean = false; |
|
|
|
|
|
|
|
const {lists} = getItemMultiListContext(); |
|
|
|
|
|
|
|
let totalStr = ""; |
|
|
|
$: { |
|
|
|
totalStr = significantDecimals(($lists[key]||[]).map(v => useAcquiredTotal ? v.weightedAcquired : v.weightedRequired).reduce((p,c) => p + c, 0)); |
|
|
|
if (Number(totalStr) < 0.01) { |
|
|
|
totalStr = ""; |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
{#if ($lists[key]||[]).length > 0} |
|
|
|
<Row title={title}> |
|
|
|
<div class="total" slot="right">{totalStr}</div> |
|
|
|
{#each $lists[key] as item (item.id)} |
|
|
|
<ItemSubSection showAcquiredTime={showAcquiredTime} item={item} /> |
|
|
|
{/each} |
|
|
|
</Row> |
|
|
|
{/if} |
|
|
|
{/if} |
|
|
|
|
|
|
|
<style lang="sass"> |
|
|
|
@import "../../css/colors.sass" |
|
|
|
|
|
|
|
div.total |
|
|
|
color: $color-entry5 |
|
|
|
margin-top: 0.25em |
|
|
|
</style> |