[TASK] improve ux in mobile form

This commit is contained in:
Marie Birner 2023-09-28 16:18:47 +02:00 committed by philipp
parent 8cec4e4c11
commit 9b433f977a

View File

@ -93,30 +93,45 @@ function reloadPage() {
function setMaxAmountRowers(rowers: number, isShipmasterSteering='false') { function setMaxAmountRowers(rowers: number, isShipmasterSteering='false') {
let curSelection = choiceObjects['newrower'].getValue(true); let curSelection = choiceObjects['newrower'].getValue(true);
let amount_to_delete = (<any>curSelection).length - rowers; 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['newrower'].removeActiveItemsByValue(del);
}
}
choiceObjects['newrower'].config.maxItemCount = rowers; if (amount_to_delete > 0){
if (rowers === 0) { let to_delete = (<any>curSelection).slice(-amount_to_delete);
choiceObjects['newrower'].disable() for (let del of to_delete) {
}else{ choiceObjects['newrower'].removeActiveItemsByValue(del);
choiceObjects['newrower'].enable() }
} }
let input = <HTMLElement>document.querySelector('#newrower');
if(input) {
choiceObjects['newrower'].config.maxItemCount = rowers;
if (rowers === 0) {
choiceObjects['newrower'].disable()
input.parentElement?.parentElement?.parentElement?.classList.add('hidden');
input.parentElement?.parentElement?.parentElement?.classList.add('md:block');
input.parentElement?.parentElement?.parentElement?.classList.add('opacity-50');
} else{
choiceObjects['newrower'].enable();
input.parentElement?.parentElement?.parentElement?.classList.remove('hidden');
input.parentElement?.parentElement?.parentElement?.classList.remove('md:block');
input.parentElement?.parentElement?.parentElement?.classList.remove('opacity-50');
}
}
let only_steering = <HTMLSelectElement>document.querySelector('#shipmaster_only_steering'); let only_steering = <HTMLSelectElement>document.querySelector('#shipmaster_only_steering');
if(only_steering) { if(only_steering) {
if(isShipmasterSteering == 'true') { if(isShipmasterSteering == 'true') {
only_steering.removeAttribute('disabled'); only_steering.removeAttribute('disabled');
only_steering.setAttribute('checked', 'true'); only_steering.setAttribute('checked', 'true');
only_steering.parentElement?.parentElement?.parentElement?.classList.remove('hidden');
only_steering.parentElement?.parentElement?.parentElement?.classList.remove('md:block');
only_steering.parentElement?.parentElement?.parentElement?.classList.remove('opacity-50'); only_steering.parentElement?.parentElement?.parentElement?.classList.remove('opacity-50');
} else { } else {
only_steering.setAttribute('disabled', 'disabled'); only_steering.setAttribute('disabled', 'disabled');
only_steering.removeAttribute('checked'); only_steering.removeAttribute('checked');
only_steering.parentElement?.parentElement?.parentElement?.classList.add('hidden');
only_steering.parentElement?.parentElement?.parentElement?.classList.add('md:block');
only_steering.parentElement?.parentElement?.parentElement?.classList.add('opacity-50'); only_steering.parentElement?.parentElement?.parentElement?.classList.add('opacity-50');
} }
} }