From 99d8fbdfa7023cc6c88fa9d4cbec0d0c53e2a386 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 29 Aug 2023 11:11:37 +0200 Subject: [PATCH] feat(quick actions): show tasks for a label when selecting it --- .../quick-actions/quick-actions.vue | 25 +++++++++++++++++++ src/i18n/lang/en.json | 1 + 2 files changed, 26 insertions(+) diff --git a/src/components/quick-actions/quick-actions.vue b/src/components/quick-actions/quick-actions.vue index 1648d81db5..4ffee13d5a 100644 --- a/src/components/quick-actions/quick-actions.vue +++ b/src/components/quick-actions/quick-actions.vue @@ -83,6 +83,7 @@ import {success} from '@/message' import type {ITeam} from '@/modelTypes/ITeam' import type {ITask} from '@/modelTypes/ITask' import type {IProject} from '@/modelTypes/IProject' +import type {ILabel} from '@/modelTypes/ILabel' const {t} = useI18n({useScope: 'global'}) const router = useRouter() @@ -100,6 +101,7 @@ enum ACTION_TYPE { TASK = 'task', PROJECT = 'project', TEAM = 'team', + LABELS = 'labels', } enum COMMAND_TYPE { @@ -152,6 +154,19 @@ const foundProjects = computed(() => { .filter(p => Boolean(p)) }) +const foundLabels = computed(() => { + const {labels, text} = parsedQuery.value + if (text === '' && labels.length === 0) { + return [] + } + + if (labels.length > 0) { + return labelStore.filterLabelsByQuery([], labels[0]) + } + + return labelStore.filterLabelsByQuery([], text) +}) + // FIXME: use fuzzysearch const foundCommands = computed(() => availableCmds.value.filter((a) => a.title.toLowerCase().includes(query.value.toLowerCase()), @@ -180,6 +195,11 @@ const results = computed(() => { title: t('quickActions.tasks'), items: foundTasks.value, }, + { + type: ACTION_TYPE.LABELS, + title: t('quickActions.labels'), + items: foundLabels.value, + }, { type: ACTION_TYPE.TEAM, title: t('quickActions.teams'), @@ -447,6 +467,11 @@ async function doAction(type: ACTION_TYPE, item: DoAction) { selectedCmd.value = item as DoAction searchInput.value?.focus() break + case ACTION_TYPE.LABELS: + query.value = '*'+item.title + searchInput.value?.focus() + searchTasks() + break } } diff --git a/src/i18n/lang/en.json b/src/i18n/lang/en.json index bd87f8f1ae..be6bf4ed60 100644 --- a/src/i18n/lang/en.json +++ b/src/i18n/lang/en.json @@ -905,6 +905,7 @@ "tasks": "Tasks", "projects": "Projects", "teams": "Teams", + "labels": "Labels", "newProject": "Enter the title of the new project…", "newTask": "Enter the title of the new task…", "newTeam": "Enter the name of the new team…",