Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-saving checkbox values for manual Interims in Analysis Services #1443

Merged
merged 4 commits into from
Sep 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions bika/lims/browser/js/bika.lims.analysisservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -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;
});
});
};
Expand Down
22 changes: 18 additions & 4 deletions bika/lims/browser/js/coffee/bika.lims.analysisservice.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -537,17 +537,27 @@ 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]
value = input.value
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


Expand Down Expand Up @@ -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: =>
###*
Expand Down Expand Up @@ -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
Expand Down