Implement filter on tag click

master
bel 2019-12-07 13:25:14 -07:00
parent 3247a8d7c7
commit de93fa2145
3 changed files with 13 additions and 4 deletions

View File

@ -9,7 +9,11 @@ import (
func NewUUID() string { func NewUUID() string {
uuid := uuid.New().String() uuid := uuid.New().String()
return Hash(uuid)
}
func Hash(s string) string {
h := fnv.New32a() h := fnv.New32a()
h.Write([]byte(uuid)) h.Write([]byte(s))
return fmt.Sprint(h.Sum32()) return fmt.Sprint(h.Sum32())
} }

View File

@ -81,6 +81,10 @@ func (t *Task) MarshalJSON() ([]byte, error) {
if t.Complete { if t.Complete {
compl = 1 compl = 1
} }
tagsIds := make([]string, len(t.Tags))
for i, tag := range t.Tags {
tagsIds[i] = form.Hash(tag)
}
m := map[string]interface{}{ m := map[string]interface{}{
"id": t.UUID, "id": t.UUID,
"title": t.Title, "title": t.Title,
@ -99,7 +103,7 @@ func (t *Task) MarshalJSON() ([]byte, error) {
"noteText": strings.Join(t.Note, "\n"), "noteText": strings.Join(t.Note, "\n"),
"ow": 0, "ow": 0,
"tags": strings.Join([]string(t.Tags), ", "), "tags": strings.Join([]string(t.Tags), ", "),
"tags_ids": "", "tags_ids": strings.Join([]string(tagsIds), ", "),
"duedate": t.Due.Format(fullFormat), "duedate": t.Due.Format(fullFormat),
"dueClass": "", "dueClass": "",
"dueStr": t.Due.Format(shortFormat), "dueStr": t.Due.Format(shortFormat),

View File

@ -11,7 +11,7 @@ for ((i=0; i<3; i++)); do
curl \ curl \
-X POST \ -X POST \
localhost:39909/ajax.php?addList \ localhost:39909/ajax.php?addList \
-d "name=Todo$i" \ --data-urlencode "name=Todo$i" \
2> /dev/null \ 2> /dev/null \
| jq -r '.list[0].id' \ | jq -r '.list[0].id' \
)" )"
@ -19,7 +19,8 @@ for ((i=0; i<3; i++)); do
curl \ curl \
-X POST \ -X POST \
localhost:39909/ajax.php?newTask \ localhost:39909/ajax.php?newTask \
-d "list=$listid&title=abc${i}&tag=" --data-urlencode "list=$listid" \
--data-urlencode "title=abc${i} /$((RANDOM%2))/"
done done
taskid=$( \ taskid=$( \