1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-30 05:01:10 +02:00

Warn users when a transaction has no source or no destination

This commit is contained in:
Yohann D'ANELLO
2020-08-03 10:03:51 +02:00
parent 58fe8914cf
commit 0e3c4fcaf6
4 changed files with 31 additions and 12 deletions

View File

@ -154,6 +154,22 @@ function reset() {
* Apply all transactions: all notes in `notes` buy each item in `buttons`
*/
function consumeAll() {
let error = false;
if (notes_display.length === 0) {
$("#note").addClass('is-invalid');
$("#note_list").html(li("", "<strong>Ajoutez des émetteurs.</strong>", "text-danger"));
error = true;
}
if (buttons.length === 0) {
$("#consos_list").html(li("", "<strong>Ajoutez des consommations.</strong>", "text-danger"));
error = true;
}
if (error)
return;
notes_display.forEach(function(note_display) {
buttons.forEach(function(button) {
consume(note_display.note, note_display.name, button.dest, button.quantity * note_display.quantity, button.amount,