mirror of https://kolaente.dev/vikunja/api.git
Add default view setting
This commit is contained in:
parent
fd126fa234
commit
94a7bf2539
|
@ -95,6 +95,7 @@
|
|||
"weekStartMonday": "Montag",
|
||||
"language": "Sprache",
|
||||
"defaultProject": "Standard-Projekt",
|
||||
"defaultView": "Standard-Ansicht",
|
||||
"timezone": "Zeitzone",
|
||||
"overdueTasksRemindersTime": "Zeit der E-Mail-Zusammenfassung der überfälligen Aufgaben",
|
||||
"filterUsedOnOverview": "Gespeicherter Filter, der für die Startseite verwendet wird"
|
||||
|
|
|
@ -95,6 +95,7 @@
|
|||
"weekStartMonday": "Monday",
|
||||
"language": "Language",
|
||||
"defaultProject": "Default Project",
|
||||
"defaultView": "Default View",
|
||||
"timezone": "Time Zone",
|
||||
"overdueTasksRemindersTime": "Overdue tasks reminder email time",
|
||||
"filterUsedOnOverview": "Saved filter used on the overview page"
|
||||
|
|
|
@ -4,12 +4,14 @@ import type {IProject} from './IProject'
|
|||
import type {PrefixMode} from '@/modules/parseTaskText'
|
||||
import type {BasicColorSchema} from '@vueuse/core'
|
||||
import type {SupportedLocale} from '@/i18n'
|
||||
import type {ProjectViewKind} from '@/modelTypes/IProjectView'
|
||||
|
||||
export interface IFrontendSettings {
|
||||
playSoundWhenDone: boolean
|
||||
quickAddMagicMode: PrefixMode
|
||||
colorSchema: BasicColorSchema
|
||||
filterIdUsedOnOverview: IProject['id'] | null
|
||||
defaultView: ProjectViewKind
|
||||
}
|
||||
|
||||
export interface IUserSettings extends IAbstract {
|
||||
|
|
|
@ -8,6 +8,8 @@ import ProjectList from '@/components/project/views/ProjectList.vue'
|
|||
import ProjectGantt from '@/components/project/views/ProjectGantt.vue'
|
||||
import ProjectTable from '@/components/project/views/ProjectTable.vue'
|
||||
import ProjectKanban from '@/components/project/views/ProjectKanban.vue'
|
||||
import {useAuthStore} from '@/stores/auth'
|
||||
import {PROJECT_VIEW_KINDS} from '@/modelTypes/IProjectView'
|
||||
|
||||
const {
|
||||
projectId,
|
||||
|
@ -19,6 +21,7 @@ const {
|
|||
|
||||
const router = useRouter()
|
||||
const projectStore = useProjectStore()
|
||||
const authStore = useAuthStore()
|
||||
|
||||
const currentView = computed(() => {
|
||||
const project = projectStore.projects[projectId]
|
||||
|
@ -26,17 +29,21 @@ const currentView = computed(() => {
|
|||
return project?.views.find(v => v.id === viewId)
|
||||
})
|
||||
|
||||
function redirectToFirstViewIfNecessary() {
|
||||
function getDefaultView(): number {
|
||||
return PROJECT_VIEW_KINDS.indexOf(authStore.settings.frontendSettings.defaultView)
|
||||
}
|
||||
|
||||
function redirectToDefaultViewIfNecessary() {
|
||||
if (viewId === 0 || !projectStore.projects[projectId]?.views.find(v => v.id === viewId)) {
|
||||
// Ideally, we would do that in the router redirect, but the projects (and therefore, the views)
|
||||
// are not always loaded then.
|
||||
const firstViewId = projectStore.projects[projectId]?.views[0].id
|
||||
if (firstViewId) {
|
||||
const defaultViewId = projectStore.projects[projectId]?.views[getDefaultView()].id
|
||||
if (defaultViewId) {
|
||||
router.replace({
|
||||
name: 'project.view',
|
||||
params: {
|
||||
projectId,
|
||||
viewId: firstViewId,
|
||||
viewId: defaultViewId,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -45,13 +52,13 @@ function redirectToFirstViewIfNecessary() {
|
|||
|
||||
watch(
|
||||
() => viewId,
|
||||
redirectToFirstViewIfNecessary,
|
||||
redirectToDefaultViewIfNecessary,
|
||||
{immediate: true},
|
||||
)
|
||||
|
||||
watch(
|
||||
() => projectStore.projects[projectId],
|
||||
redirectToFirstViewIfNecessary,
|
||||
redirectToDefaultViewIfNecessary,
|
||||
)
|
||||
|
||||
// using a watcher instead of beforeEnter because beforeEnter is not called when only the viewId changes
|
||||
|
|
|
@ -26,6 +26,22 @@
|
|||
</label>
|
||||
<ProjectSearch v-model="defaultProject" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">
|
||||
{{ $t('user.settings.general.defaultView') }}
|
||||
</label>
|
||||
<div class="select ml-2">
|
||||
<select v-model="settings.frontendSettings.defaultView">
|
||||
<option
|
||||
v-for="view in PROJECT_VIEW_KINDS"
|
||||
:key="view"
|
||||
:value="view"
|
||||
>
|
||||
{{ $t(`project.${view}.title`) }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="hasFilters"
|
||||
class="field"
|
||||
|
@ -221,6 +237,7 @@ import {useProjectStore} from '@/stores/projects'
|
|||
import {useAuthStore} from '@/stores/auth'
|
||||
import type {IUserSettings} from '@/modelTypes/IUserSettings'
|
||||
import {isSavedFilter} from '@/services/savedFilter'
|
||||
import {PROJECT_VIEW_KINDS} from '@/modelTypes/IProjectView'
|
||||
|
||||
const {t} = useI18n({useScope: 'global'})
|
||||
useTitle(() => `${t('user.settings.general.title')} - ${t('user.settings.title')}`)
|
||||
|
|
Loading…
Reference in New Issue