Begin to impl list order, should have prereq

master
bel 2019-12-01 17:51:30 -07:00
parent c756c005ac
commit 0f49595f0b
4 changed files with 7 additions and 19 deletions

View File

@ -1,17 +0,0 @@
package feed
import (
"errors"
"local/storage"
"net/url"
)
type Feed struct{}
func New(db storage.DB, values url.Values) (*Feed, error) {
return nil, errors.New("not impl")
}
func (f *Feed) Read(p []byte) (int, error) {
return 0, errors.New("not impl")
}

View File

@ -8,7 +8,8 @@ import (
) )
type Ajax struct { type Ajax struct {
DB storage.DB DB storage.DB
ListCnt int
} }
func New() (*Ajax, error) { func New() (*Ajax, error) {

View File

@ -15,6 +15,7 @@ func (a *Ajax) loadLists(w http.ResponseWriter, r *http.Request) error {
if err != nil { if err != nil {
return err return err
} }
a.ListCnt = len(lists)
return json.NewEncoder(w).Encode(map[string]interface{}{ return json.NewEncoder(w).Encode(map[string]interface{}{
"total": len(lists), "total": len(lists),
"list": lists, "list": lists,
@ -26,6 +27,8 @@ func (a *Ajax) addList(w http.ResponseWriter, r *http.Request) error {
if err != nil { if err != nil {
return err return err
} }
a.ListCnt += 1
newList.Index = a.ListCnt
if err := a.storageSetList(newList); err != nil { if err := a.storageSetList(newList); err != nil {
return err 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 { 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 { func (a *Ajax) clearCompletedInList(w http.ResponseWriter, r *http.Request) error {

View File

@ -15,6 +15,7 @@ type List struct {
ShowNotes int `json:"showNotes"` ShowNotes int `json:"showNotes"`
Hidden int `json:"hidden"` Hidden int `json:"hidden"`
Max int `json:"max"` Max int `json:"max"`
Index int `json:"index"`
} }
func New(r *http.Request) (*List, error) { func New(r *http.Request) (*List, error) {