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 (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"log"
|
"log"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"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)
|
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)))
|
task.Content = string(md.Markdown([]byte(task.Content)))
|
||||||
// TaskContent = strings.Replace(TaskContent, "\n", "<br>", -1)
|
// TaskContent = strings.Replace(TaskContent, "\n", "<br>", -1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
|
|
||||||
<span class="noteContent">
|
<span class="noteContent">
|
||||||
{{$value.Content}}
|
{{$value.Content}}
|
||||||
|
{{$value.CompletedMsg}}
|
||||||
<div class="commentslist">
|
<div class="commentslist">
|
||||||
{{range $value.Comments}}
|
{{range $value.Comments}}
|
||||||
<div class="comment">
|
<div class="comment">
|
||||||
|
|
|
@ -16,6 +16,7 @@ type Task struct {
|
||||||
Comments []Comment `json:"comments,omitempty"`
|
Comments []Comment `json:"comments,omitempty"`
|
||||||
IsOverdue bool `json:"isoverdue, omitempty"`
|
IsOverdue bool `json:"isoverdue, omitempty"`
|
||||||
IsHidden int `json:"ishidden, omitempty`
|
IsHidden int `json:"ishidden, omitempty`
|
||||||
|
CompletedMsg string `json:"ishidden, omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Tasks []Task
|
type Tasks []Task
|
||||||
|
|
Loading…
Reference in New Issue