MWF.xApplication.process.FormDesigner.widget = MWF.xApplication.process.FormDesigner.widget || {};
MWF.require("MWF.widget.UUID", null, false);
MWF.require("MWF.widget.O2Identity", null, false);
MWF.xApplication.process.FormDesigner.widget.ScriptIncluder = new Class({
Implements: [Options, Events],
Extends: MWF.widget.Common,
options: {
"style": "default",
"maxObj": document.body
},
initialize: function(node, designer, options){
this.setOptions(options);
this.node = $(node);
this.designer = designer;
this.path = "../x_component_process_FormDesigner/widget/$ScriptIncluder/";
this.cssPath = "../x_component_process_FormDesigner/widget/$ScriptIncluder/"+this.options.style+"/css.wcss";
this._loadCss();
this.lp = this.designer.lp.scriptIncluder;
this.items = [];
},
load: function(data){
this.editorNode = new Element("div", {"styles": this.css.editorNode}).inject(this.node);
this.actionNode = new Element("div", {"styles": this.css.actionNode}).inject(this.node);
this.listNode = new Element("div", {"styles": this.css.listNode}).inject(this.node);
this.loadEditorNode();
this.loadActionNode();
this.loadListNode(data);
},
loadEditorNode: function(){
debugger;
var html = "
";
this.editorNode.set("html", html);
var tds = this.editorNode.getElements("td").setStyles(this.css.editTableTdValue);
this.asyncLoadScript = this.editorNode.getElements("[type='radio']");
this.scriptSelectorArea = this.editorNode.getElement(".scriptSelectorArea");
this.loadScriptSelector();
},
loadScriptSelector: function( data ){
MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
var _self = this;
if( !data )data = [];
this.scriptSelector = new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(this.scriptSelectorArea, this.designer, {
"type": "Script",
"count": 0,
"names": data,
"onChange": function(ids){
var value = [];
ids.each( function (id) {
var d = id.data;
value.push({
"type" : "script",
"name": d.name,
"alias": d.alias,
"id": d.id,
"appName" : d.appName || d.applicationName,
"appId": d.appId || d.application,
"appType" : d.appType
});
})
this.currentSelectScripts = value;
}.bind(this)
});
}.bind(this));
},
loadActionNode: function(){
this.actionAreaNode = new Element("div", {"styles": this.css.actionAreaNode}).inject(this.actionNode);
this.addAction = new Element("div", {"styles": this.css.addAction, "text": this.designer.lp.validation.add}).inject(this.actionAreaNode);
this.modifyAction = new Element("div", {"styles": this.css.modifyAction_disabled, "text": this.designer.lp.validation.modify}).inject(this.actionAreaNode);
this.addAction.addEvent("click", function(){
this.add();
}.bind(this));
this.modifyAction.addEvent("click", function(){
this.modify();
}.bind(this));
},
getCurrentData: function(){
var async = true;
this.asyncLoadScript.each( function (el) {
if( el.checked ){
async = el.get("value") === "true";
}
});
return {
"async": async,
"scriptList": this.currentSelectScripts || []
};
},
add: function(){
this.hideErrorNode();
var data = this.getCurrentData();
if ( data.scriptList.length === 0 ){
this.showErrorNode(this.lp.selectScriptNotice);
return false;
}
for( var i=0; i