Disable more elements when form is closed
This commit is contained in:
@ -24,9 +24,9 @@
|
||||
{% endmacro %}
|
||||
|
||||
{# Simple driver select for forms #}
|
||||
{% macro driver_select(name, label, include_none, drivers=none) %}
|
||||
{% macro driver_select(name, label, include_none, drivers=none, disabled=false) %}
|
||||
<div class="form-floating">
|
||||
<select name="{{ name }}" id="{{ name }}" class="form-select" aria-label="{{ name }}">
|
||||
<select name="{{ name }}" id="{{ name }}" class="form-select" aria-label="{{ name }}" {% if disabled %}disabled="disabled"{% endif %}>
|
||||
<option value="" selected disabled hidden></option>
|
||||
|
||||
{% if drivers == none %}
|
||||
@ -42,9 +42,9 @@
|
||||
{% endmacro %}
|
||||
|
||||
{# Driver select for forms where a value might be preselected #}
|
||||
{% macro driver_select_with_preselect(driver_match, name, label, include_none, drivers=none) %}
|
||||
{% macro driver_select_with_preselect(driver_match, name, label, include_none, drivers=none, disabled=false) %}
|
||||
<div class="form-floating">
|
||||
<select name="{{ name }}" id="{{ name }}" class="form-select" aria-label="{{ name }}">
|
||||
<select name="{{ name }}" id="{{ name }}" class="form-select" aria-label="{{ name }}" {% if disabled %}disabled="disabled"{% endif %}>
|
||||
{# Use namespace wrapper to persist scope between loop iterations #}
|
||||
{% set user_has_chosen = namespace(driverpre=false) %}
|
||||
|
||||
@ -75,9 +75,9 @@
|
||||
{% endmacro %}
|
||||
|
||||
{# Simple team select for forms #}
|
||||
{% macro team_select(name, label, include_none, teams=none) %}
|
||||
{% macro team_select(name, label, include_none, teams=none, disabled=false) %}
|
||||
<div class="form-floating">
|
||||
<select name="{{ name }}" id="{{ name }}" class="form-select" aria-label="{{ name }}">
|
||||
<select name="{{ name }}" id="{{ name }}" class="form-select" aria-label="{{ name }}" {% if disabled %}disabled="disabled"{% endif %}>
|
||||
<option value="" selected disabled hidden></option>
|
||||
|
||||
{% if teams == none %}
|
||||
@ -93,9 +93,9 @@
|
||||
{% endmacro %}
|
||||
|
||||
{# Team select for forms where a value might be preselected #}
|
||||
{% macro team_select_with_preselect(team_match, name, label, include_none, teams=none) %}
|
||||
{% macro team_select_with_preselect(team_match, name, label, include_none, teams=none, disabled=false) %}
|
||||
<div class="form-floating">
|
||||
<select name="{{ name }}" id="{{ name }}" class="form-select" aria-label="{{ name }}">
|
||||
<select name="{{ name }}" id="{{ name }}" class="form-select" aria-label="{{ name }}" {% if disabled %}disabled="disabled"{% endif %}>
|
||||
{# Use namespace wrapper to persist scope between loop iterations #}
|
||||
{% set user_has_chosen = namespace(teampre=false) %}
|
||||
|
||||
|
@ -51,17 +51,26 @@
|
||||
{{ model.active_result_race_name_or_current_race_name() }}
|
||||
</h5>
|
||||
|
||||
<form action="/result-enter/{{ model.active_result_race_name_or_current_race_name_sanitized() }}" method="post">
|
||||
{% set race_result_open=model.race_result_open(model.active_result_race_name_or_current_race_name()) %}
|
||||
{% if race_result_open == true %}
|
||||
{% set action_save_href = "/result-enter/" ~ model.active_result_race_name_or_current_race_name_sanitized() %}
|
||||
{% else %}
|
||||
{% set action_save_href = "" %}
|
||||
{% endif %}
|
||||
|
||||
<form action="{{ action_save_href }}" method="post">
|
||||
<ul class="list-group list-group-flush d-inline-block">
|
||||
{% for driver in model.all_drivers_or_active_result_standing_drivers() %}
|
||||
<li class="list-group-item p-1"><span id="place_number" class="fw-bold">P{{ "%02d" % loop.index }}</span>: </li>
|
||||
<li class="list-group-item p-1"><span id="place_number"
|
||||
class="fw-bold">P{{ "%02d" % loop.index }}</span>:
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<ul id="columns" class="list-group list-group-flush d-inline-block float-end">
|
||||
|
||||
{% for driver in model.all_drivers_or_active_result_standing_drivers() %}
|
||||
<li class="list-group-item column p-1" draggable="true">
|
||||
<li class="list-group-item {% if race_result_open == true %}column{% endif %} p-1" {% if race_result_open == true %}draggable="true"{% endif %}>
|
||||
{{ driver.name }}
|
||||
|
||||
<div class="d-inline-block float-end" style="margin-left: 30px;">
|
||||
@ -69,7 +78,8 @@
|
||||
<div class="form-check form-check-reverse d-inline-block">
|
||||
<input type="checkbox" class="form-check-input" value="{{ driver.name }}"
|
||||
id="first-dnf-{{ driver.name }}" name="first-dnf-drivers"
|
||||
{% if (model.active_result is not none) and (driver in model.active_result.initial_dnf) %}checked{% endif %}>
|
||||
{% if (model.active_result is not none) and (driver in model.active_result.initial_dnf) %}checked{% endif %}
|
||||
{% if race_result_open == false %}disabled="disabled"{% endif %}>
|
||||
<label for="first-dnf-{{ driver.name }}"
|
||||
class="form-check-label text-muted">1. DNF</label>
|
||||
</div>
|
||||
@ -78,7 +88,8 @@
|
||||
<div class="form-check form-check-reverse d-inline-block mx-2">
|
||||
<input type="checkbox" class="form-check-input" value="{{ driver.name }}"
|
||||
id="dnf-{{ driver.name }}" name="dnf-drivers"
|
||||
{% if (model.active_result is not none) and (driver in model.active_result.all_dnfs) %}checked{% endif %}>
|
||||
{% if (model.active_result is not none) and (driver in model.active_result.all_dnfs) %}checked{% endif %}
|
||||
{% if race_result_open == false %}disabled="disabled"{% endif %}>
|
||||
<label for="dnf-{{ driver.name }}"
|
||||
class="form-check-label text-muted">DNF</label>
|
||||
</div>
|
||||
@ -87,7 +98,8 @@
|
||||
<div class="form-check form-check-reverse d-inline-block">
|
||||
<input type="checkbox" class="form-check-input" value="{{ driver.name }}"
|
||||
id="exclude-{{ driver.name }}" name="excluded-drivers"
|
||||
{% if (model.active_result is not none) and (driver in model.active_result.standing_exclusions) %}checked{% endif %}>
|
||||
{% if (model.active_result is not none) and (driver in model.active_result.standing_exclusions) %}checked{% endif %}
|
||||
{% if race_result_open == false %}disabled="disabled"{% endif %}>
|
||||
<label for="exclude-{{ driver.name }}"
|
||||
class="form-check-label text-muted" data-bs-toggle="tooltip"
|
||||
title="Driver is not counted for standing">NC</label>
|
||||
@ -100,7 +112,8 @@
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<input type="submit" class="btn btn-danger mt-2 w-100" value="Save">
|
||||
<input type="submit" class="btn btn-danger mt-2 w-100" value="Save"
|
||||
{% if race_result_open == false %}disabled="disabled"{% endif %}>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
@ -101,7 +101,8 @@
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{% if model.race_guess_open(model.current_race) == true %}
|
||||
{% set race_guess_open = model.race_guess_open(model.current_race) %}
|
||||
{% if race_guess_open == true %}
|
||||
{% set action_save_href = "/race-guess/" ~ model.current_race.name_sanitized ~ "/" ~ model.active_user.name_sanitized %}
|
||||
{% set action_delete_href = "/race-guess-delete/" ~ model.current_race.name_sanitized ~ "/" ~ model.active_user.name_sanitized %}
|
||||
{% else %}
|
||||
@ -114,21 +115,21 @@
|
||||
{% set user_guess = model.race_guesses_by(user_name=model.active_user.name, race_name=model.current_race.name) %}
|
||||
|
||||
{# Driver PXX Select #}
|
||||
{{ driver_select_with_preselect(driver_match=user_guess.pxx_guess, name="pxxselect", label="P" ~ model.current_race.place_to_guess ~ ":", include_none=true) }}
|
||||
{{ driver_select_with_preselect(driver_match=user_guess.pxx_guess, name="pxxselect", label="P" ~ model.current_race.place_to_guess ~ ":", include_none=true, disabled=not race_guess_open) }}
|
||||
|
||||
<div class="mt-2"></div>
|
||||
|
||||
{# Driver DNF Select #}
|
||||
{{ driver_select_with_preselect(driver_match=user_guess.dnf_guess, name="dnfselect", label="DNF:", include_none=true) }}
|
||||
{{ driver_select_with_preselect(driver_match=user_guess.dnf_guess, name="dnfselect", label="DNF:", include_none=true, disabled=not race_guess_open) }}
|
||||
|
||||
<input type="submit" class="btn btn-danger mt-2 w-100" value="Save"
|
||||
{% if model.race_guess_open(model.current_race) == false %}disabled="disabled"{% endif %}>
|
||||
{% if race_guess_open == false %}disabled="disabled"{% endif %}>
|
||||
</form>
|
||||
|
||||
{# Delete guess #}
|
||||
<form action="{{ action_delete_href }}" method="post">
|
||||
<input type="submit" class="btn btn-dark mt-2 w-100" value="Delete"
|
||||
{% if model.race_guess_open(model.current_race) == false %}disabled{% endif %}>
|
||||
{% if race_guess_open == false %}disabled{% endif %}>
|
||||
</form>
|
||||
</td>
|
||||
|
||||
|
@ -28,7 +28,8 @@
|
||||
|
||||
{% set user_guess = model.season_guesses_by(user_name=user.name) %}
|
||||
|
||||
{% if model.season_guess_open() == true %}
|
||||
{% set season_guess_open = model.season_guess_open() %}
|
||||
{% if season_guess_open == true %}
|
||||
{% set action_save_href = "/season-guess/" ~ user.name %}
|
||||
{% else %}
|
||||
{% set action_save_href = "" %}
|
||||
@ -37,33 +38,31 @@
|
||||
|
||||
{# Hot Take #}
|
||||
<div class="form-floating">
|
||||
{% if user_guess is not none %}
|
||||
<textarea class="form-control" id="hot-take-input-{{ user.name }}" name="hottakeselect"
|
||||
style="height: 150px">{{ user_guess.hot_take_string() }}</textarea>
|
||||
{% else %}
|
||||
<textarea class="form-control" id="hot-take-input-{{ user.name }}" name="hottakeselect"
|
||||
style="height: 150px"></textarea>
|
||||
{% endif %}
|
||||
style="height: 150px"
|
||||
{% if season_guess_open == false %}disabled="disabled"{% endif %}>
|
||||
{%- if user_guess is not none -%}{{ user_guess.hot_take_string() }}{%- endif -%}
|
||||
</textarea>
|
||||
|
||||
<label for="hot-take-input-{{ user.name }}" class="text-primary">Hot Take:</label>
|
||||
</div>
|
||||
|
||||
{# P2 Constructor #}
|
||||
<div class="mt-2">
|
||||
{{ team_select_with_preselect(team_match=user_guess.p2_wcc, name="p2select", label="P2 in WCC:", include_none=false) }}
|
||||
{{ team_select_with_preselect(team_match=user_guess.p2_wcc, name="p2select", label="P2 in WCC:", include_none=false, disabled=not season_guess_open) }}
|
||||
</div>
|
||||
|
||||
{# Most Overtakes + DNFs #}
|
||||
<div class="input-group mt-2">
|
||||
{{ driver_select_with_preselect(driver_match=user_guess.most_overtakes, name="overtakeselect", label="Most overtakes:", include_none=false) }}
|
||||
{{ driver_select_with_preselect(driver_match=user_guess.most_dnfs, name="dnfselect", label="Most DNFs:", include_none=false) }}
|
||||
{{ driver_select_with_preselect(driver_match=user_guess.most_overtakes, name="overtakeselect", label="Most overtakes:", include_none=false, disabled=not season_guess_open) }}
|
||||
{{ driver_select_with_preselect(driver_match=user_guess.most_dnfs, name="dnfselect", label="Most DNFs:", include_none=false, disabled=not season_guess_open) }}
|
||||
</div>
|
||||
|
||||
{# Most Gained + Lost #}
|
||||
<div class="input-group mt-2" data-bs-toggle="tooltip"
|
||||
title="Which driver will gain/lose the most places in comparison to last season's results?">
|
||||
{{ driver_select_with_preselect(driver_match=user_guess.most_wdc_gained, name="gainedselect", label="Most WDC places gained:", include_none=false, drivers=model.drivers_for_wdc_gained()) }}
|
||||
{{ driver_select_with_preselect(driver_match=user_guess.most_wdc_lost, name="lostselect", label="Most WDC places lost:", include_none=false) }}
|
||||
{{ driver_select_with_preselect(driver_match=user_guess.most_wdc_gained, name="gainedselect", label="Most WDC places gained:", include_none=false, drivers=model.drivers_for_wdc_gained(), disabled=not season_guess_open) }}
|
||||
{{ driver_select_with_preselect(driver_match=user_guess.most_wdc_lost, name="lostselect", label="Most WDC places lost:", include_none=false, disabled=not season_guess_open) }}
|
||||
</div>
|
||||
|
||||
{# Team-internal Winners #}
|
||||
@ -81,7 +80,8 @@
|
||||
name="teamwinner-{{ team.name }}"
|
||||
id="teamwinner-{{ team.name }}-1-{{ user.name }}"
|
||||
value="{{ driver_a.name }}"
|
||||
{% if (user_guess is not none) and (driver_a in user_guess.team_winners) %}checked="checked"{% endif %}>
|
||||
{% if (user_guess is not none) and (driver_a in user_guess.team_winners) %}checked="checked"{% endif %}
|
||||
{% if season_guess_open == false %}disabled="disabled"{% endif %}>
|
||||
<label class="form-check-label"
|
||||
for="teamwinner-{{ team.name }}-1-{{ user.name }}">{{ driver_a.name }}</label>
|
||||
</div>
|
||||
@ -93,7 +93,8 @@
|
||||
name="teamwinner-{{ team.name }}"
|
||||
id="teamwinner-{{ team.name }}-2-{{ user.name }}"
|
||||
value="{{ driver_b.name }}"
|
||||
{% if (user_guess is not none) and (driver_b in user_guess.team_winners) %}checked="checked"{% endif %}>
|
||||
{% if (user_guess is not none) and (driver_b in user_guess.team_winners) %}checked="checked"{% endif %}
|
||||
{% if season_guess_open == false %}disabled="disabled"{% endif %}>
|
||||
<label class="form-check-label"
|
||||
for="teamwinner-{{ team.name }}-2-{{ user.name }}">{{ driver_b.name }}</label>
|
||||
</div>
|
||||
@ -115,7 +116,8 @@
|
||||
name="podiumdrivers"
|
||||
id="podium-{{ driver_a.name }}-{{ user.name }}"
|
||||
value="{{ driver_a.name }}"
|
||||
{% if (user_guess is not none) and (driver_a in user_guess.podiums) %}checked="checked"{% endif %}>
|
||||
{% if (user_guess is not none) and (driver_a in user_guess.podiums) %}checked="checked"{% endif %}
|
||||
{% if season_guess_open == false %}disabled="disabled"{% endif %}>
|
||||
<label class="form-check-label"
|
||||
for="podium-{{ driver_a.name }}-{{ user.name }}">{{ driver_a.name }}</label>
|
||||
</div>
|
||||
@ -127,7 +129,8 @@
|
||||
name="podiumdrivers"
|
||||
id="podium-{{ driver_b.name }}-{{ user.name }}"
|
||||
value="{{ driver_b.name }}"
|
||||
{% if (user_guess is not none) and (driver_b in user_guess.podiums) %}checked="checked"{% endif %}>
|
||||
{% if (user_guess is not none) and (driver_b in user_guess.podiums) %}checked="checked"{% endif %}
|
||||
{% if season_guess_open == false %}disabled="disabled"{% endif %}>
|
||||
<label class="form-check-label"
|
||||
for="podium-{{ driver_b.name }}-{{ user.name }}">{{ driver_b.name }}</label>
|
||||
</div>
|
||||
@ -135,7 +138,8 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<input type="submit" class="btn btn-danger mt-2 w-100" value="Save" {% if model.season_guess_open() == false %}disabled{% endif %}>
|
||||
<input type="submit" class="btn btn-danger mt-2 w-100" value="Save"
|
||||
{% if season_guess_open == false %}disabled{% endif %}>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user