Skip to content

Commit

Permalink
Improve some UX
Browse files Browse the repository at this point in the history
  • Loading branch information
outkine committed Feb 10, 2024
1 parent 6e079a4 commit d0ff6d2
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 29 deletions.
16 changes: 15 additions & 1 deletion app/models/Schema.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,19 @@ object Schema {
rating: Int,
deviation: Double,
volatility: Double,
)
) {
val publishedFormatter = new DateTimeFormatterBuilder()
.appendMonthOfYear(2)
.appendLiteral('/')
.appendDayOfMonth(2)
.appendLiteral('/')
.appendTwoDigitYear(0)
.toFormatter

def formatPublished(): String = {
publishedFormatter.print(created)
}
}

object PRobot {
def apply(rId: RobotId, boardId: BoardId, code: String, glickoSettings: GlickoSettings) =
Expand Down Expand Up @@ -187,6 +199,8 @@ object Schema {
.appendMonthOfYear(2)
.appendLiteral('/')
.appendDayOfMonth(2)
.appendLiteral('/')
.appendTwoDigitYear(0)
.toFormatter

def formatCreated(): String = {
Expand Down
54 changes: 28 additions & 26 deletions app/views/board/robot.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,34 @@ <h1><a href="@routes.BoardController.view(boardWithBattles.board.id.id)">@boardW
<div class="_table">
<table class="_battles _body">
@for(FullBattle(battle, r1, r2) <- boardWithBattles.battles) {
<tr>
<td class="text-gray">@battle.formatCreated()</td>
<td><a href="@routes.BattleController.view(battle.id.id)">
<img src="@assetsFinder.path("images/battle.svg")">
#@battle.id.id
</a></td>
<td class="_robot pr-0
@{if (battle.didRobotWin(r1.id).contains(true)) " _winner" else ""}
"><a href="@routes.RobotController.viewById(battle.r1Id.id)">
<img src="@assetsFinder.path("images/robot.svg")">
@r1.name
</a></td>
<td class="_robot _rating
@{if (battle.didRobotWin(r1.id).contains(true)) " _winner" else ""}
">@battle.pr1Rating</td>
<td>vs</td>
<td class="_robot pr-0
@{if (battle.didRobotWin(r2.id).contains(true)) "_winner" else ""}
"><a href="@routes.RobotController.viewById(battle.r2Id.id)">
<img src="@assetsFinder.path("images/robot.svg")">
@r2.name
</a></td>
<td class="_robot _rating
@{if (battle.didRobotWin(r2.id).contains(true)) " _winner" else ""}
">@battle.pr2Rating</td>
</tr>
@defining(if (r1.id == robot.id) { (r1, r2) } else (r2, r1)) { case (ourR, otherR) =>
<tr>
<td class="text-gray">@battle.formatCreated()</td>
<td><a href="@routes.BattleController.view(battle.id.id)">
<img src="@assetsFinder.path("images/battle.svg")">
#@battle.id.id
</a></td>
<td class="_robot pr-0
@{if (battle.didRobotWin(ourR.id).contains(true)) " _winner" else ""}
"><a href="@routes.RobotController.viewById(ourR.id.id)">
<img src="@assetsFinder.path("images/robot.svg")">
@ourR.name
</a></td>
<td class="_robot _rating
@{if (battle.didRobotWin(ourR.id).contains(true)) " _winner" else ""}
">@{if (r1.id == robot.id) battle.pr1Rating else battle.pr2Rating}</td>
<td>vs</td>
<td class="_robot pr-0
@{if (battle.didRobotWin(otherR.id).contains(true)) "_winner" else ""}
"><a href="@routes.RobotController.viewById(otherR.id.id)">
<img src="@assetsFinder.path("images/robot.svg")">
@otherR.name
</a></td>
<td class="_robot _rating
@{if (battle.didRobotWin(otherR.id).contains(true)) " _winner" else ""}
">@{if (r1.id == robot.id) battle.pr2Rating else battle.pr1Rating}</td>
</tr>
}
}
</table>
<div class="_footer">
Expand Down
8 changes: 6 additions & 2 deletions app/views/robot/view.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,16 @@ <h2>Battles</h2>
<div class="_table mb-3">
<div class="_header">
<p>
@board.name <span class="text-grey">
@board.name
@if(board.password.isDefined) {
<img src="@assetsFinder.path("images/lock.svg")">
}
&nbsp;rating: @pRobot.rating</span>
</p>

<div>
<span class="text-grey">rating: @pRobot.rating&nbsp;</span>
<span class="text-grey">last published: @pRobot.formatPublished()</span>
</div>
</div>
<table class="_body _battles">
@if(battles.nonEmpty) {
Expand Down

0 comments on commit d0ff6d2

Please sign in to comment.