Improved user experience with part withdraw modal

Related to issue #201
This commit is contained in:
Jan Böhmer 2023-01-07 20:49:36 +01:00
parent ba4085d882
commit 436aff7533
6 changed files with 128 additions and 17 deletions

View file

@ -31,6 +31,38 @@ export default class extends Controller
this.element.querySelector('input[name="action"]').setAttribute('value', action);
this.element.querySelector('input[name="lot_id"]').setAttribute('value', lotID);
//Set the title
const titleElement = this.element.querySelector('.modal-title');
switch (action) {
case 'withdraw':
titleElement.innerText = titleElement.getAttribute('data-withdraw');
break;
case 'add':
titleElement.innerText = titleElement.getAttribute('data-add');
break;
case 'move':
titleElement.innerText = titleElement.getAttribute('data-move');
break;
}
//Hide the move to lot select, if the action is not move (and unhide it, if it is)
const moveToLotSelect = this.element.querySelector('#withdraw-modal-move-to');
if (action === 'move') {
moveToLotSelect.classList.remove('d-none');
} else {
moveToLotSelect.classList.add('d-none');
}
//First unhide all move to lot options and then hide the currently selected lot
const moveToLotOptions = moveToLotSelect.querySelectorAll('input[type="radio"]');
moveToLotOptions.forEach(option => option.parentElement.classList.remove('d-none'));
moveToLotOptions.forEach(option => {
if (option.getAttribute('value') === lotID) {
option.parentElement.classList.add('d-none');
option.selected = false;
}
});
//For adding parts there is no limit on the amount to add
if (action == 'add') {
amountInput.removeAttribute('max');