Compare commits

..

No commits in common. "4f9778eccfe33a62c8393e6115226dac00a0eca1" and "d7d0a3feddfb116aed2a4e7a3e0fe62f7d307ad5" have entirely different histories.

View File

@ -8,7 +8,7 @@ export interface choiceMap {
declare var loggedin_user_id: string; declare var loggedin_user_id: string;
let choiceObjects: choiceMap = {}; let choiceObjects: choiceMap = {};
let boat_in_ottensheim = true; let boat_in_ottensheim = true;
let boat_reserved_today = true; let boat_reserved_today= true;
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {
changeTheme(); changeTheme();
@ -103,11 +103,7 @@ function setTheme(theme: string, setLocalStorage = true) {
function setCurrentdate(input: HTMLInputElement) { function setCurrentdate(input: HTMLInputElement) {
if (input) { if (input) {
const now = new Date(); const now = new Date();
const formattedDateTime = `${now.getFullYear()}-${String( 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")}`;
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")}`;
input.value = formattedDateTime; input.value = formattedDateTime;
} }
@ -143,33 +139,29 @@ function selectBoatChange() {
boatSelect.addEventListener( boatSelect.addEventListener(
"addItem", "addItem",
function (e) { function (e) {
const event = e as ChoiceBoatEvent; const event = e as ChoiceBoatEvent;
boat_reserved_today = event.detail.customProperties.boat_reserved_today; boat_reserved_today = event.detail.customProperties.boat_reserved_today;
if (boat_reserved_today) { if (boat_reserved_today){
alert( alert(event.detail.label.trim()+' wurde heute reserviert. Bitte kontrolliere, dass du die Reservierung nicht störst.');
event.detail.label.trim() + }
" wurde heute reserviert. Bitte kontrolliere, dass du die Reservierung nicht störst."
);
}
boat_in_ottensheim = event.detail.customProperties.boat_in_ottensheim; boat_in_ottensheim = event.detail.customProperties.boat_in_ottensheim;
const amount_seats = event.detail.customProperties.amount_seats; const amount_seats = event.detail.customProperties.amount_seats;
setMaxAmountRowers("newrower", amount_seats); setMaxAmountRowers("newrower", amount_seats);
let only_steering = <HTMLSelectElement>( let only_steering = <HTMLSelectElement>document.querySelector('#shipmaster_only_steering');
document.querySelector("#shipmaster_only_steering") if (event.detail.customProperties.default_handoperated) {
); only_steering.setAttribute('checked', 'true');
if (event.detail.customProperties.default_handoperated) { }else {
only_steering.setAttribute("checked", "true"); only_steering.removeAttribute('checked');
} else { }
only_steering.removeAttribute("checked");
}
if (event.detail.customProperties.convert_handoperated_possible) { if (event.detail.customProperties.convert_handoperated_possible) {
only_steering.removeAttribute("readonly"); only_steering.removeAttribute('readonly');
} else { }else {
only_steering.setAttribute("readonly", "readonly"); only_steering.setAttribute('readonly', 'readonly');
} }
const destination = <HTMLSelectElement>( const destination = <HTMLSelectElement>(
document.querySelector("#destination") document.querySelector("#destination")
@ -178,35 +170,22 @@ function selectBoatChange() {
if (event.detail.customProperties.owner) { if (event.detail.customProperties.owner) {
choiceObjects["newrower"].setChoiceByValue( choiceObjects["newrower"].setChoiceByValue(
event.detail.customProperties.owner.toString() event.detail.customProperties.owner.toString(),
); );
if (event.detail.value === "36") { if(event.detail.value === '36') {
/** custom code for Etsch */ /** custom code for Etsch */
choiceObjects["newrower"].setChoiceByValue("81"); choiceObjects["newrower"].setChoiceByValue("81");
} }
} else if (typeof loggedin_user_id !== "undefined") { }else if (typeof loggedin_user_id !== 'undefined'){
const currentSelection = choiceObjects["newrower"].getValue(); choiceObjects["newrower"].setChoiceByValue(loggedin_user_id);
let selectedItemsCount: number; }
if (Array.isArray(currentSelection)) {
selectedItemsCount = currentSelection.length;
} else {
selectedItemsCount = currentSelection !== undefined ? 1 : 0;
}
if (selectedItemsCount == 0) {
choiceObjects["newrower"].setChoiceByValue(loggedin_user_id);
}
}
const inputElement = document.getElementById( const inputElement = document.getElementById(
"departure" "departure",
) as HTMLInputElement; ) as HTMLInputElement;
const now = new Date(); const now = new Date();
const formattedDateTime = `${now.getFullYear()}-${String( 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")}`;
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; inputElement.value = formattedDateTime;
@ -215,7 +194,7 @@ function selectBoatChange() {
); );
destinput.dispatchEvent(new Event("input")); destinput.dispatchEvent(new Event("input"));
}, },
false false,
); );
choiceObjects[boatSelect.id] = boatChoice; choiceObjects[boatSelect.id] = boatChoice;
@ -243,16 +222,16 @@ function reloadPage() {
function setMaxAmountRowers(name: string, rowers: number) { function setMaxAmountRowers(name: string, rowers: number) {
if (choiceObjects[name]) { if (choiceObjects[name]) {
//choiceObjects[name].removeActiveItems(-1); choiceObjects[name].removeActiveItems(-1);
let curSelection = choiceObjects[name].getValue(true); //let curSelection = choiceObjects[name].getValue(true);
let amount_to_delete = (<any>curSelection).length - rowers; //let amount_to_delete = (<any>curSelection).length - rowers;
if (amount_to_delete > 0) { //if (amount_to_delete > 0){
let to_delete = (<any>curSelection).slice(-amount_to_delete); // let to_delete = (<any>curSelection).slice(-amount_to_delete);
for (let del of to_delete) { // for (let del of to_delete) {
choiceObjects[name].removeActiveItemsByValue(del); // choiceObjects[name].removeActiveItemsByValue(del);
} // }
} //}
let input = <HTMLElement>document.querySelector("#" + name); let input = <HTMLElement>document.querySelector("#" + name);
if (input) { if (input) {
@ -260,24 +239,24 @@ function setMaxAmountRowers(name: string, rowers: number) {
if (rowers === 0) { if (rowers === 0) {
choiceObjects[name].disable(); choiceObjects[name].disable();
input.parentElement?.parentElement?.parentElement?.classList.add( input.parentElement?.parentElement?.parentElement?.classList.add(
"hidden" "hidden",
); );
input.parentElement?.parentElement?.parentElement?.classList.add( input.parentElement?.parentElement?.parentElement?.classList.add(
"md:block" "md:block",
); );
input.parentElement?.parentElement?.parentElement?.classList.add( input.parentElement?.parentElement?.parentElement?.classList.add(
"opacity-50" "opacity-50",
); );
} else { } else {
choiceObjects[name].enable(); choiceObjects[name].enable();
input.parentElement?.parentElement?.parentElement?.classList.remove( input.parentElement?.parentElement?.parentElement?.classList.remove(
"hidden" "hidden",
); );
input.parentElement?.parentElement?.parentElement?.classList.remove( input.parentElement?.parentElement?.parentElement?.classList.remove(
"md:block" "md:block",
); );
input.parentElement?.parentElement?.parentElement?.classList.remove( input.parentElement?.parentElement?.parentElement?.classList.remove(
"opacity-50" "opacity-50",
); );
} }
} }
@ -314,7 +293,7 @@ function setMaxAmountRowers(name: string, rowers: number) {
function initBoatActions() { function initBoatActions() {
const boatSelects = document.querySelectorAll( const boatSelects = document.querySelectorAll(
'.boats-js[data-onclick="true"]' '.boats-js[data-onclick="true"]',
); );
if (boatSelects) { if (boatSelects) {
Array.prototype.forEach.call(boatSelects, (select: HTMLInputElement) => { Array.prototype.forEach.call(boatSelects, (select: HTMLInputElement) => {
@ -387,7 +366,7 @@ function initNewChoice(select: HTMLInputElement) {
steering_person.setAttribute("required", "required"); steering_person.setAttribute("required", "required");
} }
const choice = new Choices(select, { const choice = new Choices(select, {
searchFields: ["label", "value", "customProperties.searchableText"], searchFields: ['label', 'value', 'customProperties.searchableText'],
removeItemButton: true, removeItemButton: true,
loadingText: "Wird geladen...", loadingText: "Wird geladen...",
noResultsText: "Keine Ergebnisse gefunden", noResultsText: "Keine Ergebnisse gefunden",
@ -470,7 +449,7 @@ function initNewChoice(select: HTMLInputElement) {
steeringSelect.add(new Option(name, user_id)); steeringSelect.add(new Option(name, user_id));
} }
}, },
false false,
); );
select.addEventListener( select.addEventListener(
@ -499,7 +478,7 @@ function initNewChoice(select: HTMLInputElement) {
} }
} }
}, },
false false,
); );
choiceObjects[select.id] = choice; choiceObjects[select.id] = choice;
@ -529,7 +508,7 @@ function initToggle() {
} }
sessionStorage.setItem( sessionStorage.setItem(
"tripsFilter", "tripsFilter",
JSON.stringify(Array.from(filterMap.entries())) JSON.stringify(Array.from(filterMap.entries())),
); );
} }
resetFilteredElements(); resetFilteredElements();
@ -556,7 +535,7 @@ function initToggle() {
} else { } else {
sessionStorage.setItem( sessionStorage.setItem(
"tripsFilter", "tripsFilter",
JSON.stringify(Array.from(filterObject.entries())) JSON.stringify(Array.from(filterObject.entries())),
); );
} }
} }
@ -568,14 +547,14 @@ function resetFilteredElements() {
hiddenElements, hiddenElements,
(hiddenElement: HTMLButtonElement) => { (hiddenElement: HTMLButtonElement) => {
hiddenElement.classList.remove("hidden"); hiddenElement.classList.remove("hidden");
} },
); );
} }
} }
function triggerFilterAction(activeFilter: any) { function triggerFilterAction(activeFilter: any) {
const activeBtn = document.querySelector( const activeBtn = document.querySelector(
'button[data-action="' + activeFilter + '"]' 'button[data-action="' + activeFilter + '"]',
); );
if (activeBtn) { if (activeBtn) {
activeBtn.setAttribute("aria-pressed", "true"); activeBtn.setAttribute("aria-pressed", "true");
@ -675,7 +654,7 @@ function initSidebar() {
sidebar.toggle(); sidebar.toggle();
}); });
} }
} },
); );
} }
} }
@ -772,15 +751,14 @@ function addRelationMagic(bodyElement: HTMLElement) {
dataList.options, dataList.options,
function (option) { function (option) {
return option.value === field.value; return option.value === field.value;
} },
); );
if (option && option.value !== "") { if (option && option.value !== ""){
// Get distance // Get distance
const distance = option.getAttribute("distance"); const distance = option.getAttribute("distance");
if (distance && relatedField.value === "") if (distance && relatedField.value === "") relatedField.value = distance;
relatedField.value = distance; }
}
} }
}); });
} }
@ -795,3 +773,4 @@ function replaceStrings() {
weekday.innerHTML = weekday.innerHTML.replace("Freitag", "Markttag"); weekday.innerHTML = weekday.innerHTML.replace("Freitag", "Markttag");
}); });
} }