Skip to content

Commit

Permalink
- made landing page be configurable in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
cioraneanu committed Oct 19, 2024
1 parent 01828ac commit 4fc2d00
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 1 deletion.
16 changes: 16 additions & 0 deletions front/components/select/page-select.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<app-select label="Starting page" v-model="modelValue" v-model:showDropdown="showDropdown" :list="list" :columns="1" v-bind="dynamicAttrs" :has-search="false" />
</template>

<script setup>
import Account from '~/models/Account'
import { useFormAttributes } from '~/composables/useFormAttributes'
import Page from '~/models/Page.js'
const attrs = useAttrs()
const { dynamicAttrs } = useFormAttributes(attrs)
const modelValue = defineModel()
const list = Page.typesList()
const showDropdown = ref(null)
</script>
30 changes: 30 additions & 0 deletions front/models/Page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { faker } from '@faker-js/faker'
import BaseModel from '~/models/BaseModel'
import AccountTransformer from '~/transformers/AccountTransformer'
import AccountRepository from '~/repository/AccountRepository'
import _, { get } from 'lodash'
import Transaction from '~/models/Transaction'
import { NUMBER_FORMAT } from '~/utils/MathUtils.js'

export default class Page {
static get types() {
return {
transactionNew: {
name: 'New transaction',
code: 'transaction',
},
transactionList: {
name: 'Transaction list',
code: 'transactionList',
},
dashboard: {
name: 'Dashboard',
code: 'dashboard',
},
}
}

static typesList() {
return Object.values(this.types)
}
}
20 changes: 19 additions & 1 deletion front/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
<template>
<transaction-create />
<component :is="startingPage" />
</template>

<script setup>
import TransactionCreate from './transactions/[[id]].vue'
import TransactionList from './transactions/list.vue'
import Dashboard from './dashboard.vue'
import Page from '~/models/Page.js'
const profileStore = useProfileStore()
let startingPage = computed(() => {
switch (profileStore.startingPage?.code) {
case Page.types.transactionNew.code:
return markRaw(TransactionCreate)
case Page.types.transactionList.code:
return markRaw(TransactionList)
case Page.types.dashboard.code:
return markRaw(Dashboard)
}
return markRaw(TransactionCreate)
})
</script>
4 changes: 4 additions & 0 deletions front/pages/settings/ui.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<app-icon :size="23" :stroke-width="2.0" :icon="value ? TablerIconConstants.darkTheme : TablerIconConstants.whiteTheme" />
</template>
</app-boolean>

<page-select v-model="startingPage"></page-select>
</van-cell-group>

<van-cell-group inset>
Expand Down Expand Up @@ -55,6 +57,7 @@ const dataStore = useDataStore()
const themeText = computed(() => (darkTheme.value ? 'Dark' : 'Light'))
const darkTheme = ref(false)
const startingPage = ref(null)
const heroIconsList = HERO_ICONS_LIST
const isHeroIconsDropdownVisible = ref(false)
Expand All @@ -63,6 +66,7 @@ const heroIcons = ref([])
const syncedSettings = [
{ store: profileStore, path: 'darkTheme', ref: darkTheme },
{ store: profileStore, path: 'heroIcons', ref: heroIcons },
{ store: profileStore, path: 'startingPage', ref: startingPage },
]
watchSettingsStore(syncedSettings)
Expand Down
2 changes: 2 additions & 0 deletions front/stores/profileStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import ProfileRepository from '~/repository/ProfileRepository'
import ProfileTransformer from '~/transformers/ProfileTransformer'
import { useAppStore } from '~/stores/appStore.js'
import { DASHBOARD_SECTIONS_LIST } from '~/constants/DashboardConstants.js'
import Page from '~/models/Page.js'

export const useProfileStore = defineStore('profile', {
state: () => {
Expand All @@ -21,6 +22,7 @@ export const useProfileStore = defineStore('profile', {
loadingMessage: 'Loading...',

darkTheme: useLocalStorage('darkTheme', false),
startingPage: useLocalStorage('startingPage', Page.types.transactionNew),

defaultAccountSource: useLocalStorage('defaultAccountSource', null, { serializer: StorageSerializers.object }),
defaultAccountDestination: useLocalStorage('defaultAccountDestination', null, { serializer: StorageSerializers.object }),
Expand Down

0 comments on commit 4fc2d00

Please sign in to comment.