From f68794bd01063fd14d96b30434e4dfd140568f5b Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 6 Jul 2021 14:53:32 +0200 Subject: [PATCH] Change quick add magic characters to be more familiar with the todoist ones --- .../tasks/partials/quick-add-magic.vue | 6 ++-- src/helpers/parseTaskText.js | 6 ++-- src/helpers/parseTaskText.test.js | 30 +++++++++---------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/components/tasks/partials/quick-add-magic.vue b/src/components/tasks/partials/quick-add-magic.vue index 172d41af..0204a9cc 100644 --- a/src/components/tasks/partials/quick-add-magic.vue +++ b/src/components/tasks/partials/quick-add-magic.vue @@ -13,13 +13,13 @@

{{ $t('task.attributes.labels') }}

- {{ $t('task.quickAddMagic.label1', {prefix: '~'}) }} + {{ $t('task.quickAddMagic.label1', {prefix: '@'}) }} {{ $t('task.quickAddMagic.label2') }} {{ $t('task.quickAddMagic.multiple') }}

{{ $t('task.quickAddMagic.label3') }} - {{ $t('task.quickAddMagic.label4', {prefix: '~'}) }} + {{ $t('task.quickAddMagic.label4', {prefix: '@'}) }}

{{ $t('task.attributes.priority') }}

@@ -36,7 +36,7 @@

{{ $t('list.list.title') }}

- {{ $t('task.quickAddMagic.list1', {prefix: '*'}) }} + {{ $t('task.quickAddMagic.list1', {prefix: '#'}) }} {{ $t('task.quickAddMagic.list2') }}

diff --git a/src/helpers/parseTaskText.js b/src/helpers/parseTaskText.js index 0039a6d8..e7c70752 100644 --- a/src/helpers/parseTaskText.js +++ b/src/helpers/parseTaskText.js @@ -1,10 +1,10 @@ import {parseDate} from './time/parseDate' import priorities from '../models/priorities.json' -const LABEL_PREFIX = '~' -const LIST_PREFIX = '*' +const LABEL_PREFIX = '@' +const LIST_PREFIX = '#' const PRIORITY_PREFIX = '!' -const ASSIGNEE_PREFIX = '@' +const ASSIGNEE_PREFIX = '+' /** * Parses task text for dates, assignees, labels, lists, priorities and returns an object with all found intents. diff --git a/src/helpers/parseTaskText.test.js b/src/helpers/parseTaskText.test.js index 618e9722..459ad628 100644 --- a/src/helpers/parseTaskText.test.js +++ b/src/helpers/parseTaskText.test.js @@ -277,7 +277,7 @@ describe('Parse Task Text', () => { describe('Labels', () => { it('should parse labels', () => { - const result = parseTaskText('Lorem Ipsum ~label1 ~label2') + const result = parseTaskText('Lorem Ipsum @label1 @label2') expect(result.text).toBe('Lorem Ipsum') expect(result.labels).toHaveLength(2) @@ -285,7 +285,7 @@ describe('Parse Task Text', () => { expect(result.labels[1]).toBe('label2') }) it('should parse labels from the start', () => { - const result = parseTaskText('~label1 Lorem Ipsum ~label2') + const result = parseTaskText('@label1 Lorem Ipsum @label2') expect(result.text).toBe('Lorem Ipsum') expect(result.labels).toHaveLength(2) @@ -293,7 +293,7 @@ describe('Parse Task Text', () => { expect(result.labels[1]).toBe('label2') }) it('should resolve duplicate labels', () => { - const result = parseTaskText('Lorem Ipsum ~label1 ~label1 ~label2') + const result = parseTaskText('Lorem Ipsum @label1 @label1 @label2') expect(result.text).toBe('Lorem Ipsum') expect(result.labels).toHaveLength(2) @@ -301,14 +301,14 @@ describe('Parse Task Text', () => { expect(result.labels[1]).toBe('label2') }) it('should correctly parse labels with spaces in them', () => { - const result = parseTaskText(`Lorem ~'label with space' Ipsum`) + const result = parseTaskText(`Lorem @'label with space' Ipsum`) expect(result.text).toBe('Lorem Ipsum') expect(result.labels).toHaveLength(1) expect(result.labels[0]).toBe('label with space') }) it('should correctly parse labels with spaces in them and "', () => { - const result = parseTaskText('Lorem ~"label with space" Ipsum') + const result = parseTaskText('Lorem @"label with space" Ipsum') expect(result.text).toBe('Lorem Ipsum') expect(result.labels).toHaveLength(1) @@ -318,27 +318,27 @@ describe('Parse Task Text', () => { describe('List', () => { it('should parse a list', () => { - const result = parseTaskText('Lorem Ipsum *list') + const result = parseTaskText('Lorem Ipsum #list') expect(result.text).toBe('Lorem Ipsum') expect(result.list).toBe('list') }) it('should parse a list with a space in it', () => { - const result = parseTaskText(`Lorem Ipsum *'list with long name'`) + const result = parseTaskText(`Lorem Ipsum #'list with long name'`) expect(result.text).toBe('Lorem Ipsum') expect(result.list).toBe('list with long name') }) it('should parse a list with a space in it and "', () => { - const result = parseTaskText(`Lorem Ipsum *"list with long name"`) + const result = parseTaskText(`Lorem Ipsum #"list with long name"`) expect(result.text).toBe('Lorem Ipsum') expect(result.list).toBe('list with long name') }) it('should parse only the first list', () => { - const result = parseTaskText(`Lorem Ipsum *list1 *list2 *list3`) + const result = parseTaskText(`Lorem Ipsum #list1 #list2 #list3`) - expect(result.text).toBe('Lorem Ipsum *list2 *list3') + expect(result.text).toBe('Lorem Ipsum #list2 #list3') expect(result.list).toBe('list1') }) }) @@ -368,14 +368,14 @@ describe('Parse Task Text', () => { describe('Assignee', () => { it('should parse an assignee', () => { - const result = parseTaskText('Lorem Ipsum @user') + const result = parseTaskText('Lorem Ipsum +user') expect(result.text).toBe('Lorem Ipsum') expect(result.assignees).toHaveLength(1) expect(result.assignees[0]).toBe('user') }) it('should parse multiple assignees', () => { - const result = parseTaskText('Lorem Ipsum @user1 @user2 @user3') + const result = parseTaskText('Lorem Ipsum +user1 +user2 +user3') expect(result.text).toBe('Lorem Ipsum') expect(result.assignees).toHaveLength(3) @@ -384,7 +384,7 @@ describe('Parse Task Text', () => { expect(result.assignees[2]).toBe('user3') }) it('should parse avoid duplicate assignees', () => { - const result = parseTaskText('Lorem Ipsum @user1 @user1 @user2') + const result = parseTaskText('Lorem Ipsum +user1 +user1 +user2') expect(result.text).toBe('Lorem Ipsum') expect(result.assignees).toHaveLength(2) @@ -392,14 +392,14 @@ describe('Parse Task Text', () => { expect(result.assignees[1]).toBe('user2') }) it('should parse an assignee with a space in it', () => { - const result = parseTaskText(`Lorem Ipsum @'user with long name'`) + const result = parseTaskText(`Lorem Ipsum +'user with long name'`) expect(result.text).toBe('Lorem Ipsum') expect(result.assignees).toHaveLength(1) expect(result.assignees[0]).toBe('user with long name') }) it('should parse an assignee with a space in it and "', () => { - const result = parseTaskText(`Lorem Ipsum @"user with long name"`) + const result = parseTaskText(`Lorem Ipsum +"user with long name"`) expect(result.text).toBe('Lorem Ipsum') expect(result.assignees).toHaveLength(1)