diff --git a/frontend/src/components/quick-actions/QuickActions.vue b/frontend/src/components/quick-actions/QuickActions.vue index b0525e60b..0ccd5557b 100644 --- a/frontend/src/components/quick-actions/QuickActions.vue +++ b/frontend/src/components/quick-actions/QuickActions.vue @@ -318,12 +318,11 @@ const hintText = computed(() => { }) const availableCmds = computed(() => { - const cmds = [] - if (currentProject.value !== null) { - cmds.push(commands.value.newTask, commands.value.newProject) - } - cmds.push(commands.value.newTeam) - return cmds + return [ + commands.value.newTask, + commands.value.newProject, + commands.value.newTeam, + ] }) const parsedQuery = computed(() => parseTaskText(query.value, authStore.settings.frontendSettings.quickAddMagicMode)) @@ -509,7 +508,7 @@ async function doCmd() { async function newTask() { let projectId = authStore.settings.defaultProjectId - if (currentProject.value.id) { + if (currentProject.value?.id && currentProject.value.id > 0) { projectId = currentProject.value.id } const task = await taskStore.createNewTask({ @@ -521,11 +520,10 @@ async function newTask() { } async function newProject() { - if (currentProject.value === null) { - return - } + const parentProjectId = currentProject.value?.id ?? 0 await projectStore.createProject(new ProjectModel({ title: query.value, + parentProjectId: Math.max(parentProjectId, 0), })) success({message: t('project.create.createdSuccess')}) } diff --git a/frontend/src/stores/tasks.ts b/frontend/src/stores/tasks.ts index 9eff65ab4..792d52c09 100644 --- a/frontend/src/stores/tasks.ts +++ b/frontend/src/stores/tasks.ts @@ -401,8 +401,9 @@ export const useTaskStore = defineStore('task', () => { } // 3. Otherwise use the id from the route parameter - if (typeof router.currentRoute.value.params.projectId !== 'undefined') { - foundProjectId = Number(router.currentRoute.value.params.projectId) + const projectIdFromRoute = Number(router.currentRoute.value.params.projectId) + if (typeof router.currentRoute.value.params.projectId !== 'undefined' && projectIdFromRoute > 0) { + foundProjectId = projectIdFromRoute } // 4. If none of the above worked, reject the promise with an error.