From 9c46d064ac3a432815bed6616446ad892203b1ec Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 6 Sep 2023 16:51:23 +0200 Subject: [PATCH] feat(quick add magic): allow using the project identifier via quick add magic Related discussion: https://community.vikunja.io/t/using-shorter-list-names-in-quick-add-magic/895 --- src/stores/projects.ts | 10 ++++++++++ src/stores/tasks.ts | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/stores/projects.ts b/src/stores/projects.ts index a18e14956..f977337a4 100644 --- a/src/stores/projects.ts +++ b/src/stores/projects.ts @@ -55,6 +55,15 @@ export const useProjectStore = defineStore('project', () => { return typeof project === 'undefined' ? null : project } }) + + const findProjectByIdentifier = computed(() => { + return (identifier: string) => { + const project = Object.values(projects.value).find(p => { + return p.identifier.toLowerCase() === identifier.toLowerCase() + }) + return typeof project === 'undefined' ? null : project + } + }) const searchProject = computed(() => { return (query: string, includeArchived = false) => { @@ -205,6 +214,7 @@ export const useProjectStore = defineStore('project', () => { getChildProjects, findProjectByExactname, + findProjectByIdentifier, searchProject, searchSavedFilter, diff --git a/src/stores/tasks.ts b/src/stores/tasks.ts index 9e02ea16a..3ea876dc5 100644 --- a/src/stores/tasks.ts +++ b/src/stores/tasks.ts @@ -370,7 +370,12 @@ export const useTaskStore = defineStore('task', () => { // Uses the following ways to get the project id of the new task: // 1. If specified in quick add magic, look in store if it exists and use it if it does if (typeof projectName !== 'undefined' && projectName !== null) { - const project = projectStore.findProjectByExactname(projectName) + let project = projectStore.findProjectByExactname(projectName) + + if (project === null) { + project = projectStore.findProjectByIdentifier(projectName) + } + foundProjectId = project === null ? null : project.id }