forked from vikunja/frontend
Cleanup
This commit is contained in:
parent
e405ebe88f
commit
3d18c69429
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<div v-if="listIdToUse !== null">
|
||||
<div>
|
||||
<div class="field is-grouped">
|
||||
<p :class="{ 'is-loading': taskService.loading}" class="control has-icons-left is-expanded">
|
||||
<input
|
||||
|
@ -9,7 +9,7 @@
|
|||
:placeholder="$t('list.list.addPlaceholder')"
|
||||
type="text"
|
||||
v-focus
|
||||
v-model="newTaskText"
|
||||
v-model="newTaskTitle"
|
||||
ref="newTaskInput"
|
||||
@keyup="errorMessage = ''"
|
||||
/>
|
||||
|
@ -19,7 +19,7 @@
|
|||
</p>
|
||||
<p class="control">
|
||||
<x-button
|
||||
:disabled="newTaskText.length === 0"
|
||||
:disabled="newTaskTitle.length === 0"
|
||||
@click="addTask()"
|
||||
icon="plus"
|
||||
>
|
||||
|
@ -32,39 +32,6 @@
|
|||
</p>
|
||||
<quick-add-magic v-if="errorMessage === ''"/>
|
||||
</div>
|
||||
<!-- <div class="field is-grouped" >-->
|
||||
<!-- <p-->
|
||||
<!-- :class="{ 'is-loading': taskService.loading }"-->
|
||||
<!-- class="control has-icons-left is-expanded"-->
|
||||
<!-- v-if="validListIdAvailable"-->
|
||||
<!-- >-->
|
||||
<!-- <input-->
|
||||
<!-- :class="{ disabled: taskService.loading }"-->
|
||||
<!-- @keyup.enter="addTask()"-->
|
||||
<!-- class="input"-->
|
||||
<!-- placeholder="Add a new task..."-->
|
||||
<!-- type="text"-->
|
||||
<!-- v-focus-->
|
||||
<!-- v-model="newTaskText"-->
|
||||
<!-- ref="newTaskInput"-->
|
||||
<!-- />-->
|
||||
<!-- <span class="icon is-small is-left">-->
|
||||
<!-- <icon icon="tasks" />-->
|
||||
<!-- </span>-->
|
||||
<!-- </p>-->
|
||||
<!-- <p class="control" v-if="validListIdAvailable">-->
|
||||
<!-- <x-button-->
|
||||
<!-- :disabled="newTaskText.length === 0"-->
|
||||
<!-- @click="addTask()"-->
|
||||
<!-- icon="plus"-->
|
||||
<!-- >-->
|
||||
<!-- Add-->
|
||||
<!-- </x-button>-->
|
||||
<!-- </p>-->
|
||||
<!-- <p class="help is-warning" v-if="!validListIdAvailable">-->
|
||||
<!-- No default list set. Please go to settings and specify default list.-->
|
||||
<!-- </p> -->
|
||||
<!-- </div>-->
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@ -79,24 +46,17 @@ export default {
|
|||
name: 'add-task',
|
||||
data() {
|
||||
return {
|
||||
newTaskText: '',
|
||||
newTaskTitle: '',
|
||||
listService: ListService,
|
||||
taskService: TaskService,
|
||||
labelService: LabelService,
|
||||
labelTaskService: LabelTaskService,
|
||||
listIdToUse: null,
|
||||
errorMessage: '',
|
||||
}
|
||||
},
|
||||
mixins: [
|
||||
createTask,
|
||||
],
|
||||
props: {
|
||||
listId: {
|
||||
type: Number,
|
||||
required: false,
|
||||
},
|
||||
},
|
||||
components: {
|
||||
QuickAddMagic,
|
||||
},
|
||||
|
@ -106,26 +66,17 @@ export default {
|
|||
this.labelService = new LabelService()
|
||||
this.labelTaskService = new LabelTaskService()
|
||||
},
|
||||
beforeMount() {
|
||||
// If the parent provides the ID alway use that be falling back to the one
|
||||
// stored in settings. If neither are avliable then hide the component.
|
||||
if (this.listId !== undefined) {
|
||||
this.listIdToUse = this.listId
|
||||
} else if (this.$store.state.auth.settings.defaultListId !== undefined) {
|
||||
this.listIdToUse = this.$store.state.auth.settings.defaultListId
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
addTask() {
|
||||
if (this.newTaskText === '') {
|
||||
if (this.newTaskTitle === '') {
|
||||
this.errorMessage = this.$t('list.create.addTitleRequired')
|
||||
return
|
||||
}
|
||||
this.errorMessage = ''
|
||||
|
||||
this.createNewTask(this.newTaskText, 0, this.$store.state.auth.settings.defaultListId)
|
||||
this.createNewTask(this.newTaskTitle, 0, this.$store.state.auth.settings.defaultListId)
|
||||
.then(task => {
|
||||
this.newTaskText = ''
|
||||
this.newTaskTitle = ''
|
||||
this.$emit('taskAdded', task)
|
||||
})
|
||||
.catch(e => {
|
||||
|
|
|
@ -26,6 +26,11 @@ export default {
|
|||
const parsedTask = parseTaskText(newTaskTitle)
|
||||
const assignees = []
|
||||
|
||||
// Uses the following ways to get the list id of the new task:
|
||||
// 1. If specified in quick add magic, look in store if it exists and use it if it does
|
||||
// 2. Else check if a list was passed as parameter
|
||||
// 3. Otherwise use the id from the route parameter
|
||||
// 4. If none of the above worked, reject the promise with an error.
|
||||
let listId = null
|
||||
if (parsedTask.list !== null) {
|
||||
const list = this.$store.getters['lists/findListByExactname'](parsedTask.list)
|
||||
|
|
Loading…
Reference in New Issue