Added percent done to tasks (#102)
This commit is contained in:
@ -204,4 +204,11 @@
|
||||
list_id: 3
|
||||
created: 1543626724
|
||||
updated: 1543626724
|
||||
- id: 33
|
||||
text: 'task #33 with percent done'
|
||||
created_by_id: 1
|
||||
list_id: 1
|
||||
percent_done: 0.5
|
||||
created: 1543626724
|
||||
updated: 1543626724
|
||||
|
||||
|
@ -336,6 +336,16 @@ func sortTasksForTesting(by SortBy) (tasks []*Task) {
|
||||
Created: 1543626724,
|
||||
Updated: 1543626724,
|
||||
},
|
||||
{
|
||||
ID: 33,
|
||||
Text: "task #33 with percent done",
|
||||
CreatedByID: 1,
|
||||
CreatedBy: user1,
|
||||
ListID: 1,
|
||||
PercentDone: 0.5,
|
||||
Created: 1543626724,
|
||||
Updated: 1543626724,
|
||||
},
|
||||
}
|
||||
|
||||
switch by {
|
||||
|
@ -60,6 +60,8 @@ type Task struct {
|
||||
Labels []*Label `xorm:"-" json:"labels"`
|
||||
// The task color in hex
|
||||
HexColor string `xorm:"varchar(6) null" json:"hexColor" valid:"runelength(0|6)" maxLength:"6"`
|
||||
// Determines how far a task is left from being done
|
||||
PercentDone float64 `xorm:"DOUBLE null" json:"percentDone"`
|
||||
|
||||
// The UID is currently not used for anything other than caldav, which is why we don't expose it over json
|
||||
UID string `xorm:"varchar(250) null" json:"-"`
|
||||
@ -632,6 +634,10 @@ func (t *Task) Update() (err error) {
|
||||
if t.HexColor == "" {
|
||||
ot.HexColor = ""
|
||||
}
|
||||
// Percent DOnw
|
||||
if t.PercentDone == 0 {
|
||||
ot.PercentDone = 0
|
||||
}
|
||||
|
||||
_, err = x.ID(t.ID).
|
||||
Cols("text",
|
||||
@ -644,7 +650,8 @@ func (t *Task) Update() (err error) {
|
||||
"start_date_unix",
|
||||
"end_date_unix",
|
||||
"hex_color",
|
||||
"done_at_unix").
|
||||
"done_at_unix",
|
||||
"percent_done").
|
||||
Update(ot)
|
||||
*t = ot
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user