Skip to content

Commit

Permalink
added option to add free text to enum using select2
Browse files Browse the repository at this point in the history
  • Loading branch information
Motti Bechhofer authored and Motti Bechhofer committed Jun 27, 2018
1 parent d293d92 commit 8e68372
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
18 changes: 11 additions & 7 deletions dist/js/brutusin-json-forms-bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ if ("undefined" === typeof markdown && window.console) {
console.warn("Include markdown.js (https://github.com/evilstreak/markdown-js) to add markdown support in property description popups");
}

if (("undefined" === typeof $ || "undefined" === typeof $.fn || "undefined" === typeof $.fn.selectpicker) && window.console) {
console.warn("Include bootstrap-select.js (https://github.com/silviomoreto/bootstrap-select) to turn native selects into bootstrap components");
if (("undefined" === typeof $ || "undefined" === typeof $.fn || "undefined" === typeof $.fn.select2) && window.console) {
console.warn("Include select2.js (https://github.com/select2/select2) to turn native selects into select2 components");
}

(function () {
Expand Down Expand Up @@ -109,16 +109,20 @@ if (("undefined" === typeof $ || "undefined" === typeof $.fn || "undefined" ===
// }input
// }
//});
// Bootstrap select
// select2
BrutusinForms.addDecorator(function (element, schema) {
if (element.tagName) {
var tagName = element.tagName.toLowerCase();
// https://github.com/silviomoreto/bootstrap-select
if (!("undefined" === typeof $ || "undefined" === typeof $.fn || "undefined" === typeof $.fn.selectpicker) && tagName === "select") {
// https://github.com/select2/select2
if (!("undefined" === typeof $ || "undefined" === typeof $.fn || "undefined" === typeof $.fn.select2) && tagName === "select") {
element.title = "";
element.className += " selectpicker";
element.className += "select2";
element.setAttribute("data-live-search", true);
$(element).selectpicker();
var options = {};
if(schema.enum){
options.tags = 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.

18 changes: 11 additions & 7 deletions src/js/brutusin-json-forms-bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ if ("undefined" === typeof markdown && window.console) {
console.warn("Include markdown.js (https://github.com/evilstreak/markdown-js) to add markdown support in property description popups");
}

if (("undefined" === typeof $ || "undefined" === typeof $.fn || "undefined" === typeof $.fn.selectpicker) && window.console) {
console.warn("Include bootstrap-select.js (https://github.com/silviomoreto/bootstrap-select) to turn native selects into bootstrap components");
if (("undefined" === typeof $ || "undefined" === typeof $.fn || "undefined" === typeof $.fn.select2) && window.console) {
console.warn("Include select2.js (https://github.com/select2/select2) to turn native selects into select2 components");
}

(function () {
Expand Down Expand Up @@ -109,16 +109,20 @@ if (("undefined" === typeof $ || "undefined" === typeof $.fn || "undefined" ===
// }input
// }
//});
// Bootstrap select
// select2
BrutusinForms.addDecorator(function (element, schema) {
if (element.tagName) {
var tagName = element.tagName.toLowerCase();
// https://github.com/silviomoreto/bootstrap-select
if (!("undefined" === typeof $ || "undefined" === typeof $.fn || "undefined" === typeof $.fn.selectpicker) && tagName === "select") {
// https://github.com/select2/select2
if (!("undefined" === typeof $ || "undefined" === typeof $.fn || "undefined" === typeof $.fn.select2) && tagName === "select") {
element.title = "";
element.className += " selectpicker";
element.className += "select2";
element.setAttribute("data-live-search", true);
$(element).selectpicker();
var options = {};
if(schema.enum){
options.tags = true;
}
$(element).select2(options);
}
}
});
Expand Down

0 comments on commit 8e68372

Please sign in to comment.