(function () { var DialogDynaforms = function (appendTo, uidParentDynaform) { this.onClose = new Function(); this.onSelectItem = new Function(); this.uidParentDynaform = uidParentDynaform; DialogDynaforms.prototype.init.call(this, appendTo); }; DialogDynaforms.prototype.init = function (appendTo) { var that = this; this.dialog = $("
"); this.dialog.dialog({ appendTo: appendTo ? appendTo : document.body, modal: true, autoOpen: true, width: 500, height: 400, resizable: false, close: function (event, ui) { that.onClose(event, ui); that.dialog.remove(); } }); FormDesigner.main.DialogStyle(this.dialog); this.body = $("
"); this.dialog.append("

Please select the control you want to use with your variable.

".translate()); this.dialog.append(this.body); this.load(); }; DialogDynaforms.prototype.load = function () { var that = this; this.body.find(">div").remove(); (new PMRestClient({ endpoint: 'dynaforms', typeRequest: 'get', functionSuccess: function (xhr, response) { for (var i = 0; i < response.length; i++) { if (response[i].dyn_uid !== that.uidParentDynaform) {//todo that.addItem(response[i]); } } }, messageError: 'There are problems getting the list of DynaForms, please try again.'.translate() })).executeRestClient(); }; DialogDynaforms.prototype.addItem = function (dynaform) { var that = this; var item = $( "
" + "
" + "
" + dynaform.dyn_title + "
" + "
"); this.body.append(item); item.attr("render", "subform"); item.attr("dynaform", JSON.stringify(dynaform)); item.on("click", function (event) { that.onSelectItem(event, item); that.dialog.dialog("close").remove(); }); return item; }; FormDesigner.extendNamespace('FormDesigner.main.DialogDynaforms', DialogDynaforms); }());