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
This commit is contained in:
kolaente 2023-09-06 16:51:23 +02:00
parent 0d3143d465
commit 9c46d064ac
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 16 additions and 1 deletions

View File

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

View File

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