Skip to content

Commit

Permalink
support multiselect for enums with select2
Browse files Browse the repository at this point in the history
  • Loading branch information
Motti Bechhofer authored and Motti Bechhofer committed Jun 28, 2018
1 parent c4be416 commit 2a6bd13
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
3 changes: 2 additions & 1 deletion dist/js/brutusin-json-forms-bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ if (("undefined" === typeof $ || "undefined" === typeof $.fn || "undefined" ===
element.title = "";
element.className += " select2";
var options = {
width: '100%'
width: '100%'
};
if(schema.enum){
options.tags = true;
options.multiple= true;
}
$(element).select2(options);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/js/brutusin-json-forms-bootstrap.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions dist/js/brutusin-json-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -1265,8 +1265,11 @@ if (typeof brutusin === "undefined") {
}
var value;

if (input.tagName.toLowerCase() === "select") {
value = input.options[input.selectedIndex].value;
if (input.tagName.toLowerCase() === "select") {
value = $(input).val();
if(typeof value === "object"){
value = value.join();
}
} else {
value = input.value;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/js/brutusin-json-forms.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/js/brutusin-json-forms-bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ if (("undefined" === typeof $ || "undefined" === typeof $.fn || "undefined" ===
element.title = "";
element.className += " select2";
var options = {
width: '100%'
width: '100%'
};
if(schema.enum){
options.tags = true;
options.multiple= true;
}
$(element).select2(options);
}
Expand Down
7 changes: 5 additions & 2 deletions src/js/brutusin-json-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -1265,8 +1265,11 @@ if (typeof brutusin === "undefined") {
}
var value;

if (input.tagName.toLowerCase() === "select") {
value = input.options[input.selectedIndex].value;
if (input.tagName.toLowerCase() === "select") {
value = $(input).val();
if(typeof value === "object"){
value = value.join();
}
} else {
value = input.value;
}
Expand Down

0 comments on commit 2a6bd13

Please sign in to comment.