Open source personal finance application
Refactor
ilkomea5c7bbaaad5b
diff --git a/src/components/dashboard/Dashboard.vue b/src/components/dashboard/Dashboard.vueindex a0066e46..645d4c39 100644--- a/src/components/dashboard/Dashboard.vue+++ b/src/components/dashboard/Dashboard.vue@@ -4,8 +4,8 @@ import DashboardNav from '@/components/dashboard/DashboardNav'import DashboardStatControl from '@/components/dashboard/DashboardStatControl'import EmptyData from '@/components/shared/emptyData/EmptyData'import StatChartsLine from '@/components/stat/StatChartsLine'-import StatSummaryPc from '@/components/stat/StatSummaryPc'import StatPc from '@/components/stat/StatPc'+import StatSummaryPc from '@/components/stat/StatSummaryPc'import TrnsList from '@/components/trns/list/TrnsList'export default {@@ -24,6 +24,17 @@ export default {return {visiblePeriodMenu: false}+ },++ computed: {+ isEmptyData () {+ const statCurrentPeriod = this.$store.getters.statCurrentPeriod+ if (statCurrentPeriod.incomes.categoriesIds.length === 0 &&+ statCurrentPeriod.expenses.categoriesIds.length === 0 &&+ this.$store.getters.selectedTrnsIdsWithDate.length === 0) {+ return true+ }+ }}}</script>@@ -37,20 +48,24 @@ export default {DashboardStatControl.dashboard__content- .dashboard__wrap- //- empty- //------------------------------------------------- template(v-if="$store.getters.stat.incomes.categoriesIds.length === 0 && $store.getters.stat.expenses.categoriesIds.length === 0 && $store.getters.selectedTrnsIdsWithDate.length === 0")- EmptyData(text="No stat for this period")+ //- empty+ //------------------------------------------------+ template(v-if="isEmptyData")+ transition(name="animation-tab")+ .dashboard__wrap+ .dashboard__tab(v-show="$store.state.dashboard.activeTab === 'stat'")+ EmptyData(text="No stat for this period")- //- stat & history- template(v-else)- transition(name="animation-tab")- .dashboard__tab(v-show="!$store.state.dashboard.showTrnsHistory")+ //- stat & history+ template(v-else)+ transition(name="animation-tab")+ .dashboard__wrap+ .dashboard__tab(v-show="$store.state.dashboard.activeTab === 'stat'")StatPc- transition(name="animation-tab")- .dashboard__tab._trns(v-show="$store.state.dashboard.showTrnsHistory")+ transition(name="animation-tab")+ .dashboard__wrap+ .dashboard__tab._trns(v-show="$store.state.dashboard.activeTab === 'history'")TrnsList</template>diff --git a/src/components/dashboard/DashboardStatControl.vue b/src/components/dashboard/DashboardStatControl.vueindex 3c939eda..20d9c479 100644--- a/src/components/dashboard/DashboardStatControl.vue+++ b/src/components/dashboard/DashboardStatControl.vue@@ -13,9 +13,23 @@ export default {.tabItem(@click="$store.dispatch('setPeriodNext')":class="{ _disable: $store.state.filter.period === 'all' || $store.getters.isLastPeriodSelected }") Last {{ this.$store.state.filter.period }}- .tabs(@click="$store.commit('toogleDashboardTrnsHistory')")- .tabItem(:class="{ _active: !$store.state.dashboard.showTrnsHistory }") Stat- .tabItem(:class="{ _active: $store.state.dashboard.showTrnsHistory }") History++ .tabs+ .tabItem(+ @click="$store.commit('setDashboardActiveTab', 'stat')"+ :class="{ _active: $store.state.dashboard.activeTab === 'stat' }") Stat++ .tabItem(+ @click="$store.commit('setDashboardActiveTab', 'balance')"+ :class="{ _active: $store.state.dashboard.activeTab === 'balance' }") Balance++ .tabItem(+ @click="$store.commit('setDashboardActiveTab', 'compare')"+ :class="{ _active: $store.state.dashboard.activeTab === 'compare' }") Compare++ .tabItem(+ @click="$store.commit('setDashboardActiveTab', 'history')"+ :class="{ _active: $store.state.dashboard.activeTab === 'history' }") History</template><style lang="stylus" scoped>diff --git a/src/components/dashboard/store/index.js b/src/components/dashboard/store/index.jsindex 066f8c51..87f7fa2e 100644--- a/src/components/dashboard/store/index.js+++ b/src/components/dashboard/store/index.js@@ -3,7 +3,7 @@ import getters from './getters'import mutations from './mutations'const state = {- showTrnsHistory: false+ activeTab: 'stat'}export default {diff --git a/src/components/dashboard/store/mutations.js b/src/components/dashboard/store/mutations.jsindex 8cad946a..4f90a9d7 100644--- a/src/components/dashboard/store/mutations.js+++ b/src/components/dashboard/store/mutations.js@@ -1,5 +1,5 @@export default {- toogleDashboardTrnsHistory (state) {- state.showTrnsHistory = !state.showTrnsHistory+ setDashboardActiveTab (state, nextTab) {+ state.activeTab = nextTab}}diff --git a/src/components/stat/chart/ChartPopup.vue b/src/components/stat/chart/ChartPopup.vueindex 1c86b2ea..d0c8e013 100644--- a/src/components/stat/chart/ChartPopup.vue+++ b/src/components/stat/chart/ChartPopup.vue@@ -9,27 +9,25 @@ export default {</script><template lang="pug">-.chart-popup(- :style="{ left: $store.state.chart.hoveredPeriod.offset }"-)+.chart-popup(:style="{ left: $store.state.chart.hoveredPeriod.offset }")+.chart-popup__itemAmount(:value="$store.state.chart.hoveredPeriod.values.incomes":currency="$store.state.currencies.base"- :type="1"- )+ :type="1")+.chart-popup__itemAmount(:value="$store.state.chart.hoveredPeriod.values.expenses":currency="$store.state.currencies.base"- :type="0"- )+ :type="0")+template(v-if="$store.state.chart.hoveredPeriod.values.incomes !== 0 && $store.state.chart.hoveredPeriod.values.expenses !== 0").chart-popup__itemAmount(:value="$store.state.chart.hoveredPeriod.values.incomes - $store.state.chart.hoveredPeriod.values.expenses"- :currency="$store.state.currencies.base"- )+ :currency="$store.state.currencies.base")</template><style lang="stylus" scoped>