diff --git a/app/components/filter/Item.vue b/app/components/filter/Item.vue index a434f5c..0d15550 100644 --- a/app/components/filter/Item.vue +++ b/app/components/filter/Item.vue @@ -4,18 +4,46 @@ const model = defineModel(); const { canClear = false, options } = defineProps<{ title: string; explanation: string; - options: string[]; + options: (string | { name: string; icon: string })[]; canClear?: boolean; }>(); const open = ref(false); -function onSelect(option: string) { - if (canClear && model.value === option) { +function onSelect(option: string | { name: string; icon: string }) { + const name = getName(option); + + if (canClear && model.value === name) { model.value = undefined; } else { - model.value = option; + model.value = name; + } +} + +function getIconFromModel() : string { + for (const option of options) { + if (getName(option) === model.value) { + return getIcon(option); + } + } + + return "" +} + +function getIcon(option: string | { name: string; icon: string }) { + if (typeof option === "string") { + return ""; + } + + return option.icon; +} + +function getName(option: string | { name: string; icon: string }) { + if (typeof option === "string") { + return option; } + + return option.name; } @@ -28,12 +56,14 @@ function onSelect(option: string) {
-
diff --git a/app/pages/charts.vue b/app/pages/charts.vue index b6e7923..048f186 100644 --- a/app/pages/charts.vue +++ b/app/pages/charts.vue @@ -57,7 +57,7 @@ const sideBarOpen = ref(false);
- +