fix user title tags

This commit is contained in:
Thibault Duplessis 2020-08-19 13:59:45 +02:00
parent b8ae3a909a
commit 3dbe001e36
4 changed files with 12 additions and 19 deletions

View file

@ -95,18 +95,10 @@ trait GameHelper { self: I18nHelper with UserHelper with AiHelper with StringHel
def playerUsername(player: Player, withRating: Boolean = true, withTitle: Boolean = true): Frag =
player.aiLevel.fold[Frag](
player.userId.flatMap(lightUser).fold[Frag](lila.user.User.anonymous) { user =>
val title = user.title ifTrue withTitle map { t =>
frag(
span(
cls := "utitle",
(Title(t) == Title.BOT) option dataBotAttr,
st.title := Title titleName Title(t)
)(t),
" "
)
}
frag(
title,
user.title ifTrue withTitle map Title.apply map { t =>
frag(userTitleTag(t), " ")
},
if (withRating) s"${user.name} (${lila.game.Namer ratingString player})"
else user.name
)

View file

@ -131,7 +131,7 @@ trait UserHelper { self: I18nHelper with StringHelper with NumberHelper =>
title map { t =>
frag(
span(
cls := s"utitle${(t == Title.BOT) ?? " data-bot"}",
cls := "utitle",
st.title := Title.titleName(t)
)(t),
nbsp

View file

@ -2,12 +2,12 @@ package lila.app
package ui
import ornicar.scalalib.Zero
import scalatags.Text.all._
import scalatags.text.Builder
import scalatags.Text.{ Aggregate, Cap }
import lila.api.Context
import lila.user.Title
// collection of lila attrs
trait ScalatagsAttrs {
@ -53,9 +53,12 @@ trait ScalatagsSnippets extends Cap {
val badTag = tag("bad")
val timeTag = tag("time")
def dataBot(title: lila.user.Title): Modifier =
if (title == lila.user.Title.BOT) dataBotAttr
else emptyModifier
def userTitleTag(t: Title) =
span(
cls := "utitle",
t == lila.user.Title.BOT option dataBotAttr,
title := Title titleName t
)(t.value)
def pagerNext(pager: lila.common.paginator.Paginator[_], url: Int => String): Option[Frag] =
pager.nextPage.map { np =>

View file

@ -55,9 +55,7 @@ object bits {
)(name)
private def playerTitle(player: Player) =
player.userId.flatMap(lightUser).flatMap(_.title) map Title.apply map { t =>
span(cls := "title", dataBot(t), title := Title titleName t)(t.value)
}
player.userId.flatMap(lightUser).flatMap(_.title) map Title.apply map userTitleTag
def vstext(pov: Pov)(ctxOption: Option[Context]): Frag =
span(cls := "vstext")(