diff --git a/CHANGES.rst b/CHANGES.rst index d3671c90fe..b064d048ba 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -26,6 +26,7 @@ Changelog **Fixed** +- #1443 Fix non-saving checkbox values for manual Interims in Analysis Services - #1439 Fix global Auditlog when Analyses/Attachments were removed - #1426 Render HTML Texts in Info Popups correctly - #1423 Use the value set for ui_item property when displaying ReferenceWidget diff --git a/bika/lims/browser/js/bika.lims.analysisservice.js b/bika/lims/browser/js/bika.lims.analysisservice.js index e52fc9d84b..e87b74f91d 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; }); }); }; diff --git a/bika/lims/browser/js/coffee/bika.lims.analysisservice.coffee b/bika/lims/browser/js/coffee/bika.lims.analysisservice.coffee index b99b1d465f..8cfd532553 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: => ###* @@ -803,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