Subtasks (#28)
This commit is contained in:
parent
007d8ec375
commit
6c5885747b
8 changed files with 59 additions and 11 deletions
|
@ -163,7 +163,7 @@ Teams sind global, d.h. Ein Team kann mehrere Namespaces verwalten.
|
||||||
* [ ] Labels
|
* [ ] Labels
|
||||||
* [ ] Priorities
|
* [ ] Priorities
|
||||||
* [ ] Assignees
|
* [ ] Assignees
|
||||||
* [ ] Subtasks
|
* [x] Subtasks
|
||||||
* [ ] Attachments
|
* [ ] Attachments
|
||||||
* [x] Repeating tasks
|
* [x] Repeating tasks
|
||||||
* [x] Tagesübersicht ("Was ist heute/diese Woche due?") -> Machen letztenendes die Clients, wir brauchen nur nen endpoint, der alle tasks auskotzt, der Client macht dann die Sortierung.
|
* [x] Tagesübersicht ("Was ist heute/diese Woche due?") -> Machen letztenendes die Clients, wir brauchen nur nen endpoint, der alle tasks auskotzt, der Client macht dann die Sortierung.
|
||||||
|
|
|
@ -25,7 +25,7 @@ Try it under [try.vikunja.io](https://try.vikunja.io)!
|
||||||
* [ ] Labels for todo lists and tasks
|
* [ ] Labels for todo lists and tasks
|
||||||
* [ ] Prioritize tasks
|
* [ ] Prioritize tasks
|
||||||
* [ ] Assign users to tasks
|
* [ ] Assign users to tasks
|
||||||
* [ ] Subtasks
|
* [x] Subtasks
|
||||||
* [x] Repeating tasks
|
* [x] Repeating tasks
|
||||||
* [ ] Attachments on tasks
|
* [ ] Attachments on tasks
|
||||||
* [ ] Get all tasks for you per interval (day/month/period)
|
* [ ] Get all tasks for you per interval (day/month/period)
|
||||||
|
|
|
@ -3,8 +3,8 @@ POST http://localhost:8080/api/v1/login
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"username": "user5",
|
"username": "user",
|
||||||
"password": "1234"
|
"password": "12345"
|
||||||
}
|
}
|
||||||
|
|
||||||
> {% client.global.set("auth_token", response.body.token); %}
|
> {% client.global.set("auth_token", response.body.token); %}
|
||||||
|
|
|
@ -22,11 +22,15 @@ Content-Type: application/json
|
||||||
###
|
###
|
||||||
|
|
||||||
# Add a new item
|
# Add a new item
|
||||||
PUT http://localhost:8080/api/v1/lists/14
|
PUT http://localhost:8080/api/v1/lists/15
|
||||||
Authorization: Bearer {{auth_token}}
|
Authorization: Bearer {{auth_token}}
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{"text": "test2", "description": "Schinken"}
|
{
|
||||||
|
"text": "this is a subtask 2",
|
||||||
|
"description": "Schinken",
|
||||||
|
"parentTaskID": 34
|
||||||
|
}
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
|
|
11
docs/docs.go
11
docs/docs.go
|
@ -1,6 +1,6 @@
|
||||||
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
||||||
// This file was generated by swaggo/swag at
|
// This file was generated by swaggo/swag at
|
||||||
// 2018-12-01 02:54:44.444779863 +0100 CET m=+0.257728460
|
// 2018-12-01 03:00:26.732522708 +0100 CET m=+0.097387323
|
||||||
|
|
||||||
package docs
|
package docs
|
||||||
|
|
||||||
|
@ -2877,6 +2877,9 @@ var doc = `{
|
||||||
"listID": {
|
"listID": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
"parentTaskID": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
"reminderDates": {
|
"reminderDates": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
@ -2886,6 +2889,12 @@ var doc = `{
|
||||||
"repeatAfter": {
|
"repeatAfter": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
"subtasks": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/models.ListTask"
|
||||||
|
}
|
||||||
|
},
|
||||||
"text": {
|
"text": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
|
@ -2864,6 +2864,9 @@
|
||||||
"listID": {
|
"listID": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
"parentTaskID": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
"reminderDates": {
|
"reminderDates": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
@ -2873,6 +2876,12 @@
|
||||||
"repeatAfter": {
|
"repeatAfter": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
"subtasks": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/models.ListTask"
|
||||||
|
}
|
||||||
|
},
|
||||||
"text": {
|
"text": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
|
@ -53,12 +53,18 @@ definitions:
|
||||||
type: integer
|
type: integer
|
||||||
listID:
|
listID:
|
||||||
type: integer
|
type: integer
|
||||||
|
parentTaskID:
|
||||||
|
type: integer
|
||||||
reminderDates:
|
reminderDates:
|
||||||
items:
|
items:
|
||||||
type: integer
|
type: integer
|
||||||
type: array
|
type: array
|
||||||
repeatAfter:
|
repeatAfter:
|
||||||
type: integer
|
type: integer
|
||||||
|
subtasks:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/models.ListTask'
|
||||||
|
type: array
|
||||||
text:
|
text:
|
||||||
type: string
|
type: string
|
||||||
updated:
|
updated:
|
||||||
|
|
|
@ -29,6 +29,9 @@ type ListTask struct {
|
||||||
CreatedByID int64 `xorm:"int(11)" json:"-"` // ID of the user who put that task on the list
|
CreatedByID int64 `xorm:"int(11)" json:"-"` // ID of the user who put that task on the list
|
||||||
ListID int64 `xorm:"int(11) INDEX" json:"listID" param:"list"`
|
ListID int64 `xorm:"int(11) INDEX" json:"listID" param:"list"`
|
||||||
RepeatAfter int64 `xorm:"int(11) INDEX" json:"repeatAfter"`
|
RepeatAfter int64 `xorm:"int(11) INDEX" json:"repeatAfter"`
|
||||||
|
ParentTaskID int64 `xorm:"int(11) INDEX" json:"parentTaskID"`
|
||||||
|
|
||||||
|
Subtasks []*ListTask `xorm:"-" json:"subtasks"`
|
||||||
|
|
||||||
Created int64 `xorm:"created" json:"created"`
|
Created int64 `xorm:"created" json:"created"`
|
||||||
Updated int64 `xorm:"updated" json:"updated"`
|
Updated int64 `xorm:"updated" json:"updated"`
|
||||||
|
@ -56,6 +59,9 @@ func GetTasksByListID(listID int64) (tasks []*ListTask, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make a map so we can put in subtasks more easily
|
||||||
|
taskMap := make(map[int64]*ListTask)
|
||||||
|
|
||||||
// Get all users and put them into the array
|
// Get all users and put them into the array
|
||||||
var userIDs []int64
|
var userIDs []int64
|
||||||
for _, i := range tasks {
|
for _, i := range tasks {
|
||||||
|
@ -70,6 +76,8 @@ func GetTasksByListID(listID int64) (tasks []*ListTask, err error) {
|
||||||
if !found {
|
if !found {
|
||||||
userIDs = append(userIDs, i.CreatedByID)
|
userIDs = append(userIDs, i.CreatedByID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taskMap[i.ID] = i
|
||||||
}
|
}
|
||||||
|
|
||||||
var users []User
|
var users []User
|
||||||
|
@ -78,16 +86,28 @@ func GetTasksByListID(listID int64) (tasks []*ListTask, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for in, task := range tasks {
|
// Add all user objects to the appropriate tasks
|
||||||
|
for _, task := range taskMap {
|
||||||
|
|
||||||
|
// Make created by user objects
|
||||||
for _, u := range users {
|
for _, u := range users {
|
||||||
if task.CreatedByID == u.ID {
|
if task.CreatedByID == u.ID {
|
||||||
tasks[in].CreatedBy = u
|
taskMap[task.ID].CreatedBy = u
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// obsfucate the user password
|
// Reorder all subtasks
|
||||||
tasks[in].CreatedBy.Password = ""
|
if task.ParentTaskID != 0 {
|
||||||
|
taskMap[task.ParentTaskID].Subtasks = append(taskMap[task.ParentTaskID].Subtasks, task)
|
||||||
|
delete(taskMap, task.ID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// make a complete slice from the map
|
||||||
|
tasks = []*ListTask{}
|
||||||
|
for _, t := range taskMap {
|
||||||
|
tasks = append(tasks, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue