Skip to content
Snippets Groups Projects
Commit 972bce47 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

ENH: allow to provide a function that creates the form to create_show_form_callback

parent ac7248b1
No related branches found
No related tags found
2 merge requests!103Quick main-release of documentation,!98ENH: allow to provide a function that creates the form to create_show_form_callback
Pipeline #35305 passed
......@@ -67,13 +67,26 @@ var form_panel = new function () {
/**
* Creates a callback function that toggles the form panel which
*/
this.create_show_form_callback = function (panel_id, title, form_config) {
this.create_show_form_callback = function (
panel_id, title, form_config, form_creator=undefined
) {
return (e) => {
logger.trace("enter show_form_panel", e);
const panel = $(form_panel.get_form_panel(panel_id, title));
if (panel.find("form").length === 0) {
const form = form_elements.make_form(form_config);
if (form_config != undefined && form_creator!=undefined){
throw new Error("create_show_form_callback takes either a FormConfig or a function that creates the form");
}
var form;
if (form_config != undefined ){
form = form_elements.make_form(form_config);
} else if (form_creator != undefined ){
form = form_creator();
} else {
throw new Error("create_show_form_callback takes a FormConfig or a function that creates the form");
}
panel.append(form);
$(form).find(".selectpicker").selectpicker();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment