Bug fixes for hidden task

This commit is contained in:
Suraj Patil 2016-08-07 16:05:57 +05:30
parent 46b4e52100
commit 07767a0a0c
4 changed files with 22 additions and 5 deletions

View File

@ -152,7 +152,7 @@ func GetTaskByID(username string, id int) (types.Context, error) {
var tasks []types.Task
var task types.Task
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=?;"
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, t.hide, 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)
defer rows.Close()
@ -250,7 +250,7 @@ func GetCategoryIDByName(username string, category string) int {
}
//UpdateTask is used to update the tasks in the database
func UpdateTask(id int, title, content, category string, priority int, username string) error {
func UpdateTask(id int, title, content, category string, priority int, username string, hidden int) error {
categoryID := GetCategoryIDByName(username, category)
userID, err := GetUserID(username)
if err != nil {

View File

@ -18,7 +18,7 @@
<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
</div>
<input type="checkbox" name="hide" id="hideChk"> Hide from timeline
<input type="checkbox" name="hide" id="hideChk"> Hide from timeline<br>
Category:
<select name="category">
<option>---</option>

View File

@ -262,8 +262,16 @@ func UpdateTaskFuncAPI(w http.ResponseWriter, r *http.Request) {
priority = 1
}
var hidden int
hideTimeline := r.FormValue("hide")
if hideTimeline != "" {
hidden = 1
} else {
hidden = 0
}
if strID != "" && title != "" && content != "" {
err = db.UpdateTask(id, title, content, category, priority, username)
err = db.UpdateTask(id, title, content, category, priority, username, hidden)
if err != nil {
taskErr = true
}

View File

@ -109,7 +109,16 @@ func UpdateTaskFunc(w http.ResponseWriter, r *http.Request) {
log.Println(err)
}
username := sessions.GetCurrentUserName(r)
err = db.UpdateTask(id, title, content, category, priority, username)
var hidden int
hideTimeline := r.FormValue("hide")
if hideTimeline != "" {
hidden = 1
} else {
hidden = 0
}
err = db.UpdateTask(id, title, content, category, priority, username, hidden)
if err != nil {
message = "Error updating task"
} else {