search games by loser player name
This commit is contained in:
parent
5688302bb1
commit
f482ee2b6f
|
@ -22,6 +22,7 @@ description = s"Search in ${nbGames.localize} chess games using advanced criteri
|
|||
<h1 class="title">@trans.advancedSearch()</h1>
|
||||
<form rel="nofollow" class="search" action="@routes.Search.index()" method="get"
|
||||
data-req-winner="@form("players")("winner").value"
|
||||
data-req-loser="@form("players")("loser").value"
|
||||
data-req-white="@form("players")("white").value"
|
||||
data-req-black="@form("players")("black").value">
|
||||
@globalError(form)
|
||||
|
@ -59,6 +60,16 @@ description = s"Search in ${nbGames.localize} chess games using advanced criteri
|
|||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="loser user_row none">
|
||||
<th>
|
||||
<label for="@form("players")("loser").id">Loser</label>
|
||||
</th>
|
||||
<td class="single">
|
||||
<select id="@form("players")("loser").id" name="@form("players")("loser").name">
|
||||
<option class="blank" value=""></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<label>@trans.rating() <span class="help" title="The average rating of both players">(?)</span></label>
|
||||
|
|
|
@ -16,6 +16,7 @@ private[gameSearch] final class DataForm {
|
|||
"a" -> optional(nonEmptyText),
|
||||
"b" -> optional(nonEmptyText),
|
||||
"winner" -> optional(nonEmptyText),
|
||||
"loser" -> optional(nonEmptyText),
|
||||
"white" -> optional(nonEmptyText),
|
||||
"black" -> optional(nonEmptyText)
|
||||
)(SearchPlayer.apply)(SearchPlayer.unapply),
|
||||
|
@ -88,6 +89,7 @@ private[gameSearch] case class SearchData(
|
|||
user1 = players.cleanA,
|
||||
user2 = players.cleanB,
|
||||
winner = players.cleanWinner,
|
||||
loser = players.cleanLoser,
|
||||
winnerColor = winnerColor,
|
||||
perf = perf,
|
||||
source = source,
|
||||
|
@ -124,6 +126,7 @@ private[gameSearch] case class SearchPlayer(
|
|||
a: Option[String] = None,
|
||||
b: Option[String] = None,
|
||||
winner: Option[String] = None,
|
||||
loser: Option[String] = None,
|
||||
white: Option[String] = None,
|
||||
black: Option[String] = None
|
||||
) {
|
||||
|
@ -131,6 +134,7 @@ private[gameSearch] case class SearchPlayer(
|
|||
lazy val cleanA = clean(a)
|
||||
lazy val cleanB = clean(b)
|
||||
def cleanWinner = oneOf(winner)
|
||||
def cleanLoser = oneOf(loser)
|
||||
def cleanWhite = oneOf(white)
|
||||
def cleanBlack = oneOf(black)
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ private[gameSearch] object Fields {
|
|||
val perf = "p"
|
||||
val uids = "u"
|
||||
val winner = "w"
|
||||
val loser = "o"
|
||||
val winnerColor = "c"
|
||||
val averageRating = "a"
|
||||
val ai = "i"
|
||||
|
|
|
@ -50,7 +50,8 @@ final class GameSearchApi(
|
|||
Fields.rated -> game.rated,
|
||||
Fields.perf -> game.perfType.map(_.id),
|
||||
Fields.uids -> game.userIds.toArray.some.filterNot(_.isEmpty),
|
||||
Fields.winner -> (game.winner flatMap (_.userId)),
|
||||
Fields.winner -> game.winner.flatMap(_.userId),
|
||||
Fields.loser -> game.loser.flatMap(_.userId),
|
||||
Fields.winnerColor -> game.winner.fold(3)(_.color.fold(1, 2)),
|
||||
Fields.averageRating -> game.averageUsersRating,
|
||||
Fields.ai -> game.aiLevel,
|
||||
|
|
|
@ -10,6 +10,7 @@ case class Query(
|
|||
user1: Option[String] = None,
|
||||
user2: Option[String] = None,
|
||||
winner: Option[String] = None,
|
||||
loser: Option[String] = None,
|
||||
winnerColor: Option[Int] = None,
|
||||
perf: Option[Int] = None,
|
||||
source: Option[Int] = None,
|
||||
|
@ -32,6 +33,7 @@ case class Query(
|
|||
user1.nonEmpty ||
|
||||
user2.nonEmpty ||
|
||||
winner.nonEmpty ||
|
||||
loser.nonEmpty ||
|
||||
winnerColor.nonEmpty ||
|
||||
perf.nonEmpty ||
|
||||
source.nonEmpty ||
|
||||
|
|
|
@ -24,6 +24,7 @@ $(function() {
|
|||
var option = [];
|
||||
option.push("<option value='" + user + "'");
|
||||
option.push(isSelected(row, "winner", user, 'req-winner'));
|
||||
option.push(isSelected(row, "loser", user, 'req-loser'));
|
||||
option.push(isSelected(row, "whiteUser", user, 'req-white'));
|
||||
option.push(isSelected(row, "blackUser", user, 'req-black'));
|
||||
option.push(">" + user + "</option>");
|
||||
|
|
|
@ -18,8 +18,8 @@ form.search label {
|
|||
}
|
||||
|
||||
form.search input {
|
||||
width: 96%;
|
||||
padding: 0.5% 1%;
|
||||
width: 86%;
|
||||
padding: 3% 5%;
|
||||
}
|
||||
|
||||
form.search select {
|
||||
|
@ -34,8 +34,7 @@ form.search .single select {
|
|||
width: 99%;
|
||||
}
|
||||
|
||||
form.search .half select,
|
||||
form.search .half input {
|
||||
form.search .half select {
|
||||
width: 78%;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue