Merge branch 'select-dataset-issue' into 'staging'
Select dataset issue See merge request PhilippHofer/rot!35
This commit is contained in:
commit
a2c91b784a
@ -19,18 +19,47 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function selectBoatChange() {
|
function selectBoatChange() {
|
||||||
const boatSelect = document.querySelector('#boat_id');
|
const boatSelect = <HTMLSelectElement>document.querySelector('#boat_id');
|
||||||
if(boatSelect) {
|
const boatChoice = new Choices(boatSelect, {
|
||||||
boatSelect.addEventListener('change', function() {
|
loadingText: 'Wird geladen...',
|
||||||
const selectedElement = boatSelect as HTMLSelectElement;
|
noResultsText: 'Keine Ergebnisse gefunden',
|
||||||
const opt = selectedElement.options[selectedElement.selectedIndex];
|
noChoicesText: 'Keine Ergebnisse gefunden',
|
||||||
const selectedValue = (<HTMLOptionElement>opt).dataset.amount_seats;
|
itemSelectText: 'Zum Auswählen klicken',
|
||||||
const rowers = Number(selectedValue) - 1;
|
callbackOnCreateTemplates: function () {
|
||||||
|
return {
|
||||||
|
option: ({ label, value, customProperties, active, disabled, }: any) => {
|
||||||
|
const opt: HTMLOptionElement = Choices.defaults.templates.option.call(
|
||||||
|
this,
|
||||||
|
{ label, value, customProperties, active, disabled }
|
||||||
|
);
|
||||||
|
|
||||||
|
// We get the original <option> from choicejs
|
||||||
|
const originalOption: HTMLOptionElement = this._presetOptions.filter(
|
||||||
|
(option: HTMLOptionElement) => option.value === value
|
||||||
|
)[0];
|
||||||
|
|
||||||
|
const rowers = Number(originalOption.dataset.amount_seats) - 1;
|
||||||
choiceObjects['newrower'].config.maxItemCount = rowers;
|
choiceObjects['newrower'].config.maxItemCount = rowers;
|
||||||
choiceObjects['newrower'].removeActiveItems(rowers);
|
choiceObjects['newrower'].removeActiveItems(rowers);
|
||||||
(rowers === 0 ? choiceObjects['newrower'].disable() : choiceObjects['newrower'].enable())
|
(rowers === 0 ? choiceObjects['newrower'].disable() : choiceObjects['newrower'].enable());
|
||||||
});
|
|
||||||
|
return opt;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
choiceObjects[boatSelect.id] = boatChoice;
|
||||||
|
|
||||||
|
const shipmasterSelect = <HTMLSelectElement>document.querySelector('#shipmaster');
|
||||||
|
const shipmasterChoice = new Choices(shipmasterSelect, {
|
||||||
|
loadingText: 'Wird geladen...',
|
||||||
|
noResultsText: 'Keine Ergebnisse gefunden',
|
||||||
|
noChoicesText: 'Keine Ergebnisse gefunden',
|
||||||
|
itemSelectText: 'Zum Auswählen klicken',
|
||||||
|
});
|
||||||
|
|
||||||
|
choiceObjects[shipmasterSelect.id] = shipmasterChoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
function initBoatActions() {
|
function initBoatActions() {
|
||||||
@ -42,10 +71,11 @@ function initBoatActions() {
|
|||||||
const rowers = Number(select.dataset.seats) - 1;
|
const rowers = Number(select.dataset.seats) - 1;
|
||||||
choiceObjects['newrower'].config.maxItemCount = rowers;
|
choiceObjects['newrower'].config.maxItemCount = rowers;
|
||||||
choiceObjects['newrower'].removeActiveItems(rowers);
|
choiceObjects['newrower'].removeActiveItems(rowers);
|
||||||
let boatSelect = <HTMLSelectElement>document.querySelector('#boat_id');
|
|
||||||
if(boatSelect && select.dataset.id) {
|
if (select.dataset.id) {
|
||||||
boatSelect.value = select.dataset.id;
|
choiceObjects['boat_id'].setChoiceByValue(select.dataset.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
(rowers === 0 ? choiceObjects['newrower'].disable() : choiceObjects['newrower'].enable());
|
(rowers === 0 ? choiceObjects['newrower'].disable() : choiceObjects['newrower'].enable());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -64,8 +64,6 @@ async fn index(
|
|||||||
|
|
||||||
let on_water = Logbook::on_water(db).await;
|
let on_water = Logbook::on_water(db).await;
|
||||||
|
|
||||||
println!("{on_water:?}");
|
|
||||||
|
|
||||||
let mut context = Context::new();
|
let mut context = Context::new();
|
||||||
if let Some(msg) = flash {
|
if let Some(msg) = flash {
|
||||||
context.insert("flash", &msg.into_inner());
|
context.insert("flash", &msg.into_inner());
|
||||||
@ -111,8 +109,20 @@ async fn kiosk(
|
|||||||
kiosk: KioskCookie,
|
kiosk: KioskCookie,
|
||||||
) -> Template {
|
) -> Template {
|
||||||
let boats = Boat::all_at_location(db, kiosk.0).await;
|
let boats = Boat::all_at_location(db, kiosk.0).await;
|
||||||
let coxes = User::cox(db).await;
|
let coxes: Vec<UserWithWaterStatus> = futures::future::join_all(
|
||||||
let users = User::all(db).await;
|
User::cox(db)
|
||||||
|
.await
|
||||||
|
.into_iter()
|
||||||
|
.map(|user| UserWithWaterStatus::from_user(user, db)),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
let users: Vec<UserWithWaterStatus> = futures::future::join_all(
|
||||||
|
User::all(db)
|
||||||
|
.await
|
||||||
|
.into_iter()
|
||||||
|
.map(|user| UserWithWaterStatus::from_user(user, db)),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
let logtypes = LogType::all(db).await;
|
let logtypes = LogType::all(db).await;
|
||||||
let distances = Logbook::distances(db).await;
|
let distances = Logbook::distances(db).await;
|
||||||
|
|
||||||
|
@ -35,12 +35,20 @@
|
|||||||
<select name="shipmaster" id="shipmaster" class="input rounded-md h-10">
|
<select name="shipmaster" id="shipmaster" class="input rounded-md h-10">
|
||||||
<optgroup label="Steuerleute">
|
<optgroup label="Steuerleute">
|
||||||
{% for cox in coxes %}
|
{% for cox in coxes %}
|
||||||
<option value="{{ cox.id }}" {% if cox.on_water %} disabled="disabled" {% else %} {% if cox.id == shipmaster %} selected {% endif %} {% endif %}>{{ cox.name }} {% if cox.on_water %} (am Wasser) {% endif %}</option>
|
<option value="{{ cox.id }}" {% if cox.on_water %} disabled="disabled" {% else %} {% if cox.id == shipmaster %} selected {% endif %} {% endif %}>{{ cox.name }}
|
||||||
|
{% if cox.on_water %}
|
||||||
|
(am Wasser)
|
||||||
|
{% endif %}
|
||||||
|
</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</optgroup>
|
</optgroup>
|
||||||
<optgroup label="Mitglieder">
|
<optgroup label="Mitglieder">
|
||||||
{% for user in users | filter(attribute="is_cox", value=false) %}
|
{% for user in users | filter(attribute="is_cox", value=false) %}
|
||||||
<option value="{{ user.id }}" {% if user.id == shipmaster %} selected {% endif %} {% if user.on_water %} disabled="disabled" {% endif %}>{{ user.name }} {% if user.on_water %} (am Wasser) {% endif %}</option>
|
<option value="{{ user.id }}" {% if user.id == shipmaster %} selected {% endif %} {% if user.on_water %} disabled="disabled" {% endif %}>{{ user.name }}
|
||||||
|
{% if user.on_water %}
|
||||||
|
(am Wasser)
|
||||||
|
{% endif %}
|
||||||
|
</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</optgroup>
|
</optgroup>
|
||||||
</select>
|
</select>
|
||||||
@ -64,7 +72,7 @@
|
|||||||
<input class="input rounded-md set-distance-js" type="search" list="destinations" placeholder="Destination" id="destination" name="destination" value="" data-relation="distance_in_km"/>
|
<input class="input rounded-md set-distance-js" type="search" list="destinations" placeholder="Destination" id="destination" name="destination" value="" data-relation="distance_in_km"/>
|
||||||
<datalist id="destinations">
|
<datalist id="destinations">
|
||||||
{% for distance in distances %}
|
{% for distance in distances %}
|
||||||
<option value="{{ distance.0 }}" distance={{ distance.1 }} />
|
<option value="{{ distance.0 }}" distance={{ distance.1 }}/>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</datalist>
|
</datalist>
|
||||||
</div>
|
</div>
|
||||||
@ -105,7 +113,12 @@
|
|||||||
{% set_global sel = true %}
|
{% set_global sel = true %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<option value="{{ user.id }}" {% if sel %} selected {% endif %} {% if user.on_water %} disabled="disabled" {% endif %}>{{user.name}} {% if user.on_water %} (am Wasser) {% endif %}</option>
|
<option value="{{ user.id }}" {% if sel %} selected {% endif %} {% if user.on_water %} disabled="disabled" {% endif %}>
|
||||||
|
{{user.name}}
|
||||||
|
{% if user.on_water %}
|
||||||
|
(am Wasser)
|
||||||
|
{% endif %}
|
||||||
|
</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -83,7 +83,7 @@
|
|||||||
<option selected value>{{ default }}</option>
|
<option selected value>{{ default }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for d in data %}
|
{% for d in data %}
|
||||||
<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 %}>
|
<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 %}>
|
||||||
{% for displa in display -%}
|
{% for displa in display -%}
|
||||||
{%- if d[displa] -%}
|
{%- if d[displa] -%}
|
||||||
{{- d[displa] -}}
|
{{- d[displa] -}}
|
||||||
|
Loading…
Reference in New Issue
Block a user