From de93fa21453658a32e86506ec709431a42897975 Mon Sep 17 00:00:00 2001 From: bel Date: Sat, 7 Dec 2019 13:25:14 -0700 Subject: [PATCH] Implement filter on tag click --- server/ajax/form/uuid.go | 6 +++++- server/ajax/task/task.go | 6 +++++- source_to_run_loaded.sh | 5 +++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/server/ajax/form/uuid.go b/server/ajax/form/uuid.go index d1639f4..46a0fc3 100755 --- a/server/ajax/form/uuid.go +++ b/server/ajax/form/uuid.go @@ -9,7 +9,11 @@ import ( func NewUUID() string { uuid := uuid.New().String() + return Hash(uuid) +} + +func Hash(s string) string { h := fnv.New32a() - h.Write([]byte(uuid)) + h.Write([]byte(s)) return fmt.Sprint(h.Sum32()) } diff --git a/server/ajax/task/task.go b/server/ajax/task/task.go index 8028486..5b17e25 100755 --- a/server/ajax/task/task.go +++ b/server/ajax/task/task.go @@ -81,6 +81,10 @@ func (t *Task) MarshalJSON() ([]byte, error) { if t.Complete { compl = 1 } + tagsIds := make([]string, len(t.Tags)) + for i, tag := range t.Tags { + tagsIds[i] = form.Hash(tag) + } m := map[string]interface{}{ "id": t.UUID, "title": t.Title, @@ -99,7 +103,7 @@ func (t *Task) MarshalJSON() ([]byte, error) { "noteText": strings.Join(t.Note, "\n"), "ow": 0, "tags": strings.Join([]string(t.Tags), ", "), - "tags_ids": "", + "tags_ids": strings.Join([]string(tagsIds), ", "), "duedate": t.Due.Format(fullFormat), "dueClass": "", "dueStr": t.Due.Format(shortFormat), diff --git a/source_to_run_loaded.sh b/source_to_run_loaded.sh index b0878d6..4cbd62d 100644 --- a/source_to_run_loaded.sh +++ b/source_to_run_loaded.sh @@ -11,7 +11,7 @@ for ((i=0; i<3; i++)); do curl \ -X POST \ localhost:39909/ajax.php?addList \ - -d "name=Todo$i" \ + --data-urlencode "name=Todo$i" \ 2> /dev/null \ | jq -r '.list[0].id' \ )" @@ -19,7 +19,8 @@ for ((i=0; i<3; i++)); do curl \ -X POST \ localhost:39909/ajax.php?newTask \ - -d "list=$listid&title=abc${i}&tag=" + --data-urlencode "list=$listid" \ + --data-urlencode "title=abc${i} /$((RANDOM%2))/" done taskid=$( \