feat(task wizard): show error message when no title is provided

This commit is contained in:
kolaente 2022-09-21 21:59:37 +02:00
parent bf027397b5
commit d950aae3a5
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -12,7 +12,10 @@
v-model="newTask.title" v-model="newTask.title"
v-focus v-focus
/> />
<QuickAddMagic class="ml-4"/> <p class="help is-danger ml-4" v-if="errorMessage !== ''">
{{ errorMessage }}
</p>
<QuickAddMagic class="ml-4" v-else/>
<BaseButton <BaseButton
v-if="!descriptionFormVisible" v-if="!descriptionFormVisible"
@click="() => descriptionFormVisible = true" @click="() => descriptionFormVisible = true"
@ -63,6 +66,7 @@ const heading = computed(() => {
: t('task.new') : t('task.new')
}) })
const errorMessage = ref('')
const descriptionFormVisible = ref(false) const descriptionFormVisible = ref(false)
const newTask = ref<ITask>(new TaskModel({})) const newTask = ref<ITask>(new TaskModel({}))
const taskService = ref(new TaskService()) const taskService = ref(new TaskService())
@ -70,6 +74,12 @@ const taskService = ref(new TaskService())
const parsedTask = computed(() => parseTaskText(newTask.value.title, getQuickAddMagicMode())) const parsedTask = computed(() => parseTaskText(newTask.value.title, getQuickAddMagicMode()))
async function create() { async function create() {
if (newTask.value.title === '') {
errorMessage.value = t('list.create.addTitleRequired')
return
}
errorMessage.value = ''
newTask.value.listId = props.listId newTask.value.listId = props.listId
newTask.value.title = parsedTask.value.text newTask.value.title = parsedTask.value.text
const assignees = await findAssignees(parsedTask.value.assignees) const assignees = await findAssignees(parsedTask.value.assignees)