Browse Source

hide amounts in goal composition if all items are 1x

main
Gisle Aune 3 years ago
parent
commit
d0a8d90a81
  1. 7
      svelte-ui/src/components/Composition.svelte

7
svelte-ui/src/components/Composition.svelte

@ -16,6 +16,7 @@
export let ignoreZeroWeight: boolean = false; export let ignoreZeroWeight: boolean = false;
let list: CompositionItem[] = []; let list: CompositionItem[] = [];
let allOnes: boolean = false;
function calculateAmount(log: LogResult, unweighted: boolean) { function calculateAmount(log: LogResult, unweighted: boolean) {
let amount = 0; 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); 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;
</script> </script>
<div class="composition"> <div class="composition">
{#each list as item} {#each list as item}
<div class="item"> <div class="item">
{#if !allOnes}
<span class="amount">{item.amount}x&nbsp;</span> <span class="amount">{item.amount}x&nbsp;</span>
{/if}
<Link to={item.link}>{item.name}</Link> <Link to={item.link}>{item.name}</Link>
</div> </div>
{/each} {/each}
@ -102,7 +107,7 @@
} }
div.item { div.item {
padding: 0.125em 0.5ch;
padding: 0.125em 0.75ch;
display: inline-block; display: inline-block;
} }

Loading…
Cancel
Save