ability to hide tasks from the timeline
This commit is contained in:
parent
47d4f3a345
commit
11e232abfa
28
db/tasks.go
28
db/tasks.go
|
@ -89,11 +89,11 @@ func GetTasks(username, status, category string) (types.Context, error) {
|
||||||
if category == "" {
|
if category == "" {
|
||||||
switch status {
|
switch status {
|
||||||
case "pending":
|
case "pending":
|
||||||
getTaskSQL = basicSQL + " and s.status='PENDING'"
|
getTaskSQL = basicSQL + " and s.status='PENDING' and t.hide!=1"
|
||||||
case "deleted":
|
case "deleted":
|
||||||
getTaskSQL = basicSQL + " and s.status='DELETED' "
|
getTaskSQL = basicSQL + " and s.status='DELETED' and t.hide!=1"
|
||||||
case "completed":
|
case "completed":
|
||||||
getTaskSQL = basicSQL + " and s.status='COMPLETE'"
|
getTaskSQL = basicSQL + " and s.status='COMPLETE' and t.hide!=1"
|
||||||
}
|
}
|
||||||
|
|
||||||
getTaskSQL += " order by t.created_date asc"
|
getTaskSQL += " order by t.created_date asc"
|
||||||
|
@ -152,12 +152,12 @@ func GetTaskByID(username string, id int) (types.Context, error) {
|
||||||
var tasks []types.Task
|
var tasks []types.Task
|
||||||
var task types.Task
|
var task types.Task
|
||||||
|
|
||||||
getTaskSQL := "select t.id, t.title, t.content, t.priority, 'UNCATEGORIZED' from task t join user u where t.user_id=u.id and t.cat_id=0 union select t.id, t.title, t.content, t.priority, c.name from task t join user u left outer join category c where c.id = t.cat_id and t.user_id=u.id and t.id=? and u.username=?;"
|
getTaskSQL := "select t.id, t.title, t.content, t.priority, t.hide, 'UNCATEGORIZED' from task t join user u where t.user_id=u.id and t.cat_id=0 union select t.id, t.title, t.content, t.priority, c.name from task t join user u left outer join category c where c.id = t.cat_id and t.user_id=u.id and t.id=? and u.username=?;"
|
||||||
|
|
||||||
rows := database.query(getTaskSQL, id, username)
|
rows := database.query(getTaskSQL, id, username)
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
if rows.Next() {
|
if rows.Next() {
|
||||||
err := rows.Scan(&task.Id, &task.Title, &task.Content, &task.Priority, &task.Category)
|
err := rows.Scan(&task.Id, &task.Title, &task.Content, &task.Priority, &task.IsHidden, &task.Category)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
//send email to respective people
|
//send email to respective people
|
||||||
|
@ -205,23 +205,27 @@ func DeleteTask(username string, id int) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
//AddTask is used to add the task in the database
|
//AddTask is used to add the task in the database
|
||||||
func AddTask(title, content, category string, taskPriority int, username, dueDate string) error {
|
//TODO: add dueDate feature later
|
||||||
|
func AddTask(title, content, category string, taskPriority int, username string, hidden int) error {
|
||||||
log.Println("AddTask: started function")
|
log.Println("AddTask: started function")
|
||||||
var err error
|
var err error
|
||||||
timeDueDate, err := time.Parse("31/12/2016", dueDate)
|
// var timeDueDate time.Time
|
||||||
if err != nil {
|
// if dueDate != "" {
|
||||||
log.Fatal(err)
|
// timeDueDate, err = time.Parse("31/12/2016", dueDate)
|
||||||
}
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
userID, err := GetUserID(username)
|
userID, err := GetUserID(username)
|
||||||
if err != nil && (title != "" || content != "") {
|
if err != nil && (title != "" || content != "") {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if category == "" {
|
if category == "" {
|
||||||
err = taskQuery("insert into task(title, content, priority, task_status_id, created_date, last_modified_at, user_id,due_date) values(?,?,?,?,datetime(), datetime(),?)", title, content, taskPriority, taskStatus["PENDING"], userID, timeDueDate)
|
err = taskQuery("insert into task(title, content, priority, task_status_id, created_date, last_modified_at, user_id,hide) values(?,?,?,?,datetime(), datetime(),?,?)", title, content, taskPriority, taskStatus["PENDING"], userID, hidden)
|
||||||
} else {
|
} else {
|
||||||
categoryID := GetCategoryByName(username, category)
|
categoryID := GetCategoryByName(username, category)
|
||||||
err = taskQuery("insert into task(title, content, priority, created_date, last_modified_at, cat_id, task_status_id, user_id,due_date) values(?,?,?,datetime(), datetime(), ?,?,?)", title, content, taskPriority, categoryID, taskStatus["PENDING"], userID, timeDueDate)
|
err = taskQuery("insert into task(title, content, priority, created_date, last_modified_at, cat_id, task_status_id, user_id,hide) values(?,?,?,datetime(), datetime(), ?,?,?,?)", title, content, taskPriority, categoryID, taskStatus["PENDING"], userID, hidden)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
<input type="radio" name="priority" value="2" {{if eq .Priority "2"}} checked="checked" {{end}} /> Medium
|
<input type="radio" name="priority" value="2" {{if eq .Priority "2"}} checked="checked" {{end}} /> Medium
|
||||||
<input type="radio" name="priority" value="1" {{if eq .Priority "1"}} checked="checked" {{end}} /> Low
|
<input type="radio" name="priority" value="1" {{if eq .Priority "1"}} checked="checked" {{end}} /> Low
|
||||||
</div>
|
</div>
|
||||||
|
<input type="checkbox" name="hide" id="hideChk"> Hide from timeline
|
||||||
Category:
|
Category:
|
||||||
<select name="category">
|
<select name="category">
|
||||||
<option>---</option>
|
<option>---</option>
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
<input type="radio" name="priority" value="3" /> High
|
<input type="radio" name="priority" value="3" /> High
|
||||||
<input type="radio" name="priority" value="2" /> Medium
|
<input type="radio" name="priority" value="2" /> Medium
|
||||||
<input type="radio" name="priority" value="1" /> Low
|
<input type="radio" name="priority" value="1" /> Low
|
||||||
|
<br>
|
||||||
|
<input type="checkbox" name="hide" id="hideChk"> Hide from timeline
|
||||||
</div>
|
</div>
|
||||||
Category:
|
Category:
|
||||||
<select name="category" class="dropdown">
|
<select name="category" class="dropdown">
|
||||||
|
|
|
@ -15,6 +15,7 @@ type Task struct {
|
||||||
Referer string `json:"referer,omitempty"`
|
Referer string `json:"referer,omitempty"`
|
||||||
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`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Tasks []Task
|
type Tasks []Task
|
||||||
|
|
|
@ -64,8 +64,14 @@ func AddTaskFunc(w http.ResponseWriter, r *http.Request) {
|
||||||
if !found {
|
if !found {
|
||||||
taskPriority = 1
|
taskPriority = 1
|
||||||
}
|
}
|
||||||
|
var hidden int
|
||||||
dueDate := r.FormValue("dueDate")
|
hideTimeline := r.FormValue("hide")
|
||||||
|
if hideTimeline != "" {
|
||||||
|
hidden = 1
|
||||||
|
} else {
|
||||||
|
hidden = 0
|
||||||
|
}
|
||||||
|
// dueDate := r.FormValue("dueDate")
|
||||||
category := r.FormValue("category")
|
category := r.FormValue("category")
|
||||||
title := template.HTMLEscapeString(r.Form.Get("title"))
|
title := template.HTMLEscapeString(r.Form.Get("title"))
|
||||||
content := template.HTMLEscapeString(r.Form.Get("content"))
|
content := template.HTMLEscapeString(r.Form.Get("content"))
|
||||||
|
@ -103,8 +109,8 @@ func AddTaskFunc(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Println("error adding task to db")
|
log.Println("error adding task to db")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taskTruth := db.AddTask(title, content, category, taskPriority, username, dueDate)
|
//taskTruth := db.AddTask(title, content, category, taskPriority, username, dueDate)
|
||||||
|
taskTruth := db.AddTask(title, content, category, taskPriority, username, hidden)
|
||||||
if taskTruth != nil {
|
if taskTruth != nil {
|
||||||
message = "Error adding task"
|
message = "Error adding task"
|
||||||
log.Println("error adding task to db")
|
log.Println("error adding task to db")
|
||||||
|
|
|
@ -183,10 +183,17 @@ func AddTaskFuncAPI(w http.ResponseWriter, r *http.Request) {
|
||||||
if !found {
|
if !found {
|
||||||
taskPriority = 1
|
taskPriority = 1
|
||||||
}
|
}
|
||||||
|
var hidden int
|
||||||
|
hideTimeline := r.FormValue("hide")
|
||||||
|
if hideTimeline != "" {
|
||||||
|
hidden = 1
|
||||||
|
} else {
|
||||||
|
hidden = 0
|
||||||
|
}
|
||||||
var taskErr bool
|
var taskErr bool
|
||||||
|
|
||||||
if title != "" && content != "" {
|
if title != "" && content != "" {
|
||||||
taskTruth := db.AddTask(title, content, category, taskPriority, username, "")
|
taskTruth := db.AddTask(title, content, category, taskPriority, username, hidden)
|
||||||
if taskTruth != nil {
|
if taskTruth != nil {
|
||||||
taskErr = true
|
taskErr = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue