diff --git a/api/watchlist/handler.go b/api/watchlist/handler.go index 417d598..650faa7 100644 --- a/api/watchlist/handler.go +++ b/api/watchlist/handler.go @@ -105,20 +105,23 @@ func (h *Handler) HandleGetWatchlist(w http.ResponseWriter, r *http.Request) { watchlistByStatus := make(map[string][]database.GetUserWatchListRow) allEntries := make([]database.GetUserWatchListRow, 0) + watchlistIDs := make([]int64, len(entries)) - for _, entry := range entries { + for i, entry := range entries { status := entry.Status if status == "" { status = "plan_to_watch" } watchlistByStatus[status] = append(watchlistByStatus[status], entry) allEntries = append(allEntries, entry) + watchlistIDs[i] = entry.AnimeID } data := map[string]any{ "CurrentPath": r.URL.Path, "WatchlistByStatus": watchlistByStatus, "AllEntries": allEntries, + "WatchlistIDs": watchlistIDs, "StatusOrder": []string{"watching", "plan_to_watch", "on_hold", "completed", "dropped"}, "StatusLabels": map[string]string{ "watching": "Currently Watching", diff --git a/templates/watchlist.gohtml b/templates/watchlist.gohtml index 0c36439..64ebfb1 100644 --- a/templates/watchlist.gohtml +++ b/templates/watchlist.gohtml @@ -1,45 +1,156 @@ {{define "title"}}Watchlist{{end}} {{define "content"}} -
- {{range $status := $.StatusOrder}} - {{$entries := index $.WatchlistByStatus $status}} - {{if $entries}} -
-
-

{{index $.StatusLabels $status}}

+{{if .WatchlistIDs}}{{end}} +
+

Watchlist

+ +
+
+ + + + + +
+ +
+ +
+
+ +
-
- {{range $entries}} -
-
- - {{.DisplayTitle}} + +
+
-
-
- +
+ {{range $status := $.StatusOrder}} + {{$entries := index $.WatchlistByStatus $status}} + {{if $entries}} +
+
+ {{range $entries}} +
+
+ + {{.DisplayTitle}} + +
+
+ +
+

+ {{.DisplayTitle}} +

-

- {{.DisplayTitle}} -

-
- {{end}} + {{end}} +
-
+ {{end}} {{end}} - {{end}} - {{if eq (len $.AllEntries) 0}} -
- -

Your watchlist is empty.

- Browse anime -
- {{end}} + {{if eq (len $.AllEntries) 0}} +
+ +

Your watchlist is empty.

+ Browse anime +
+ {{end}} +
+ + {{end}} diff --git a/templates/watchlist_partial.gohtml b/templates/watchlist_partial.gohtml index c2d9ae8..d54b901 100644 --- a/templates/watchlist_partial.gohtml +++ b/templates/watchlist_partial.gohtml @@ -1,45 +1,155 @@ {{define "title"}}Watchlist{{end}} {{define "content"}} -
- {{range $status := $.StatusOrder}} - {{$entries := index $.WatchlistByStatus $status}} - {{if $entries}} -
-
-

{{index $.StatusLabels $status}}

+
+

Watchlist

+ +
+
+ + + + + +
+ +
+ +
+
+ +
-
- {{range $entries}} -
-
- - {{.DisplayTitle}} + +
+
-
-
- +
+ {{range $status := $.StatusOrder}} + {{$entries := index $.WatchlistByStatus $status}} + {{if $entries}} +
+
+ {{range $entries}} +
+
+ + {{.DisplayTitle}} + +
+
+ +
+

+ {{.DisplayTitle}} +

-

- {{.DisplayTitle}} -

-
- {{end}} + {{end}} +
-
+ {{end}} {{end}} - {{end}} - {{if eq (len $.AllEntries) 0}} -
- -

Your watchlist is empty.

- Browse anime -
- {{end}} + {{if eq (len $.AllEntries) 0}} +
+ +

Your watchlist is empty.

+ Browse anime +
+ {{end}} +
+ + {{end}} \ No newline at end of file