forked from OrgGo/Tasks
We now show the task list status, x out of x completed
This commit is contained in:
parent
65a05d54ba
commit
e0ec55ac2c
14
db/tasks.go
14
db/tasks.go
|
@ -10,6 +10,7 @@ DeleteAll()
|
|||
import (
|
||||
"database/sql"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -121,6 +122,19 @@ func GetTasks(username, status, category string) (types.Context, error) {
|
|||
|
||||
err = rows.Scan(&task.Id, &task.Title, &task.Content, &TaskCreated, &task.Priority, &task.Category)
|
||||
|
||||
taskCompleted := 0
|
||||
totalTasks := 0
|
||||
|
||||
if strings.HasPrefix(task.Content, "- [") {
|
||||
for _, value := range strings.Split(task.Content, "\n") {
|
||||
if strings.HasPrefix(value, "- [x]") {
|
||||
taskCompleted += 1
|
||||
}
|
||||
totalTasks += 1
|
||||
}
|
||||
task.CompletedMsg = strconv.Itoa(taskCompleted) + " complete out of " + strconv.Itoa(totalTasks)
|
||||
}
|
||||
|
||||
task.Content = string(md.Markdown([]byte(task.Content)))
|
||||
// TaskContent = strings.Replace(TaskContent, "\n", "<br>", -1)
|
||||
if err != nil {
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
|
||||
<span class="noteContent">
|
||||
{{$value.Content}}
|
||||
{{$value.CompletedMsg}}
|
||||
<div class="commentslist">
|
||||
{{range $value.Comments}}
|
||||
<div class="comment">
|
||||
|
|
|
@ -16,6 +16,7 @@ type Task struct {
|
|||
Comments []Comment `json:"comments,omitempty"`
|
||||
IsOverdue bool `json:"isoverdue, omitempty"`
|
||||
IsHidden int `json:"ishidden, omitempty`
|
||||
CompletedMsg string `json:"ishidden, omitempty"`
|
||||
}
|
||||
|
||||
type Tasks []Task
|
||||
|
|
Loading…
Reference in New Issue