create now uses the model only
All checks were successful
the build was successful

This commit is contained in:
kolaente 2019-02-22 08:37:28 +01:00
parent a31e069655
commit f98af40bd6
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 8 additions and 9 deletions

View File

@ -273,7 +273,8 @@
})
},
addTask() {
this.taskService.create({listID: this.$route.params.id}, this.newTask)
this.newTask.listID = this.$route.params.id
this.taskService.create(this.newTask)
.then(r => {
this.list.addTaskToList(r)
this.handleSuccess({message: 'The task was successfully created.'})

View File

@ -18,7 +18,6 @@ export default class TaskModel extends AbstractModel {
defaults() {
return {
id: 0,
listID: 0,
text: '',
description: '',
done: false,
@ -37,6 +36,8 @@ export default class TaskModel extends AbstractModel {
createdBy: {},
created: 0,
updated: 0,
listID: 0, // Meta, only used when creating a new task
}
}

View File

@ -4,7 +4,6 @@ import {reduce, replace} from 'lodash'
let config = require('../../public/config.json')
// TODO: Reject requests if they don't have route set
// TODO: create and get should only take the model as param
export default class AbstractService {
@ -165,15 +164,14 @@ export default class AbstractService {
/**
* Performs a put request to the url specified before
* @param pathparams
* @param data
* @param model
* @returns {Promise<any | never>}
*/
create(pathparams, data) {
create(model) {
const cancel = this.setLoading()
// Finally make the request and get our data.
return this.http.put(this.getReplacedRoute(this.paths.create, pathparams), data)
return this.http.put(this.getReplacedRoute(this.paths.create, model), model)
.catch(error => {
return this.errorHandler(error)
})
@ -187,8 +185,7 @@ export default class AbstractService {
/**
* Performs a post request to the update url
* @param pathparams
* @param data
* @param model
* @returns {Q.Promise<any>}
*/
update(model) {