forked from OrgGo/Tasks
diffrentiate between delete & complete
This commit is contained in:
parent
77104f4e06
commit
cde24f7ee9
31
db/db.go
31
db/db.go
|
@ -23,17 +23,19 @@ func Close() {
|
||||||
database.Close()
|
database.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetTasks(deleted bool) []types.Task {
|
func GetTasks(status string) []types.Task {
|
||||||
var task []types.Task
|
var task []types.Task
|
||||||
var TaskId int
|
var TaskId int
|
||||||
var TaskTitle string
|
var TaskTitle string
|
||||||
var TaskContent string
|
var TaskContent string
|
||||||
var TaskCreated time.Time
|
var TaskCreated time.Time
|
||||||
var getTasksql string
|
var getTasksql string
|
||||||
if deleted == true {
|
if status == "pending" {
|
||||||
getTasksql = "select id, title, content, created_date from task where is_deleted!='Y' order by created_date asc"
|
getTasksql = "select id, title, content, created_date from task where finish_date is null and is_deleted='N' order by created_date asc"
|
||||||
} else {
|
} else if status == "trashed" {
|
||||||
getTasksql = "select id, title, content, created_date from task where is_deleted='Y' order by created_date asc"
|
getTasksql = "select id, title, content, created_date from task where is_deleted='Y' order by created_date asc"
|
||||||
|
} else if status == "complete" {
|
||||||
|
getTasksql = "select id, title, content, created_date from task where finish_date is not null order by created_date asc"
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := database.Query(getTasksql)
|
rows, err := database.Query(getTasksql)
|
||||||
|
@ -76,7 +78,26 @@ func GetTaskById(id int) types.Task {
|
||||||
return task
|
return task
|
||||||
}
|
}
|
||||||
|
|
||||||
func ArchiveTask(id int) error {
|
func TrashTask(id int) error {
|
||||||
|
trashSql, err := database.Prepare("update task set is_deleted='Y',last_modified_at=datetime() where id=?")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
tx, err := database.Begin()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
_, err = tx.Stmt(trashSql).Exec(id)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("doing rollback")
|
||||||
|
tx.Rollback()
|
||||||
|
} else {
|
||||||
|
tx.Commit()
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func CompleteTask(id int) error {
|
||||||
stmt, err := database.Prepare("update task set is_deleted='Y', finish_date=datetime(),last_modified_at=datetime() where id=?")
|
stmt, err := database.Prepare("update task set is_deleted='Y', finish_date=datetime(),last_modified_at=datetime() where id=?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
|
44
main.go
44
main.go
|
@ -16,6 +16,7 @@ import (
|
||||||
|
|
||||||
var homeTemplate *template.Template
|
var homeTemplate *template.Template
|
||||||
var deletedTemplate *template.Template
|
var deletedTemplate *template.Template
|
||||||
|
var completedTemplate *template.Template
|
||||||
var editTemplate *template.Template
|
var editTemplate *template.Template
|
||||||
var searchTemplate *template.Template
|
var searchTemplate *template.Template
|
||||||
var err error
|
var err error
|
||||||
|
@ -39,12 +40,19 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
|
completedTemplate, err = template.ParseFiles("./templates/completed.gtpl")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
router := httprouter.New()
|
router := httprouter.New()
|
||||||
router.GET("/", ShowAllTasks)
|
router.GET("/", ShowAllTasks)
|
||||||
router.GET("/archive/:id", ArchiveTask)
|
router.GET("/complete/:id", CompleteTask)
|
||||||
router.GET("/delete/:id", DeleteTask)
|
router.GET("/delete/:id", DeleteTask)
|
||||||
|
router.GET("/deleted/", ShowTrashTask)
|
||||||
|
router.GET("/trash/:id", TrashTask)
|
||||||
router.GET("/edit/:id", EditTask)
|
router.GET("/edit/:id", EditTask)
|
||||||
router.GET("/trash/", ShowTrashTask)
|
router.GET("/complete/", ShowCompleteTasks)
|
||||||
router.GET("/restore/:id", RestoreTask)
|
router.GET("/restore/:id", RestoreTask)
|
||||||
router.POST("/add/", AddTask)
|
router.POST("/add/", AddTask)
|
||||||
router.POST("/update/", UpdateTask)
|
router.POST("/update/", UpdateTask)
|
||||||
|
@ -55,10 +63,15 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ShowAllTasks(w http.ResponseWriter, r *http.Request, parm httprouter.Params) {
|
func ShowAllTasks(w http.ResponseWriter, r *http.Request, parm httprouter.Params) {
|
||||||
context := viewmodels.GetTasks(true) //true when you want non deleted notes
|
context := viewmodels.GetTasks("pending") //true when you want non deleted notes
|
||||||
homeTemplate.Execute(w, context)
|
homeTemplate.Execute(w, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ShowTrashTask(w http.ResponseWriter, r *http.Request, parm httprouter.Params) {
|
||||||
|
context := viewmodels.GetTasks("trashed") //false when you want deleted notes
|
||||||
|
deletedTemplate.Execute(w, context)
|
||||||
|
}
|
||||||
|
|
||||||
func SearchTask(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
func SearchTask(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
query := r.Form.Get("query")
|
query := r.Form.Get("query")
|
||||||
|
@ -76,9 +89,9 @@ func AddTask(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ShowTrashTask(w http.ResponseWriter, r *http.Request, parm httprouter.Params) {
|
func ShowCompleteTasks(w http.ResponseWriter, r *http.Request, parm httprouter.Params) {
|
||||||
context := viewmodels.GetTasks(false) //false when you want finished notes
|
context := viewmodels.GetTasks("complete") //false when you want finished notes
|
||||||
deletedTemplate.Execute(w, context)
|
completedTemplate.Execute(w, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
func EditTask(w http.ResponseWriter, r *http.Request, param httprouter.Params) {
|
func EditTask(w http.ResponseWriter, r *http.Request, param httprouter.Params) {
|
||||||
|
@ -91,12 +104,12 @@ func EditTask(w http.ResponseWriter, r *http.Request, param httprouter.Params) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ArchiveTask(w http.ResponseWriter, r *http.Request, param httprouter.Params) {
|
func CompleteTask(w http.ResponseWriter, r *http.Request, param httprouter.Params) {
|
||||||
id, err := strconv.Atoi(param.ByName("id"))
|
id, err := strconv.Atoi(param.ByName("id"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
} else {
|
} else {
|
||||||
viewmodels.ArchiveTask(id)
|
viewmodels.CompleteTask(id)
|
||||||
http.Redirect(w, r, "/", http.StatusFound)
|
http.Redirect(w, r, "/", http.StatusFound)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,18 +125,29 @@ func DeleteTask(w http.ResponseWriter, r *http.Request, param httprouter.Params)
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
} else {
|
} else {
|
||||||
viewmodels.DeleteTask(id)
|
viewmodels.DeleteTask(id)
|
||||||
http.Redirect(w, r, "/trash/", http.StatusFound)
|
http.Redirect(w, r, "/deleted/", http.StatusFound)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TrashTask(w http.ResponseWriter, r *http.Request, param httprouter.Params) {
|
||||||
|
id, err := strconv.Atoi(param.ByName("id"))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
} else {
|
||||||
|
fmt.Println("deleting ", id)
|
||||||
|
viewmodels.TrashTask(id)
|
||||||
|
http.Redirect(w, r, "/", http.StatusFound)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func RestoreTask(w http.ResponseWriter, r *http.Request, param httprouter.Params) {
|
func RestoreTask(w http.ResponseWriter, r *http.Request, param httprouter.Params) {
|
||||||
id, err := strconv.Atoi(param.ByName("id"))
|
id, err := strconv.Atoi(param.ByName("id"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
} else {
|
} else {
|
||||||
viewmodels.RestoreTask(id)
|
viewmodels.RestoreTask(id)
|
||||||
http.Redirect(w, r, "/trash/", http.StatusFound)
|
http.Redirect(w, r, "/", http.StatusFound)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,128 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<title>Completed Tasks</title>
|
||||||
|
|
||||||
|
<!-- Mobile viewport optimized -->
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||||
|
|
||||||
|
<!-- Bootstrap CSS -->
|
||||||
|
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="/static/css/bootstrap-glyphicons.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- Custom CSS -->
|
||||||
|
<link href="/static/css/styles.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" >
|
||||||
|
|
||||||
|
<!-- Include Modernizr in the head, before any other Javascript -->
|
||||||
|
<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>
|
||||||
|
<!-- 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>
|
||||||
|
-->
|
||||||
|
<!-- Bootstrap JS -->
|
||||||
|
<script src="/static/js/bootstrap.min.js"></script>
|
||||||
|
|
||||||
|
<!-- Custom JS -->
|
||||||
|
<script src="/static/js/script.js"></script>
|
||||||
|
<script src="/static/js/hammer.min.js"></script>
|
||||||
|
<script src="/static/js/sidebar.js"></script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<!-- The navigation bar-->
|
||||||
|
<nav class="navbar navbar-default navbar-fixed-top mainHeader">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="navbar-header">
|
||||||
|
|
||||||
|
<a class="navbar-brand" href="/completed/"> Completed</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<!-- SIDEBAR -->
|
||||||
|
<div data-sidebar="true" class="sidebar-trigger">
|
||||||
|
|
||||||
|
<a class="sidebar-toggle" href="">
|
||||||
|
<span class="glyphicon glyphicon-align-justify"></span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="sidebar-wrapper sidebar-default">
|
||||||
|
<div class="sidebar-scroller">
|
||||||
|
<ul class="sidebar-menu">
|
||||||
|
<li class="sidebar-group"><span>Tasks</span>
|
||||||
|
<ul class="sidebar-group-menu">
|
||||||
|
<li class="sidebar-item">
|
||||||
|
<a href="/" ><span class="glyphicon glyphicon-time"></span> <span class="nav-item">Pending</span></a>
|
||||||
|
</li>
|
||||||
|
<!--<li class="sidebar-item">
|
||||||
|
|
||||||
|
<a href="" ><span class="glyphicon glyphicon-time"></span> <span class="nav-item"> Reminders</span></a>
|
||||||
|
</li>-->
|
||||||
|
<li class="sidebar-item">
|
||||||
|
<a href="/complete/" class="active"><span class="glyphicon glyphicon-tick"></span> <span class="nav-item"> Complete</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="sidebar-item">
|
||||||
|
<a href="/deleted/"><span class="glyphicon glyphicon-trash"></span> <span class="nav-item"> Deleted</span></a>
|
||||||
|
</li>
|
||||||
|
<!--
|
||||||
|
<li class="sidebar-item"><a href="">
|
||||||
|
<span class="glyphicon glyphicon-folder-open"></span> <span class="nav-item">Uncategorized</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="sidebar-item">
|
||||||
|
<a href=""><span class="glyphicon glyphicon-cog"></span> <span class="nav-item">Settings</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="sidebar-item">
|
||||||
|
<a href="#changeLogModal" data-toggle="modal"><span class="glyphicon glyphicon-hand-up"></span> ChangeLog</a>
|
||||||
|
</li>
|
||||||
|
-->
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="timeline">
|
||||||
|
{{ if .}}
|
||||||
|
{{range .}}
|
||||||
|
<div class="note">
|
||||||
|
<p class="noteHeading">{{.Title}}</p><hr>
|
||||||
|
<p class="noteContent">{{.Content}}</p>
|
||||||
|
<span class="notefooter">
|
||||||
|
<ul class="menu">
|
||||||
|
<!-- <li role="presentation">
|
||||||
|
<a role="menuitem" tabindex="-1" href="/share/{{.Id}}">
|
||||||
|
<span class="glyphicon glyphicon-share"></span> Share</a></li>
|
||||||
|
<li role="presentation">
|
||||||
|
<a role="menuitem" tabindex="-1" href="/mask/{{.Id}}">
|
||||||
|
<span class="glyphicon glyphicon-lock"></span> Mask</a></li>
|
||||||
|
<li role="presentation"><a role="menuitem" tabindex="-1" href="/archive/{{.Id}}">
|
||||||
|
<span class="glyphicon glyphicon-inbox"></span> Edit</a></li>!-->
|
||||||
|
<li role="presentation"><a role="menuitem" tabindex="-1" href="/delete/{{.Id}}">
|
||||||
|
<span class="glyphicon glyphicon-trash"></span> Delete</a></li>
|
||||||
|
<!-- <li role="presentation"><a role="menuitem" tabindex="-1" href="/restore/{{.Id}}">
|
||||||
|
<span class="glyphicon glyphicon-inbox"></span> Restore</a></li> -->
|
||||||
|
</ul>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
{{else}}
|
||||||
|
<p>No tasks here</p>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
<footer class="footer" >
|
||||||
|
Made in India with <span class="glyphicon glyphicon-heart"></span> by <a href="htp://github.com/thewhitetulip">@thewhitetulip</a>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -61,14 +61,17 @@
|
||||||
<li class="sidebar-group"><span>Tasks</span>
|
<li class="sidebar-group"><span>Tasks</span>
|
||||||
<ul class="sidebar-group-menu">
|
<ul class="sidebar-group-menu">
|
||||||
<li class="sidebar-item">
|
<li class="sidebar-item">
|
||||||
<a href="/" ><span class="glyphicon glyphicon-file"></span> <span class="nav-item">All</span></a>
|
<a href="/" ><span class="glyphicon glyphicon-time"></span> <span class="nav-item">Pending</span></a>
|
||||||
</li>
|
</li>
|
||||||
<!--<li class="sidebar-item">
|
<!--<li class="sidebar-item">
|
||||||
|
|
||||||
<a href="" ><span class="glyphicon glyphicon-time"></span> <span class="nav-item"> Reminders</span></a>
|
<a href="" ><span class="glyphicon glyphicon-time"></span> <span class="nav-item"> Reminders</span></a>
|
||||||
</li>-->
|
</li>-->
|
||||||
<li class="sidebar-item">
|
<li class="sidebar-item">
|
||||||
<a href="/trash/" class="active"><span class="glyphicon glyphicon-trash"></span> <span class="nav-item"> Trash</span></a>
|
<a href="/complete/"><span class="glyphicon glyphicon-tick"></span> <span class="nav-item"> Complete</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="sidebar-item">
|
||||||
|
<a href="/deleted/" class="active"><span class="glyphicon glyphicon-trash"></span> <span class="nav-item"> Deleted</span></a>
|
||||||
</li>
|
</li>
|
||||||
<!--
|
<!--
|
||||||
<li class="sidebar-item"><a href="">
|
<li class="sidebar-item"><a href="">
|
||||||
|
|
|
@ -67,26 +67,14 @@
|
||||||
<li class="sidebar-group"><span>Tasks</span>
|
<li class="sidebar-group"><span>Tasks</span>
|
||||||
<ul class="sidebar-group-menu">
|
<ul class="sidebar-group-menu">
|
||||||
<li class="sidebar-item">
|
<li class="sidebar-item">
|
||||||
<a href="/" class="active"><span class="glyphicon glyphicon-file"></span> <span class="nav-item">All</span></a>
|
<a href="/" class="active"><span class="glyphicon glyphicon-tasks"></span> <span class="nav-item">Pending</span></a>
|
||||||
</li>
|
|
||||||
<!--<li class="sidebar-item">
|
|
||||||
|
|
||||||
<a href="" ><span class="glyphicon glyphicon-time"></span> <span class="nav-item"> Reminders</span></a>
|
|
||||||
</li>-->
|
|
||||||
<li class="sidebar-item">
|
|
||||||
<a href="/trash/" ><span class="glyphicon glyphicon-trash"></span> <span class="nav-item"> Trash</span></a>
|
|
||||||
</li>
|
|
||||||
<!--
|
|
||||||
<li class="sidebar-item"><a href="">
|
|
||||||
<span class="glyphicon glyphicon-folder-open"></span> <span class="nav-item">Uncategorized</span></a>
|
|
||||||
</li>
|
</li>
|
||||||
<li class="sidebar-item">
|
<li class="sidebar-item">
|
||||||
<a href=""><span class="glyphicon glyphicon-cog"></span> <span class="nav-item">Settings</span></a>
|
<a href="/complete/" ><span class="glyphicon glyphicon-check"></span> <span class="nav-item"> Completed</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="sidebar-item">
|
<li class="sidebar-item">
|
||||||
<a href="#changeLogModal" data-toggle="modal"><span class="glyphicon glyphicon-hand-up"></span> ChangeLog</a>
|
<a href="/deleted/" ><span class="glyphicon glyphicon-trash"></span> <span class="nav-item"> Deleted</span></a>
|
||||||
</li>
|
</li>
|
||||||
-->
|
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
@ -126,22 +114,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- modal for opening note -->
|
<div class="timeline">
|
||||||
<div class="modal fade" id="openNoteModal" tabindex="-1" role="dialog" aria-hidden="true">
|
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<button class="close" data-dismiss="modal"> ×</button>
|
|
||||||
<h4 class="modal-title"></h4>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="timeline">
|
|
||||||
{{ if .}}
|
{{ if .}}
|
||||||
{{range .}}
|
{{range .}}
|
||||||
<div class="note">
|
<div class="note">
|
||||||
|
@ -155,14 +128,13 @@
|
||||||
<!-- <li role="presentation">
|
<!-- <li role="presentation">
|
||||||
<a role="menuitem" tabindex="-1" href="/mask/{{.Id}}">
|
<a role="menuitem" tabindex="-1" href="/mask/{{.Id}}">
|
||||||
<span class="glyphicon glyphicon-lock"></span> Mask</a></li> !-->
|
<span class="glyphicon glyphicon-lock"></span> Mask</a></li> !-->
|
||||||
<li role="presentation"><a role="menuitem" tabindex="-1" href="/edit/{{.Id}}">
|
<li role="presentation"><a role="menuitem" tabindex="-1" href="/trash/{{.Id}}">
|
||||||
|
<span class="glyphicon glyphicon-trash"></span> Trash</a></li>
|
||||||
|
<li role="presentation"><a role="menuitem" tabindex="-1" href="/complete/{{.Id}}">
|
||||||
|
<span class="glyphicon glyphicon-check"></span> Complete</a></li>
|
||||||
|
<li role="presentation"><a role="menuitem" tabindex="-1" href="/edit/{{.Id}}">
|
||||||
<span class="glyphicon glyphicon-pencil"></span> Edit</a></li>
|
<span class="glyphicon glyphicon-pencil"></span> Edit</a></li>
|
||||||
<li role="presentation"><a role="menuitem" tabindex="-1" href="/archive/{{.Id}}">
|
|
||||||
<span class="glyphicon glyphicon-inbox"></span> Complete</a></li>
|
|
||||||
<!--
|
|
||||||
<li role="presentation"><a role="menuitem" tabindex="-1" href="/delete/{{.Id}}">
|
|
||||||
<span class="glyphicon glyphicon-trash"></span> Delete</a></li>
|
|
||||||
-->
|
|
||||||
</ul>
|
</ul>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"github.com/thewhitetulip/task/types"
|
"github.com/thewhitetulip/task/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetTasks(deleted bool) []types.Task {
|
func GetTasks(status string) []types.Task {
|
||||||
return db.GetTasks(deleted)
|
return db.GetTasks(status)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SearchTask(query string) []types.Task {
|
func SearchTask(query string) []types.Task {
|
||||||
|
@ -21,6 +21,14 @@ func AddTask(title, content string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TrashTask(id int) bool {
|
||||||
|
err := db.TrashTask(id)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func RestoreTask(id int) bool {
|
func RestoreTask(id int) bool {
|
||||||
err := db.RestoreTask(id)
|
err := db.RestoreTask(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -45,8 +53,8 @@ func DeleteAll() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func ArchiveTask(id int) bool {
|
func CompleteTask(id int) bool {
|
||||||
err := db.ArchiveTask(id)
|
err := db.CompleteTask(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue