MWF.xApplication.process.FormDesigner.Module = MWF.xApplication.process.FormDesigner.Module || {}; MWF.xDesktop.requireApp("process.FormDesigner", "Module.$Element", null, false); MWF.xApplication.process.FormDesigner.Module.Subform = MWF.FCSubform = new Class({ Extends: MWF.FC$Element, Implements: [Options, Events], options: { "style": "default", "propertyPath": "/x_component_process_FormDesigner/Module/Subform/subform.html", "actions": [ { "name": "move", "icon": "move1.png", "event": "mousedown", "action": "move", "title": MWF.APPFD.LP.formAction.move }, { "name": "delete", "icon": "delete1.png", "event": "click", "action": "delete", "title": MWF.APPFD.LP.formAction["delete"] } // { // "name": "styleBrush", // "icon": "styleBrush.png", // "event": "click", // "action": "styleBrush", // "title": MWF.APPFD.LP.formAction["styleBrush"] // } ], }, initialize: function(form, options){ this.setOptions(options); this.path = "/x_component_process_FormDesigner/Module/Subform/"; this.cssPath = "/x_component_process_FormDesigner/Module/Subform/"+this.options.style+"/css.wcss"; this._loadCss(); this.moduleType = "element"; this.moduleName = "subform"; this.form = form; this.container = null; this.containerNode = null; }, load : function(json, node, parent){ this.json = json; this.node= node; this.node.store("module", this); //this.node.empty(); this.node.setStyles(this.css.moduleNode); //this._loadNodeStyles(); this._initModule(); if (this.json.subformSelected && this.json.subformSelected!=="none" && this.json.subformType!=="script"){ this.redoSelectedSubform(this.json.subformSelected, null, ""); }else{ this.node.empty(); this.loadIcon(); } this._loadTreeNode(parent); this.setCustomStyles(); this.parentContainer = this.treeNode.parentNode.module; this._setEditStyle_custom("id"); this.parseModules(); this.json.moduleName = this.moduleName; this.node.addEvent("click", function(){ this.refreshSubform(); }.bind(this)); this.node.addEvent("dblclick", function(e){ this.openSubform(e); }.bind(this)); }, _initModule: function(){ if (!this.json.isSaved) this.setStyleTemplate(); this.setPropertiesOrStyles("styles"); this.setPropertiesOrStyles("inputStyles"); this.setPropertiesOrStyles("properties"); this._setNodeProperty(); if (!this.form.isSubform) this._createIconAction(); this._setNodeEvent(); this.json.isSaved = true; this.queryGetFormDataFun = this.queryGetFormData.bind(this); this.postGetFormDataFun = this.postGetFormData.bind(this); this.form.addEvent("queryGetFormData", this.queryGetFormDataFun); this.form.addEvent("postGetFormData", this.postGetFormDataFun); }, openSubform: function(e){ if (this.json.subformSelected && this.json.subformSelected!=="none" && this.json.subformType!=="script"){ layout.desktop.openApplication(e, "process.FormDesigner", {"id": this.json.subformSelected, "appId": "FormDesigner"+this.json.subformSelected}); } }, _createMoveNode: function(){ this.moveNode = new Element("div", { "MWFType": "subform", "id": this.json.id, "styles": this.css.moduleNodeMove, "events": { "selectstart": function(){ return false; } } }).inject(this.form.container); }, _createNode: function(){ this.node = this.moveNode.clone(true, true); this.node.setStyles(this.css.moduleNode); this.node.set("id", this.json.id); this.node.addEvent("selectstart", function(){ return false; }); // debugger; // if (this.json.subformSelected && this.json.subformSelected!="none" && this.json.subformType!=="script"){ // this.redoSelectedSubform(this.json.subformSelected, $(this.property.data.pid+"selectSubform").getElement("select"), ""); // }else{ this.loadIcon(); // } this.node.addEvent("click", function(){ this.refreshSubform(); }.bind(this)); }, postGetFormData: function(node){ if (!node || node.contains(this.node)) this.show(); }, queryGetFormData: function(node){ if (!node || node.contains(this.node)) this.hide(); }, hide: function(){ this.node.empty(); }, show: function(){ if (this.subformData){ this.subformModule = new MWF.FCSubform.Form(this.form, this.node); this.subformModule.load(this.subformData); }else{ this.node.empty(); this.loadIcon(); } }, "delete": function(e){ var module = this; this.form.designer.shortcut = false; this.form.designer.confirm("warn", module.node, MWF.APPFD.LP.notice.deleteElementTitle, MWF.APPFD.LP.notice.deleteElement, 300, 120, function(){ if (this.queryGetFormDataFun) module.form.removeEvent("queryGetFormData", this.queryGetFormDataFun); if (this.postGetFormDataFun) module.form.removeEvent("postGetFormData", this.postGetFormDataFun); module.destroy(); module.form.selected(); module.form.designer.shortcut = true; this.close(); }, function(){ module.form.designer.shortcut = true; this.close(); }, null); }, refreshSubform: function(){ if (this.json.subformSelected && this.json.subformSelected!=="none" && this.json.subformType!=="script"){ MWF.Actions.get("x_processplatform_assemble_designer").getForm(this.json.subformSelected, function(json){ if (this.subformData.updateTime!==json.data.updateTime){ var select = null; if (this.property){ select = $(this.property.data.pid+"selectSubform").getElement("select"); } this.clearSubformList(this.json.subformSelected); this.reloadSubform(json.data, select, ""); } }.bind(this)); } }, loadIcon: function(){ this.iconNode = new Element("div", { "styles": this.css.iconNode }).inject(this.node); new Element("div", { "styles": this.css.iconNodeIcon }).inject(this.iconNode); new Element("div", { "styles": this.css.iconNodeText, "text": "Subform" }).inject(this.iconNode); }, _loadNodeStyles: function(){ this.iconNode = this.node.getElement("div").setStyles(this.css.iconNode); this.iconNode.getFirst("div").setStyles(this.css.iconNodeIcon); this.iconNode.getLast("div").setStyles(this.css.iconNodeText); }, _setEditStyle: function(name, input, oldValue){ if (name==="subformSelected"){ if (this.json.subformSelected!==oldValue){ this.redoSelectedSubform(name, input, oldValue); } } if (name==="subformType"){ if (this.json.subformType!==oldValue){ if (this.json.subformType !== "script"){ this.redoSelectedSubform(name, $(this.property.data.pid+"selectSubform").getElement("select"), ""); } if (this.json.subformType === "script"){ this.subformData = null; this.clearSubformList(this.json.subformSelected); this.node.empty(); this.loadIcon(); } } } }, redoSelectedSubform: function(name, input, oldValue){ if (this.json.subformSelected==="none") this.json.subformSelected=""; if (this.json.subformSelected && this.json.subformSelected!=="none"){ if (this.form.subformList && this.form.subformList[this.json.subformSelected]){ //var p = (input) ? input.getPosition() : this.node.getPosition(); var p = this.node.getPosition(document.bosy); this.form.designer.alert("error", { "event": { "x": p.x+150, "y": p.y+80 } }, this.form.designer.lp.subformConflictTitle, this.form.designer.lp.subformConflictInfor, 400, 120); this.json.subformSelected = oldValue; if (input){ for (var i=0; i