lila/app/views/userTournament/list.scala

61 lines
1.9 KiB
Scala
Raw Normal View History

2019-04-16 08:31:32 -06:00
package views.html
package userTournament
2020-02-09 07:38:26 -07:00
import play.api.i18n.Lang
2019-04-16 08:31:32 -06:00
import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
import lila.common.paginator.Paginator
2020-03-20 15:36:51 -06:00
import lila.user.User
2019-04-16 08:31:32 -06:00
import controllers.routes
object list {
2019-12-13 07:30:20 -07:00
def apply(
u: User,
path: String,
pager: Paginator[lila.tournament.LeaderboardApi.TourEntry],
count: String
2020-02-09 07:38:26 -07:00
)(implicit lang: Lang) =
2020-03-20 15:36:51 -06:00
if (pager.nbResults == 0)
2019-04-16 08:31:32 -06:00
div(cls := "box-pad")(u.username, " hasn't played in any tournament yet!")
2020-03-20 15:36:51 -06:00
else
2019-04-16 08:31:32 -06:00
div(cls := "tournament-list")(
table(cls := "slist")(
thead(
tr(
th(cls := "count")(count),
th(h1(userLink(u, withOnline = true), " tournaments")),
th("Games"),
th("Points"),
th("Rank")
)
),
tbody(cls := "infinitescroll")(
2019-04-16 09:18:04 -06:00
pagerNextTable(pager, np => routes.UserTournament.path(u.username, path, np).url),
2019-04-16 08:31:32 -06:00
pager.currentPageResults.map { e =>
tr(cls := List("paginated" -> true, "scheduled" -> e.tour.isScheduled))(
td(cls := "icon")(iconTag(tournamentIconChar(e.tour))),
td(cls := "header")(
a(href := routes.Tournament.show(e.tour.id))(
span(cls := "name")(e.tour.name()),
2019-04-16 08:31:32 -06:00
span(cls := "setup")(
2019-12-13 07:30:20 -07:00
e.tour.clock.show,
" • ",
2020-02-15 09:27:34 -07:00
if (e.tour.variant.exotic) e.tour.variant.name else e.tour.perfType.map(_.trans),
2019-12-13 07:30:20 -07:00
" • ",
2019-04-16 08:31:32 -06:00
momentFromNow(e.tour.startsAt)
)
)
),
td(cls := "games")(e.entry.nbGames),
td(cls := "score")(e.entry.score),
td(cls := "rank")(strong(e.entry.rank), " / ", e.tour.nbPlayers)
)
}
)
)
)
}