MWF.xApplication.process.Xform.widget = MWF.xApplication.process.Xform.widget || {}; //MWF.xDesktop.requireApp("process.Xform", "widget.RestActions", null, false); MWF.require("MWF.widget.Common", null, false); MWF.require("MWF.widget.MWFRaphael", null, false); MWF.xApplication.process.Xform.widget.Monitor = new Class({ Implements: [Options, Events], Extends: MWF.widget.Common, options: { "style": "default" }, initialize: function(container, worklog, recordList, processid, options, module){ this.setOptions(options); this.path = "../x_component_process_Xform/widget/$Monitor/"; this.cssPath = "../x_component_process_Xform/widget/$Monitor/"+this.options.style+"/css.wcss"; this._loadCss(); this.container = $(container); this.worklog = worklog; this.recordList = recordList; this.processid = processid; this.mobileScale = 2; this.module = module; this.load(); }, load: function(){ this.logProcessChartNode = new Element("div", {"styles": this.css.logProcessChartNode}).inject(this.container); this.logPathChartNode = new Element("div", {"styles": this.css.logPathChartNode}).inject(this.container); this.checkMonitorOpen(); }, checkMonitorOpen: function(){ var moduleNode = this.container; var module = moduleNode.retrieve("module"); var isDisplayNode = false; var isTabContent = false; while (true){ if (moduleNode.getStyle("display")==="none"){ isDisplayNode = true; } if (module && module.json.type==="Tab$Content"){ isTabContent = true; } if (isDisplayNode && isTabContent) break; moduleNode = moduleNode.getParent(); if (!moduleNode) break; if (!isTabContent) module = moduleNode.retrieve("module"); } if (isDisplayNode){ if (isTabContent){ for (var i=0; ioffset.x+psize.x){ x = activity.point.x - size.x - 15 + offset.x; if (x psize.x )x = psize.x - size.x; if( y + size.y > psize.y )y = psize.y - size.y; if( x < 0 )x = 0; if( y < 0 )y = 0; // var p = this.paperNode.getScroll(); // var scrollY = 0; // var scrollX = 0; // var tmpNode = this.paperNode.getParent(); // while (tmpNode){ // var s = tmpNode.getScroll(); // scrollY += s.y; // scrollX += s.x; // tmpNode = tmpNode.getParent(); // } // y = y-p.y-scrollY; // x = x-p.x-scrollX; return {"x": x, "y": y}; }, showWorklog: function(activity, offset, psize){ this.hideCurrentWorklog(); if (!activity.worklogNode) activity.worklogNode = this.createWorkLogNode(activity.worklogs, activity); this.currentWorklogNode = activity.worklogNode; this.currentWorklogNode.setStyle("display", !!this.currentWorklogNode.get("html") ? "block" : "none"); if( layout.mobile ){ var pSize = this.paperNode.getSize(); var bodySize = $(document.body).getSize(); if( this.paperNode.getPosition().y + pSize.y > bodySize.y ){ var mobileActionNode = document.body.getElement(".o2_form_mobile_actions"); activity.worklogNode.inject( $(document.body) ); activity.worklogNode.setStyles({ "display": "block", "position": "absolute", "width": "calc( 100% - 4px )", "max-width": "500px", "bottom": mobileActionNode ? (mobileActionNode.getSize().y+1+"px") : "1px", "left": "0px" }); activity.worklogNode.setStyle("left", (bodySize.x - activity.worklogNode.getSize().x)/2 + "px"); }else{ activity.worklogNode.inject( this.paperNode ); activity.worklogNode.setStyles({ "display": "block", "position": "absolute", "width": "calc( 100% - 4px )", "max-width": "500px", "bottom": "1px", "left": "0px" }); activity.worklogNode.setStyle("left", (pSize.x - activity.worklogNode.getSize().x)/2 + "px"); } }else{ var p = this.getlogNodePosition(activity, activity.worklogNode, offset, psize) activity.worklogNode.setPosition({"x": p.x, "y": p.y}); } }, hideCurrentWorklog: function(){ if (this.currentWorklogNode){ this.currentWorklogNode.setStyle("display", "none"); this.currentWorklogNode = null; } }, bindTabEvent: function(){ if( this.module ){ var tab = this.module.getParentModule(); if( tab && tab.page ){ tab.page.addEvent("postHide", function () { if(this.currentWorklogNode)this.currentWorklogNode.hide() }.bind(this)) } } }, createWorkLogNode: function(worklogs, activity){ var node = new Element("div", {"styles": this.css.workLogNode}); if (this.recordList){ var logs = this.recordList.filter(function(r){ return r.fromActivity === activity.data.id; }); logs.each(function(log, idx){ var workNode = new Element("div", {"styles": this.css.workLogWorkNode}).inject(node); if ((idx % 2)==0){ workNode.setStyle("background-color", "#FFF"); }else{ workNode.setStyle("background-color", "#EEE"); } var router, opinion, arrivedActivitys, arrivedUsers; arrivedActivitys = log.properties.nextManualList.map(function(o){ return o.activityName; }).join(","); arrivedUsers = (log.properties.nextManualTaskIdentityList && log.properties.nextManualTaskIdentityList.length) ? o2.name.cns(log.properties.nextManualTaskIdentityList).join(",") : ""; switch (log.type) { case "empower": router = MWF.xApplication.process.Xform.LP.empower; var empowerTo = (log.properties.nextManualTaskIdentityList && log.properties.nextManualTaskIdentityList.length) ? o2.name.cns(log.properties.nextManualTaskIdentityList).join(",") : ""; opinion = MWF.xApplication.process.Xform.LP.empowerTo + empowerTo; break; case "retract": router = MWF.xApplication.process.Xform.LP.retract; opinion = MWF.xApplication.process.Xform.LP.retract; break; case "reroute": router = log.properties.routeName || MWF.xApplication.process.Xform.LP.reroute; opinion = log.properties.opinion || MWF.xApplication.process.Xform.LP.rerouteTo+": "+arrivedActivitys; break; case "rollback": router = log.properties.routeName || MWF.xApplication.process.Xform.LP.rollback; opinion = log.properties.opinion || MWF.xApplication.process.Xform.LP.rollbackTo+": "+log.arrivedActivityName; break; case "reset": var resetUser = log.properties.nextManualTaskIdentityList.erase(log.identity); resetUserText = o2.name.cns(resetUser).join(","); router = MWF.xApplication.process.Xform.LP.resetTo+":"+resetUserText; opinion = log.properties.opinion || "" break; case "appendTask": case "back": case "addSplit": case "urge": case "expire": case "read": default: router = log.properties.routeName || ""; opinion = log.properties.opinion || ""; } if (log.type==="currentTask"){ var taskNode = new Element("div", {"styles": this.css.workLogTaskNode}).inject(workNode); var html = "
"+log.person.substring(0, log.person.indexOf("@"))+" "+MWF.xApplication.process.Xform.LP.processing+"
"; taskNode.set("html", html); }else{ var taskNode = new Element("div", {"styles": this.css.workLogTaskNode}).inject(workNode); var html = "
"+log.person.substring(0, log.person.indexOf("@"))+":
"; html += "
["+router+"] "+o2.txt(opinion)+"
"; html += "
"+log.recordTime+"
"; taskNode.set("html", html); } }.bind(this)); }else{ worklogs.each(function(log, idx){ var workNode = new Element("div", {"styles": this.css.workLogWorkNode}).inject(node); if ((idx % 2)==0){ workNode.setStyle("background-color", "#FFF"); }else{ workNode.setStyle("background-color", "#EEE"); } if (log.taskCompletedList.length+log.taskList.length<1){ if (log.connected){ var taskNode = new Element("div", {"styles": this.css.workLogTaskNode}).inject(workNode); var html = "
"+MWF.xApplication.process.Xform.LP.systemProcess+"
"; html += "
"+log.arrivedTime+"
"; taskNode.set("html", html); }else{ var taskNode = new Element("div", {"styles": this.css.workLogTaskNode}).inject(workNode); var html = "
"+MWF.xApplication.process.Xform.LP.systemProcess+"
"; taskNode.set("html", html); } }else{ log.taskCompletedList.each(function(task){ var taskNode = new Element("div", {"styles": this.css.workLogTaskNode}).inject(workNode); var html = "
"+task.person.substring(0, task.person.indexOf("@"))+":
"; html += "
["+(task.routeName || "")+"] "+o2.txt(task.opinion)+"
"; html += "
"+task.completedTime+"
"; taskNode.set("html", html); }.bind(this)); log.taskList.each(function(task){ var taskNode = new Element("div", {"styles": this.css.workLogTaskNode}).inject(workNode); var html = "
"+task.person.substring(0, task.person.indexOf("@"))+" "+MWF.xApplication.process.Xform.LP.processing+"
"; taskNode.set("html", html); }.bind(this)); } }.bind(this)); } node.inject(this.paperNode); return node; } }); MWF.xApplication.process.Xform.widget.Monitor.Animation = new Class({ Implements: [Events], initialize: function(monitor, log){ } });