MWF.xDesktop.requireApp("process.ProcessManager", "Explorer", null, false); MWF.xApplication.service.ServiceManager.InvokeExplorer = new Class({ Extends: MWF.xApplication.process.ProcessManager.Explorer, Implements: [Options, Events], options: { "style": "default", "tooltip": { "create": MWF.xApplication.service.ServiceManager.LP.invoke.create, "search": MWF.xApplication.service.ServiceManager.LP.invoke.search, "searchText": MWF.xApplication.service.ServiceManager.LP.invoke.searchText, "noElement": MWF.xApplication.service.ServiceManager.LP.invoke.noInvokeNoticeText } }, openFindDesigner: function(){ var options = { "filter": { "moduleList": ["service"] } }; layout.openApplication(null, "FindDesigner", options); }, createCreateElementNode: function(){ if( MWF.AC.isServiceManager() ) { this.createElementNode = new Element("div", { "styles": this.css.createElementNode, "title": this.options.tooltip.create }).inject(this.toolbarNode); this.createElementNode.addEvent("click", function (e) { this._createElement(e); }.bind(this)); } }, createTitleElementNode: function() { this.titleElementNode = new Element("div", { "styles": this.css.titleElementNode, "text": MWF.xApplication.service.ServiceManager.LP.interfaceConfig }).inject(this.toolbarNode); }, _createElement: function(e){ var _self = this; var options = { "onQueryLoad": function(){ this.actions = _self.app.restActions; this.application = _self.app.options.application; this.explorer = _self; } }; this.app.desktop.openApplication(e, "service.InvokeDesigner", options); }, loadElementList: function(){ if( MWF.AC.isServiceManager() ){ this._loadItemDataList(function(json){ if (json.data.length){ json.data.each(function(item){ var itemObj = this._getItemObject(item); itemObj.load() }.bind(this)); }else{ var noElementNode = new Element("div.noElementNode", { "styles": this.css.noElementNode, "text": this.options.tooltip.noElement }).inject(this.elementContentListNode); noElementNode.addEvent("click", function(e){ this._createElement(e); }.bind(this)); } if( !this.isSetContentSize ){ this.setContentSize(); this.isSetContentSize = true; } }.bind(this)); }else{ var noElementNode = new Element("div.noElementNode", { "styles": this.css.noElementNode, "text": MWF.xApplication.service.ServiceManager.LP.invoke.noPermission }).inject(this.elementContentListNode); } }, _loadItemDataList: function(callback){ this.app.restActions.listInvoke(callback); }, _getItemObject: function(item){ return new MWF.xApplication.service.ServiceManager.InvokeExplorer.Invoke(this, item) }, deleteItems: function(){ this.hideDeleteAction(); while (this.deleteMarkItems.length){ var item = this.deleteMarkItems.shift(); if (this.deleteMarkItems.length){ item.deleteInvoke(); }else{ item.deleteInvoke(function(){ // this.reloadItems(); //this.hideDeleteAction(); }.bind(this)); } } }, keyCopy: function(e){ if (this.selectMarkItems.length){ var items = []; var i = 0; var checkItems = function(e){ if (i>=this.selectMarkItems.length){ if (items.length){ var str = JSON.encode(items); if (e){ e.clipboardData.setData('text/plain', str); }else { window.clipboardData.setData("Text", str); } this.app.notice(this.app.lp.copyed, "success"); } } }.bind(this); this.selectMarkItems.each(function(item){ this.app.restActions.getInvoke(item.data.id, function(json){ json.data.elementType = "invoke"; items.push(json.data); i++; checkItems(e); }.bind(this), null, false) }.bind(this)); if (e) e.preventDefault(); } }, keyPaste: function(e){ var dataStr = ""; if (e){ dataStr = e.clipboardData.getData('text/plain'); }else{ dataStr = window.clipboardData.getData("Text"); } var data = JSON.decode(dataStr); this.pasteItem(data, 0); }, pasteItem: function(data, i){ if (i"; html += "
"+lp.copySource+" "+someItem.name+"
"; html += "
"+someItem.updateTime+"
" + //"
"+MWF.name.cn(someItem.lastUpdatePerson)+"
" + "
"+((d1>=d2) ? "": lp.copynew)+"
"; html += "
"+lp.copyTarget+" "+data.name+"
"; html += "
"+data.updateTime+"
" + //"
"+MWF.name.cn(data.lastUpdatePerson)+"
" + "
"+((d1<=d2) ? "": lp.copynew)+"
"; // html += "<>" this.app.dlg("inofr", null, this.app.lp.copyConfirmTitle, {"html": html}, 500, 290, [ { "text": lp.copyConfirm_overwrite, "action": function(){_self.saveItemAsUpdate(someItem, data, success, failure);this.close();} }, { "text": lp.copyConfirm_new, "action": function(){_self.saveItemAsNew(dJson, data, success, failure);this.close();} }, { "text": lp.copyConfirm_skip, "action": function(){/*nothing*/ this.close(); if (success) success();} }, { "text": lp.copyConfirm_cancel, "action": function(){this.close(); if (cancel) cancel();} } ]); }else{ this.saveItemAsNew(dJson, data, success, failure) } }.bind(this), function(){if (failure) failure();}.bind(this)); }, saveItemAsUpdate: function(someItem, data, success, failure){ data.id = someItem.id; data.name = someItem.name; data.alias = someItem.alias; this.app.restActions.updateInvoke(someItem.id, data, function(){ if (success) success(); }.bind(this), function(){ if (failure) failure(); }.bind(this)); }, saveItemAsNew: function(dJson, data, success, failure){ var oldName = data.name; var i=1; while (dJson.data.some(function(d){ return d.name==data.name || d.alias==data.name })){ data.name = oldName+"_copy"+i; data.alias = oldName+"_copy"+i; i++; } data.id = ""; data.id = ""; this.app.restActions.createInvoke(data, function(){ if (success) success(); }.bind(this), function(){ if (failure) failure(); }.bind(this)); } }); MWF.xApplication.service.ServiceManager.InvokeExplorer.Invoke= new Class({ Extends: MWF.xApplication.process.ProcessManager.Explorer.Item, createActionNode: function(){ this.deleteActionNode = new Element("div", { "styles": this.css.deleteActionNode }).inject(this.node); this.deleteActionNode.addEvent("click", function(e){ this.deleteItem(e); }.bind(this)); }, createTextNodes: function(){ var titleNode = new Element("div", { "styles": this.css.itemTextTitleNode, "text": ( this.data.enable ? "" : "("+MWF.xApplication.service.ServiceManager.LP.disable+")" ) + this.data.name , "title": this.data.name, "events": { "click": function(e){this._open(e);}.bind(this) } }).inject(this.node); if( !this.data.enable ){ titleNode.setStyle("color","#999"); } new Element("div", { "styles": this.css.itemTextDescriptionNode, "text": this.data.description || "", "title": this.data.description || "" }).inject(this.node); new Element("div", { "styles": this.css.itemTextDateNode, "text": (this.data.updateTime || "") }).inject(this.node); }, _open: function(e){ var _self = this; var options = { "appId": "service.InvokeDesigner"+_self.data.id, "id": _self.data.id, "onQueryLoad": function(){ this.actions = _self.explorer.actions; this.category = _self; this.options.id = _self.data.id; } }; this.explorer.app.desktop.openApplication(e, "service.InvokeDesigner", options); }, _getIcon: function(){ var x = (Math.random()*49).toInt(); return "process_icon_"+x+".png"; }, _getLnkPar: function(){ return { "icon": this.explorer.path+this.explorer.options.style+"/processIcon/lnk.png", "title": this.data.name, "par": "service.InvokeDesigner#{\"id\": \""+this.data.id+"\"}" }; }, // deleteItem: function(e){ // var _self = this; // this.explorer.app.confirm("info", e, this.explorer.app.lp.process.deleteProcessTitle, this.explorer.app.lp.process.deleteProcess, 320, 110, function(){ // _self.deleteProcess(); // this.close(); // },function(){ // this.close(); // }); // }, deleteInvoke: function(callback){ this.explorer.actions.deleteInvoke(this.data.id, function(){ this.node.destroy(); if (callback) callback(); }.bind(this)); } });