Fixed not being able to create new tasks
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
konrad 2019-04-29 21:23:56 +02:00
parent 3ae66346a6
commit ccf90d4e31
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 20 additions and 9 deletions

View File

@ -3,7 +3,7 @@
<form @submit.prevent="addTask()">
<div class="field is-grouped">
<p class="control has-icons-left is-expanded" :class="{ 'is-loading': taskService.loading}">
<input v-focus class="input" :class="{ 'disabled': taskService.loading}" v-model="newTask.text" type="text" placeholder="Add a new task...">
<input v-focus class="input" :class="{ 'disabled': taskService.loading}" v-model="newTaskText" type="text" placeholder="Add a new task...">
<span class="icon is-small is-left">
<icon icon="tasks"/>
</span>
@ -102,7 +102,7 @@
list: {},
isTaskEdit: false,
taskEditTask: TaskModel,
newTask: TaskModel,
newTaskText: '',
priorities: {},
}
},
@ -135,8 +135,8 @@
},
methods: {
addTask() {
this.newTask.listID = this.$route.params.id
this.taskService.create(this.newTask)
let task = new TaskModel({text: this.newTaskText, listID: this.$route.params.id})
this.taskService.create(task)
.then(r => {
this.list.addTaskToList(r)
message.success({message: 'The task was successfully created.'}, this)
@ -144,8 +144,6 @@
.catch(e => {
message.error(e, this)
})
this.newTask = {}
},
markAsDone(e) {
let updateFunc = () => {

View File

@ -16,6 +16,17 @@ export default class TaskService extends AbstractService {
}
beforeUpdate(model) {
return this.processModel(model)
}
beforeCreate(model) {
return this.processModel(model)
}
processModel(model) {
// Ensure the listID is an int
model.listID = Number(model.listID)
// Convert the date in a unix timestamp
model.dueDate = Math.round(+new Date(model.dueDate) / 1000)
model.startDate = Math.round(+new Date(model.startDate) / 1000)
@ -29,9 +40,11 @@ export default class TaskService extends AbstractService {
}
// Make normal timestamps from js dates
model.reminderDates = model.reminderDates.map(r => {
return Math.round(+new Date(r) / 1000)
})
if(model.reminderDates.length > 0) {
model.reminderDates = model.reminderDates.map(r => {
return Math.round(+new Date(r) / 1000)
})
}
// Make the repeating amount to seconds
let repeatAfterSeconds = 0