Open source personal finance application
refactor: simplify StatHeader props and filter/config API
Ilya Komichevdc194179a52e
diff --git a/app/components/categories/StatPage.vue b/app/components/categories/StatPage.vueindex e03876d1..9d6e3e7f 100644--- a/app/components/categories/StatPage.vue+++ b/app/components/categories/StatPage.vue@@ -79,13 +79,8 @@ useHead({ title: category.value?.name })<template><UiPage v-if="category"><StatHeader- :filter="{- isShowCategories: false,- isShowWallets: true,- }"- :config="{- isShowWallets: true,- }"+ configWallets+ filterWallets><template #title><CategoriesHeader@@ -107,11 +102,11 @@ useHead({ title: category.value?.name })<StatWrap:activeTab+ :categoryId:hasChildren="categoriesIdsOrParent.length > 1":range="statDate.range.value":storageKey:trnsIds- isOneCategory/></UiPage></template>diff --git a/app/components/categories/page/id/Index.vue b/app/components/categories/page/id/Index.vueindex c5ba43fe..17960590 100644--- a/app/components/categories/page/id/Index.vue+++ b/app/components/categories/page/id/Index.vue@@ -184,10 +184,8 @@ const categoriesIds = computed(() => categoriesStore.getChildrenIds(categoryId.v<template><UiPage v-if="category"><StatHeader- :filter="{- isShowCategories: true,- isShowWallets: true,- }"+ v-model:activeTab="activeTab"+ filterWallets><template #title><CategoriesHeader@@ -196,13 +194,6 @@ const categoriesIds = computed(() => categoriesStore.getChildrenIds(categoryId.v/></template>- <template #selected>- <StatMenu- :active="activeTab"- @click="(id: StatTabSlug) => activeTab = id"- />- </template>-<templatev-if="categoryId !== 'transfer'"#popover="{ close }"@@ -256,12 +247,12 @@ const categoriesIds = computed(() => categoriesStore.getChildrenIds(categoryId.v<StatWrap:activeTab+ :categoryId:hasChildren="categoriesIdsOrParent.length > 1":preCategoriesIds:range="statDate.range.value":storageKey:trnsIds- isOneCategory/></UiPage></template>diff --git a/app/components/stat/ConfigModal.vue b/app/components/stat/ConfigModal.vueindex 7666f4c7..04f2d19c 100644--- a/app/components/stat/ConfigModal.vue+++ b/app/components/stat/ConfigModal.vue@@ -26,15 +26,9 @@ const isOpen = ref(false)><template #trigger><UTooltip :text="t('stat.config.menu.label')">- <UButton- :aria-label="t('stat.config.menu.label')"- class="text-muted"- color="neutral"- icon="lucide:settings-2"- size="lg"- square- variant="ghost"- />+ <UiActionButton :ariaLabel="t('stat.config.menu.label')">+ <Icon name="lucide:settings-2" size="20" />+ </UiActionButton></UTooltip></template>diff --git a/app/components/stat/Page.vue b/app/components/stat/Page.vueindex 1b60c2c8..8d4e0f5b 100644--- a/app/components/stat/Page.vue+++ b/app/components/stat/Page.vue@@ -64,24 +64,14 @@ onDeactivated(() => {<template><UiPage><StatHeader- :filter="{- isShowCategories: true,- isShowWallets: true,- }"- :config="{- isShowWallets: true,- }"+ v-model:activeTab="activeTab"+ configWallets+ filterCategories+ filterWallets><template #title><UiHeaderTitle>{{ t('stat.title') }}</UiHeaderTitle></template>-- <template #selected>- <StatMenu- :active="activeTab"- @click="(id: StatTabSlug) => activeTab = id"- />- </template></StatHeader><StatWrapdiff --git a/app/components/stat/filter/Selector.vue b/app/components/stat/filter/Selector.vueindex 019779e6..ca4a6bb6 100644--- a/app/components/stat/filter/Selector.vue+++ b/app/components/stat/filter/Selector.vue@@ -11,35 +11,33 @@ const { t } = useI18n()</script><template>- <div class="flex gap-1">- <StatFilterSelectorItem- v-if="props.isShowWallets"- :hasSelection="filter?.walletsIds.value.length > 0"- :title="t('wallets.filter')"- icon="hugeicons:wallet-01"- >- <WalletsSelector- :selectedIds="filter?.walletsIds.value"+ <StatFilterSelectorItem+ v-if="props.isShowWallets"+ :hasSelection="filter?.walletsIds.value.length > 0"+ :title="t('wallets.filter')"+ icon="hugeicons:wallet-01"+ >+ <WalletsSelector+ :selectedIds="filter?.walletsIds.value"+ class="min-w-80 px-3"+ @selected="filter.toggleWalletId"+ />+ </StatFilterSelectorItem>++ <StatFilterSelectorItem+ v-if="props.isShowCategories"+ :buttonLabel="t('base.close')"+ :hasSelection="filter?.categoriesIds.value.length > 0"+ :title="t('categories.filter')"+ icon="hugeicons:folder-library"+ >+ <div class="scrollerBlock overflow-y-auto">+ <CategoriesSelectorTree+ :selectedIds="filter?.categoriesIds.value"class="min-w-80 px-3"- @selected="filter.toggleWalletId"+ @selected="filter.toggleCategoryId"+ @setCategories="filter.setCategories"/>- </StatFilterSelectorItem>-- <StatFilterSelectorItem- v-if="props.isShowCategories"- :buttonLabel="t('base.close')"- :hasSelection="filter?.categoriesIds.value.length > 0"- :title="t('categories.filter')"- icon="hugeicons:folder-library"- >- <div class="scrollerBlock overflow-y-auto">- <CategoriesSelectorTree- :selectedIds="filter?.categoriesIds.value"- class="min-w-80 px-3"- @selected="filter.toggleCategoryId"- @setCategories="filter.setCategories"- />- </div>- </StatFilterSelectorItem>- </div>+ </div>+ </StatFilterSelectorItem></template>diff --git a/app/components/stat/filter/SelectorItem.vue b/app/components/stat/filter/SelectorItem.vueindex 7206bedd..628d48cc 100644--- a/app/components/stat/filter/SelectorItem.vue+++ b/app/components/stat/filter/SelectorItem.vue@@ -27,15 +27,9 @@ const isOpen = ref(false)insetsize="xs">- <UButton- :aria-label="props.title"- :icon="props.icon"- class="text-muted"- color="neutral"- size="lg"- square- variant="ghost"- />+ <UiActionButton :ariaLabel="props.title">+ <Icon :name="props.icon" size="20" />+ </UiActionButton></UChip></UTooltip></template>diff --git a/app/components/wallets/page/id/Index.vue b/app/components/wallets/page/id/Index.vueindex 67cb533f..4ec3316a 100644--- a/app/components/wallets/page/id/Index.vue+++ b/app/components/wallets/page/id/Index.vue@@ -112,7 +112,8 @@ async function onDeleteConfirm() {<template><UiPage v-if="wallet"><StatHeader- :filter="{ isShowCategories: true }"+ v-model:activeTab="activeTab"+ filterCategories><template #title><UiHeaderTitle>@@ -125,13 +126,6 @@ async function onDeleteConfirm() {</UiHeaderTitle></template>- <template #selected>- <StatMenu- :active="activeTab"- @click="(id: StatTabSlug) => activeTab = id"- />- </template>-<template #popover="{ close }"><UiHeaderLinkicon="lucide:pencil"