From 61400e93a9a047228654d77943ae19d3ed0d7ba5 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 31 Aug 2025 19:28:58 +0200 Subject: [PATCH] feat(task): make default project relation configurable Resolves https://community.vikunja.io/t/change-default-task-relation/3637 --- .../tasks/partials/RelatedTasks.vue | 7 +++++-- frontend/src/i18n/lang/en.json | 1 + frontend/src/modelTypes/IUserSettings.ts | 2 ++ frontend/src/models/userSettings.ts | 2 ++ frontend/src/stores/auth.ts | 2 ++ frontend/src/views/user/settings/General.vue | 21 +++++++++++++++++++ 6 files changed, 33 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/tasks/partials/RelatedTasks.vue b/frontend/src/components/tasks/partials/RelatedTasks.vue index efd7b58a5..95ff3b17d 100644 --- a/frontend/src/components/tasks/partials/RelatedTasks.vue +++ b/frontend/src/components/tasks/partials/RelatedTasks.vue @@ -191,7 +191,7 @@ import TaskService from '@/services/task' import TaskModel from '@/models/task' import type {ITask} from '@/modelTypes/ITask' import type {ITaskRelation} from '@/modelTypes/ITaskRelation' -import {RELATION_KINDS, RELATION_KIND, type IRelationKind} from '@/types/IRelationKind' +import {RELATION_KINDS, type IRelationKind} from '@/types/IRelationKind' import TaskRelationService from '@/services/taskRelation' import TaskRelationModel from '@/models/taskRelation' @@ -204,6 +204,7 @@ import FancyCheckbox from '@/components/input/FancyCheckbox.vue' import {error, success} from '@/message' import {useTaskStore} from '@/stores/tasks' import {useProjectStore} from '@/stores/projects' +import {useAuthStore} from '@/stores/auth' import {playPopSound} from '@/helpers/playPop' const props = withDefaults(defineProps<{ @@ -219,6 +220,7 @@ const props = withDefaults(defineProps<{ const taskStore = useTaskStore() const projectStore = useProjectStore() +const authStore = useAuthStore() const route = useRoute() const {t} = useI18n({useScope: 'global'}) @@ -229,7 +231,7 @@ const taskService = shallowReactive(new TaskService()) const relatedTasks = ref({}) const newTaskRelation: TaskRelation = reactive({ - kind: RELATION_KIND.RELATED, + kind: authStore.settings.frontendSettings.defaultTaskRelationType as IRelationKind, task: new TaskModel(), }) @@ -318,6 +320,7 @@ async function addTaskRelation() { newTaskRelation.task, ] newTaskRelation.task = new TaskModel() + newTaskRelation.kind = authStore.settings.frontendSettings.defaultTaskRelationType as IRelationKind saved.value = true showNewRelationForm.value = false setTimeout(() => { diff --git a/frontend/src/i18n/lang/en.json b/frontend/src/i18n/lang/en.json index 26a966281..d28a8ca00 100644 --- a/frontend/src/i18n/lang/en.json +++ b/frontend/src/i18n/lang/en.json @@ -93,6 +93,7 @@ "discoverableByEmail": "Allow other users to add me as a member to teams or projects when they search for my full email", "playSoundWhenDone": "Play a sound when marking tasks as done", "allowIconChanges": "Show special logos during certain times", + "defaultTaskRelationType": "Default task relation type", "weekStart": "Week starts on", "weekStartSunday": "Sunday", "weekStartMonday": "Monday", diff --git a/frontend/src/modelTypes/IUserSettings.ts b/frontend/src/modelTypes/IUserSettings.ts index 53c106b9d..1582d9612 100644 --- a/frontend/src/modelTypes/IUserSettings.ts +++ b/frontend/src/modelTypes/IUserSettings.ts @@ -7,6 +7,7 @@ import type {SupportedLocale} from '@/i18n' import type {DefaultProjectViewKind} from '@/modelTypes/IProjectView' import type {Priority} from '@/constants/priorities' import type {DateDisplay} from '@/constants/dateDisplay' +import type {IRelationKind} from '@/types/IRelationKind' export interface IFrontendSettings { playSoundWhenDone: boolean @@ -17,6 +18,7 @@ export interface IFrontendSettings { defaultView?: DefaultProjectViewKind minimumPriority: Priority dateDisplay: DateDisplay + defaultTaskRelationType: IRelationKind } export interface IExtraSettingsLink { diff --git a/frontend/src/models/userSettings.ts b/frontend/src/models/userSettings.ts index 2dd3b9d29..73ded15da 100644 --- a/frontend/src/models/userSettings.ts +++ b/frontend/src/models/userSettings.ts @@ -6,6 +6,7 @@ import {PrefixMode} from '@/modules/parseTaskText' import {DEFAULT_PROJECT_VIEW_SETTINGS} from '@/modelTypes/IProjectView' import {PRIORITIES} from '@/constants/priorities' import {DATE_DISPLAY} from '@/constants/dateDisplay' +import {RELATION_KIND} from '@/types/IRelationKind' export default class UserSettingsModel extends AbstractModel implements IUserSettings { name = '' @@ -26,6 +27,7 @@ export default class UserSettingsModel extends AbstractModel impl defaultView: DEFAULT_PROJECT_VIEW_SETTINGS.FIRST, minimumPriority: PRIORITIES.MEDIUM, dateDisplay: DATE_DISPLAY.RELATIVE, + defaultTaskRelationType: RELATION_KIND.RELATED, } extraSettingsLinks = {} diff --git a/frontend/src/stores/auth.ts b/frontend/src/stores/auth.ts index 0ffda0a0c..2e90e9eca 100644 --- a/frontend/src/stores/auth.ts +++ b/frontend/src/stores/auth.ts @@ -23,6 +23,7 @@ import UserSettingsModel from '@/models/userSettings' import {MILLISECONDS_A_SECOND} from '@/constants/date' import {PrefixMode} from '@/modules/parseTaskText' import {DATE_DISPLAY} from '@/constants/dateDisplay' +import {RELATION_KIND} from '@/types/IRelationKind' import type {IProvider} from '@/types/IProvider' function redirectToSpecifiedProvider() { @@ -133,6 +134,7 @@ export const useAuthStore = defineStore('auth', () => { colorSchema: 'auto', allowIconChanges: true, dateDisplay: DATE_DISPLAY.RELATIVE, + defaultTaskRelationType: RELATION_KIND.RELATED, ...newSettings.frontendSettings, }, }) diff --git a/frontend/src/views/user/settings/General.vue b/frontend/src/views/user/settings/General.vue index 6b22c5262..1b230ebd9 100644 --- a/frontend/src/views/user/settings/General.vue +++ b/frontend/src/views/user/settings/General.vue @@ -259,6 +259,24 @@ +
+ +