Implemented adding and removing anime
This commit is contained in:
@ -22,9 +22,11 @@ component Anime(anime *arn.Anime, user *arn.User)
|
||||
if user != nil
|
||||
.anime-actions
|
||||
if user.AnimeList().Contains(anime.ID)
|
||||
a.button.ajax(href="/+" + user.Nick + "/animelist/" + anime.ID) View in collection
|
||||
a.button.ajax(href="/+" + user.Nick + "/animelist/" + anime.ID)
|
||||
Icon("pencil")
|
||||
span Edit in collection
|
||||
else
|
||||
button Add to collection
|
||||
button.action(data-action="addAnimeToCollection", data-anime-id=anime.ID, data-user-id=user.ID, data-user-nick=user.Nick) Add to collection
|
||||
|
||||
h3.anime-section-name Ratings
|
||||
.anime-rating-categories
|
||||
|
@ -8,6 +8,7 @@ component AnimeList(animeList *arn.AnimeList)
|
||||
tbody
|
||||
each item in animeList.Items
|
||||
tr.anime-list-item
|
||||
td= item.Anime().Title.Canonical
|
||||
td
|
||||
a.ajax(href=item.Anime().Link())= item.Anime().Title.Canonical
|
||||
td= toString(item.Episodes) + " / " + item.Anime().EpisodeCountString()
|
||||
td= item.FinalRating()
|
@ -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()
|
||||
|
@ -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
|
@ -1,4 +1,4 @@
|
||||
component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, threads []*arn.Thread)
|
||||
component ProfileHeader(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, threads []*arn.Thread)
|
||||
.profile
|
||||
img.profile-cover(src=viewUser.CoverImageURL(), alt="Cover image")
|
||||
|
||||
@ -44,10 +44,8 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
|
||||
Icon("rocket")
|
||||
span= arn.Capitalize(viewUser.Role)
|
||||
|
||||
//- nav.light-button-group
|
||||
//- a.light-button(href="#") Bio
|
||||
//- a.light-button(href="#") Anime
|
||||
//- a.light-button(href="#") Forum
|
||||
component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, threads []*arn.Thread)
|
||||
ProfileHeader(viewUser, user, animeList, threads)
|
||||
|
||||
.profile-category
|
||||
h3
|
||||
|
Reference in New Issue
Block a user