finish frontend(?)
This commit is contained in:
@ -38,30 +38,21 @@ function selectBoatChange() {
|
||||
noResultsText: 'Keine Ergebnisse gefunden',
|
||||
noChoicesText: 'Keine Ergebnisse gefunden',
|
||||
itemSelectText: 'Zum Auswählen klicken',
|
||||
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);
|
||||
|
||||
setMaxAmountRowers("newrower", rowers);
|
||||
|
||||
return opt;
|
||||
}
|
||||
}
|
||||
}
|
||||
} as any);
|
||||
|
||||
boatSelect.addEventListener('addItem', function(e) {
|
||||
const amount_seats = e.detail.customProperties.amount_seats;
|
||||
setMaxAmountRowers("newrower", amount_seats);
|
||||
|
||||
const inputElement = document.getElementById("departure") as HTMLInputElement;
|
||||
const now = new Date();
|
||||
const formattedDateTime = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}T${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}`;
|
||||
|
||||
inputElement.value = formattedDateTime;
|
||||
},false);
|
||||
|
||||
choiceObjects[boatSelect.id] = boatChoice;
|
||||
choiceObjects["boat_id"] = boatChoice;
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,16 +73,18 @@ function reloadPage() {
|
||||
}
|
||||
|
||||
function setMaxAmountRowers(name: string, rowers: number) {
|
||||
console.log("called fct: name="+name+"; rowers="+rowers);
|
||||
if(choiceObjects[name]) {
|
||||
let curSelection = choiceObjects[name].getValue(true);
|
||||
let amount_to_delete = (<any>curSelection).length - rowers;
|
||||
choiceObjects[name].removeActiveItems();
|
||||
//let curSelection = choiceObjects[name].getValue(true);
|
||||
//let amount_to_delete = (<any>curSelection).length - rowers;
|
||||
|
||||
if (amount_to_delete > 0){
|
||||
let to_delete = (<any>curSelection).slice(-amount_to_delete);
|
||||
for (let del of to_delete) {
|
||||
choiceObjects[name].removeActiveItemsByValue(del);
|
||||
}
|
||||
}
|
||||
//if (amount_to_delete > 0){
|
||||
// let to_delete = (<any>curSelection).slice(-amount_to_delete);
|
||||
// for (let del of to_delete) {
|
||||
// choiceObjects[name].removeActiveItemsByValue(del);
|
||||
// }
|
||||
//}
|
||||
|
||||
let input = <HTMLElement>document.querySelector('#'+name);
|
||||
|
||||
@ -127,6 +120,7 @@ function setMaxAmountRowers(name: string, rowers: number) {
|
||||
// }
|
||||
//}
|
||||
}
|
||||
console.log(choiceObjects["newrower"].config.maxItemCount);
|
||||
}
|
||||
|
||||
function initBoatActions() {
|
||||
@ -135,21 +129,11 @@ function initBoatActions() {
|
||||
Array.prototype.forEach.call(boatSelects, (select: HTMLInputElement) => {
|
||||
select.addEventListener('click', function() {
|
||||
if(select.dataset.seats) {
|
||||
const rowers = Number(select.dataset.seats);
|
||||
|
||||
setMaxAmountRowers("newrower", rowers);
|
||||
|
||||
if (select.dataset.id) {
|
||||
choiceObjects['boat_id'].setChoiceByValue(select.dataset.id);
|
||||
}
|
||||
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
const inputElement = document.getElementById("departure") as HTMLInputElement;
|
||||
const now = new Date();
|
||||
const formattedDateTime = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}T${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}`;
|
||||
|
||||
inputElement.value = formattedDateTime;
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -173,6 +157,7 @@ interface ChoiceEvent extends Event{
|
||||
is_cox: boolean,
|
||||
steers: boolean,
|
||||
cox_on_boat: boolean,
|
||||
amount_seats: number,
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -205,7 +190,7 @@ function initNewChoice(select: HTMLInputElement) {
|
||||
//const rowers = Number(originalOption.dataset.amount_seats);
|
||||
//const isShipmasterSteering = originalOption.dataset.default_shipmaster_only_steering;
|
||||
|
||||
//setMaxAmountRowers(select.id, curr_boat_rowers, isShipmasterSteering);
|
||||
//setMaxAmountRowersoselect.id, curr_boat_rowers, isShipmasterSteering);
|
||||
|
||||
return opt;
|
||||
}
|
||||
|
Reference in New Issue
Block a user