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-model="newTaskText"
ref="newTaskInput"
@keyup="errorMessage = ''"
/>
<span class="icon is-small is-left">
<icon icon="tasks"/>
</span>
<icon icon="tasks"/>
</span>
</p>
<p class="control">
<x-button
@ -26,10 +27,10 @@
</x-button>
</p>
</div>
<p class="help is-danger" v-if="showError && newTaskText === ''">
{{ $t('list.list.addTitleRequired') }}
<p class="help is-danger" v-if="errorMessage !== ''">
{{ errorMessage }}
</p>
<quick-add-magic v-if="!showError"/>
<quick-add-magic v-if="errorMessage === ''"/>
</div>
<!-- <div class="field is-grouped" >-->
<!-- <p-->
@ -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)
})
},

View File

@ -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)
})
}),
)
})

View File

@ -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"