2020-04-29 12:57:13 -06:00
|
|
|
package views.html
|
|
|
|
package swiss
|
|
|
|
|
2020-10-05 06:39:25 -06:00
|
|
|
import controllers.routes
|
2020-04-29 12:57:13 -06:00
|
|
|
import play.api.libs.json.Json
|
|
|
|
|
|
|
|
import lila.api.Context
|
|
|
|
import lila.app.templating.Environment._
|
|
|
|
import lila.app.ui.ScalatagsTemplate._
|
|
|
|
import lila.common.String.html.safeJsonValue
|
2020-10-05 06:39:25 -06:00
|
|
|
import lila.swiss.{ Swiss, SwissCondition }
|
2020-04-29 12:57:13 -06:00
|
|
|
|
|
|
|
object show {
|
|
|
|
|
|
|
|
def apply(
|
2020-04-29 15:46:31 -06:00
|
|
|
s: Swiss,
|
2020-10-05 06:39:25 -06:00
|
|
|
verdicts: SwissCondition.All.WithVerdicts,
|
2020-04-29 12:57:13 -06:00
|
|
|
data: play.api.libs.json.JsObject,
|
2020-09-23 04:07:06 -06:00
|
|
|
chatOption: Option[lila.chat.UserChat.Mine],
|
2021-01-20 14:50:11 -07:00
|
|
|
streamers: List[lila.user.User.ID],
|
2020-09-23 04:07:06 -06:00
|
|
|
isLocalMod: Boolean
|
2020-05-15 12:15:14 -06:00
|
|
|
)(implicit ctx: Context): Frag = {
|
|
|
|
val isDirector = ctx.userId.has(s.createdBy)
|
|
|
|
val hasScheduleInput = isDirector && s.settings.manualRounds && s.isNotFinished
|
2020-04-29 15:46:31 -06:00
|
|
|
views.html.base.layout(
|
|
|
|
title = s"${s.name} #${s.id}",
|
|
|
|
moreJs = frag(
|
2020-07-31 05:52:49 -06:00
|
|
|
jsModule("swiss"),
|
2020-09-12 04:30:40 -06:00
|
|
|
hasScheduleInput option jsModule("flatpickr"),
|
2020-09-04 08:10:30 -06:00
|
|
|
embedJsUnsafeLoadThen(s"""LichessSwiss.start(${safeJsonValue(
|
2020-05-15 12:15:14 -06:00
|
|
|
Json
|
|
|
|
.obj(
|
|
|
|
"data" -> data,
|
|
|
|
"i18n" -> bits.jsI18n,
|
|
|
|
"userId" -> ctx.userId,
|
|
|
|
"chat" -> chatOption.map { c =>
|
|
|
|
chat.json(
|
|
|
|
c.chat,
|
|
|
|
name = trans.chatRoom.txt(),
|
|
|
|
timeout = c.timeout,
|
|
|
|
public = true,
|
2020-09-23 04:07:06 -06:00
|
|
|
resourceId = lila.chat.Chat.ResourceId(s"swiss/${c.chat.id}"),
|
|
|
|
localMod = isLocalMod
|
2020-05-15 12:15:14 -06:00
|
|
|
)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.add("schedule" -> hasScheduleInput)
|
2020-04-29 15:46:31 -06:00
|
|
|
)})""")
|
|
|
|
),
|
2020-05-15 12:15:14 -06:00
|
|
|
moreCss = frag(
|
|
|
|
cssTag("swiss.show"),
|
|
|
|
hasScheduleInput option cssTag("flatpickr")
|
|
|
|
),
|
2020-04-29 15:46:31 -06:00
|
|
|
chessground = false,
|
|
|
|
openGraph = lila.app.ui
|
|
|
|
.OpenGraph(
|
|
|
|
title = s"${s.name}: ${s.variant.name} ${s.clock.show} #${s.id}",
|
|
|
|
url = s"$netBaseUrl${routes.Swiss.show(s.id.value).url}",
|
2020-05-05 22:11:15 -06:00
|
|
|
description =
|
|
|
|
s"${s.nbPlayers} players compete in the ${showEnglishDate(s.startsAt)} ${s.name} swiss tournament " +
|
|
|
|
s"organized by ${teamIdToName(s.teamId)}. " +
|
|
|
|
s.winnerId.fold("Winner is not yet decided.") { winnerId =>
|
|
|
|
s"${usernameOrId(winnerId)} takes the prize home!"
|
|
|
|
}
|
2020-04-29 15:46:31 -06:00
|
|
|
)
|
|
|
|
.some
|
|
|
|
)(
|
|
|
|
main(cls := "swiss")(
|
|
|
|
st.aside(cls := "swiss__side")(
|
2021-01-20 14:50:11 -07:00
|
|
|
swiss.side(s, verdicts, streamers, chatOption.isDefined)
|
2020-04-29 15:46:31 -06:00
|
|
|
),
|
|
|
|
div(cls := "swiss__main")(div(cls := "box"))
|
|
|
|
)
|
|
|
|
)
|
2020-05-15 12:15:14 -06:00
|
|
|
}
|
2020-04-29 12:57:13 -06:00
|
|
|
}
|