Fix lobby setup default time mode

pull/9003/head
Benedikt Werner 2021-05-22 18:53:19 +02:00
parent b5d56aef8c
commit 24294eba7e
No known key found for this signature in database
GPG Key ID: 1DBFF0F8E9E121EB
4 changed files with 17 additions and 12 deletions

View File

@ -136,7 +136,8 @@ final class Setup(
Open { implicit ctx =>
NoBot {
if (HTTPRequest isXhr ctx.req) NoPlaybanOrCurrent {
fuccess(forms.hookFilled(timeModeString = get("time"))) map { html.setup.forms.hook(_) }
val timeMode = get("time")
fuccess(forms.hookFilled(timeModeString = timeMode)) map { html.setup.forms.hook(_, timeMode.isDefined) }
}
else
fuccess {

View File

@ -149,10 +149,11 @@ private object bits {
val dataRandomColorVariants =
attr("data-random-color-variants") := lila.game.Game.variantsWhereWhiteIsBetter.map(_.id).mkString(",")
val dataAnon = attr("data-anon")
val dataMin = attr("data-min")
val dataMax = attr("data-max")
val dataValidateUrl = attr("data-validate-url")
val dataResizable = attr("data-resizable")
val dataType = attr("data-type")
val dataAnon = attr("data-anon")
val dataMin = attr("data-min")
val dataMax = attr("data-max")
val dataValidateUrl = attr("data-validate-url")
val dataResizable = attr("data-resizable")
val dataType = attr("data-type")
val dataForceTimeMode = attr("data-force-time-mode")
}

View File

@ -13,11 +13,12 @@ object forms {
import bits._
def hook(form: Form[_])(implicit ctx: Context) =
def hook(form: Form[_], forceTimeMode: Boolean = false)(implicit ctx: Context) =
layout(
"hook",
trans.createAGame(),
routes.Setup.hook("sri-placeholder")
routes.Setup.hook("sri-placeholder"),
forceTimeMode = forceTimeMode
) {
frag(
renderVariant(form, translatedVariantChoicesWithVariants),
@ -122,7 +123,8 @@ object forms {
typ: String,
titleF: Frag,
route: Call,
error: Option[Frag] = None
error: Option[Frag] = None,
forceTimeMode: Boolean = false,
)(fields: Frag)(implicit ctx: Context) =
div(cls := error.isDefined option "error")(
h2(titleF),
@ -140,7 +142,8 @@ object forms {
novalidate,
dataRandomColorVariants,
dataType := typ,
dataAnon := ctx.isAnon.option("1")
dataAnon := ctx.isAnon.option("1"),
dataForceTimeMode := forceTimeMode.option("1")
)(
fields,
if (ctx.blind) submitButton("Create the game")

View File

@ -176,7 +176,7 @@ export default class Setup {
if (c) {
Object.keys(c).forEach(k => {
$form.find(`[name="${k}"]`).each(function (this: HTMLInputElement) {
if (k === 'timeMode' && this.value !== '1') return;
if (k === 'timeMode' && $form.data('forceTimeMode')) return;
if (this.type == 'checkbox') this.checked = true;
else if (this.type == 'radio') this.checked = this.value == c[k];
else if (k != 'fen' || !this.value) this.value = c[k];