Added filters to maldiff

This commit is contained in:
Eduard Urbach 2018-03-10 10:15:05 +01:00
parent 9626204f15
commit 0670e9f886
5 changed files with 27 additions and 8 deletions

View File

@ -2,6 +2,7 @@ package editor
import (
"sort"
"strconv"
"github.com/animenotifier/notify.moe/utils/animediff"
@ -18,9 +19,14 @@ const maxCompareMALEntries = 15
func CompareMAL(ctx *aero.Context) string {
user := utils.GetUser(ctx)
year, _ := ctx.GetInt("year")
status := ctx.Get("status")
animeType := ctx.Get("type")
animes := arn.FilterAnime(func(anime *arn.Anime) bool {
if status != "" && anime.Status != status {
return false
}
if year != 0 && year != anime.StartDateTime().Year() {
return false
}
@ -100,7 +106,7 @@ func CompareMAL(ctx *aero.Context) string {
}
// Airing start date
if anime.StartDate != malAnime.StartDate {
if anime.StartDate != malAnime.StartDate && malAnime.StartDate != "" {
hash := utils.HashString(malAnime.StartDate)
if !arn.IsAnimeDifferenceIgnored(anime.ID, "mal", malAnime.ID, "StartDate", hash) {
@ -192,5 +198,5 @@ func CompareMAL(ctx *aero.Context) string {
}
}
return ctx.HTML(components.CompareMAL(comparisons, ctx.URI(), user))
return ctx.HTML(components.CompareMAL(comparisons, strconv.Itoa(year), status, animeType, ctx.URI(), user))
}

View File

@ -1,6 +1,7 @@
component CompareMAL(comparisons []*utils.MALComparison, url string, user *arn.User)
component CompareMAL(comparisons []*utils.MALComparison, year string, status string, typ string, url string, user *arn.User)
EditorTabs(url)
h1.mountable MAL comparison
ExploreFilters(year, status, typ, "malDiffFilterAnime")
.data-comparisons
each comparison in comparisons

View File

@ -1,5 +1,5 @@
component ExploreAnime(animeList []*arn.Anime, year string, status string, typ string, user *arn.User)
ExploreFilters(year, status, typ)
ExploreFilters(year, status, typ, "filterAnime")
.corner-buttons-hide-on-mobile
button.action(data-trigger="click", data-action="hideAddedAnime", title="Hide anime in my collection")
@ -16,18 +16,18 @@ component ExploreAnime(animeList []*arn.Anime, year string, status string, typ s
else
AnimeGrid(animeList, user)
component ExploreFilters(year string, status string, typ string)
component ExploreFilters(year string, status string, typ string, action string)
.explore-filters
select#filter-year.action(value=year, data-action="filterAnime", data-trigger="change")
select#filter-year.action(value=year, data-action=action, data-trigger="change")
for year := time.Now().Year()+1; year >= 1951; year--
option(value=year)= year
select#filter-status.action(value=status, data-action="filterAnime", data-trigger="change")
select#filter-status.action(value=status, data-action=action, data-trigger="change")
option(value="current") Current
option(value="upcoming") Upcoming
option(value="finished") Finished
select#filter-type.action(value=typ, data-action="filterAnime", data-trigger="change")
select#filter-type.action(value=typ, data-action=action, data-trigger="change")
option(value="tv") TV
option(value="movie") Movie
option(value="ova") OVA

View File

@ -215,6 +215,9 @@ func Configure(app *aero.Application) {
l.Page("/editor/anime/missing/genres/:year", editor.Genres)
l.Page("/editor/anime/missing/genres/:year/:type", editor.Genres)
l.Page("/editor/anime/maldiff", editor.CompareMAL)
l.Page("/editor/anime/maldiff/:year", editor.CompareMAL)
l.Page("/editor/anime/maldiff/:year/:status", editor.CompareMAL)
l.Page("/editor/anime/maldiff/:year/:status/:type", editor.CompareMAL)
// Log
l.Page("/log", editlog.Get)

View File

@ -17,4 +17,13 @@ export function newAnimeDiffIgnore(arn: AnimeNotifier, button: HTMLButtonElement
arn.reloadContent()
})
.catch(err => arn.statusMessage.showError(err))
}
// Filter anime on maldiff page
export function malDiffFilterAnime(arn: AnimeNotifier, input: HTMLInputElement) {
let year = arn.app.find("filter-year") as HTMLSelectElement
let status = arn.app.find("filter-status") as HTMLSelectElement
let type = arn.app.find("filter-type") as HTMLSelectElement
arn.app.load(`/editor/anime/maldiff/${year.value}/${status.value}/${type.value}`)
}