Display list item status on edit button

This commit is contained in:
Eduard Urbach 2018-03-01 13:33:07 +01:00
parent dcc4a33d9d
commit 9aa6283b6c
2 changed files with 15 additions and 8 deletions

View File

@ -70,6 +70,13 @@ func Get(ctx *aero.Context) string {
return tracks[i].Title < tracks[j].Title
})
// Anime list item
var animeListItem *arn.AnimeListItem
if user != nil {
animeListItem = user.AnimeList().Find(anime.ID)
}
// Open Graph
description := anime.Summary
@ -100,5 +107,5 @@ func Get(ctx *aero.Context) string {
ctx.Data = openGraph
return ctx.HTML(components.Anime(anime, tracks, episodes, friends, friendsAnimeListItems, user))
return ctx.HTML(components.Anime(anime, animeListItem, tracks, episodes, friends, friendsAnimeListItems, user))
}

View File

@ -1,11 +1,11 @@
component Anime(anime *arn.Anime, tracks []*arn.SoundTrack, episodes []*arn.AnimeEpisode, friends []*arn.User, listItems map[*arn.User]*arn.AnimeListItem, user *arn.User)
component Anime(anime *arn.Anime, listItem *arn.AnimeListItem, tracks []*arn.SoundTrack, episodes []*arn.AnimeEpisode, friends []*arn.User, listItems map[*arn.User]*arn.AnimeListItem, user *arn.User)
.anime
.anime-main-column
AnimeMainColumn(anime, tracks, episodes, user)
AnimeMainColumn(anime, listItem, tracks, episodes, user)
.anime-side-column
AnimeSideColumn(anime, friends, listItems, user)
component AnimeMainColumn(anime *arn.Anime, tracks []*arn.SoundTrack, episodes []*arn.AnimeEpisode, user *arn.User)
component AnimeMainColumn(anime *arn.Anime, listItem *arn.AnimeListItem, tracks []*arn.SoundTrack, episodes []*arn.AnimeEpisode, user *arn.User)
.anime-header(data-id=anime.ID)
.anime-image-container.mountable
img.anime-cover-image.lazy(data-src=anime.Image("large"), data-webp="true", alt=anime.Title.ByUser(user))
@ -23,7 +23,7 @@ component AnimeMainColumn(anime *arn.Anime, tracks []*arn.SoundTrack, episodes [
.anime-summary-footer-container
.anime-summary-footer
AnimeGenres(anime)
AnimeActions(anime, user)
AnimeActions(anime, listItem, user)
AnimeCharacters(anime)
AnimeRelations(anime, user)
@ -38,7 +38,7 @@ component AnimeSideColumn(anime *arn.Anime, friends []*arn.User, listItems map[*
AnimeFriends(friends, listItems)
AnimeLinks(anime)
component AnimeActions(anime *arn.Anime, user *arn.User)
component AnimeActions(anime *arn.Anime, listItem *arn.AnimeListItem, user *arn.User)
if user != nil
.buttons.anime-actions
if user.Role == "editor" || user.Role == "admin"
@ -46,10 +46,10 @@ component AnimeActions(anime *arn.Anime, user *arn.User)
Icon("pencil-square-o")
span Edit anime
if user.AnimeList().Contains(anime.ID)
if listItem != nil
a.button.mountable.ajax(href="/+" + user.Nick + "/animelist/anime/" + anime.ID, data-mountable-type="footer")
Icon("pencil")
span Edit in collection
span= listItem.StatusHumanReadable()
else
button.mountable.action(data-api="/api/animelist/" + user.ID, data-action="addAnimeToCollection", data-trigger="click", data-anime-id=anime.ID, data-mountable-type="footer")
Icon("plus")