Implemented adding and removing anime

This commit is contained in:
2017-06-20 12:41:26 +02:00
parent 6bd57a9135
commit a0c8fb19ca
12 changed files with 119 additions and 27 deletions

View File

@ -1,6 +1,7 @@
package animelistitem
import (
"errors"
"net/http"
"github.com/aerogo/aero"
@ -29,12 +30,12 @@ func Get(ctx *aero.Context) string {
item := animeList.Find(animeID)
if item == nil {
return ctx.Error(http.StatusNotFound, "List item not found", err)
return ctx.Error(http.StatusNotFound, "List item not found", errors.New("This anime does not exist in "+viewUser.Nick+"'s anime list"))
}
anime := item.Anime()
return ctx.HTML(components.AnimeListItem(item, anime))
return ctx.HTML(components.AnimeListItem(animeList.User(), item, anime))
}
// t := reflect.TypeOf(item).Elem()

View File

@ -1,12 +1,22 @@
component AnimeListItem(item *arn.AnimeListItem, anime *arn.Anime)
component AnimeListItem(viewUser *arn.User, item *arn.AnimeListItem, anime *arn.Anime)
.widgets
.widget.anime-list-item-view
h2
a.ajax(href=anime.Link())= anime.Title.Canonical
h2= anime.Title.Canonical
if anime.EpisodeCount == 0
InputNumber("episodes", item.Episodes, "Episodes", "Number of episodes you watched", 0, 10000)
else
InputNumber("episodes", item.Episodes, "Episodes", "Number of episodes you watched", 0, anime.EpisodeCount)
InputTextArea("notes", item.Notes, "Notes", "Notes")
InputTextArea("notes", item.Notes, "Notes", "Notes")
.actions
a.ajax.button(href="/+" + viewUser.Nick + "/animelist")
Icon("list")
span View collection
a.ajax.button(href=anime.Link())
Icon("search-plus")
span View anime
button.action(data-action="removeAnimeFromCollection", data-anime-id=anime.ID, data-user-id=viewUser.ID, data-user-nick=viewUser.Nick)
Icon("trash")
span Remove from collection