From 77339269c355fa85015c5bf7f6c25ff074efa6a8 Mon Sep 17 00:00:00 2001 From: Ramon Bartl Date: Thu, 19 Sep 2019 15:44:23 +0200 Subject: [PATCH 1/3] Fix Analysis Service JavaScript Interim Handling --- .../browser/js/bika.lims.analysisservice.js | 24 +++++++++---------- .../coffee/bika.lims.analysisservice.coffee | 20 +++++++++++++--- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/bika/lims/browser/js/bika.lims.analysisservice.js b/bika/lims/browser/js/bika.lims.analysisservice.js index e52fc9d84b..6cc80d3c3b 100644 --- a/bika/lims/browser/js/bika.lims.analysisservice.js +++ b/bika/lims/browser/js/bika.lims.analysisservice.js @@ -577,20 +577,23 @@ rows = field.find("tr.records_row_InterimFields"); interims = []; $.each(rows, function(index, row) { - var values; + var inputs, values; values = {}; - $.each($(row).find("td input"), function(index, input) { + inputs = row.querySelectorAll("td input"); + $.each(inputs, function(index, input) { var key, value; key = this.name.split(":")[0].split(".")[1]; value = input.value; if (input.type === "checkbox") { value = input.checked; } - return values[key] = value; + values[key] = value; + return true; }); if (values.keyword !== "") { - return interims.push(values); + interims.push(values); } + return true; }); return interims; }; @@ -634,18 +637,15 @@ key = this.name.split(":")[0].split(".")[1]; value = interim[key]; if (input.type === "checkbox") { - if (value) { - value = true; - } else { - value = false; - } - return input.checked = value; + input.checked = value; + input.value = "on"; } else { if (!value) { value = ""; } - return input.value = value; + input.value = value; } + return true; }); }); }; @@ -848,7 +848,7 @@ catalog_name: "bika_setup_catalog", page_size: 0, UID: calculation_uid, - is_active: true, + active_state: true, sort_on: "sortable_title" } }; diff --git a/bika/lims/browser/js/coffee/bika.lims.analysisservice.coffee b/bika/lims/browser/js/coffee/bika.lims.analysisservice.coffee index b99b1d465f..051db63d2e 100644 --- a/bika/lims/browser/js/coffee/bika.lims.analysisservice.coffee +++ b/bika/lims/browser/js/coffee/bika.lims.analysisservice.coffee @@ -537,7 +537,8 @@ class window.AnalysisServiceEditView interims = [] $.each rows, (index, row) -> values = {} - $.each $(row).find("td input"), (index, input) -> + inputs = row.querySelectorAll "td input" + $.each inputs, (index, input) -> # Extract the key from the element name # InterimFields.keyword:records:ignore_empty key = @name.split(":")[0].split(".")[1] @@ -545,9 +546,18 @@ class window.AnalysisServiceEditView if input.type is "checkbox" value = input.checked values[key] = value + # N.B. coffee-script always returns the last value if not explicitly returned + # and false values act as a break in $.each loops! + return true + # Only rows with Keyword set if values.keyword isnt "" interims.push values + + # N.B. coffee-script always returns the last value if not explicitly returned + # and false values act as a break in $.each loops! + return true + return interims @@ -592,13 +602,17 @@ class window.AnalysisServiceEditView key = @name.split(":")[0].split(".")[1] value = interim[key] if input.type is "checkbox" - # transform to bool value - if value then value = yes else value = no input.checked = value + # N.B. if we omit the value, the field won't be set on save + input.value = "on" else if not value then value = "" input.value = value + # N.B. coffee-script always returns the last value if not explicitly returned + # and false values act as a break in $.each loops! + return true + flush_interims: => ###* From 2f655a3d28fa53812f861b4d29b2a81a5197d434 Mon Sep 17 00:00:00 2001 From: Ramon Bartl Date: Thu, 19 Sep 2019 15:50:23 +0200 Subject: [PATCH 2/3] Changelog updated --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index b5d3da8f88..b6b26b83c9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -22,6 +22,7 @@ Changelog **Fixed** +- #1443 Fix non-saving checkbox values for manual Interims in Analysis Services - #1426 Render HTML Texts in Info Popups correctly - #1423 Use the value set for ui_item property when displaying ReferenceWidget - #1425 Fix adapter priority for widget visibility From f0c3d3ad3a224465181ca07da551ed64da663604 Mon Sep 17 00:00:00 2001 From: Ramon Bartl Date: Thu, 19 Sep 2019 16:35:03 +0200 Subject: [PATCH 3/3] Fixed query filter --- bika/lims/browser/js/bika.lims.analysisservice.js | 2 +- bika/lims/browser/js/coffee/bika.lims.analysisservice.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bika/lims/browser/js/bika.lims.analysisservice.js b/bika/lims/browser/js/bika.lims.analysisservice.js index 6cc80d3c3b..e87b74f91d 100644 --- a/bika/lims/browser/js/bika.lims.analysisservice.js +++ b/bika/lims/browser/js/bika.lims.analysisservice.js @@ -848,7 +848,7 @@ catalog_name: "bika_setup_catalog", page_size: 0, UID: calculation_uid, - active_state: true, + is_active: true, sort_on: "sortable_title" } }; diff --git a/bika/lims/browser/js/coffee/bika.lims.analysisservice.coffee b/bika/lims/browser/js/coffee/bika.lims.analysisservice.coffee index 051db63d2e..8cfd532553 100644 --- a/bika/lims/browser/js/coffee/bika.lims.analysisservice.coffee +++ b/bika/lims/browser/js/coffee/bika.lims.analysisservice.coffee @@ -817,7 +817,7 @@ class window.AnalysisServiceEditView catalog_name: "bika_setup_catalog" page_size: 0 UID: calculation_uid - active_state: true + is_active: true sort_on: "sortable_title" @ajax_submit options