123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496 |
- MWF.xDesktop.requireApp("process.ProcessManager", "Explorer", null, false);
- MWF.xApplication.process.ProcessManager.ProcessExplorer = new Class({
- Extends: MWF.xApplication.process.ProcessManager.Explorer,
- Implements: [Options, Events],
- 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.getProcess(item.data.id, function(json){
- json.data.elementType = "process";
- 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);
- // data.each(function(item){
- // if (item.elementType==="process"){
- // this.saveItemAs(this.app.options.application, item);
- // }
- // }.bind(this));
- },
- pasteItem: function(data, i){
- if (i<data.length){
- var item = data[i];
- if (item.elementType==="process"){
- this.saveItemAs(item, function(){
- i++;
- this.pasteItem(data, i);
- }.bind(this), function(){
- i++;
- this.pasteItem(data, i);
- }.bind(this), function(){
- this.reload();
- }.bind(this));
- }else{
- i++;
- this.pasteItem(data, i);
- }
- }else{
- this.reload();
- }
- },
- saveItemAs: function(data, success, failure, cancel){
- this.app.restActions.listProcess(this.app.options.application.id, function(dJson){
- var i=1;
- var someItems = dJson.data.filter(function(d){ return d.id===data.id });
- if (someItems.length){
- var someItem = someItems[0];
- var lp = this.app.lp;
- var _self = this;
- var d1 = new Date().parse(data.lastUpdateTime);
- var d2 = new Date().parse(someItem.lastUpdateTime);
- var html = "<div>"+lp.copyConfirmInfor+"</div>";
- html += "<div style='overflow: hidden; margin: 10px 0px; padding: 5px 10px; background-color: #ffffff; border-radius: 6px;'><div style='font-weight: bold; font-size:14px;'>"+lp.copySource+" "+someItem.name+"</div>";
- html += "<div style='font-size:12px; color: #666666; float: left'>"+someItem.lastUpdateTime+"</div>" +
- "<div style='font-size:12px; color: #666666; float: left; margin-left: 20px;'>"+MWF.name.cn(someItem.lastUpdatePerson)+"</div>" +
- "<div style='color: red; float: right;'>"+((d1>=d2) ? "": lp.copynew)+"</div></div>";
- html += "<div style='overflow: hidden; margin: 10px 0px; padding: 5px 10px; background-color: #ffffff; border-radius: 6px;'><div style='clear: both;font-weight: bold; font-size:14px;'>"+lp.copyTarget+" "+data.name+"</div>";
- html += "<div style='font-size:12px; color: #666666; float: left;'>"+data.lastUpdateTime+"</div>" +
- "<div style='font-size:12px; color: #666666; float: left; margin-left: 20px;'>"+MWF.name.cn(data.lastUpdatePerson)+"</div>" +
- "<div style='color: red; float: right;'>"+((d1<=d2) ? "": lp.copynew)+"</div></div>";
- // 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, process, success, failure){
- debugger;
- var isSameApp = process.application === someItem.application;
- process.id = someItem.id;
- process.name = someItem.name;
- process.alias = someItem.alias;
- process.category = someItem.category || "";
- process.application = someItem.application;
- process.applicationName = someItem.applicationName;
- process.isNewProcess = false;
- var checkActivity = function(a) {
- a.process = process.id;
- if(a.form && !isSameApp)a.form="";
- }
- if (process.begin) {
- process.begin.process = process.id;
- if(process.begin.form && !isSameApp)process.begin.form="";
- }
- if (process.endList) process.endList.each(function(a){ checkActivity(a); });
- if (process.agentList) process.agentList.each(function(a){ checkActivity(a); });
- if (process.manualList) process.manualList.each(function(a){ checkActivity(a); });
- if (process.conditionList) process.conditionList.each(function(a){ checkActivity(a); });
- if (process.choiceList) process.choiceList.each(function(a){ checkActivity(a); });
- if (process.parallelList) process.parallelList.each(function(a){ checkActivity(a); });
- if (process.splitList) process.splitList.each(function(a){ checkActivity(a); });
- if (process.mergeList) process.mergeList.each(function(a){ checkActivity(a); });
- if (process.embedList) process.embedList.each(function(a){ checkActivity(a); });
- if (process.publishList) process.publishList.each(function(a){ checkActivity(a); });
- if (process.invokeList) process.invokeList.each(function(a){ checkActivity(a); });
- if (process.cancelList) process.cancelList.each(function(a){ checkActivity(a); });
- if (process.delayList) process.delayList.each(function(a){ checkActivity(a); });
- if (process.messageList) process.messageList.each(function(a){ checkActivity(a); });
- if (process.serviceList) process.serviceList.each(function(a){ checkActivity(a); });
- if (process.routeList) process.routeList.each(function(a){ checkActivity(a); });
- this.app.restActions.saveProcess(process, function(){
- if (success) success();
- }.bind(this), function(){
- if (failure) failure();
- }.bind(this));
- },
- saveItemAsNew: function(processJson, process, success, failure){
- debugger;
- var item = this.app.options.application;
- var id = item.id;
- var name = item.name;
- var isSameApp = process.application === id;
- process.alias = "";
- var oldName = process.name;
- var i=1;
- while (processJson.data.some(function(d){ return d.name==process.name })){
- process.name = oldName+"_copy"+i;
- i++;
- }
- process.application = id;
- process.applicationName = name;
- var oldIds = [];
- oldIds.push(process.id);
- var checkActivity = function(a) {
- oldIds.push(a.id);
- if(a.form && !isSameApp)a.form="";
- };
- if (process.begin) {
- oldIds.push(process.begin.id);
- if(process.begin.form && !isSameApp)process.begin.form="";
- }
- if (process.endList) process.endList.each(function(a){ checkActivity(a); });
- if (process.agentList) process.agentList.each(function(a){ checkActivity(a); });
- if (process.manualList) process.manualList.each(function(a){ checkActivity(a); });
- if (process.conditionList) process.conditionList.each(function(a){ checkActivity(a); });
- if (process.choiceList) process.choiceList.each(function(a){ checkActivity(a); });
- if (process.parallelList) process.parallelList.each(function(a){ checkActivity(a); });
- if (process.splitList) process.splitList.each(function(a){ checkActivity(a); });
- if (process.mergeList) process.mergeList.each(function(a){ checkActivity(a); });
- if (process.embedList) process.embedList.each(function(a){ checkActivity(a); });
- if (process.publishList) process.publishList.each(function(a){ checkActivity(a); });
- if (process.invokeList) process.invokeList.each(function(a){ checkActivity(a); });
- if (process.cancelList) process.cancelList.each(function(a){ checkActivity(a); });
- if (process.delayList) process.delayList.each(function(a){ checkActivity(a); });
- if (process.messageList) process.messageList.each(function(a){ checkActivity(a); });
- if (process.serviceList) process.serviceList.each(function(a){ checkActivity(a); });
- if (process.routeList) process.routeList.each(function(a){ checkActivity(a); });
- if (!isSameApp){
- process.isNewProcess = true;
- this.app.restActions.saveProcess(process, function(){
- if (success) success();
- }.bind(this), function(){
- if (failure) failure();
- }.bind(this));
- }else{
- this.app.restActions.getId(oldIds.length, function(ids) {
- var checkUUIDs = ids.data;
- var processStr = JSON.encode(process);
- oldIds.each(function(oid, i){
- var reg = new RegExp(oid, "ig");
- processStr = processStr.replace(reg, checkUUIDs[i].id);
- }.bind(this));
- process = JSON.decode(processStr);
- process.isNewProcess = true;
- this.app.restActions.saveProcess(process, function(){
- if (success) success();
- }.bind(this), function(){
- if (failure) failure();
- }.bind(this));
- }.bind(this));
- }
- },
- // saveItemAs: function(item, process){
- // var id = item.id;
- // var name = item.name;
- //
- // process.alias = "";
- // var oldName = process.name;
- // this.app.restActions.listProcess(id, function(processJson){
- //
- // }.bind(this));
- // },
- _createElement: function(e){
- var createProcess = function(e, template){
- var options = {
- "template": template,
- "application":{
- "name": _self.app.options.application.name,
- "id": _self.app.options.application.id
- },
- "onQueryLoad": function(){
- this.actions = _self.app.restActions;
- this.application = _self.app.options.application;
- }
- };
- layout.desktop.openApplication(e, "process.ProcessDesigner", options);
- };
- var createTemplateMaskNode = new Element("div", {"styles": this.css.createTemplateMaskNode}).inject(this.app.content);
- var createTemplateAreaNode = new Element("div", {"styles": this.css.createTemplateAreaNode}).inject(this.app.content);
- createTemplateAreaNode.fade("in");
- var createTemplateScrollNode = new Element("div", {"styles": this.css.createTemplateScrollNode}).inject(createTemplateAreaNode);
- var createTemplateContentNode = new Element("div", {"styles": this.css.createTemplateContentNode}).inject(createTemplateScrollNode);
- MWF.require("MWF.widget.ScrollBar", function(){
- new MWF.widget.ScrollBar(createTemplateScrollNode, {"indent": false});
- }.bind(this));
- var _self = this;
- var url = "../x_component_process_ProcessDesigner/$Process/template/templates.json";
- MWF.getJSON(url, function(json){
- json.each(function(template){
- var templateNode = new Element("div", {"styles": this.css.templateNode}).inject(createTemplateContentNode);
- var templateIconNode = new Element("div", {"styles": this.css.templateIconNode}).inject(templateNode);
- var templateTitleNode = new Element("div", {"styles": this.css.templateTitleNode, "text": template.title}).inject(templateNode);
- templateNode.store("template", template.name);
- var templateIconImgNode = new Element("img", {"styles": this.css.templateIconImgNode}).inject(templateIconNode);
- templateIconImgNode.set("src", "../x_component_process_ProcessDesigner/$Process/template/"+template.icon);
- templateNode.addEvents({
- "mouseover": function(){this.setStyles(_self.css.templateNode_over)},
- "mouseout": function(){this.setStyles(_self.css.templateNode)},
- "mousedown": function(){this.setStyles(_self.css.templateNode_down)},
- "mouseup": function(){this.setStyles(_self.css.templateNode_over)},
- "click": function(e){
- createProcess(e, this.retrieve("template"));
- createTemplateAreaNode.destroy();
- createTemplateMaskNode.destroy();
- }
- });
- }.bind(this))
- }.bind(this));
- createTemplateMaskNode.addEvent("click", function(){
- createTemplateAreaNode.destroy();
- createTemplateMaskNode.destroy();
- });
- var size = this.app.content.getSize();
- var y = (size.y - 262)/2;
- var x = (size.x - 828)/2;
- if (y<0) y=0;
- if (x<0) x=0;
- createTemplateAreaNode.setStyles({
- "top": ""+y+"px",
- "left": ""+x+"px"
- });
- },
- _loadItemDataList: function(callback){
- this.app.restActions.listProcess(this.app.options.application.id,callback);
- },
- _getItemObject: function(item){
- return new MWF.xApplication.process.ProcessManager.ProcessExplorer.Process(this, item)
- },
- showDeleteAction: function(){
- if (!this.deleteItemsAction){
- this.deleteItemsAction = new Element("div", {
- "styles": this.css.deleteItemsAction,
- "text": this.app.lp.deleteItems
- }).inject(this.node);
- this.deleteItemsAction.fade("in");
- this.deleteItemsAction.position({
- relativeTo: this.elementContentListNode,
- position: 'centerTop',
- edge: 'centerTop',
- "offset": {"y": this.elementContentNode.getScroll().y}
- });
- this.deleteItemsAction.addEvent("click", function(){
- var _self = this;
- this.app.confirm("warn", this.deleteItemsAction, MWF.APPPM.LP.deleteProcessTitle, MWF.APPPM.LP.deleteProcess, 430, 120, function(){
- _self.deleteItems();
- this.close();
- }, function(){
- this.close();
- });
- }.bind(this));
- }
- },
- deleteItems: function(){
- this.hideDeleteAction();
- while (this.deleteMarkItems.length){
- var item = this.deleteMarkItems.shift();
- if (this.deleteMarkItems.length){
- item.deleteProcess();
- }else{
- item.deleteProcess(function(){
- // this.reloadItems();
- //this.hideDeleteAction();
- }.bind(this));
- }
- }
- }
- });
- MWF.xApplication.process.ProcessManager.ProcessExplorer.Process = new Class({
- Extends: MWF.xApplication.process.ProcessManager.Explorer.Item,
-
- _open: function(e){
- var _self = this;
- var options = {
- "appId": "process.ProcessDesigner"+_self.data.id,
- "id": _self.data.id,
- // "application": _self.explorer.app.options.application.id,
- "application":{
- "name": _self.explorer.app.options.application.name,
- "id": _self.explorer.app.options.application.id
- },
- "onQueryLoad": function(){
- this.actions = _self.explorer.actions;
- this.category = _self;
- this.options.id = _self.data.id;
- this.application = _self.explorer.app.options.application;
- }
- };
- this.explorer.app.desktop.openApplication(e, "process.ProcessDesigner", 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": "process.ProcessDesigner#{\"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();
- // });
- // },
- deleteProcess: function(callback){
- this.explorer.actions.deleteProcess(this.data.id, function(){
- this.node.destroy();
- if (callback) callback();
- }.bind(this));
- },
- saveas: function(){
- MWF.xDesktop.requireApp("Selector", "package", function(){
- var selector = new MWF.O2Selector(this.explorer.app.content, {
- "title": this.explorer.app.lp.copyto,
- "count": 1,
- "type": "Application",
- "values": [this.explorer.app.options.application],
- "onComplete": function(items){
- items.each(function(item){
- this.saveItemAs(item.data);
- }.bind(this));
- }.bind(this)
- });
- }.bind(this));
- },
- saveItemAs: function(item){
- var id = item.id;
- var name = item.name;
- this.explorer.app.restActions.getProcess(this.data.id, function(json){
- var process = json.data;
- process.alias = "";
- var oldName = process.name;
- this.explorer.app.restActions.listProcess(id, function(processJson){
- var i=1;
- while (processJson.data.some(function(d){ return d.name==process.name })){
- process.name = oldName+"_copy"+i;
- i++;
- }
- var isSameApp = process.application === id;
- process.application = id;
- process.applicationName = name;
- var oldIds = [];
- oldIds.push(process.id);
- var checkActivity = function(a) {
- oldIds.push(a.id);
- if(a.form && !isSameApp)a.form="";
- };
- if (process.begin) {
- oldIds.push(process.begin.id);
- if(process.begin.form && !isSameApp)process.begin.form="";
- }
- if (process.endList) process.endList.each(function(a){ checkActivity(a); });
- if (process.agentList) process.agentList.each(function(a){ checkActivity(a); });
- if (process.manualList) process.manualList.each(function(a){ checkActivity(a); });
- if (process.conditionList) process.conditionList.each(function(a){ checkActivity(a); });
- if (process.choiceList) process.choiceList.each(function(a){ checkActivity(a); });
- if (process.parallelList) process.parallelList.each(function(a){ checkActivity(a); });
- if (process.splitList) process.splitList.each(function(a){ checkActivity(a); });
- if (process.mergeList) process.mergeList.each(function(a){ checkActivity(a); });
- if (process.embedList) process.embedList.each(function(a){ checkActivity(a); });
- if (process.publishList) process.publishList.each(function(a){ checkActivity(a); });
- if (process.invokeList) process.invokeList.each(function(a){ checkActivity(a); });
- if (process.cancelList) process.cancelList.each(function(a){ checkActivity(a); });
- if (process.delayList) process.delayList.each(function(a){ checkActivity(a); });
- if (process.messageList) process.messageList.each(function(a){ checkActivity(a); });
- if (process.serviceList) process.serviceList.each(function(a){ checkActivity(a); });
- if (process.routeList) process.routeList.each(function(a){ checkActivity(a); });
- this.explorer.app.restActions.getId(oldIds.length, function(ids) {
- var checkUUIDs = ids.data;
- var processStr = JSON.encode(process);
- oldIds.each(function(oid, i){
- var reg = new RegExp(oid, "ig");
- processStr = processStr.replace(reg, checkUUIDs[i].id);
- }.bind(this));
- process = JSON.decode(processStr);
- process.isNewProcess = true;
- this.explorer.app.restActions.saveProcess(process, function(){
- if (id == this.explorer.app.options.application.id) this.explorer.reload();
- }.bind(this));
- }.bind(this));
- }.bind(this));
- }.bind(this));
- }
- });
|