From 365a8a2abc6a2962829aceba68d81ceea6d5c84f Mon Sep 17 00:00:00 2001 From: Akos Pinter Date: Wed, 4 Aug 2021 14:06:32 +0200 Subject: [PATCH] Possible fix for the chore & battery dropdown clearing issue - #1560 --- public/viewjs/batterytracking.js | 35 +++++++++++++------------------- public/viewjs/choretracking.js | 26 ++++++++++++------------ 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/public/viewjs/batterytracking.js b/public/viewjs/batterytracking.js index a0633ce1..657551e5 100644 --- a/public/viewjs/batterytracking.js +++ b/public/viewjs/batterytracking.js @@ -122,10 +122,8 @@ function UndoChargeCycle(chargeCycleId) ); }; -$('#battery_id_text_input').on('blur', function(e) -{ - if ($('#battery_id').hasClass("combobox-menu-visible")) - { +$('#battery_id_text_input').on('blur', function(e) { + if ($('#battery_id').hasClass("combobox-menu-visible")) { return; } @@ -133,26 +131,21 @@ $('#battery_id_text_input').on('blur', function(e) var possibleOptionElement = []; // grocycode handling - if (input.startsWith("grcy")) - { + if (input.startsWith("grcy")) { var gc = input.split(":"); - if (gc[1] == "b") - { + if (gc[1] == "b") { possibleOptionElement = $("#battery_id option[value=\"" + gc[2] + "\"]").first(); } - } - if (possibleOptionElement.length > 0) - { - $('#battery_id').val(possibleOptionElement.val()); - $('#battery_id').data('combobox').refresh(); - $('#battery_id').trigger('change'); - } - else - { - $('#battery_id').val(null); - $('#battery_id_text_input').val(""); - $('#battery_id').data('combobox').refresh(); - $('#battery_id').trigger('change'); + if (possibleOptionElement.length > 0) { + $('#battery_id').val(possibleOptionElement.val()); + $('#battery_id').data('combobox').refresh(); + $('#battery_id').trigger('change'); + } else { + $('#battery_id').val(null); + $('#battery_id_text_input').val(""); + $('#battery_id').data('combobox').refresh(); + $('#battery_id').trigger('change'); + } } }); diff --git a/public/viewjs/choretracking.js b/public/viewjs/choretracking.js index 64435ed8..6cc3d286 100644 --- a/public/viewjs/choretracking.js +++ b/public/viewjs/choretracking.js @@ -161,19 +161,19 @@ $('#chore_id_text_input').on('blur', function(e) { possibleOptionElement = $("#chore_id option[value=\"" + gc[2] + "\"]").first(); } - } - if (possibleOptionElement.length > 0) - { - $('#chore_id').val(possibleOptionElement.val()); - $('#chore_id').data('combobox').refresh(); - $('#chore_id').trigger('change'); - } - else - { - $('#chore_id').val(null); - $('#chore_id_text_input').val(""); - $('#chore_id').data('combobox').refresh(); - $('#chore_id').trigger('change'); + if (possibleOptionElement.length > 0) + { + $('#chore_id').val(possibleOptionElement.val()); + $('#chore_id').data('combobox').refresh(); + $('#chore_id').trigger('change'); + } + else + { + $('#chore_id').val(null); + $('#chore_id_text_input').val(""); + $('#chore_id').data('combobox').refresh(); + $('#chore_id').trigger('change'); + } } });