added necessary features for due date

This commit is contained in:
Suraj Patil 2016-07-30 20:51:16 +05:30
parent 7b62fa2488
commit 3c4a010e2c
6 changed files with 17 additions and 5 deletions

View File

@ -205,19 +205,23 @@ func DeleteTask(username string, id int) error {
}
//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")
var err error
timeDueDate, err := time.Parse("31/12/2016", dueDate)
if err != nil {
log.Fatal(err)
}
userID, err := GetUserID(username)
if err != nil && (title != "" || content != "") {
return err
}
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 {
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
}

View File

@ -22,6 +22,8 @@ $(document).ready(function(){
$('#addNoteModal').modal('show');
});
$("#datepicker").datepicker();
$('#editCatFrmBtn').click(function(){
$('#EditForm').toggleClass('hidden')
});

View File

@ -17,6 +17,7 @@
<!-- Custom CSS -->
<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-bootstrap.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>-->
<!-- 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-ui.min.js"></script>
<!-- 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>
-->

View File

@ -25,6 +25,7 @@
<span id="file-group" class="hidden">
File: <input type="file" name="uploadfile" />
</span>
Date: <input id="datepicker" name="dueDate"/>
<br> Priority:
<input type="radio" name="priority" value="3" /> High
<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>
{{end}}
</select>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>

View File

@ -65,6 +65,7 @@ func AddTaskFunc(w http.ResponseWriter, r *http.Request) {
taskPriority = 1
}
dueDate := r.FormValue("dueDate")
category := r.FormValue("category")
title := template.HTMLEscapeString(r.Form.Get("title"))
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")
}
}
taskTruth := db.AddTask(title, content, category, taskPriority, username)
taskTruth := db.AddTask(title, content, category, taskPriority, username, dueDate)
if taskTruth != nil {
message = "Error adding task"

View File

@ -186,7 +186,7 @@ func AddTaskFuncAPI(w http.ResponseWriter, r *http.Request) {
var taskErr bool
if title != "" && content != "" {
taskTruth := db.AddTask(title, content, category, taskPriority, username)
taskTruth := db.AddTask(title, content, category, taskPriority, username, "")
if taskTruth != nil {
taskErr = true
}