From 0724776ccbe6cb78da293e60739c7db3fb1a158b Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 3 Apr 2023 19:21:52 +0200 Subject: [PATCH 01/18] fix(quick add magic): don't replace the prefix in every occurrence when it is present in the matched part --- src/modules/parseTaskText.test.ts | 8 ++++++++ src/modules/parseTaskText.ts | 8 +++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/modules/parseTaskText.test.ts b/src/modules/parseTaskText.test.ts index e9fe5b56f..6464b2162 100644 --- a/src/modules/parseTaskText.test.ts +++ b/src/modules/parseTaskText.test.ts @@ -691,6 +691,14 @@ describe('Parse Task Text', () => { expect(result.assignees).toHaveLength(1) expect(result.assignees[0]).toBe('today') }) + it('should recognize an email address', () => { + const text = 'Lorem Ipsum @email@example.com' + const result = parseTaskText(text) + + expect(result.text).toBe('Lorem Ipsum @email@example.com') + expect(result.assignees).toHaveLength(1) + expect(result.assignees[0]).toBe('email@example.com') + }) }) describe('Recurring Dates', () => { diff --git a/src/modules/parseTaskText.ts b/src/modules/parseTaskText.ts index 53fa34e9c..79eab5d86 100644 --- a/src/modules/parseTaskText.ts +++ b/src/modules/parseTaskText.ts @@ -109,7 +109,9 @@ const getItemsFromPrefix = (text: string, prefix: string): string[] => { return } - p = p.replace(prefix, '') + if (p.substring(0, 1) === prefix) { + p = p.substring(1) + } let itemText if (p.charAt(0) === '\'') { @@ -120,8 +122,8 @@ const getItemsFromPrefix = (text: string, prefix: string): string[] => { // Only until the next space itemText = p.split(' ')[0] } - - if(itemText !== '') { + + if (itemText !== '') { items.push(itemText) } }) From 02c24a4814216c7725f20777f26b8909bdcb3982 Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 3 Apr 2023 19:34:05 +0200 Subject: [PATCH 02/18] fix(quick add magic): use the project user service to find assignees for quick add magic --- src/stores/tasks.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/stores/tasks.ts b/src/stores/tasks.ts index 4dbee906d..2833845ae 100644 --- a/src/stores/tasks.ts +++ b/src/stores/tasks.ts @@ -29,6 +29,7 @@ import {useProjectStore} from '@/stores/projects' import {useAttachmentStore} from '@/stores/attachments' import {useKanbanStore} from '@/stores/kanban' import {useBaseStore} from '@/stores/base' +import ProjectUserService from '@/services/projectUsers' // IDEA: maybe use a small fuzzy search here to prevent errors function findPropertyByValue(object, key, value) { @@ -63,14 +64,14 @@ async function addLabelToTask(task: ITask, label: ILabel) { return response } -async function findAssignees(parsedTaskAssignees: string[]): Promise { +async function findAssignees(parsedTaskAssignees: string[], projectId: number): Promise { if (parsedTaskAssignees.length <= 0) { return [] } - const userService = new UserService() + const userService = new ProjectUserService() const assignees = parsedTaskAssignees.map(async a => { - const users = await userService.getAll({}, {s: a}) + const users = await userService.getAll({projectId}, {s: a}) return validateUser(users, a) }) @@ -389,7 +390,7 @@ export const useTaskStore = defineStore('task', () => { throw new Error('NO_PROJECT') } - const assignees = await findAssignees(parsedTask.assignees) + const assignees = await findAssignees(parsedTask.assignees, foundProjectId) // Only clean up those assignees from the task title which actually exist let cleanedTitle = parsedTask.text From 34d1e4bddd788d88c957b64672236743a82050a4 Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 3 Apr 2023 19:34:33 +0200 Subject: [PATCH 03/18] fix(quick add magic): cleanup all assignee properties --- src/stores/tasks.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/stores/tasks.ts b/src/stores/tasks.ts index 2833845ae..81c23b249 100644 --- a/src/stores/tasks.ts +++ b/src/stores/tasks.ts @@ -397,7 +397,9 @@ export const useTaskStore = defineStore('task', () => { if (assignees.length > 0) { const assigneePrefix = PREFIXES[quickAddMagicMode]?.assignee if (assigneePrefix) { + cleanedTitle = cleanupItemText(cleanedTitle, assignees.map(a => a.email), assigneePrefix) cleanedTitle = cleanupItemText(cleanedTitle, assignees.map(a => a.username), assigneePrefix) + cleanedTitle = cleanupItemText(cleanedTitle, assignees.map(a => a.name), assigneePrefix) } } From 302ba2bec7f592f6b0b1fba84a5a1a9fd5f994de Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 3 Apr 2023 19:39:03 +0200 Subject: [PATCH 04/18] chore: clarify users when can still be found even if they disabled it --- src/i18n/lang/en.json | 2 ++ src/views/user/settings/General.vue | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/i18n/lang/en.json b/src/i18n/lang/en.json index 6faaed9fb..202d822dd 100644 --- a/src/i18n/lang/en.json +++ b/src/i18n/lang/en.json @@ -77,7 +77,9 @@ "emailReminders": "Send me reminders for tasks via Email", "overdueReminders": "Send me a summary of my undone overdue tasks every day", "discoverableByName": "Let other users find me when they search for my name", + "stillDiscoverableByName": "Users can still find you by name if they want to assign you to a task on a project shared with you.", "discoverableByEmail": "Let other users find me when they search for my full email", + "stillDiscoverableByEmail": "Users can still find you by email if they want to assign you to a task on a project shared with you.", "playSoundWhenDone": "Play a sound when marking tasks as done", "weekStart": "Week starts on", "weekStartSunday": "Sunday", diff --git a/src/views/user/settings/General.vue b/src/views/user/settings/General.vue index 87624daaf..5d572802e 100644 --- a/src/views/user/settings/General.vue +++ b/src/views/user/settings/General.vue @@ -48,12 +48,18 @@ {{ $t('user.settings.general.discoverableByName') }} +

+ {{ $t('user.settings.general.stillDiscoverableByName') }} +

+

+ {{ $t('user.settings.general.stillDiscoverableByEmail') }} +