Check if we have a list specified

This commit is contained in:
kolaente 2021-07-17 21:34:14 +02:00
parent 0e02b38c1e
commit e405ebe88f
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 23 additions and 14 deletions

View File

@ -11,10 +11,11 @@
v-focus v-focus
v-model="newTaskText" v-model="newTaskText"
ref="newTaskInput" ref="newTaskInput"
@keyup="errorMessage = ''"
/> />
<span class="icon is-small is-left"> <span class="icon is-small is-left">
<icon icon="tasks"/> <icon icon="tasks"/>
</span> </span>
</p> </p>
<p class="control"> <p class="control">
<x-button <x-button
@ -26,10 +27,10 @@
</x-button> </x-button>
</p> </p>
</div> </div>
<p class="help is-danger" v-if="showError && newTaskText === ''"> <p class="help is-danger" v-if="errorMessage !== ''">
{{ $t('list.list.addTitleRequired') }} {{ errorMessage }}
</p> </p>
<quick-add-magic v-if="!showError"/> <quick-add-magic v-if="errorMessage === ''"/>
</div> </div>
<!-- <div class="field is-grouped" >--> <!-- <div class="field is-grouped" >-->
<!-- <p--> <!-- <p-->
@ -84,7 +85,7 @@ export default {
labelService: LabelService, labelService: LabelService,
labelTaskService: LabelTaskService, labelTaskService: LabelTaskService,
listIdToUse: null, listIdToUse: null,
showError: false, errorMessage: '',
} }
}, },
mixins: [ mixins: [
@ -117,17 +118,21 @@ export default {
methods: { methods: {
addTask() { addTask() {
if (this.newTaskText === '') { if (this.newTaskText === '') {
this.showError = true this.errorMessage = this.$t('list.create.addTitleRequired')
return 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 => { .then(task => {
this.newTaskText = '' this.newTaskText = ''
this.$emit('taskAdded', task) this.$emit('taskAdded', task)
}) })
.catch(e => { .catch(e => {
if (e === 'NO_LIST') {
this.errorMessage = this.$t('list.create.addListRequired')
return
}
this.error(e) this.error(e)
}) })
}, },

View File

@ -34,7 +34,11 @@ export default {
if (listId === null) { if (listId === null) {
listId = lId !== 0 ? lId : this.$route.params.listId 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 // 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. // task create request. Because _that_ happens in a promise, we'll need something to call when it resolves.
const createTask = () => { const createTask = () => {
@ -83,7 +87,7 @@ export default {
.then(res => { .then(res => {
return addLabelToTask(res) return addLabelToTask(res)
}) })
.catch(e => Promise.reject(e)) .catch(e => Promise.reject(e)),
) )
} }
}) })
@ -110,7 +114,7 @@ export default {
assignees.push(user) assignees.push(user)
} }
return Promise.resolve(users) return Promise.resolve(users)
}) }),
) )
}) })

View File

@ -109,7 +109,8 @@
"header": "Create a new list", "header": "Create a new list",
"titlePlaceholder": "The list's title goes here…", "titlePlaceholder": "The list's title goes here…",
"addTitleRequired": "Please specify a title.", "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": { "archive": {
"title": "Archive \"{list}\"", "title": "Archive \"{list}\"",
@ -204,7 +205,6 @@
"title": "List", "title": "List",
"add": "Add", "add": "Add",
"addPlaceholder": "Add a new task…", "addPlaceholder": "Add a new task…",
"addTitleRequired": "Please specify a title.",
"empty": "This list is currently empty.", "empty": "This list is currently empty.",
"newTaskCta": "Create a new task.", "newTaskCta": "Create a new task.",
"editTask": "Edit Task" "editTask": "Edit Task"