[TASK] refactor select
This commit is contained in:
parent
85d35eaf41
commit
c6fa27f046
@ -10,7 +10,7 @@
|
|||||||
{{ macros::checkbox(label='Gäste erlauben', name='tripdetails.allow_guests') }}
|
{{ macros::checkbox(label='Gäste erlauben', name='tripdetails.allow_guests') }}
|
||||||
{{ macros::checkbox(label='Immer anzeigen', name='tripdetails.always_show') }}
|
{{ macros::checkbox(label='Immer anzeigen', name='tripdetails.always_show') }}
|
||||||
{{ macros::input(label='Anmerkungen', name='tripdetails.notes', type='input') }}
|
{{ macros::input(label='Anmerkungen', name='tripdetails.notes', type='input') }}
|
||||||
{{ macros::select(data=trip_types, name='tripdetails.trip_type', default='Reguläre Ausfahrt') }}
|
{{ macros::select(label='Typ', data=trip_types, name='tripdetails.trip_type', default='Reguläre Ausfahrt') }}
|
||||||
|
|
||||||
<input value="Erstellen" class="w-full btn btn-primary" type="submit"/>
|
<input value="Erstellen" class="w-full btn btn-primary" type="submit"/>
|
||||||
</form>
|
</form>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
{{ macros::checkbox(label='Gäste erlauben', name='allow_guests') }}
|
{{ macros::checkbox(label='Gäste erlauben', name='allow_guests') }}
|
||||||
{{ macros::checkbox(label='Immer anzeigen', name='always_show') }}
|
{{ macros::checkbox(label='Immer anzeigen', name='always_show') }}
|
||||||
{{ macros::input(label='Anmerkungen', name='notes', type='input') }}
|
{{ macros::input(label='Anmerkungen', name='notes', type='input') }}
|
||||||
{{ macros::select(data=trip_types, name='trip_type', default='Reguläre Ausfahrt') }}
|
{{ macros::select(label='Typ', data=trip_types, name='trip_type', default='Reguläre Ausfahrt') }}
|
||||||
|
|
||||||
<input value="Erstellen" class="w-full btn btn-primary" type="submit"/>
|
<input value="Erstellen" class="w-full btn btn-primary" type="submit"/>
|
||||||
</form>
|
</form>
|
||||||
|
@ -8,9 +8,9 @@
|
|||||||
{{ macros::input(label="Anzahl Sitze", name="amount_seats", type="number", required=true, min=1) }}
|
{{ macros::input(label="Anzahl Sitze", name="amount_seats", type="number", required=true, min=1) }}
|
||||||
{{ macros::input(label="Baujahr", name="year_built", type="number", min=1950, max=2050) }}
|
{{ macros::input(label="Baujahr", name="year_built", type="number", min=1950, max=2050) }}
|
||||||
{{ macros::input(label="Bootsbauer", name="boatbuilder", type="text") }}
|
{{ macros::input(label="Bootsbauer", name="boatbuilder", type="text") }}
|
||||||
{{ macros::select(data=locations, label='location', name='location_id', selected_id=1) }}
|
{{ macros::select(label="Standort", data=locations, name='location_id', selected_id=1) }}
|
||||||
{{ macros::select(data=users, label='users', name='owner', default="Vereinsboot") }}
|
{{ macros::select(label="Besitzer", data=users, name='owner', default="Verein") }}
|
||||||
{{ macros::checkbox(label="Steuerperson steuert nur", name="default_shipmaster_only_steering")}}
|
{{ macros::checkbox(label="handgesteuert", name="default_shipmaster_only_steering")}}
|
||||||
{{ macros::checkbox(label="Skull", name="skull", checked=true)}}
|
{{ macros::checkbox(label="Skull", name="skull", checked=true)}}
|
||||||
{{ macros::checkbox(label="Externes Boot (anderer Verein)", name="external")}}
|
{{ macros::checkbox(label="Externes Boot (anderer Verein)", name="external")}}
|
||||||
</div>
|
</div>
|
||||||
@ -29,8 +29,8 @@
|
|||||||
<div class="grid md:grid-cols-3">
|
<div class="grid md:grid-cols-3">
|
||||||
{{ macros::input(label='Name', name='name', type='text', value=boat.name) }}
|
{{ macros::input(label='Name', name='name', type='text', value=boat.name) }}
|
||||||
{{ macros::input(label='Amount Seats', name='amount_seats', type='number', min=0, value=boat.amount_seats) }}
|
{{ macros::input(label='Amount Seats', name='amount_seats', type='number', min=0, value=boat.amount_seats) }}
|
||||||
{{ macros::select(data=locations, label='location', name='location_id', selected_id=boat.location_id) }}
|
{{ macros::select(data=locations, label='Standort', name='location_id', selected_id=boat.location_id) }}
|
||||||
{{ macros::select(data=users, label='users', name='owner', selected_id=boat.owner, default="Vereinsboot") }}
|
{{ macros::select(data=users, label='Besitzer', name='owner', selected_id=boat.owner, default="Vereinsboot") }}
|
||||||
{{ macros::input(label='Baujahr', name='year_built', type='number', min=1950, value=boat.year_built) }}
|
{{ macros::input(label='Baujahr', name='year_built', type='number', min=1950, value=boat.year_built) }}
|
||||||
{{ macros::input(label='Bootsbauer', name='boatbuilder', type='text', value=boat.boatbuilder) }}
|
{{ macros::input(label='Bootsbauer', name='boatbuilder', type='text', value=boat.boatbuilder) }}
|
||||||
{{ macros::checkbox(label='default_shipmaster_only_steering', name='default_shipmaster_only_steering', id=uuid , checked=boat.default_shipmaster_only_steering) }}
|
{{ macros::checkbox(label='default_shipmaster_only_steering', name='default_shipmaster_only_steering', id=uuid , checked=boat.default_shipmaster_only_steering) }}
|
||||||
|
@ -88,25 +88,20 @@
|
|||||||
|
|
||||||
{{ macros::input(label="Kommentar", name="comments", type="text", wrapper_class="col-span-2") }}
|
{{ macros::input(label="Kommentar", name="comments", type="text", wrapper_class="col-span-2") }}
|
||||||
|
|
||||||
<div class="col-span-2">
|
{{ macros::select(label="Typ", data=logtypes, name='logtype', default="Normal", wrapper_class="col-span-2") }}
|
||||||
<label for="logtype" class=" text-sm text-gray-600 ">Typ</label>
|
|
||||||
{{ macros::select(data=logtypes, name='logtype', default="Normal") }}
|
|
||||||
</div>
|
|
||||||
<input type="submit" value="Ausfahrt starten" class="btn btn-primary w-full col-span-2 m-auto"/>
|
<input type="submit" value="Ausfahrt starten" class="btn btn-primary w-full col-span-2 m-auto"/>
|
||||||
</form>
|
</form>
|
||||||
{% endmacro new %}
|
{% endmacro new %}
|
||||||
|
|
||||||
|
|
||||||
{% macro boat_select(only_ones) %}
|
{% macro boat_select(only_ones) %}
|
||||||
<div class="col-span-2">
|
{% if not only_ones %}
|
||||||
<label for="boat_id" class=" text-sm text-gray-600 ">Boot</label>
|
{{ macros::select(label="Boot", data=boats, name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats", "on_water"], wrapper_class="col-span-2") }}
|
||||||
{% if not only_ones %}
|
{% else %}
|
||||||
{{ macros::select(data=boats, name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats", "on_water"], class="col-span-2") }}
|
{% set ones = boats | filter(attribute="amount_seats", value=1) %}
|
||||||
{% else %}
|
{{ macros::select(label="Boot", data=ones, name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats", "on_water"], wrapper_class="col-span-2") }}
|
||||||
{% set ones = boats | filter(attribute="amount_seats", value=1) %}
|
{% endif %}
|
||||||
{{ macros::select(data=ones, name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats", "on_water"], class="col-span-2") }}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% endmacro boat_select %}
|
{% endmacro boat_select %}
|
||||||
|
|
||||||
{% macro rower_select(id, selected, amount_seats='', class='', init='false') %}
|
{% macro rower_select(id, selected, amount_seats='', class='', init='false') %}
|
||||||
@ -266,11 +261,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ macros::input(label="Kommentar", name="comments", id="comments" ~ log.id, type="text", value=log.comments, class="rounded-md change-id-js") }}
|
{{ macros::input(label="Kommentar", name="comments", id="comments" ~ log.id, type="text", value=log.comments, class="rounded-md change-id-js") }}
|
||||||
|
{{ macros::select(label="Typ", data=logtypes, name="logtype", id="logtype" ~ log.id, default="Normal", selected_id=log.logtype, class="rounded-md change-id-js") }}
|
||||||
|
|
||||||
<div>
|
|
||||||
<label for="logtype" class="text-sm text-gray-600 ">Typ</label>
|
|
||||||
{{ macros::select(data=logtypes, name="logtype", id="logtype" ~ log.id, default="Normal", selected_id=log.logtype, class="rounded-md change-id-js") }}
|
|
||||||
</div>
|
|
||||||
<input class="btn btn-primary" type="submit" value="Ausfahrt beenden"/>
|
<input class="btn btn-primary" type="submit" value="Ausfahrt beenden"/>
|
||||||
</form>
|
</form>
|
||||||
{% endmacro home %}
|
{% endmacro home %}
|
||||||
|
@ -74,26 +74,29 @@
|
|||||||
</label>
|
</label>
|
||||||
{% endmacro checkbox %}
|
{% endmacro checkbox %}
|
||||||
|
|
||||||
{% macro select(data, name='trip_type', default='', id='', selected_id='', display='', extras='', class='') %}
|
{% macro select(label, data, name='trip_type', default='', id='', selected_id='', display='', extras='', class='', wrapper_class='') %}
|
||||||
{% if display == '' %}
|
<div class="{{wrapper_class}}">
|
||||||
{% set display = ["name"] %}
|
<label for="{{ name }}" class="text-sm text-gray-600">{{ label }}</label>
|
||||||
{% endif %}
|
{% if display == '' %}
|
||||||
<select name="{{ name }}" {% if id %} id="{{ id }}" {% else %} id="{{ name }}" {% endif %} class="input rounded-md h-10 {{ class }}">
|
{% set display = ["name"] %}
|
||||||
{% if default %}
|
{% endif %}
|
||||||
<option selected value>{{ default }}</option>
|
<select name="{{ name }}" {% if id %} id="{{ id }}" {% else %} id="{{ name }}" {% endif %} class="input rounded-md h-10 {{ class }}">
|
||||||
{% endif %}
|
{% if default %}
|
||||||
{% for d in data %}
|
<option selected value>{{ default }}</option>
|
||||||
<option value="{{ d.id }}" {% if d.id == selected_id %} selected {% endif %} {% if extras != '' %} {% for extra in extras %} {% if extra != 'on_water' %} data-{{extra}}={{d[extra]}} {% else %} {% if d[extra] %} disabled {% endif %} {% endif %} {% endfor %} {% endif %}>
|
{% endif %}
|
||||||
{% for displa in display -%}
|
{% for d in data %}
|
||||||
{%- if d[displa] -%}
|
<option value="{{ d.id }}" {% if d.id == selected_id %} selected {% endif %} {% if extras != '' %} {% for extra in extras %} {% if extra != 'on_water' %} data-{{extra}}={{d[extra]}} {% else %} {% if d[extra] %} disabled {% endif %} {% endif %} {% endfor %} {% endif %}>
|
||||||
{{- d[displa] -}}
|
{% for displa in display -%}
|
||||||
{%- else -%}
|
{%- if d[displa] -%}
|
||||||
{{- displa -}}
|
{{- d[displa] -}}
|
||||||
{%- endif -%}
|
{%- else -%}
|
||||||
{%- endfor %}
|
{{- displa -}}
|
||||||
</option>
|
{%- endif -%}
|
||||||
{% endfor %}
|
{%- endfor %}
|
||||||
</select>
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
{% endmacro select %}
|
{% endmacro select %}
|
||||||
|
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@
|
|||||||
{{ macros::input(label='Anmerkungen', name='notes', type='input', value=trip.notes) }}
|
{{ macros::input(label='Anmerkungen', name='notes', type='input', value=trip.notes) }}
|
||||||
{{ macros::checkbox(label='Immer anzeigen', name='always_show', id=trip.id,checked=trip.always_show) }}
|
{{ macros::checkbox(label='Immer anzeigen', name='always_show', id=trip.id,checked=trip.always_show) }}
|
||||||
{{ macros::checkbox(label='Gesperrt', name='is_locked', id=trip.id,checked=trip.is_locked) }}
|
{{ macros::checkbox(label='Gesperrt', name='is_locked', id=trip.id,checked=trip.is_locked) }}
|
||||||
{{ macros::select(name='trip_type', data=trip_types, default='Reguläre Ausfahrt', selected_id=trip.trip_type_id) }}
|
{{ macros::select(label='Typ', name='trip_type', data=trip_types, default='Reguläre Ausfahrt', selected_id=trip.trip_type_id) }}
|
||||||
|
|
||||||
<input value="Speichern" class="btn btn-primary" type="submit"/>
|
<input value="Speichern" class="btn btn-primary" type="submit"/>
|
||||||
</form>
|
</form>
|
||||||
|
Loading…
Reference in New Issue
Block a user