Skip to content

Open source personal finance application

refactor: enhance statistical item display and layout

Ilya Komichevdcb26826a326
diff --git a/app/components/stat/Item.vue b/app/components/stat/Item.vue
index 2d5df38c..2bacf69b 100644
--- a/app/components/stat/Item.vue
+++ b/app/components/stat/Item.vue
@@ -67,9 +67,7 @@ const statTypeShow = computed(() => ({
}))
const isPeriodOneDay = computed(() => (statDate.params.value.rangeBy === 'day' && statDate.params.value.rangeDuration === 1) || (statDate.params.value.intervalsBy === 'day' && statDate.params.value.intervalSelected !== -1))
-
const rangeTrnsIds = computed(() => trnsStore.getStoreTrnsIds({ trnsIds: props.trnsIds }, { includesChildCategories: false }))
-
const intervalsData = computed(() => getIntervalsData(rangeTrnsIds.value, statDate.intervalsInRange.value))
const selectedTrnsIds = computed(() => {
@@ -230,10 +228,43 @@ function getIntervalsData(trnsIds: TrnId[], intervalsInRange: Range[]) {
:total="rangeTotal"
:type="props.type"
:isShowAverage="statConfig.config.value.statAverage.isShow"
- class="pb-2"
+ class="@2xl/page:bg-item-2 @2xl/page:my-2 @2xl/page:rounded-xl @2xl/page:p-2 mb-2"
@click="onClickSumItem"
@clickAverage="statConfig.updateConfig('statAverage', { isShow: !statConfig.config.value.statAverage.isShow })"
>
+ <template #income>
+ <StatAverage
+ :averageConfig="statConfig.config.value.statAverage.count"
+ :categoryId
+ :filter
+ :statDate
+ :trnsIds
+ :walletId
+ statTabSlug="income"
+ />
+ </template>
+ <template #expense>
+ <StatAverage
+ :averageConfig="statConfig.config.value.statAverage.count"
+ :categoryId
+ :filter
+ :statDate
+ :trnsIds
+ :walletId
+ statTabSlug="expense"
+ />
+ </template>
+ <template #summary>
+ <StatAverage
+ :averageConfig="statConfig.config.value.statAverage.count"
+ :categoryId
+ :filter
+ :statDate
+ :trnsIds
+ :walletId
+ statTabSlug="netIncome"
+ />
+ </template>
<template #average>
<StatAverage
:averageConfig="statConfig.config.value.statAverage.count"
diff --git a/app/components/stat/sum/Wrap.vue b/app/components/stat/sum/Wrap.vue
index 1c74727b..e776575f 100644
--- a/app/components/stat/sum/Wrap.vue
+++ b/app/components/stat/sum/Wrap.vue
@@ -37,39 +37,45 @@ function onClick(type: StatTabSlug) {
</script>
<template>
- <div>
+ <div class="overflow-x-auto">
<div
v-if="props.type === 'netIncome'"
- class="flex flex-wrap justify-stretch md:max-w-lg"
+ class="@2xl/page:justify-start @2xl/page:gap-x-4 flex flex-wrap justify-stretch"
>
<StatSumItem
v-if="props.isShowExpense"
:amount="-total.expense"
:isActive="selectedType === 'expense'"
:class="classes"
- class="grow"
+ class="grow md:grow-0"
type="expense"
@click="onClick('expense')"
- />
+ >
+ <slot v-if="props.isShowAverage" name="expense" />
+ </StatSumItem>
<StatSumItem
v-if="props.isShowIncome"
:amount="total.income"
:isActive="selectedType === 'income'"
:class="classes"
- class="grow"
+ class="grow md:grow-0"
type="income"
@click="onClick('income')"
- />
+ >
+ <slot v-if="props.isShowAverage" name="income" />
+ </StatSumItem>
<StatSumItem
v-if="props.isShowIncome && props.isShowExpense"
:amount="total.sum"
:class="classes"
- class="grow"
+ class="grow md:grow-0"
type="summary"
@click="onClick('summary')"
- />
+ >
+ <slot v-if="props.isShowAverage" name="summary" />
+ </StatSumItem>
</div>
<div