From c14d37eaeb76b4e02edac2b1a6f8fee37596bd43 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 30 Jul 2020 16:06:21 +0200 Subject: [PATCH] Fix deletion of consumptions in double consumption mode --- static/js/base.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/static/js/base.js b/static/js/base.js index 8bd6b8ca..fccb5b4f 100644 --- a/static/js/base.js +++ b/static/js/base.js @@ -95,6 +95,8 @@ function li(id, text, extra_css) { * @param note The concerned note. */ function displayStyle(note) { + if (!note) + return ""; let balance = note.balance; var css = ""; if (balance < -5000) @@ -274,7 +276,6 @@ function autoCompleteNote(field_id, note_list_id, notes, notes_display, alias_pr field.attr('data-original-title', aliases_matched_html).tooltip('show'); consumers.results.forEach(function (consumer) { - let note = consumer.note; let consumer_obj = $("#" + alias_prefix + "_" + consumer.id); consumer_obj.hover(function () { displayNote(consumer.note, consumer.name, user_note_field, profile_pic_field) @@ -282,8 +283,8 @@ function autoCompleteNote(field_id, note_list_id, notes, notes_display, alias_pr consumer_obj.click(function () { var disp = null; notes_display.forEach(function (d) { - // We compare the note ids - if (d.id === note.id) { + // We compare the alias ids + if (d.id === consumer.id) { d.quantity += 1; disp = d; } @@ -293,7 +294,7 @@ function autoCompleteNote(field_id, note_list_id, notes, notes_display, alias_pr disp = { name: consumer.name, id: consumer.id, - note: note, + note: consumer.note, quantity: 1 }; notes_display.push(disp);