From ad561c5652b54b5bf4c984b03155559e2a88378c Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Fri, 20 Apr 2018 00:06:13 +0200 Subject: [PATCH] Improved list item editor --- pages/anime/anime.go | 2 +- pages/animelist/animelist.go | 11 ++-- pages/animelist/animelist.pixy | 2 +- pages/animelistitem/animelistitem.pixy | 74 +++++++++++++---------- pages/animelistitem/animelistitem.scarlet | 42 ++++++++++++- pages/profile/profile.go | 5 ++ styles/include/config.scarlet | 2 +- styles/input.scarlet | 2 +- 8 files changed, 96 insertions(+), 44 deletions(-) diff --git a/pages/anime/anime.go b/pages/anime/anime.go index 0b34a65d..a8e88991 100644 --- a/pages/anime/anime.go +++ b/pages/anime/anime.go @@ -43,7 +43,7 @@ func Get(ctx *aero.Context) string { friendAnimeList := friends[j].AnimeList() friendAnimeListItem := friendAnimeList.Find(anime.ID) - if friendAnimeListItem == nil { + if friendAnimeListItem == nil || friendAnimeListItem.Private { friends = friends[:j+copy(friends[j:], friends[j+1:])] deleted++ } else { diff --git a/pages/animelist/animelist.go b/pages/animelist/animelist.go index 51a09548..9089ee5b 100644 --- a/pages/animelist/animelist.go +++ b/pages/animelist/animelist.go @@ -7,7 +7,6 @@ import ( "github.com/aerogo/aero" "github.com/animenotifier/arn" "github.com/animenotifier/notify.moe/components" - "github.com/animenotifier/notify.moe/pages/frontpage" "github.com/animenotifier/notify.moe/utils" "github.com/animenotifier/notify.moe/utils/infinitescroll" ) @@ -21,11 +20,6 @@ const ( func FilterByStatus(status string) aero.Handle { return func(ctx *aero.Context) string { user := utils.GetUser(ctx) - - if user == nil { - return frontpage.Get(ctx) - } - return AnimeList(ctx, user, status) } } @@ -49,6 +43,11 @@ func AnimeList(ctx *aero.Context, user *arn.User, status string) string { statusList := animeList.FilterStatus(status) + // Filter private items + if user == nil || user.ID != viewUser.ID { + statusList = statusList.WithoutPrivateItems() + } + // Sort the items statusList.Sort() diff --git a/pages/animelist/animelist.pixy b/pages/animelist/animelist.pixy index 5d3f4d1f..44a9de8e 100644 --- a/pages/animelist/animelist.pixy +++ b/pages/animelist/animelist.pixy @@ -1,7 +1,7 @@ component AnimeListPage(animeListItems []*arn.AnimeListItem, nextIndex int, viewUser *arn.User, user *arn.User, status string) h1.page-title= viewUser.Nick + "'s anime list" - if user.ID != viewUser.ID + if user == nil || user.ID != viewUser.ID .anime-list-user-avatar AvatarNoTip(viewUser) diff --git a/pages/animelistitem/animelistitem.pixy b/pages/animelistitem/animelistitem.pixy index 652c4963..0d19a7fb 100644 --- a/pages/animelistitem/animelistitem.pixy +++ b/pages/animelistitem/animelistitem.pixy @@ -1,38 +1,46 @@ component AnimeListItem(viewUser *arn.User, item *arn.AnimeListItem, anime *arn.Anime, user *arn.User) - .widget-form.mountable - .widget.anime-list-item-view(data-api="/api/animelist/" + viewUser.ID + "/field/Items[AnimeID=\"" + anime.ID + "\"]") - h1= anime.Title.ByUser(user) + .anime-list-item-view.mountable(data-api="/api/animelist/" + viewUser.ID + "/field/Items[AnimeID=\"" + anime.ID + "\"]") + h1.anime-list-item-title.mountable= anime.Title.ByUser(user) + + .anime-list-item-progress-edit + .anime-list-item-episodes-edit + InputNumberWithButtons("Episodes", float64(item.Episodes), "Episodes", "Number of episodes you watched", "0", arn.EpisodeCountMax(anime.EpisodeCount), "1") - .anime-list-item-progress-edit - .anime-list-item-episodes-edit - InputNumberWithButtons("Episodes", float64(item.Episodes), "Episodes", "Number of episodes you watched", "0", arn.EpisodeCountMax(anime.EpisodeCount), "1") - - .widget-section.anime-list-item-status-edit - label(for="Status") Status: - select.widget-ui-element.action(id="Status", data-field="Status", value=item.Status, data-action="save", data-trigger="change") - option(value=arn.AnimeListStatusWatching) Watching - option(value=arn.AnimeListStatusCompleted) Completed - option(value=arn.AnimeListStatusPlanned) Plan to watch - option(value=arn.AnimeListStatusHold) On hold - option(value=arn.AnimeListStatusDropped) Dropped + .widget-section.anime-list-item-status-edit + label(for="Status") Status: + select.widget-ui-element.action(id="Status", data-field="Status", value=item.Status, data-action="save", data-trigger="change") + option(value=arn.AnimeListStatusWatching) Watching + option(value=arn.AnimeListStatusCompleted) Completed + option(value=arn.AnimeListStatusPlanned) Plan to watch + option(value=arn.AnimeListStatusHold) On hold + option(value=arn.AnimeListStatusDropped) Dropped - .anime-list-item-rating-edit - InputNumber("Rating.Overall", item.Rating.Overall, arn.OverallRatingName(item.Episodes), "Overall rating on a scale of 0 to 10", "0", "10", "0.1") - InputNumber("Rating.Story", item.Rating.Story, "Story", "Story rating on a scale of 0 to 10", "0", "10", "0.1") - InputNumber("Rating.Visuals", item.Rating.Visuals, "Visuals", "Visuals rating on a scale of 0 to 10", "0", "10", "0.1") - InputNumber("Rating.Soundtrack", item.Rating.Soundtrack, "Soundtrack", "Soundtrack rating on a scale of 0 to 10", "0", "10", "0.1") - + .anime-list-item-rating-edit(data-status=item.Status) + InputNumber("Rating.Overall", item.Rating.Overall, arn.OverallRatingName(item.Episodes), "Overall rating on a scale of 0 to 10", "0", "10", "0.1") + InputNumber("Rating.Story", item.Rating.Story, "Story", "Story rating on a scale of 0 to 10", "0", "10", "0.1") + InputNumber("Rating.Visuals", item.Rating.Visuals, "Visuals", "Visuals rating on a scale of 0 to 10", "0", "10", "0.1") + InputNumber("Rating.Soundtrack", item.Rating.Soundtrack, "Soundtrack", "Soundtrack rating on a scale of 0 to 10", "0", "10", "0.1") + + .anime-list-item-others InputNumber("RewatchCount", float64(item.RewatchCount), "Rewatched", "How often you rewatched this anime", "0", "100", "1") - - InputTextArea("Notes", item.Notes, "Notes", "Your notes") + InputBool("Private", item.Private, "Private", "Hidden entry") + + InputTextArea("Notes", item.Notes, "Notes", "Your notes") - .buttons.mountable - a.button(href="/+" + viewUser.Nick + "/animelist/" + item.Status) - Icon("list") - span View collection - a.button(href=anime.Link()) - Icon("search-plus") - span View anime - button.action(data-action="removeAnimeFromCollection", data-trigger="click", data-api="/api/animelist/" + viewUser.ID, data-anime-id=anime.ID, data-nick=viewUser.Nick) - Icon("trash") - span Remove from collection \ No newline at end of file + .buttons.mountable + a.button(href="/+" + viewUser.Nick + "/animelist/" + item.Status) + Icon("list") + span View collection + + a.button(href=anime.Link()) + Icon("search-plus") + span View anime + + button.action(data-action="removeAnimeFromCollection", data-trigger="click", data-api="/api/animelist/" + viewUser.ID, data-anime-id=anime.ID, data-nick=viewUser.Nick) + Icon("trash") + span Remove from collection + + a.anime-list-item-cover.mountable(href=anime.Link(), title="View anime") + img.anime-cover-image.lazy(data-src=anime.ImageLink("medium"), data-webp="true", data-color=anime.AverageColor(), alt=anime.Title.ByUser(user)) + RawIcon("arrow-left") + \ No newline at end of file diff --git a/pages/animelistitem/animelistitem.scarlet b/pages/animelistitem/animelistitem.scarlet index 8d2eeca8..e01d8ee3 100644 --- a/pages/animelistitem/animelistitem.scarlet +++ b/pages/animelistitem/animelistitem.scarlet @@ -10,9 +10,49 @@ // .anime-list-item-status-edit // flex-basis 50% +.anime-list-item-view + vertical + width 100% + max-width 530px + margin 0 auto + margin-top calc(content-padding / 2) + +.anime-list-item-others + display grid + grid-template-columns repeat(auto-fill, calc(50% - content-padding / 2)) + grid-gap content-padding + +.anime-list-item-cover + display none + +> 1200px + .anime-list-item-cover + display block + position absolute + left content-padding + top content-padding + + img + width anime-image-medium-width + height anime-image-medium-height + + .raw-icon + font-size 2.5rem + position absolute + left 0 + top calc(anime-image-medium-height / 2) + transform translateY(-50%) translateX(-50%) + opacity 0.85 + .anime-list-item-rating-edit horizontal justify-content space-between width 100% + .widget-section - max-width 20% \ No newline at end of file + max-width 20% + +.anime-list-item-rating-edit + [data-status="completed"] + input[value="0"] + border-color rgb(232, 0, 0) \ No newline at end of file diff --git a/pages/profile/profile.go b/pages/profile/profile.go index 093b19bd..58146cdd 100644 --- a/pages/profile/profile.go +++ b/pages/profile/profile.go @@ -25,6 +25,11 @@ func Get(ctx *aero.Context) string { func Profile(ctx *aero.Context, viewUser *arn.User) string { user := utils.GetUser(ctx) animeList := viewUser.AnimeList() + + if user == nil || user.ID != viewUser.ID { + animeList = animeList.WithoutPrivateItems() + } + animeList.SortByRating() openGraph := &arn.OpenGraph{ diff --git a/styles/include/config.scarlet b/styles/include/config.scarlet index 6b475dda..9d2568d5 100644 --- a/styles/include/config.scarlet +++ b/styles/include/config.scarlet @@ -32,7 +32,7 @@ ui-disabled-color = rgb(224, 224, 224) const ui-element-border-radius = 3px // Input -input-height = 2.4rem +input-height = 2.5rem input-focus-border-color = rgb(248, 165, 130) // Button diff --git a/styles/input.scarlet b/styles/input.scarlet index 0410a7ea..dfcaf7a5 100644 --- a/styles/input.scarlet +++ b/styles/input.scarlet @@ -39,11 +39,11 @@ input button, .button horizontal - line-height 1.5em padding 0.5rem 1rem color link-color align-items center pointer-events all + height input-height button-hover