support only looping
This commit is contained in:
@@ -20,16 +20,24 @@ type taskWithDelta struct {
|
||||
func (a *Ajax) loadTasks(w http.ResponseWriter, r *http.Request) error {
|
||||
listID, _, _ := a.Cur(r)
|
||||
filterComplete := filterComplete(form.Get(r, "compl"))
|
||||
filterLooping := filterLooping(form.Get(r, "looping"))
|
||||
filterTags := filterTags(form.ToStrArr(form.Get(r, "t")))
|
||||
filterSubstr := filterSubstr(form.Get(r, "s"))
|
||||
// TODO filter loop
|
||||
tasks, err := a.storageListTasks(listID, filterComplete, filterTags, filterSubstr)
|
||||
tasks, err := a.storageListTasks(listID, filterComplete, filterTags, filterSubstr, filterLooping)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return json.NewEncoder(w).Encode(map[string]interface{}{"list": tasks})
|
||||
}
|
||||
|
||||
func filterLooping(looping string) func(t *task.Task) bool {
|
||||
return func(t *task.Task) bool {
|
||||
hasLoop := t.Loop > 0 || t.Cron != ""
|
||||
onlyLooping := looping == "1"
|
||||
return !onlyLooping || hasLoop
|
||||
}
|
||||
}
|
||||
|
||||
func filterComplete(compl string) func(t *task.Task) bool {
|
||||
return func(t *task.Task) bool {
|
||||
return compl == "" || !t.Complete || (compl == "1" && t.Complete)
|
||||
|
||||
Reference in New Issue
Block a user