Move everything to models and services #17
|
@ -32,6 +32,7 @@
|
|||
import router from '../../router'
|
||||
import {HTTP} from '../../http-common'
|
||||
import message from '../../message'
|
||||
import TaskService from '../../services/task'
|
||||
|
||||
export default {
|
||||
name: "ShowTasks",
|
||||
|
@ -39,7 +40,8 @@
|
|||
return {
|
||||
loading: true,
|
||||
tasks: [],
|
||||
hasUndoneTasks: false
|
||||
hasUndoneTasks: false,
|
||||
taskService: TaskService,
|
||||
}
|
||||
},
|
||||
props: {
|
||||
|
@ -48,10 +50,22 @@
|
|||
showAll: Boolean,
|
||||
},
|
||||
created() {
|
||||
this.taskService = new TaskService()
|
||||
this.loadPendingTasks()
|
||||
},
|
||||
methods: {
|
||||
loadPendingTasks() {
|
||||
// We can't really make this code work until 0.6 is released which will make this exact thing a lot easier.
|
||||
// Because the feature we need here (specifying sort order and start/end date via query parameters) is already in master, we'll just wait and use the legacy method until then.
|
||||
/*
|
||||
let taskDummy = new TaskModel() // Used to specify options for the request
|
||||
this.taskService.getAll(taskDummy)
|
||||
.then(r => {
|
||||
this.tasks = r
|
||||
})
|
||||
.catch(e => {
|
||||
message.error(e, this)
|
||||
})*/
|
||||
const cancel = message.setLoading(this)
|
||||
|
||||
let url = `tasks/all/duedate`
|
||||
|
|
|
@ -30,10 +30,10 @@ export default class TaskModel extends AbstractModel {
|
|||
assignees: [],
|
||||
|
||||
dueDate: 0,
|
||||
startDate: 0,
|
||||
endDate: 0,
|
||||
repeatAfter: 0,
|
||||
reminderDates: [],
|
||||
startDate: 0,
|
||||
subtasks: [],
|
||||
parentTaskID: 0,
|
||||
|
||||
|
@ -42,6 +42,7 @@ export default class TaskModel extends AbstractModel {
|
|||
updated: 0,
|
||||
|
||||
listID: 0, // Meta, only used when creating a new task
|
||||
sortBy: 'duedate', // Meta, only used when listing all tasks
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ export default class TaskService extends AbstractService {
|
|||
constructor() {
|
||||
super({
|
||||
create: '/lists/{listID}',
|
||||
getAll: '/tasks/all',
|
||||
getAll: '/tasks/all/{sortBy}/{startDate}/{endDate}',
|
||||
update: '/tasks/{id}',
|
||||
delete: '/tasks/{id}',
|
||||
});
|
||||
|
|
Reference in New Issue
Block a user