feat(task): make default project relation configurable

Resolves https://community.vikunja.io/t/change-default-task-relation/3637
This commit is contained in:
kolaente 2025-08-31 19:28:58 +02:00
parent 4c9f112103
commit 61400e93a9
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
6 changed files with 33 additions and 2 deletions

View File

@ -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<ITask['relatedTasks']>({})
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(() => {

View File

@ -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",

View File

@ -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 {

View File

@ -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<IUserSettings> implements IUserSettings {
name = ''
@ -26,6 +27,7 @@ export default class UserSettingsModel extends AbstractModel<IUserSettings> impl
defaultView: DEFAULT_PROJECT_VIEW_SETTINGS.FIRST,
minimumPriority: PRIORITIES.MEDIUM,
dateDisplay: DATE_DISPLAY.RELATIVE,
defaultTaskRelationType: RELATION_KIND.RELATED,
}
extraSettingsLinks = {}

View File

@ -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,
},
})

View File

@ -259,6 +259,24 @@
</div>
</label>
</div>
<div class="field">
<label class="two-col">
<span>
{{ $t('user.settings.general.defaultTaskRelationType') }}
</span>
<div class="select">
<select v-model="settings.frontendSettings.defaultTaskRelationType">
<option
v-for="relationKind in RELATION_KINDS"
:key="relationKind"
:value="relationKind"
>
{{ $t(`task.relation.kinds.${relationKind}`, 1) }}
</option>
</select>
</div>
</label>
</div>
<div class="field">
<label class="checkbox">
<input
@ -348,6 +366,7 @@ import {isSavedFilter} from '@/services/savedFilter'
import {DEFAULT_PROJECT_VIEW_SETTINGS} from '@/modelTypes/IProjectView'
import {PRIORITIES} from '@/constants/priorities'
import {DATE_DISPLAY} from '@/constants/dateDisplay'
import {RELATION_KINDS} from '@/types/IRelationKind'
defineOptions({name: 'UserSettingsGeneral'})
@ -389,6 +408,8 @@ const settings = ref<IUserSettings>({
// Add fallback for old settings that don't have the logo change setting set
allowIconChanges: authStore.settings.frontendSettings.allowIconChanges ?? true,
dateDisplay: authStore.settings.frontendSettings.dateDisplay ?? DATE_DISPLAY.RELATIVE,
// Add fallback for old settings that don't have the default task relation type set
defaultTaskRelationType: authStore.settings.frontendSettings.defaultTaskRelationType ?? 'related',
},
})