Invoke.min.js 8.7 KB

1
  1. MWF.xApplication=MWF.xApplication||{};MWF.xApplication.service=MWF.xApplication.service||{};MWF.xApplication.service.InvokeDesigner=MWF.xApplication.service.InvokeDesigner||{};MWF.SRVID=MWF.xApplication.service.InvokeDesigner;MWF.require("MWF.widget.Common",null,false);MWF.xDesktop.requireApp("service.InvokeDesigner","lp."+MWF.language,null,false);MWF.require("MWF.widget.JavascriptEditor",null,false);MWF.xApplication.service.InvokeDesigner.Invoke=new Class({Extends:MWF.widget.Common,Implements:[Options,Events],options:{style:"default",showTab:true},initialize:function(e,t,i){this.setOptions(i);this.path="/x_component_service_InvokeDesigner/$Invoke/";this.cssPath="/x_component_service_InvokeDesigner/$Invoke/"+this.options.style+"/css.wcss";this._loadCss();this.isChanged=false;this.designer=e;this.data=t;if(!this.data.text)this.data.text="";this.node=this.designer.designNode;this.tab=this.designer.invokeTab;this.areaNode=new Element("div",{styles:{overflow:"hidden",height:"700px"}});this.propertyNode=this.designer.propertyContentArea;this.isNewInvoke=this.data.id?false:true;this.autoSave();this.designer.addEvent("queryClose",function(){if(this.autoSaveTimerID)window.clearInterval(this.autoSaveTimerID)}.bind(this))},autoSave:function(){this.autoSaveTimerID=window.setInterval(function(){if(!this.autoSaveCheckNode)this.autoSaveCheckNode=this.designer.contentToolbarNode.getElement("#MWFInvokeAutoSaveCheck");if(this.autoSaveCheckNode){if(this.autoSaveCheckNode.get("checked")){if(this.isChanged)this.saveSilence()}}}.bind(this),6e4)},load:function(){this.setAreaNodeSize();this.designer.addEvent("resize",this.setAreaNodeSize.bind(this));this.page=this.tab.addTab(this.areaNode,this.data.name||this.designer.lp.newInvoke,!this.data.isNewInvoke&&this.data.id!=this.designer.options.id);this.page.invoke=this;this.page.addEvent("show",function(){this.designer.invokeListAreaNode.getChildren().each(function(e){var t=e.retrieve("invoke");if(t.id==this.data.id){if(this.designer.currentListInvokeItem){this.designer.currentListInvokeItem.setStyles(this.designer.css.listInvokeItem)}e.setStyles(this.designer.css.listInvokeItem_current);this.designer.currentListInvokeItem=e;this.lisNode=e}}.bind(this));this.designer.currentScript=this;this.setPropertyContent();if(this.editor.editor){this.editor.editor.focus()}}.bind(this));this.page.addEvent("queryClose",function(){if(this.autoSaveTimerID)window.clearInterval(this.autoSaveTimerID);this.saveSilence();if(this.lisNode)this.lisNode.setStyles(this.designer.css.listInvokeItem)}.bind(this));this.page.tabNode.addEvent("dblclick",this.designer.maxOrReturnEditor.bind(this.designer));this.editor=new MWF.widget.JavascriptEditor(this.areaNode);this.editor.load(function(){if(this.data.text){this.editor.editor.setValue(this.data.text)}else{var e="/********************\n";e+="resources.getEntityManagerContainer(); //实体管理器\n";e+="resources.getContext(); //上下文根\n";e+="resources.getOrganization(); //组织访问\n";e+="resources.getWebservicesClient();//webSerivces客户端\n";e+="requestText//请求正文\n";e+="request//请求\n";e+="effectivePerson//当前用户\n";e+="********************/\n";this.editor.editor.setValue(e)}this.editor.editor.on("change",function(e){if(!this.isChanged){this.isChanged=true;this.page.textNode.set("text"," * "+this.page.textNode.get("text"))}}.bind(this));this.editor.addEvent("save",function(){this.save()}.bind(this));this.editor.addEvent("reference",function(e,t,i){if(!this.invokeReferenceMenu){MWF.require("MWF.widget.ScriptHelp",function(){this.invokeReferenceMenu=new MWF.widget.ScriptHelp(null,this.editor.editor,{onPostLoad:function(){this.showReferenceMenu()}.bind(this)});this.invokeReferenceMenu.getEditor=function(){return this.editor.editor}.bind(this)}.bind(this))}else{this.showReferenceMenu()}}.bind(this));var t=this.designer.styleSelectNode.options;for(var i=0;i<t.length;i++){var s=t[i];if(s.value==this.editor.theme){s.set("selected",true);break}}}.bind(this));if(this.options.showTab)this.page.showTabIm()},showReferenceMenu:function(){var e=this.editor.getCursorPixelPosition();var t={page:{}};t.page.x=e.left;t.page.y=e.top;this.invokeReferenceMenu.menu.showIm(t)},setIncludeNode:function(){this.designer.propertyIncludeListArea.empty();this.data.dependInvokeList.each(function(e){this.designer.addIncludeToList(e)}.bind(this))},setPropertyContent:function(){this.designer.propertyIdNode.set("text",this.data.id||"");this.designer.propertyNameNode.set("value",this.data.name||"");this.designer.propertyAliasNode.set("value",this.data.alias||"");this.designer.propertyEnableNode.getElement("option[value='"+this.data.enable+"']").set("selected",true);this.designer.propertyRemoteAddrRegexNode.set("value",this.data.remoteAddrRegex||"");this.designer.propertyLastStartTimeNode.set("text",this.data.lastStartTime||"");this.designer.propertyLastEndTimeNode.set("text",this.data.lastEndTime||"");this.designer.propertyDescriptionNode.set("value",this.data.description||"");var e=this.designer.actions.action;var t=e.address+e.actions.executeInvoke.uri;t=t.replace("{flag}",this.data.alias||this.data.name||this.data.id);this.designer.propertyInvokeUriNode.set("text",t)},setAreaNodeSize:function(){var e=this.node.getSize();var t=this.tab.tabNodeContainer.getSize();var i=e.y-t.y;this.areaNode.setStyle("height",""+i+"px");if(this.editor)if(this.editor.editor)this.editor.editor.resize()},addInclude:function(){},saveInvoke:function(e,t,i){if(e.isNewInvoke){this.designer.actions.createInvoke(e,t,i)}else{this.designer.actions.updateInvoke(e.id,e,t,i)}},save:function(s){debugger;if(!this.isSave){var e=this.editor.editor.getSession();var t=e.getAnnotations();var i=true;for(var a=0;a<t.length;a++){if(t[a].type=="error"){i=false;break}}var n=this.designer.propertyNameNode.get("value");var r=this.designer.propertyAliasNode.get("value");var o=this.designer.propertyDescriptionNode.get("value");var d=this.designer.propertyRemoteAddrRegexNode.get("value");var h=true;this.designer.propertyEnableNode.getElements("option").each(function(e){if(e.selected){h=e.value=="true"}});if(!n){this.designer.notice(this.designer.lp.notice.inputName,"error");return false}this.data.name=n;this.data.alias=r;this.data.description=o;this.data.remoteAddrRegex=d;this.data.validated=i;this.data.text=this.editor.editor.getValue();this.data.enable=h;this.isSave=true;this.saveInvoke(this.data,function(e){this.isSave=false;if(this.data.isNewInvoke){this.data.isNewInvoke=false}this.isChanged=false;this.page.textNode.set("text",this.data.name);if(this.lisNode){this.lisNode.getLast().set("text",this.data.name)}this.designer.notice(this.designer.lp.notice.save_success,"success",this.node,{x:"left",y:"bottom"});this.data.id=e.data.id;this.designer.propertyIdNode.set("text",this.data.id);var t=this.designer.actions.action;var i=t.address+t.actions.executeInvoke.uri;i=i.replace("{flag}",this.data.alias||this.data.name||this.data.id);this.designer.propertyInvokeUriNode.set("text",i);if(s)s()}.bind(this),function(e,t,i){this.isSave=false;var s=i+":"+t;if(e)s=e.responseText;MWF.xDesktop.notice("error",{x:"right",y:"top"},"request json error: "+s)}.bind(this))}else{MWF.xDesktop.notice("info",{x:"right",y:"top"},this.designer.lp.isSave)}},saveSilence:function(s){if(!this.isSave){var e=this.editor.editor.getSession();var t=e.getAnnotations();var i=true;for(var a=0;a<t.length;a++){if(t[a].type=="error"){i=false;break}}if(this.designer.currentScript==this){var n=this.designer.propertyNameNode.get("value");var r=this.designer.propertyAliasNode.get("value");var o=this.designer.propertyDescriptionNode.get("value");var d=this.designer.propertyRemoteAddrRegexNode.get("value");var h=true;this.designer.propertyEnableNode.getElements("option").each(function(e){if(e.selected){h=e.value=="true"}});if(!n){this.designer.notice(this.designer.lp.notice.inputName,"error");return false}this.data.name=n;this.data.alias=r;this.data.description=o;this.data.remoteAddrRegex=d;this.data.validated=i;this.data.enable=h}this.data.text=this.editor.editor.getValue();this.isSave=true;this.saveInvoke(this.data,function(e){this.isSave=false;if(this.data.isNewInvoke){this.data.isNewInvoke=false}this.data.isNewInvoke=false;this.isChanged=false;this.page.textNode.set("text",this.data.name);if(this.lisNode){this.lisNode.getLast().set("text",this.data.name)}this.data.id=e.data.id;if(this.designer.currentScript==this){this.designer.propertyIdNode.set("text",this.data.id);var t=this.designer.actions.action;var i=t.address+t.actions.executeInvoke.uri;i=i.replace("{flag}",this.data.alias||this.data.name||this.data.id);this.designer.propertyInvokeUriNode.set("text",i)}if(s)s()}.bind(this),function(e,t,i){this.isSave=false}.bind(this))}else{MWF.xDesktop.notice("info",{x:"right",y:"top"},this.designer.lp.isSave)}},saveAs:function(){},explode:function(){},implode:function(){}});