diff --git a/src/components/tasks/add-task.vue b/src/components/tasks/add-task.vue index d52623978..4b7894a8d 100644 --- a/src/components/tasks/add-task.vue +++ b/src/components/tasks/add-task.vue @@ -11,10 +11,11 @@ v-focus v-model="newTaskText" ref="newTaskInput" + @keyup="errorMessage = ''" /> - - + +

-

- {{ $t('list.list.addTitleRequired') }} +

+ {{ errorMessage }}

- + @@ -84,7 +85,7 @@ export default { labelService: LabelService, labelTaskService: LabelTaskService, listIdToUse: null, - showError: false, + errorMessage: '', } }, mixins: [ @@ -117,17 +118,21 @@ export default { methods: { addTask() { if (this.newTaskText === '') { - this.showError = true + this.errorMessage = this.$t('list.create.addTitleRequired') return } - this.showError = false + this.errorMessage = '' - this.createNewTask(this.newTaskText, 0, this.listIdToUse) + this.createNewTask(this.newTaskText, 0, this.$store.state.auth.settings.defaultListId) .then(task => { this.newTaskText = '' this.$emit('taskAdded', task) }) .catch(e => { + if (e === 'NO_LIST') { + this.errorMessage = this.$t('list.create.addListRequired') + return + } this.error(e) }) }, diff --git a/src/components/tasks/mixins/createTask.js b/src/components/tasks/mixins/createTask.js index 2b7b8c8d3..4484fc5e8 100644 --- a/src/components/tasks/mixins/createTask.js +++ b/src/components/tasks/mixins/createTask.js @@ -34,7 +34,11 @@ export default { if (listId === null) { listId = lId !== 0 ? lId : this.$route.params.listId } - + + if (typeof listId === 'undefined' || listId === 0) { + return Promise.reject('NO_LIST') + } + // Separate closure because we need to wait for the results of the user search if users were entered in the // task create request. Because _that_ happens in a promise, we'll need something to call when it resolves. const createTask = () => { @@ -83,7 +87,7 @@ export default { .then(res => { return addLabelToTask(res) }) - .catch(e => Promise.reject(e)) + .catch(e => Promise.reject(e)), ) } }) @@ -110,7 +114,7 @@ export default { assignees.push(user) } return Promise.resolve(users) - }) + }), ) }) diff --git a/src/i18n/lang/en.json b/src/i18n/lang/en.json index 889ed5e9a..6c6b832df 100644 --- a/src/i18n/lang/en.json +++ b/src/i18n/lang/en.json @@ -109,7 +109,8 @@ "header": "Create a new list", "titlePlaceholder": "The list's title goes here…", "addTitleRequired": "Please specify a title.", - "createdSuccess": "The list was successfully created." + "createdSuccess": "The list was successfully created.", + "addListRequired": "Please specify a list or set a default list in the settings." }, "archive": { "title": "Archive \"{list}\"", @@ -204,7 +205,6 @@ "title": "List", "add": "Add", "addPlaceholder": "Add a new task…", - "addTitleRequired": "Please specify a title.", "empty": "This list is currently empty.", "newTaskCta": "Create a new task.", "editTask": "Edit Task"