Skip to content

Open source personal finance application

Update stat visibility, update TrnItem, update date format

ilkomeb673f319405b
diff --git a/src/components/categories/store/getters.js b/src/components/categories/store/getters.js
index aab1ba69..205425a2 100644
--- a/src/components/categories/store/getters.js
+++ b/src/components/categories/store/getters.js
@@ -47,6 +47,18 @@ export default {
return categoriesForBeParent
},
+ isCategoryHasChildren: (state, getters, rootState, rootGetters) => (categoryId) => {
+ if (!rootGetters.hasCategories) return []
+ const parentCategoriesIds = rootGetters.categoriesForBeParent
+ let isCategoryHasChildren
+
+ parentCategoriesIds.find(c => c === categoryId)
+ ? isCategoryHasChildren = true
+ : isCategoryHasChildren = false
+
+ return isCategoryHasChildren
+ },
+
getChildCategoriesIds: (state, getters, rootState, rootGetters) => (categoryId) => {
if (!rootGetters.hasCategories) return []
diff --git a/src/components/layout/LayoutMobile.vue b/src/components/layout/LayoutMobile.vue
index 2cdecccf..e5f2bc51 100644
--- a/src/components/layout/LayoutMobile.vue
+++ b/src/components/layout/LayoutMobile.vue
@@ -78,12 +78,12 @@ export default {
transition(name="animation-tab")
.tab(v-show="activeTab === 'stat'")
WalletsList(
- v-if="$store.state.ui.stat.walletsVisibility === 'visible'"
+ v-show="$store.state.ui.stat.walletsVisibility === 'visible'"
:limit="3"
ui="widget"
v-on:onClick="(id) => handleShowWalletModal(id)")
StatChartsLine(
- v-if="$store.state.ui.statGraphsVisibility === 'visible' && ($store.state.filter.period !== 'all')")
+ v-show="$store.state.ui.statGraphsVisibility === 'visible' && ($store.state.filter.period !== 'all')")
StatMobile
//- trns
diff --git a/src/components/layout/PeriodNavMobile.vue b/src/components/layout/PeriodNavMobile.vue
index 4d2072dd..a805899e 100644
--- a/src/components/layout/PeriodNavMobile.vue
+++ b/src/components/layout/PeriodNavMobile.vue
@@ -3,13 +3,15 @@ import ContextMenu from '@/components/shared/contextMenu/ContextMenu'
import ContextMenuItem from '@/components/shared/contextMenu/ContextMenuItem'
import Date from '@/components/shared/date/Date'
import Dropdown from '@/components/shared/dropdown/Dropdown'
+import StatCustomizeMenuMobile from '@/components/stat/StatCustomizeMenuMobile'
export default {
components: {
ContextMenu,
ContextMenuItem,
Date,
- Dropdown
+ Dropdown,
+ StatCustomizeMenuMobile
},
data () {
@@ -32,8 +34,7 @@ export default {
ContextMenu(
:position="{ left: true, bottom: true }"
:visible="visiblePeriodMenu"
- v-on:onClickOpener="visiblePeriodMenu = !visiblePeriodMenu"
- )
+ v-on:onClickOpener="visiblePeriodMenu = !visiblePeriodMenu")
template(slot="opener")
Dropdown(:active="visiblePeriodMenu")
template(slot="title"): Date
@@ -70,6 +71,11 @@ export default {
v-on:onClick="$store.dispatch('setPeriod', 'all')"
v-on:onClose="visiblePeriodMenu = !visiblePeriodMenu")
+ .customize
+ StatCustomizeMenuMobile(
+ icon="mdi mdi-tune"
+ :position="{ right: true, bottom: true }")
+
.periodNav__link
.d-button-cirle(
@click="$store.dispatch('setPeriodNext')"
@@ -97,4 +103,9 @@ export default {
@media $media-phone
padding 0
+
+.customize
+ margin-left 20px
+ @media $media-phone-sm
+ display none
</style>
diff --git a/src/components/shared/button/Button.vue b/src/components/shared/button/Button.vue
index f44222ec..341b3a0f 100644
--- a/src/components/shared/button/Button.vue
+++ b/src/components/shared/button/Button.vue
@@ -45,7 +45,7 @@ export default {
)
.d-button__icon(v-if="icon")
div(:class="icon")
- .d-button__title {{ title }}
+ .d-button__title(v-if="title") {{ title }}
.d-button__check(v-if="showCheckbox" @click.prevent="")
Checkbox._small(v-model="checkboxValue")
@@ -104,6 +104,27 @@ export default {
&:active
transform scale(0.96)
+ &._border
+ display flex
+ align-items center
+ justify-content center
+ padding 10px 10px
+ background var(--c-bg-2)
+ border 1px solid var(--c-bg-7)
+ box-shadow 2px 2px 6px 0px var(--c-bg-2)
+ border-radius 3px
+
+ /.theme-light &
+ box-shadow 2px 2px 6px 0px var(--c-bg-11)
+
+ &:active:not(._disable)
+ color var(--c-font-3)
+ transform scale(0.96)
+
+ &._square
+ width 40px
+ height 40px
+
&._blue
display inline-flex
align-items center
@@ -177,12 +198,16 @@ export default {
&__icon
width 22px
- margin-left (- $m4)
+ margin-left -5px
margin-right $m6
font-size 18px
text-align center
opacity .85
+ &:last-child
+ margin-right 0
+ margin-right -5px
+
&__check
margin-left auto
padding-left 32px
diff --git a/src/components/stat/StatChartsLine.vue b/src/components/stat/StatChartsLine.vue
index c87f1020..2ed0d0d1 100644
--- a/src/components/stat/StatChartsLine.vue
+++ b/src/components/stat/StatChartsLine.vue
@@ -179,7 +179,7 @@ export default {
</script>
<template lang="pug">
-.charts(v-if="$store.state.ui.statGraphsVisibility === 'visible'")
+.charts(v-show="$store.state.ui.statGraphsVisibility === 'visible'")
template(v-if="$store.state.filter.period === 'all'")
.charts__allData Change period to see chart
template(v-if="$store.state.filter.period !== 'all'")
diff --git a/src/components/stat/StatCustomizeMenuMobile.vue b/src/components/stat/StatCustomizeMenuMobile.vue
index 559bc510..0bf369c2 100644
--- a/src/components/stat/StatCustomizeMenuMobile.vue
+++ b/src/components/stat/StatCustomizeMenuMobile.vue
@@ -1,32 +1,59 @@
<script>
+import Button from '@/components/shared/button/Button'
import ContextMenu from '@/components/shared/contextMenu/ContextMenu'
import ContextMenuItem from '@/components/shared/contextMenu/ContextMenuItem'
import Dropdown from '@/components/shared/dropdown/Dropdown'
export default {
components: {
+ Button,
ContextMenu,
ContextMenuItem,
Dropdown
},
+ props: {
+ icon: {
+ type: String,
+ default: null
+ },
+ position: {
+ type: Object,
+ default: () => ({
+ left: true,
+ bottom: true
+ })
+ }
+ },
+
data () {
return {
visibleCustomizeMenu: false
}
+ },
+
+ computed: {
+ positionStyles () {
+ let styles = { ...this.position }
+ return styles
+ }
}
}
</script>
<template lang="pug">
ContextMenu(
- :position="{ left: true, bottom: true }"
+ :position="position"
:visible="visibleCustomizeMenu"
v-on:onClickOpener="visibleCustomizeMenu = !visibleCustomizeMenu")
template(slot="opener")
- Dropdown._inline(
- :active="visibleCustomizeMenu"
- :title="$lang.settings.customize")
+ template(v-if="icon")
+ Button._border._square(
+ :icon="icon")
+ template(v-else)
+ Dropdown._inline(
+ :active="visibleCustomizeMenu"
+ :title="$lang.settings.customize")
template(slot="content")
ContextMenuItem(
icon="mdi mdi-credit-card-multiple"
@@ -53,18 +80,20 @@ ContextMenu(
:checkboxValue="$store.state.ui.catsChart === 'visible'"
v-on:onClick="$store.dispatch('toogleVisibleCatsChart')")
ContextMenuItem(
- icon="mdi mdi-chart-gantt"
+ icon="mdi mdi-history"
title="Stat categories list"
:showCheckbox="true"
:checkboxValue="$store.state.ui.statItems === 'visible'"
v-on:onClick="$store.dispatch('toogleVisibilityStatItems')")
+ ContextMenuItem(
+ icon="mdi mdi-history"
+ title="Last trns"
+ :showCheckbox="true"
+ :checkboxValue="$store.state.ui.statLastTrnsVisibility === 'visible'"
+ v-on:onClick="$store.dispatch('toogleStatLastTrnsVisibility')")
.context-menu-sep
ContextMenuItem(
icon="mdi mdi-palette"
title="Change theme"
v-on:onClick="$store.dispatch('changeTheme')")
</template>
-
-<style lang="stylus" scoped>
-
-</style>
diff --git a/src/components/stat/StatMobile.vue b/src/components/stat/StatMobile.vue
index fb10feda..0e1aa60f 100644
--- a/src/components/stat/StatMobile.vue
+++ b/src/components/stat/StatMobile.vue
@@ -57,7 +57,7 @@ export default {
<template lang="pug">
.stat
- StatSummaryMobile(v-if="$store.state.ui.statSummuryVisibility === 'visible'")
+ StatSummaryMobile(v-show="$store.state.ui.statSummuryVisibility === 'visible'")
.stat__filter(v-if="$store.state.filter.categoryId || $store.state.filter.walletId")
template(v-if="$store.state.filter.walletId")
@@ -114,11 +114,11 @@ export default {
:small="true"
:value="$store.getters.statAverage.incomes")
//- incomes: cats charts
- .stat__charts(v-if="$store.state.ui.catsChart === 'visible'")
+ .stat__charts(v-show="$store.state.ui.catsChart === 'visible'")
PeriodCatsChart(type="incomes")
//- incomes: cats stat item
- .stat__cats(v-if="$store.state.ui.statItems === 'visible'")
+ .stat__cats(v-show="$store.state.ui.statItems === 'visible'")
StatItem(
v-for="categoryId in stat.incomes.categoriesIds"
:biggest="stat.incomes.biggest"
@@ -150,11 +150,11 @@ export default {
:value="$store.getters.statAverage.expenses"
)
//- expenses: cats charts
- .stat__charts(v-if="$store.state.ui.catsChart === 'visible'")
+ .stat__charts(v-show="$store.state.ui.catsChart === 'visible'")
PeriodCatsChart(type="expenses")
//- expenses: cats stat item
- .stat__cats(v-if="$store.state.ui.statItems === 'visible'")
+ .stat__cats(v-show="$store.state.ui.statItems === 'visible'")
StatItem(
v-for="categoryId in stat.expenses.categoriesIds"
:biggest="stat.expenses.biggest"
@@ -165,20 +165,28 @@ export default {
:type="0"
:total="stat.categories[categoryId].expenses")
+ .stat__trns(v-if="$store.state.ui.statLastTrnsVisibility === 'visible' && $store.getters.selectedTrnsIdsWithDate.length > 0")
+ .stat__name Last transactions
+ TrnsList(:limit="6", ui="lastTrns")
+
.customize
StatCustomizeMenuMobile
</template>
<style lang="stylus" scoped>
@import "~@/stylus/variables/margins"
+@import "~@/stylus/variables/media"
@import "~@/stylus/variables/flex"
@import "~@/stylus/variables/fonts"
@import "~@/stylus/variables/scrollbar"
.customize
- padding 0 $m7
- padding-bottom $m9
- margin-top $m9
+ display none
+ @media $media-phone-sm
+ display block
+ padding 0 $m7
+ padding-bottom $m9
+ margin-top $m9
.stat
&__filter
@@ -200,6 +208,15 @@ export default {
&:last-child
padding-bottom 0
+ &__name
+ padding 0 10px
+ padding-bottom 10px
+ font-header-1()
+
+ &__trns
+ padding 0 10px
+ padding-bottom 20px
+
.statGroup
padding-top $m9
padding-bottom 10px
diff --git a/src/components/trns/item/TrnItem.vue b/src/components/trns/item/TrnItem.vue
index 5fcd1c7e..46d20cd8 100644
--- a/src/components/trns/item/TrnItem.vue
+++ b/src/components/trns/item/TrnItem.vue
@@ -38,7 +38,8 @@ export default {
return {
_detailed: this.ui === 'detailed',
_history: this.ui === 'history',
- _stat: this.ui === 'stat'
+ _stat: this.ui === 'stat',
+ _lastTrns: this.ui === 'lastTrns'
}
},
formatedDate () {
@@ -47,6 +48,9 @@ export default {
},
formatedDateDay () {
return formatDate(this.trn.date, 'numberDay')
+ },
+ formatedDateDay2 () {
+ return formatDate(this.trn.date, 'trnItem')
}
},
@@ -112,6 +116,69 @@ export default {
:value="trn.amount"
:type="trn.type")
+ //- lasr trns. shows category and wallet based on active filters
+ template(v-else-if="ui === 'lastTrns'")
+ .trnItem__statWrap
+ .trnItem__date {{ formatedDateDay2 }}
+
+ //- category selected
+ template(v-if="$store.state.filter.categoryId")
+ //- category with children
+ template(v-if="$store.getters.isCategoryHasChildren($store.state.filter.categoryId)")
+ .trnItem__wallet
+ Icon(
+ :abbr="wallet.name"
+ :background="wallet.color"
+ :medium="true"
+ :small="true")
+ .trnItem__categoryIcon
+ Icon(
+ :background="category.color"
+ :icon="category.icon"
+ :medium="true"
+ :round="true")
+ .trnItem__categoryName {{ category.name }}
+ template(v-else)
+ .trnItem__wallet
+ .walletIcon
+ Icon(
+ :abbr="wallet.name"
+ :background="wallet.color"
+ :small="true")
+ .walletName {{ wallet.name }}
+
+ //- wallet selected
+ template(v-else-if="$store.state.filter.walletId")
+ .trnItem__categoryIcon
+ Icon(
+ :background="category.color"
+ :icon="category.icon"
+ :medium="true"
+ :round="true")
+ .trnItem__categoryName {{ category.name }}
+
+ //- base
+ template(v-else)
+ .trnItem__wallet
+ Icon(
+ :abbr="wallet.name"
+ :background="wallet.color"
+ :medium="true"
+ :small="true")
+ .trnItem__categoryIcon
+ Icon(
+ :background="category.color"
+ :icon="category.icon"
+ :medium="true"
+ :round="true")
+ .trnItem__categoryName {{ category.name }}
+ .trnItem__desc(v-if="trn.description") {{ trn.description }}
+ .trnItem__amount(@click.stop="setTrnEdit")
+ Amount(
+ :currency="wallet.currency"
+ :value="trn.amount"
+ :type="trn.type")
+
//- history view
template(v-else)
.trnItem__categoryIcon(@click.stop="setTrnEdit")
@@ -159,6 +226,7 @@ export default {
margin-top 0
&._stat
+ &._lastTrns
margin-top -1px
padding-top 10px
padding-left 68px
@@ -166,9 +234,13 @@ export default {
@media $media-laptop
padding-left 62px
+ &._lastTrns
+ padding-left 10px
+
&:hover
&._history
&._stat
+ &._lastTrns
@media $media-laptop
background var(--c-bg-7)
/.theme-light &
@@ -186,6 +258,7 @@ export default {
grid-row 1 / 2
^[0]._stat &
+ ^[0]._lastTrns &
margin-left auto
&__categoryIcon
@@ -194,6 +267,10 @@ export default {
grid-row 1 / 3
align-self center
+ ^[0]._lastTrns &
+ flex 0 0 24px
+ padding-right 10px
+
&__categoryName
white-space nowrap
overflow hidden
@@ -209,6 +286,9 @@ export default {
grid-row 1 / 2
align-self center
+ ^[0]._lastTrns &
+ padding-right 20px
+
&__date
font-size 13px
@@ -216,8 +296,12 @@ export default {
grid-row 1 / 2
^[0]._stat &
+ ^[0]._lastTrns &
padding-right 20px
+ ^[0]._lastTrns &
+ flex 0 0 80px
+
&__desc
color var(--c-font-2)
font-size 14px
@@ -236,6 +320,7 @@ export default {
padding-bottom 5px
^[0]._stat &
+ ^[0]._lastTrns &
padding-right 10px
&__line
@@ -259,15 +344,18 @@ export default {
border-bottom 1px solid var(--c-bg-6)
^[0]._stat:hover &
+ ^[0]._lastTrns:hover &
@media $media-laptop
border-color transparent
^[0]._stat:last-child &
+ ^[0]._lastTrns:last-child &
border-color transparent
&__wallet
^[0]._detailed &
^[0]._stat &
+ ^[0]._lastTrns &
display flex
align-items center
.walletIcon
@@ -282,6 +370,8 @@ export default {
^[0]._stat &
padding-right 20px
+ ^[0]._lastTrns &
+ padding-right 20px
&__walletFloatIcon
position absolute
diff --git a/src/components/ui/store/actions.js b/src/components/ui/store/actions.js
index ef61cd72..1951a4e8 100644
--- a/src/components/ui/store/actions.js
+++ b/src/components/ui/store/actions.js
@@ -8,11 +8,12 @@ import localforage from 'localforage'
setActiveTab
setActiveTabStat
- toogleShowStatGraphs
toogleLastUsedCatsInTrnForm
- toogleVisibilityStatItems
+ toogleShowStatGraphs
+ toogleStatLastTrns
toogleStatWalletsVisibility
toogleStatWalletsVisibility
+ toogleVisibilityStatItems
saveUiView
setUiView
@@ -162,6 +163,19 @@ export default {
dispatch('saveUiView')
},
+ /**
+ * Toggle stat last trns
+ */
+ toogleStatLastTrnsVisibility ({ commit, dispatch, state }) {
+ let nextStatus
+ state.statLastTrnsVisibility === 'visible'
+ ? nextStatus = 'hidden'
+ : nextStatus = 'visible'
+
+ commit('setStatLastTrnsVisibility', nextStatus)
+ dispatch('saveUiView')
+ },
+
/**
* Toggle stat wallets
*/
@@ -205,6 +219,7 @@ export default {
period: rootState.filter.period,
statGraphsVisibility: rootState.ui.statGraphsVisibility,
statItems: rootState.ui.statItems,
+ statLastTrnsVisibility: rootState.ui.statLastTrnsVisibility,
statSummuryVisibility: rootState.ui.statSummuryVisibility,
totalChartPeriods: rootState.chart.periods,
walletsVisibility: rootState.ui.stat.walletsVisibility
@@ -245,6 +260,11 @@ export default {
? commit('setVisibilityStatItems', 'visible')
: commit('setVisibilityStatItems', 'hidden')
+ // stat last trns
+ localFilterUiItem.statLastTrnsVisibility === 'visible'
+ ? commit('setStatLastTrnsVisibility', 'visible')
+ : commit('setStatLastTrnsVisibility', 'hidden')
+
// stat summury
localFilterUiItem.statSummuryVisibility === 'visible'
? commit('setStatSummuryVisibility', 'visible')
diff --git a/src/components/ui/store/index.js b/src/components/ui/store/index.js
index 0b097e61..ca7e3d5a 100644
--- a/src/components/ui/store/index.js
+++ b/src/components/ui/store/index.js
@@ -7,10 +7,11 @@ const state = {
height: 0,
mobile: true,
pc: false,
- statGraphsVisibility: 'visible',
- lastUsedCatsInTrnForm: 'visible',
catsChart: 'visible',
+ lastUsedCatsInTrnForm: 'visible',
+ statGraphsVisibility: 'visible',
statItems: 'visible',
+ statLastTrnsVisibility: 'visible',
statSummuryVisibility: 'visible',
stat: {
activeTab: 'stat',
diff --git a/src/components/ui/store/mutations.js b/src/components/ui/store/mutations.js
index 91b7844c..2861ea34 100644
--- a/src/components/ui/store/mutations.js
+++ b/src/components/ui/store/mutations.js
@@ -43,5 +43,9 @@ export default {
setStatSummuryVisibility (state, status) {
state.statSummuryVisibility = status
+ },
+
+ setStatLastTrnsVisibility (state, status) {
+ state.statLastTrnsVisibility = status
}
}
diff --git a/src/utils/formatDate.js b/src/utils/formatDate.js
index adc59622..6cdfc438 100644
--- a/src/utils/formatDate.js
+++ b/src/utils/formatDate.js
@@ -27,10 +27,16 @@ export const formatDate = (value, type) => {
return date.format('DD.MM')
case 'trnItem':
+ if (today.isSame(date, 'day')) {
+ return 'Today'
+ }
+ if (today.isSame(moment(date).add(1, 'day'), 'day')) {
+ return 'Yesterday'
+ }
if (today.isSame(date, 'year')) {
- return date.format('DD MMM')
+ return date.format('DD.MM')
}
- return date.format('DD MMM YY')
+ return date.format('DD.MM.YY')
default:
return date.format('D MMMM YY')