Skip to content

Open source personal finance application

Refactor StatPc: added tabs for stat and history, moved period nav

Ilya Komicheva77226add6cb
diff --git a/src/components/dashboard/Dashboard.vue b/src/components/dashboard/Dashboard.vue
index caf94709..8abd574f 100644
--- a/src/components/dashboard/Dashboard.vue
+++ b/src/components/dashboard/Dashboard.vue
@@ -1,17 +1,31 @@
<script>
+import ContextMenu from '@/components/shared/contextMenu/ContextMenu'
+import ContextMenuItem from '@/components/shared/contextMenu/ContextMenuItem'
+import Dropdown from '@/components/shared/dropdown/Dropdown'
import DashboardFilter from '@/components/dashboard/DashboardFilter'
import DashboardNav from '@/components/dashboard/DashboardNav'
import StatChartsLine from '@/components/stat/StatChartsLine'
import StatSummaryPc from '@/components/stat/StatSummaryPc'
import StatPc from '@/components/stat/StatPc'
+import TrnsList from '@/components/trns/list/TrnsList'
export default {
components: {
+ ContextMenu,
+ ContextMenuItem,
+ Dropdown,
DashboardFilter,
DashboardNav,
StatChartsLine,
StatPc,
- StatSummaryPc
+ StatSummaryPc,
+ TrnsList
+ },
+
+ data () {
+ return {
+ visiblePeriodMenu: false
+ }
},
computed: {
@@ -31,18 +45,97 @@ export default {
StatSummaryPc
DashboardFilter
- slot
- StatPc
+ .statMain__header
+ .statMain__header__group
+ .statMain__header__item._tabName(
+ @click="$store.commit('toogleDashboardTrnsHistory')"
+ :class="{ _active: !$store.state.dashboard.showTrnsHistory }") Stat
+ .statMain__header__item._tabName(
+ @click="$store.commit('toogleDashboardTrnsHistory')"
+ :class="{ _active: $store.state.dashboard.showTrnsHistory }") History
+
+ .statMain__header__group._center
+ .statMain__header__item
+ .d-button-cirle._nav(
+ @click="$store.dispatch('setPeriodPrev')"
+ :class="{ _disable: $store.state.filter.period === 'all' || $store.getters.isFirstPeriodSelected }"
+ ): .mdi.mdi-chevron-left
+
+ .statMain__header__item
+ ContextMenu._dark(
+ :position="{ right: true, top: true }"
+ :visible="visiblePeriodMenu"
+ v-on:onClickOpener="visiblePeriodMenu = !visiblePeriodMenu")
+ template(slot="opener")
+ Dropdown._minWidth(
+ :active="visiblePeriodMenu"
+ :title="$store.state.filter.period")
+ template(slot="content")
+ ContextMenuItem(
+ icon="mdi mdi-weather-sunset-up"
+ title="Day"
+ :selected="$store.state.filter.period === 'day'"
+ v-on:onClick="$store.dispatch('setPeriod', 'day')"
+ v-on:onClose="visiblePeriodMenu = !visiblePeriodMenu")
+ ContextMenuItem(
+ icon="mdi mdi-calendar-week"
+ title="Week"
+ :selected="$store.state.filter.period === 'week'"
+ v-on:onClick="$store.dispatch('setPeriod', 'week')"
+ v-on:onClose="visiblePeriodMenu = !visiblePeriodMenu")
+ ContextMenuItem(
+ icon="mdi mdi-calendar"
+ title="Month"
+ :selected="$store.state.filter.period === 'month'"
+ v-on:onClick="$store.dispatch('setPeriod', 'month')"
+ v-on:onClose="visiblePeriodMenu = !visiblePeriodMenu")
+ ContextMenuItem(
+ icon="mdi mdi-calendar-star"
+ title="Year"
+ :selected="$store.state.filter.period === 'year'"
+ v-on:onClick="$store.dispatch('setPeriod', 'year')"
+ v-on:onClose="visiblePeriodMenu = !visiblePeriodMenu")
+ ContextMenuItem(
+ icon="mdi mdi-database"
+ title="Show all"
+ :selected="$store.state.filter.period === 'all'"
+ v-on:onClick="$store.dispatch('setPeriod', 'all')"
+ v-on:onClose="visiblePeriodMenu = !visiblePeriodMenu")
+ .statMain__header__item
+ .d-button-cirle._nav(
+ @click="$store.dispatch('setPeriodNext')"
+ :class="{ _disable: $store.state.filter.period === 'all' || $store.getters.isLastPeriodSelected }"
+ ): .mdi.mdi-chevron-right
+
+ .statMain__content
+ transition(name="animation-tab")
+ .statMain__tab(v-show="!$store.state.dashboard.showTrnsHistory")
+ StatPc
+
+ transition(name="animation-tab")
+ .statMain__tab._trns(v-show="$store.state.dashboard.showTrnsHistory")
+ TrnsList
</template>
<style lang="stylus" scoped>
@import "~@/stylus/variables/margins"
+@import "~@/stylus/variables/flex"
+@import "~@/stylus/variables/fonts"
@import "~@/stylus/variables/scrollbar"
+._minWidth
+ min-width 120px
+
+.trnsList
+ display grid
+ grid-template-columns repeat(3, 1fr)
+ grid-column-gap $m7
+ grid-row-gap $m7
+
.statMain
scrollbar()
overflow hidden
- overflow-y auto
+ overflow-y scroll
&__info
position relative
@@ -55,4 +148,40 @@ export default {
@media $media-xl
padding $m9 $mb2
+
+ &__header
+ display grid
+ grid-template-columns repeat(3, 1fr)
+ align-items center
+ padding $m9 $mb2
+ padding-bottom 0
+
+ &__group
+ display-flex()
+ &._center
+ justify-content center
+
+ &__item
+ margin-right $m9
+ &._tabName
+ font-header-4()
+ color var(--c-font-5)
+ &:last-child
+ margin-right 0
+ &._active
+ color var(--c-font-3)
+
+ &__content
+ position relative
+
+ &__tab
+ position absolute
+ left 0
+ top 0
+ width 100%
+ padding-bottom $m10
+
+ &._trns
+ padding $m9 $mb2
+ padding-bottom $m10
</style>
diff --git a/src/components/dashboard/DashboardNav.vue b/src/components/dashboard/DashboardNav.vue
index 51c86379..47f61170 100644
--- a/src/components/dashboard/DashboardNav.vue
+++ b/src/components/dashboard/DashboardNav.vue
@@ -14,8 +14,7 @@ export default {
data () {
return {
- visibleContextMenu: false,
- visiblePeriodMenu: false
+ visibleContextMenu: false
}
}
}
@@ -27,25 +26,16 @@ export default {
.period-nav__item(@click="$store.dispatch('setPeriod', $store.state.filter.period)")
.date: Date
- .period-nav__group._center
- .period-nav__item
- .d-button-cirle._nav(
- @click="$store.dispatch('setPeriodPrev')"
- :class="{ _disable: $store.state.filter.period === 'all' || $store.getters.isFirstPeriodSelected }"
- ): .mdi.mdi-chevron-left
-
- .period-nav__item
- .d-button-cirle._nav(
- @click="$store.commit('toogleDashboardTrnsHistory')"
- :class="{ _active: $store.state.dashboard.showTrnsHistory }"
- ): .mdi.mdi-history
-
+ .period-nav__group
+ ._align-right
ContextMenu(
:position="{ right: true, top: true }"
:visible="visibleContextMenu"
v-on:onClickOpener="visibleContextMenu = !visibleContextMenu")
template(slot="opener")
- .d-button-cirle._nav: .mdi.mdi-dots-horizontal
+ Dropdown(
+ :active="visibleContextMenu"
+ title="Customize")
template(slot="content")
ContextMenuItem(
icon="mdi mdi-chart-bar-stacked"
@@ -59,58 +49,17 @@ export default {
:checkValue="$store.state.ui.catsChart === 'visible'"
v-on:onClick="$store.dispatch('toogleVisibleCatsChart')"
v-on:onClose="visibleContextMenu = !visibleContextMenu")
+ ContextMenuItem(
+ icon="mdi mdi-chart-gantt"
+ title="Cats stat"
+ :checkValue="$store.state.ui.statItems === 'visible'"
+ v-on:onClick="$store.dispatch('toogleVisibilityStatItems')"
+ v-on:onClose="visibleContextMenu = !visibleContextMenu")
.context-menu-sep
ContextMenuItem(
icon="mdi mdi-palette"
title="Change theme"
v-on:onClick="$store.dispatch('changeTheme')")
- .period-nav__item
- .d-button-cirle._nav(
- @click="$store.dispatch('setPeriodNext')"
- :class="{ _disable: $store.state.filter.period === 'all' || $store.getters.isLastPeriodSelected }"
- ): .mdi.mdi-chevron-right
-
- .period-nav__group
- ._align-right
- ContextMenu(
- :position="{ right: true, top: true }"
- :visible="visiblePeriodMenu"
- v-on:onClickOpener="visiblePeriodMenu = !visiblePeriodMenu")
- template(slot="opener")
- Dropdown(
- :active="visiblePeriodMenu"
- :title="$store.state.filter.period")
- template(slot="content")
- ContextMenuItem(
- icon="mdi mdi-weather-sunset-up"
- title="Day"
- :selected="$store.state.filter.period === 'day'"
- v-on:onClick="$store.dispatch('setPeriod', 'day')"
- v-on:onClose="visiblePeriodMenu = !visiblePeriodMenu")
- ContextMenuItem(
- icon="mdi mdi-calendar-week"
- title="Week"
- :selected="$store.state.filter.period === 'week'"
- v-on:onClick="$store.dispatch('setPeriod', 'week')"
- v-on:onClose="visiblePeriodMenu = !visiblePeriodMenu")
- ContextMenuItem(
- icon="mdi mdi-calendar"
- title="Month"
- :selected="$store.state.filter.period === 'month'"
- v-on:onClick="$store.dispatch('setPeriod', 'month')"
- v-on:onClose="visiblePeriodMenu = !visiblePeriodMenu")
- ContextMenuItem(
- icon="mdi mdi-calendar-star"
- title="Year"
- :selected="$store.state.filter.period === 'year'"
- v-on:onClick="$store.dispatch('setPeriod', 'year')"
- v-on:onClose="visiblePeriodMenu = !visiblePeriodMenu")
- ContextMenuItem(
- icon="mdi mdi-database"
- title="Show all"
- :selected="$store.state.filter.period === 'all'"
- v-on:onClick="$store.dispatch('setPeriod', 'all')"
- v-on:onClose="visiblePeriodMenu = !visiblePeriodMenu")
</template>
<style lang="stylus" scoped>
@@ -154,11 +103,6 @@ export default {
display flex
flex 1 1
justify-content space-between
- max-width 264px
-
- &._center
- max-width inherit
- justify-content center
&__item
display flex
diff --git a/src/components/layout/LayoutPc.vue b/src/components/layout/LayoutPc.vue
index 53199bae..c90e4ac8 100644
--- a/src/components/layout/LayoutPc.vue
+++ b/src/components/layout/LayoutPc.vue
@@ -10,7 +10,6 @@ import LayoutPcSidebar from '@/components/layout/LayoutPcSidebar'
import Settings from '@/components/settings/Settings'
import TrnForm from '@/components/trnForm/TrnForm'
import TrnModal from '@/components/trns/modal/TrnModal'
-import TrnsList from '@/components/trns/list/TrnsList'
import WalletForm from '@/components/wallets/form/WalletForm'
import WalletModal from '@/components/wallets/modal/WalletModal'
import WalletsList from '@/components/wallets/list/WalletsList'
@@ -28,7 +27,6 @@ export default {
Settings,
TrnForm,
TrnModal,
- TrnsList,
WalletForm,
WalletModal,
WalletsList
@@ -70,10 +68,6 @@ export default {
.layout__item
Dashboard
- transition(name="slide")
- .trnsHistory(v-if="$store.state.dashboard.showTrnsHistory")
- .dashboard__title History
- TrnsList
LayoutPcTab(:show="activeTab === 'categories'")
.dashboard__title Categories
@@ -169,17 +163,6 @@ export default {
width 100%
height 100%
-.trnsHistory
- padding 0 $mb2
- padding-top $mb2
- padding-bottom $mn2
-
- .trnsList
- display grid
- grid-template-columns repeat(3, 1fr)
- grid-column-gap $m7
- grid-row-gap $m7
-
.createTrnBtn
z-index 5
display flex
diff --git a/src/components/stat/StatMobile.vue b/src/components/stat/StatMobile.vue
index 0405f574..76e91257 100644
--- a/src/components/stat/StatMobile.vue
+++ b/src/components/stat/StatMobile.vue
@@ -227,6 +227,11 @@ export default {
:checkValue="$store.state.ui.statItems === 'visible'"
v-on:onClick="$store.dispatch('toogleVisibilityStatItems')"
v-on:onClose="visibleCustomizeMenu = !visibleCustomizeMenu")
+ .context-menu-sep
+ ContextMenuItem(
+ icon="mdi mdi-palette"
+ title="Change theme"
+ v-on:onClick="$store.dispatch('changeTheme')")
</template>
<style lang="stylus" scoped>
diff --git a/src/components/stat/StatPc.vue b/src/components/stat/StatPc.vue
index 091cf2cc..a9606e8f 100644
--- a/src/components/stat/StatPc.vue
+++ b/src/components/stat/StatPc.vue
@@ -30,7 +30,7 @@ export default {
.stat__chart(v-if="$store.state.ui.catsChart === 'visible'")
PeriodCatsChart(type="expenses")
- .stat__cats
+ .stat__cats(v-if="$store.state.ui.statItems === 'visible'")
StatItem(
v-for="categoryId in stat.expenses.categoriesIds"
:biggest="stat.expenses.biggest"
@@ -49,7 +49,7 @@ export default {
.stat__chart(v-if="$store.state.ui.catsChart === 'visible'")
PeriodCatsChart(type="incomes")
- .stat__cats
+ .stat__cats(v-if="$store.state.ui.statItems === 'visible'")
StatItem(
v-for="categoryId in stat.incomes.categoriesIds"
:biggest="stat.incomes.biggest"
@@ -87,10 +87,9 @@ export default {
grid-column-gap $mb2
&__item
- overflow hidden
flex 1 1 450px
padding 0 24px
- padding-top $m10
+ padding-top $m9
&__chart
@media $media-laptop