Skip to content

Commit

Permalink
1998 - Fixing Coral3 checkbox storing json value as string instead of… (
Browse files Browse the repository at this point in the history
#1999)

* 1998 - Fixing Coral3 checkbox storing json value as string instead of boolean when using JSON_STORE
  • Loading branch information
marto authored and badvision committed Jul 31, 2019
1 parent 29918c6 commit 4c8d820
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com)
- #1993 - DialogProvider now supports styles for Dialog and Page dialogs
- #1953 - Bulk Workflow MCP process and relative path bug-fix for QueryHelperImpl when using QueryBuilder query type.
- #1997 - MCP Forms fixes for RTE configuration and NPE issue with AbstractResourceImpl when resource type is not set
- #1998 - Coral3 checkbox storing json value as string instead of boolean when using Json Store in multifields
- #2011 - Setting Travis platform to Trusty so that Oracle JDK 8 build will continue to work.

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,22 @@
});
});

function checkboxPrimativeType(value){
if (typeof value != "string") {
return value;
}
switch(value){
case true:
case "true":
return true;
case false:
case "false":
return false;
default:
return value;
}
}

function fillValue($form, fieldSetName, $field, counter){
var name = $field.attr("name"), value;

Expand All @@ -229,7 +245,8 @@
value = $field.val();

if (cmf.isCheckbox($field)) {
value = $field.prop("checked") ? $field.val() : "";
var defaultVal = $field.parent().find("[name='./" + name + "@DefaultValue']").attr('value');
value = checkboxPrimativeType($field.prop("checked") ? $field.val() : (defaultVal ? defaultVal : ""));
}

if (cmf.isAutocomplete($field) || cmf.isTagsField($field)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,22 @@
$.ajax(actionUrl).done(postProcess);
},

checkboxPrimativeType: function (value){
if (typeof value != "string") {
return value;
}
switch(value){
case true:
case "true":
return true;
case false:
case "false":
return false;
default:
return value;
}
},

fillValue: function ($field, record) {
var name = $field.attr("name"), value;

Expand All @@ -231,12 +247,12 @@
value = $field.val();

if (this.isCheckbox($field)) {
if ($field.prop("checked"))
value = $field.val();
else {
var uncheckedValue = $field.attr('name')+'@DefaultValue';
value = $field.parent().find('[name="'+uncheckedValue+'"]') ? $field.parent().find('[name="'+uncheckedValue+'"]').val() : "";
}
if ($field.prop("checked"))
value = $field.val();
else {
var defaultVal = $field.parent().find("[name='./" + name + "@DefaultValue']").attr('value');
value = this.checkboxPrimativeType($field.prop("checked") ? $field.val() : (defaultVal ? defaultVal : ""));
}
}

if (this.isAutocomplete($field) || this.isTagsField($field)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@

// To support coral 3 UI checkbox, add property granite:class=coral-Form-fieldwrapper to the field in dialog.
isCheckbox: function ($field) {
return !_.isEmpty($field) && ($field.prop("type") === "checkbox" || $field.hasClass("coral-Checkbox"));
return !_.isEmpty($field) && ($field.prop("type") === "checkbox" || $field.hasClass("coral-Checkbox") || $field.hasClass("coral3-Checkbox"));
},

setCheckBox: function ($field, value) {
if($field.parent().hasClass("coral-Checkbox")){
$field.parent().prop("checked", $field.attr("value") === value);
$field.parent().prop("checked", $field.attr("value") === value.toString());
}else {
$field.prop("checked", $field.attr("value") === value);
$field.prop("checked", $field.attr("value") === value.toString());
}
},

Expand Down

0 comments on commit 4c8d820

Please sign in to comment.