Begin to impl list order, should have prereq
This commit is contained in:
@@ -8,7 +8,8 @@ import (
|
||||
)
|
||||
|
||||
type Ajax struct {
|
||||
DB storage.DB
|
||||
DB storage.DB
|
||||
ListCnt int
|
||||
}
|
||||
|
||||
func New() (*Ajax, error) {
|
||||
|
||||
@@ -15,6 +15,7 @@ func (a *Ajax) loadLists(w http.ResponseWriter, r *http.Request) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.ListCnt = len(lists)
|
||||
return json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"total": len(lists),
|
||||
"list": lists,
|
||||
@@ -26,6 +27,8 @@ func (a *Ajax) addList(w http.ResponseWriter, r *http.Request) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.ListCnt += 1
|
||||
newList.Index = a.ListCnt
|
||||
if err := a.storageSetList(newList); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -70,7 +73,7 @@ func (a *Ajax) publishList(w http.ResponseWriter, r *http.Request) error {
|
||||
}
|
||||
|
||||
func (a *Ajax) changeListOrder(w http.ResponseWriter, r *http.Request) error {
|
||||
return errors.New("not impl")
|
||||
return errors.New("TODO not impl")
|
||||
}
|
||||
|
||||
func (a *Ajax) clearCompletedInList(w http.ResponseWriter, r *http.Request) error {
|
||||
|
||||
@@ -15,6 +15,7 @@ type List struct {
|
||||
ShowNotes int `json:"showNotes"`
|
||||
Hidden int `json:"hidden"`
|
||||
Max int `json:"max"`
|
||||
Index int `json:"index"`
|
||||
}
|
||||
|
||||
func New(r *http.Request) (*List, error) {
|
||||
|
||||
Reference in New Issue
Block a user