display little donor trophy in user mouseover badge

This commit is contained in:
Thibault Duplessis 2015-09-13 11:03:01 +02:00
parent 00826dc387
commit 29ed4c4214
5 changed files with 18 additions and 13 deletions

View file

@ -42,12 +42,13 @@ object User extends LilaController {
def showMini(username: String) = Open { implicit ctx =>
OptionFuResult(UserRepo named username) { user =>
GameRepo lastPlayedPlaying user zip
Env.donation.isDonor(user.id) zip
(ctx.userId ?? { relationApi.blocks(user.id, _) }) zip
(ctx.userId ?? { Env.game.crosstableApi(user.id, _) }) zip
(ctx.isAuth ?? { Env.pref.api.followable(user.id) }) zip
(ctx.userId ?? { relationApi.relation(_, user.id) }) map {
case ((((pov, blocked), crosstable), followable), relation) =>
Ok(html.user.mini(user, pov, blocked, followable, relation, crosstable))
case (((((pov, donor), blocked), crosstable), followable), relation) =>
Ok(html.user.mini(user, pov, blocked, followable, relation, crosstable, donor))
.withHeaders(CACHE_CONTROL -> "max-age=5")
}
}

View file

@ -169,6 +169,7 @@ trait UserHelper { self: I18nHelper with StringHelper with NumberHelper =>
cssClass: Option[String] = None,
withOnline: Boolean = true,
withPowerTip: Boolean = true,
withDonor: Boolean = false,
withTitle: Boolean = true,
withBestRating: Boolean = false,
withPerfRating: Option[PerfType] = None,
@ -181,7 +182,8 @@ trait UserHelper { self: I18nHelper with StringHelper with NumberHelper =>
val space = if (withOnline) " " else ""
val dataIcon = if (withOnline) """ data-icon="r"""" else ""
val rating = userRating(user, withPerfRating, withBestRating)
s"""<a$dataIcon $klass $href>$space$titleS$content$rating</a>"""
val donor = if (withDonor) donorBadge else ""
s"""<a$dataIcon $klass $href>$space$titleS$content$rating$donor</a>"""
}
def userInfosLink(
@ -283,4 +285,6 @@ trait UserHelper { self: I18nHelper with StringHelper with NumberHelper =>
}
s"$name played $nbGames games since $createdAt.$currentRating"
}
private val donorBadge = """<span data-icon="&#xe001;" class="donor is-gold"></span>"""
}

View file

@ -9,7 +9,7 @@
<tbody>
@users.map { u =>
<tr>
<td>@userLink(u, cssClass="revert-underline".some)</td>
<td>@userLink(u)</td>
<td>@u.perfs(perfType.key).map(_.intRating)</td>
</tr>
}
@ -25,7 +25,7 @@
<tbody>
@users.map { u =>
<tr>
<td>@userLink(u._1, cssClass="revert-underline".some)</td>
<td>@userLink(u._1)</td>
<td title="@trans.gamesPlayed()">#@u._2.localize</td>
</tr>
}
@ -45,7 +45,7 @@
<table><tbody>
@online.map { u =>
<tr>
<td>@userLink(u, cssClass="revert-underline".some)</td>
<td>@userLink(u)</td>
<td>@showBestPerf(u)</td>
</tr>
}
@ -73,8 +73,8 @@ description = "Best chess players in bullet, blitz, classical, Chess960 and more
<table class="tournament_winners"><tbody>
@tourneyWinners.map { w =>
<tr>
<td>@userIdLink(w.userId.some, cssClass="revert-underline".some)</td>
<td><a href="@routes.Tournament.show(w.tourId)" class="revert-underline">@scheduledTournamentNameShortHtml(w.tourName)</a></td>
<td>@userIdLink(w.userId.some)</td>
<td><a href="@routes.Tournament.show(w.tourId)">@scheduledTournamentNameShortHtml(w.tourName)</a></td>
</tr>
}
</tbody></table>

View file

@ -1,4 +1,4 @@
@(u: User, playing: Option[Pov], blocked: Boolean, followable: Boolean, rel: Option[lila.relation.Relation], crosstable: Option[lila.game.Crosstable])(implicit ctx: Context)
@(u: User, playing: Option[Pov], blocked: Boolean, followable: Boolean, rel: Option[lila.relation.Relation], crosstable: Option[lila.game.Crosstable], isDonor: Boolean)(implicit ctx: Context)
<div class="title">
<div>
@u.profileOrDefault.countryInfo.map {
@ -10,7 +10,7 @@
<span class="countrylang" data-icon="c">&nbsp;@name</span>
}
}
@userLink(u, withPowerTip = false)
@userLink(u, withPowerTip = false, withDonor = isDonor)
</div>
@if(u.engine && ctx.me.fold(true)(u !=)) {
<div class="warning" data-icon="j">@trans.thisPlayerUsesChessComputerAssistance()</div>

View file

@ -1658,9 +1658,6 @@ body.fpmenu #friend_box {
white-space: nowrap;
text-decoration: none;
}
a.user_link:hover {
text-decoration: underline;
}
a.user_link span.rp:before {
content: " ";
}
@ -1674,6 +1671,9 @@ a.user_link span.rp.down {
color: #d59120;
font-weight: bold;
}
.user_link span.donor {
margin-left: 5px;
}
div.warning {
padding: 5px;
background: #f2dede;