support only looping
parent
568aa6a229
commit
2bca997483
|
|
@ -46,7 +46,7 @@
|
|||
})
|
||||
*/
|
||||
|
||||
$.getJSON(this.mtt.mttUrl + 'ajax.php?loadTasks&list=' + params.list + '&compl=' + params.compl + '&sort=' + params.sort + q, callback);
|
||||
$.getJSON(this.mtt.mttUrl + 'ajax.php?loadTasks&list=' + params.list + '&compl=' + params.compl + '&looping=' + params.looping + '&sort=' + params.sort + q, callback);
|
||||
},
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -62,11 +62,11 @@ func (a *Ajax) storageListTasks(listID string, filters ...func(t *task.Task) boo
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
includeComplete := true
|
||||
includeComplete := false
|
||||
for _, f := range filters {
|
||||
t := &task.Task{Complete: true}
|
||||
if !f(t) {
|
||||
includeComplete = false
|
||||
if f(t) {
|
||||
includeComplete = true
|
||||
}
|
||||
}
|
||||
if includeComplete {
|
||||
|
|
@ -77,11 +77,16 @@ func (a *Ajax) storageListTasks(listID string, filters ...func(t *task.Task) boo
|
|||
results = append(results, completeResults...)
|
||||
}
|
||||
tasks := []*task.Task{}
|
||||
uuids := map[string]struct{}{}
|
||||
for _, result := range results {
|
||||
taskID := path.Base(result)
|
||||
if taskID == "" {
|
||||
continue
|
||||
}
|
||||
if _, ok := uuids[taskID]; ok {
|
||||
continue
|
||||
}
|
||||
uuids[taskID] = struct{}{}
|
||||
task, err := a.storageGetTask(taskID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue