From d0a8d90a8103350b1bcd53dec02b7d097b315d12 Mon Sep 17 00:00:00 2001 From: Gisle Aune Date: Mon, 9 Aug 2021 17:05:22 +0200 Subject: [PATCH] hide amounts in goal composition if all items are 1x --- svelte-ui/src/components/Composition.svelte | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/svelte-ui/src/components/Composition.svelte b/svelte-ui/src/components/Composition.svelte index 97a19d1..da360ea 100644 --- a/svelte-ui/src/components/Composition.svelte +++ b/svelte-ui/src/components/Composition.svelte @@ -16,6 +16,7 @@ export let ignoreZeroWeight: boolean = false; let list: CompositionItem[] = []; + let allOnes: boolean = false; function calculateAmount(log: LogResult, unweighted: boolean) { let amount = 0; @@ -83,12 +84,16 @@ list = Object.keys(map).sort((a, b) => map[b].amount - map[a].amount).map(k => map[k]).filter(e => e.amount > 0); } + + $: allOnes = list.find(l => l.amount !== 1) == null;
{#each list as item}
- {item.amount}x  + {#if !allOnes} + {item.amount}x  + {/if} {item.name}
{/each} @@ -102,7 +107,7 @@ } div.item { - padding: 0.125em 0.5ch; + padding: 0.125em 0.75ch; display: inline-block; }