lila/app/views/user/show/side.scala

107 lines
3.3 KiB
Scala
Raw Normal View History

2018-12-04 06:16:52 -07:00
package views.html.user.show
import controllers.routes
2018-12-04 06:16:52 -07:00
import lila.api.Context
import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
import lila.rating.PerfType
import lila.user.User
import play.api.i18n.Lang
2018-12-04 06:16:52 -07:00
object side {
def apply(
2019-12-13 07:30:20 -07:00
u: User,
rankMap: lila.rating.UserRankMap,
active: Option[lila.rating.PerfType]
2018-12-04 06:16:52 -07:00
)(implicit ctx: Context) = {
def showNonEmptyPerf(perf: lila.rating.Perf, perfType: PerfType) =
perf.nonEmpty option showPerf(perf, perfType)
def showPerf(perf: lila.rating.Perf, perfType: PerfType) = {
val isPuzzle = perfType == lila.rating.PerfType.Puzzle
2018-12-04 06:16:52 -07:00
a(
dataIcon := perfType.iconChar,
2020-02-15 09:27:34 -07:00
title := perfType.desc,
2018-12-04 06:16:52 -07:00
cls := List(
2019-12-13 07:30:20 -07:00
"empty" -> perf.isEmpty,
2018-12-04 06:16:52 -07:00
"active" -> active.has(perfType)
),
href := {
if (isPuzzle) routes.Puzzle.dashboard(30, "home")
else routes.User.perfStat(u.username, perfType.key)
},
2019-03-29 20:54:05 -06:00
span(
h3(perfType.trans),
2019-03-29 20:54:05 -06:00
st.rating(
2020-09-23 02:51:36 -06:00
if (perf.glicko.clueless) strong("?")
else
strong(
perf.glicko.intRating,
perf.provisional option "?"
),
2019-03-29 20:54:05 -06:00
" ",
ratingProgress(perf.progress),
" ",
span(
if (perfType.key == "puzzle") trans.nbPuzzles(perf.nb, perf.nb.localize)
else trans.nbGames(perf.nb, perf.nb.localize)
)
2018-12-04 06:16:52 -07:00
),
2019-08-18 07:52:49 -06:00
rankMap get perfType map { rank =>
2019-12-13 07:30:20 -07:00
span(cls := "rank", title := trans.rankIsUpdatedEveryNbMinutes.pluralSameTxt(15))(
trans.rankX(rank.localize)
)
2018-12-04 06:16:52 -07:00
}
2019-03-29 20:54:05 -06:00
),
2021-01-25 14:30:03 -07:00
iconTag("G")
2018-12-04 06:16:52 -07:00
)
}
2019-03-28 03:47:57 -06:00
div(cls := "side sub-ratings")(
2018-12-04 06:16:52 -07:00
(!u.lame || ctx.is(u) || isGranted(_.UserSpy)) option frag(
showNonEmptyPerf(u.perfs.ultraBullet, PerfType.UltraBullet),
showPerf(u.perfs.bullet, PerfType.Bullet),
showPerf(u.perfs.blitz, PerfType.Blitz),
showPerf(u.perfs.rapid, PerfType.Rapid),
showPerf(u.perfs.classical, PerfType.Classical),
showPerf(u.perfs.correspondence, PerfType.Correspondence),
br,
showNonEmptyPerf(u.perfs.crazyhouse, PerfType.Crazyhouse),
showNonEmptyPerf(u.perfs.chess960, PerfType.Chess960),
showNonEmptyPerf(u.perfs.kingOfTheHill, PerfType.KingOfTheHill),
showNonEmptyPerf(u.perfs.threeCheck, PerfType.ThreeCheck),
showNonEmptyPerf(u.perfs.antichess, PerfType.Antichess),
showNonEmptyPerf(u.perfs.atomic, PerfType.Atomic),
showNonEmptyPerf(u.perfs.horde, PerfType.Horde),
showNonEmptyPerf(u.perfs.racingKings, PerfType.RacingKings),
br,
u.noBot option showPerf(u.perfs.puzzle, PerfType.Puzzle),
u.noBot option showStorm(u.perfs.storm)
2018-12-04 06:16:52 -07:00
)
)
}
private def showStorm(storm: lila.rating.Perf.Storm)(implicit lang: Lang) =
a(
dataIcon := '~',
cls := List(
"empty" -> !storm.nonEmpty
),
2021-01-25 14:30:03 -07:00
href := routes.Storm.dashboard(),
span(
h3("Puzzle Storm"),
st.rating(
strong(storm.score),
storm.nonEmpty option frag(
" ",
span(trans.storm.xRuns.plural(storm.runs, storm.runs.localize))
)
)
),
iconTag("G")
)
2018-12-04 06:16:52 -07:00
}