| 1 |
<script lang="ts"> |
| 2 |
import { _, format } from "../i18n"; |
| 3 |
import { getInterval, intervalLabel, INTERVALS } from "../lib/interval"; |
| 4 |
import { conversion, interval } from "../stores"; |
| 5 |
import { conversions } from "../stores/chart"; |
| 6 |
import SelectCombobox from "./SelectCombobox.svelte"; |
| 7 |
|
| 8 |
const conversion_description = (option: string) => { |
| 9 |
switch (option) { |
| 10 |
case "at_cost": |
| 11 |
return _("At Cost"); |
| 12 |
case "at_value": |
| 13 |
return _("At Market Value"); |
| 14 |
case "units": |
| 15 |
return _("Units"); |
| 16 |
default: |
| 17 |
return format(_("Converted to %(currency)s"), { currency: option }); |
| 18 |
} |
| 19 |
}; |
| 20 |
|
| 21 |
const is_currency_conversion = (option: string) => |
| 22 |
!["at_cost", "at_value", "units"].includes(option); |
| 23 |
</script> |
| 24 |
|
| 25 |
<SelectCombobox |
| 26 |
bind:value={$conversion} |
| 27 |
options={$conversions} |
| 28 |
description={conversion_description} |
| 29 |
multiple_select={is_currency_conversion} |
| 30 |
/> |
| 31 |
|
| 32 |
<SelectCombobox |
| 33 |
bind:value={$interval} |
| 34 |
options={INTERVALS} |
| 35 |
description={(o: string) => intervalLabel(getInterval(o))} |
| 36 |
/> |