forked from OrgGo/Tasks
added necessary features for due date
This commit is contained in:
parent
7b62fa2488
commit
3c4a010e2c
10
db/tasks.go
10
db/tasks.go
|
@ -205,19 +205,23 @@ 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 string) error {
|
func AddTask(title, content, category string, taskPriority int, username, dueDate string) 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)
|
||||||
|
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) values(?,?,?,?,datetime(), datetime(),?)", title, content, taskPriority, taskStatus["PENDING"], userID)
|
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)
|
||||||
} 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) values(?,?,?,datetime(), datetime(), ?,?,?)", title, content, taskPriority, categoryID, taskStatus["PENDING"], userID)
|
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)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@ $(document).ready(function(){
|
||||||
$('#addNoteModal').modal('show');
|
$('#addNoteModal').modal('show');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#datepicker").datepicker();
|
||||||
|
|
||||||
$('#editCatFrmBtn').click(function(){
|
$('#editCatFrmBtn').click(function(){
|
||||||
$('#EditForm').toggleClass('hidden')
|
$('#EditForm').toggleClass('hidden')
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
<!-- Custom CSS -->
|
<!-- Custom CSS -->
|
||||||
<link href="/static/css/styles.css" rel="stylesheet">
|
<link href="/static/css/styles.css" rel="stylesheet">
|
||||||
|
<link href="/static/css/jquery-ui.min.css" rel="stylesheet">
|
||||||
<link href="/static/css/sidebar.css" rel="stylesheet">
|
<link href="/static/css/sidebar.css" rel="stylesheet">
|
||||||
<link href="/static/css/sidebar-bootstrap.css" rel="stylesheet">
|
<link href="/static/css/sidebar-bootstrap.css" rel="stylesheet">
|
||||||
<link href="/static/css/font-awesome.min.css" rel="stylesheet">
|
<link href="/static/css/font-awesome.min.css" rel="stylesheet">
|
||||||
|
@ -25,6 +26,8 @@
|
||||||
<!--<script src="/static/js/modernizr-2.6.2.min.js"></script>-->
|
<!--<script src="/static/js/modernizr-2.6.2.min.js"></script>-->
|
||||||
<!-- All Javascript at the bottom of the page for faster page loading -->
|
<!-- All Javascript at the bottom of the page for faster page loading -->
|
||||||
<script src="/static/js/jquery.min.js"></script>
|
<script src="/static/js/jquery.min.js"></script>
|
||||||
|
<script src="/static/js/jquery-ui.min.js"></script>
|
||||||
|
|
||||||
<!-- If no online access, fallback to our hardcoded version of jQuery
|
<!-- If no online access, fallback to our hardcoded version of jQuery
|
||||||
<script>window.jQuery || document.write('<script src="/static/js/jquery-1.8.2.min.js"><\/script>')</script>
|
<script>window.jQuery || document.write('<script src="/static/js/jquery-1.8.2.min.js"><\/script>')</script>
|
||||||
-->
|
-->
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
<span id="file-group" class="hidden">
|
<span id="file-group" class="hidden">
|
||||||
File: <input type="file" name="uploadfile" />
|
File: <input type="file" name="uploadfile" />
|
||||||
</span>
|
</span>
|
||||||
|
Date: <input id="datepicker" name="dueDate"/>
|
||||||
<br> Priority:
|
<br> Priority:
|
||||||
<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
|
||||||
|
@ -37,6 +38,7 @@
|
||||||
<option value="{{$cat.Name}}" {{if eq $cat.Name $navigation }} selected="true" {{end}}> {{$cat.Name}} </option>
|
<option value="{{$cat.Name}}" {{if eq $cat.Name $navigation }} selected="true" {{end}}> {{$cat.Name}} </option>
|
||||||
{{end}}
|
{{end}}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
|
||||||
|
|
|
@ -65,6 +65,7 @@ func AddTaskFunc(w http.ResponseWriter, r *http.Request) {
|
||||||
taskPriority = 1
|
taskPriority = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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"))
|
||||||
|
@ -102,7 +103,7 @@ 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)
|
taskTruth := db.AddTask(title, content, category, taskPriority, username, dueDate)
|
||||||
|
|
||||||
if taskTruth != nil {
|
if taskTruth != nil {
|
||||||
message = "Error adding task"
|
message = "Error adding task"
|
||||||
|
|
|
@ -186,7 +186,7 @@ func AddTaskFuncAPI(w http.ResponseWriter, r *http.Request) {
|
||||||
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, "")
|
||||||
if taskTruth != nil {
|
if taskTruth != nil {
|
||||||
taskErr = true
|
taskErr = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue