Viewer.min.js 30 KB

1
  1. MWF.xApplication.process=MWF.xApplication.process||{};MWF.xApplication.process.Application=MWF.xApplication.process.Application||{};MWF.require("MWF.widget.Common",null,false);MWF.require("MWF.xScript.Macro",null,false);MWF.xDesktop.requireApp("process.Application","lp.zh-cn",null,false);MWF.xApplication.process.Application.Viewer=new Class({Implements:[Options,Events],Extends:MWF.widget.Common,options:{style:"default",resizeNode:true,actions:{lookup:{uri:"/jaxrs/queryview/flag/{view}/application/flag/{application}/execute",method:"PUT"},getView:{uri:"/jaxrs/queryview/flag/{view}/application/flag/{application}"},listWorkByJob:{uri:"/jaxrs/job/{job}/find/work/workcompleted"},listTaskByWork:{uri:"/jaxrs/work/{id}/assignment/manage"}},actionRoot:"x_processplatform_assemble_surface"},initialize:function(e,t,i){this.setOptions(i);this.path="/x_component_process_Application/$Viewer/";this.cssPath="/x_component_process_Application/$Viewer/"+this.options.style+"/css.wcss";this._loadCss();this.lp=MWF.xApplication.process.Application.LP;this.container=$(e);this.json=t;this.viewJson=null;this.filterItems=[];this.searchStatus="none";this.items=[];this.selectedItems=[];this.hideColumns=[];this.openColumns=[];this.gridJson=null;this.init(function(){this.load()}.bind(this))},init:function(e){debugger;if(this.json.data){this.viewJson=JSON.decode(this.json.data);if(e)e()}else{this.getView(e)}},load:function(){this.loadLayout();this.createSearchNode();this.createViewNode({filterList:this.json.filter||null});if(this.options.resizeNode){this.setContentHeightFun=this.setContentHeight.bind(this);this.container.addEvent("resize",this.setContentHeightFun);this.setContentHeightFun()}},loadLayout:function(){this.node=new Element("div",{styles:this.css.node}).inject(this.container);this.searchAreaNode=new Element("div",{styles:this.css.searchAreaNode}).inject(this.node);this.viewAreaNode=new Element("div",{styles:this.css.viewAreaNode}).inject(this.node)},createSearchNode:function(){if(this.viewJson.customFilterEntryList&&this.viewJson.customFilterEntryList.length){this.searchStatus="default";this.loadFilterSearch()}else{this.loadSimpleSearch()}},loadSimpleSearch:function(){this.searchSimpleNode=new Element("div",{styles:this.css.searchSimpleNode}).inject(this.searchAreaNode);this.searchSimpleButtonNode=new Element("div",{styles:this.css.searchSimpleButtonNode}).inject(this.searchSimpleNode);this.searchSimpleInputNode=new Element("input",{type:"text",styles:this.css.searchSimpleInputNode,value:this.lp.searchKeywork}).inject(this.searchSimpleNode);this.searchSimpleButtonNode.addEvent("click",function(){this.search()}.bind(this));this.searchSimpleInputNode.addEvents({focus:function(){if(this.searchSimpleInputNode.get("value")===this.lp.searchKeywork)this.searchSimpleInputNode.set("value","")}.bind(this),blur:function(){if(!this.searchSimpleInputNode.get("value"))this.searchSimpleInputNode.set("value",this.lp.searchKeywork)}.bind(this),keydown:function(e){if(e.code===13)this.search()}.bind(this)})},search:function(){if(this.gridJson){var e=this.searchSimpleInputNode.get("value");var t=this.viewTable.rows;var i=this.json.isTitle!=="no"?1:0;for(var s=i;s<t.length;s++){var o=t[s];if(!e||e==this.lp.searchKeywork){if(o.getStyle("display")==="none")o.setStyle("display","table-row")}else{if(o.get("text").indexOf(e)!==-1){if(o.getStyle("display")==="none")o.setStyle("display","table-row")}else{if(o.getStyle("display")!=="none")o.setStyle("display","none")}}}}},loadFilterSearch:function(){this.viewSearchCustomActionNode=new Element("div",{styles:this.css.viewFilterSearchCustomActionNode,text:this.lp.customSearch}).inject(this.searchAreaNode);this.viewSearchInputAreaNode=new Element("div",{styles:this.css.viewFilterSearchInputAreaNode}).inject(this.searchAreaNode);this.viewSearchIconNode=new Element("div",{styles:this.css.viewFilterSearchIconNode}).inject(this.viewSearchInputAreaNode);this.viewSearchInputBoxNode=new Element("div",{styles:this.css.viewFilterSearchInputBoxNode}).inject(this.viewSearchInputAreaNode);this.viewSearchInputNode=new Element("input",{styles:this.css.viewFilterSearchInputNode,value:this.lp.searchKeywork}).inject(this.viewSearchInputBoxNode);this.viewSearchInputNode.addEvents({focus:function(){if(this.viewSearchInputNode.get("value")===this.lp.searchKeywork)this.viewSearchInputNode.set("value","")}.bind(this),blur:function(){if(!this.viewSearchInputNode.get("value"))this.viewSearchInputNode.set("value",this.lp.searchKeywork)}.bind(this),keydown:function(e){if(e.code===13)this.searchView()}.bind(this)});this.viewSearchIconNode.addEvents({click:function(){this.searchView()}.bind(this)});this.viewSearchCustomActionNode.addEvents({click:function(){this.loadCustomSearch()}.bind(this)})},searchView:function(){if(this.viewJson.customFilterEntryList){var e=this.viewSearchInputNode.get("value");if(e&&e!==this.lp.searchKeywork){var t=this.json.filter||[];this.viewJson.customFilterEntryList.each(function(i){if(i.formatType==="textValue"){var s={path:i.path,value:e,formatType:i.formatType,logic:"or",comparison:"like"};t.push(s)}if(i.formatType==="numberValue"){var o=e.toFloat();if(!isNaN(o)){var s={path:i.path,value:o,formatType:i.formatType,logic:"or",comparison:"like"};t.push(s)}}}.bind(this));this.createViewNode({filterList:t})}}},searchCustomView:function(){if(this.filterItems.length){var e=this.json.filter||[];this.filterItems.each(function(t){e.push(t.data)}.bind(this));this.createViewNode({filterList:e})}else{this.createViewNode({filterList:this.json.filter||null})}},loadCustomSearch:function(){this.viewSearchIconNode.setStyle("display","none");this.viewSearchInputBoxNode.setStyle("display","none");this.viewSearchCustomActionNode.setStyle("display","none");if(!this.searchMorph)this.searchMorph=new Fx.Morph(this.viewSearchInputAreaNode);var e=this.viewSearchInputAreaNode.getParent().getSize().x-2-20;this.css.viewFilterSearchInputAreaNode_custom.width=""+e+"px";var t=this.viewSearchInputAreaNode.getSize().x-2;this.viewSearchInputAreaNode.setStyle("width",""+t+"px");this.searchMorph.start(this.css.viewFilterSearchInputAreaNode_custom).chain(function(){this.searchStatus="custom";this.css.viewFilterSearchInputAreaNode_custom.width="auto";this.viewSearchInputAreaNode.setStyle("width","auto");if(this.viewSearchCustomContentNode){this.viewSearchCustomCloseActionNode.setStyle("display","block");this.viewSearchCustomContentNode.setStyle("display","block")}else{this.loadCustomSearchContent()}this.setContentHeightFun()}.bind(this));this.searchCustomView()},loadCustomSearchContent:function(){this.viewSearchCustomCloseActionNode=new Element("div",{styles:this.css.viewFilterSearchCustomCloseActionNode}).inject(this.viewSearchInputAreaNode);this.viewSearchCustomContentNode=new Element("div",{styles:this.css.viewFilterSearchCustomContentNode}).inject(this.viewSearchInputAreaNode);this.viewSearchCustomPathContentNode=new Element("div",{styles:this.css.viewFilterSearchCustomPathContentNode}).inject(this.viewSearchCustomContentNode);this.viewSearchCustomComparisonContentNode=new Element("div",{styles:this.css.viewFilterSearchCustomComparisonContentNode}).inject(this.viewSearchCustomContentNode);this.viewSearchCustomValueContentNode=new Element("div",{styles:this.css.viewFilterSearchCustomValueContentNode}).inject(this.viewSearchCustomContentNode);this.viewSearchCustomAddContentNode=new Element("div",{styles:this.css.viewFilterSearchCustomAddContentNode}).inject(this.viewSearchCustomContentNode);this.viewSearchCustomAddIconNode=new Element("div",{styles:this.css.viewFilterSearchCustomAddIconNode}).inject(this.viewSearchCustomAddContentNode);this.viewSearchCustomFilterContentNode=new Element("div",{styles:this.css.viewFilterSearchCustomFilterContentNode}).inject(this.viewSearchCustomContentNode);this.loadViewSearchCustomList();this.viewSearchCustomCloseActionNode.addEvents({click:function(){this.closeCustomSearch()}.bind(this)});this.viewSearchCustomAddIconNode.addEvents({click:function(){this.viewSearchCustomAddToFilter()}.bind(this)})},loadViewSearchCustomList:function(){this.viewSearchCustomPathListNode=new Element("select",{styles:this.css.viewFilterSearchCustomPathListNode,multiple:true}).inject(this.viewSearchCustomPathContentNode);this.viewSearchCustomComparisonListNode=new Element("select",{styles:this.css.viewFilterSearchCustomComparisonListNode,multiple:true}).inject(this.viewSearchCustomComparisonContentNode);this.viewJson.customFilterEntryList.each(function(e){var t=new Element("option",{style:this.css.viewFilterSearchOptionNode,value:e.path,text:e.title}).inject(this.viewSearchCustomPathListNode);t.store("entry",e)}.bind(this));this.viewSearchCustomPathListNode.addEvent("change",function(){this.loadViewSearchCustomComparisonList()}.bind(this))},loadViewSearchCustomComparisonList:function(){var e=this.viewSearchCustomPathListNode.selectedIndex;var t=this.viewSearchCustomPathListNode.options[e];var i=t.retrieve("entry");if(i){switch(i.formatType){case"numberValue":this.loadComparisonSelect(this.lp.numberFilter);this.loadViewSearchCustomValueNumberInput();break;case"dateTimeValue":this.loadComparisonSelect(this.lp.dateFilter);this.loadViewSearchCustomValueDateInput();break;case"booleanValue":this.loadComparisonSelect(this.lp.booleanFilter);this.loadViewSearchCustomValueBooleanInput();break;default:this.loadComparisonSelect(this.lp.textFilter);this.loadViewSearchCustomValueTextInput()}}},loadViewSearchCustomValueNumberInput:function(){this.viewSearchCustomValueContentNode.empty();this.viewSearchCustomValueNode=new Element("input",{styles:this.css.viewFilterSearchCustomValueNode,type:"number"}).inject(this.viewSearchCustomValueContentNode)},loadViewSearchCustomValueDateInput:function(){this.viewSearchCustomValueContentNode.empty();this.viewSearchCustomValueNode=new Element("input",{styles:this.css.viewFilterSearchCustomValueNode,type:"text",readonly:true}).inject(this.viewSearchCustomValueContentNode);MWF.require("MWF.widget.Calendar",function(){this.calendar=new MWF.widget.Calendar(this.viewSearchCustomValueNode,{style:"xform",isTime:true,target:this.container,format:"db"})}.bind(this))},loadViewSearchCustomValueBooleanInput:function(){this.viewSearchCustomValueContentNode.empty();this.viewSearchCustomValueNode=new Element("select",{styles:this.css.viewFilterSearchCustomValueSelectNode,multiple:true}).inject(this.viewSearchCustomValueContentNode);new Element("option",{value:"true",text:this.lp.yes}).inject(this.viewSearchCustomValueNode);new Element("option",{value:"false",text:this.lp.no}).inject(this.viewSearchCustomValueNode)},loadViewSearchCustomValueTextInput:function(){this.viewSearchCustomValueContentNode.empty();this.viewSearchCustomValueNode=new Element("textarea",{styles:this.css.viewFilterSearchCustomValueNode}).inject(this.viewSearchCustomValueContentNode)},loadComparisonSelect:function(e){this.viewSearchCustomComparisonListNode.empty();Object.each(e,function(e,t){var i=new Element("option",{value:t,text:e}).inject(this.viewSearchCustomComparisonListNode)}.bind(this))},closeCustomSearch:function(){if(this.viewSearchCustomContentNode&&this.viewSearchCustomContentNode.getStyle("display")==="block"){this.viewSearchCustomCloseActionNode.setStyle("display","none");this.viewSearchCustomContentNode.setStyle("display","none");var e=this.viewSearchInputAreaNode.getParent().getSize().x;t=e-2-10-90;this.css.viewFilterSearchInputAreaNode.width=""+t+"px";var t=this.viewSearchInputAreaNode.getSize().x-2;this.viewSearchInputAreaNode.setStyle("width",""+t+"px");if(!this.searchMorph)this.searchMorph=new Fx.Morph(this.viewSearchInputAreaNode);this.searchMorph.start(this.css.viewFilterSearchInputAreaNode).chain(function(){this.searchStatus="default";this.css.viewFilterSearchInputAreaNode.width="auto";this.viewSearchInputAreaNode.setStyle("margin-right","90px");this.viewSearchIconNode.setStyle("display","block");this.viewSearchInputBoxNode.setStyle("display","block");this.viewSearchCustomActionNode.setStyle("display","block");this.setContentHeightFun()}.bind(this));this.createViewNode({filterList:this.json.filter||null})}},viewSearchCustomAddToFilter:function(){var e=this.viewSearchCustomPathListNode.selectedIndex;var t=this.viewSearchCustomComparisonListNode.selectedIndex;if(e===-1){MWF.xDesktop.notice("error",{x:"left",y:"top"},this.lp.filterErrorTitle,this.viewSearchCustomPathListNode,{x:0,y:85});return false}if(t===-1){MWF.xDesktop.notice("error",{x:"left",y:"top"},this.lp.filterErrorComparison,this.viewSearchCustomComparisonListNode,{x:0,y:85});return false}var i=this.viewSearchCustomPathListNode.options[e];var s=i.retrieve("entry");if(s){var o=s.title;var n=s.path;var a=this.viewSearchCustomComparisonListNode.options[t].get("value");var h=this.viewSearchCustomComparisonListNode.options[t].get("text");var l="";switch(s.formatType){case"numberValue":l=this.viewSearchCustomValueNode.get("value");break;case"dateTimeValue":l=this.viewSearchCustomValueNode.get("value");break;case"booleanValue":var c=this.viewSearchCustomValueNode.selectedIndex;if(c!==-1){var r=this.viewSearchCustomValueNode.options[c].get("value");l=r==="true"}break;default:l=this.viewSearchCustomValueNode.get("value")}if(l===""){MWF.xDesktop.notice("error",{x:"left",y:"top"},this.lp.filterErrorValue,this.viewSearchCustomValueContentNode,{x:0,y:85});return false}this.filterItems.push(new MWF.xApplication.process.Application.Viewer.Filter(this,{logic:"and",path:n,title:o,comparison:a,comparisonTitle:h,value:l,formatType:s.formatType},this.viewSearchCustomFilterContentNode));this.searchCustomView()}},searchViewRemoveFilter:function(e){this.filterItems.erase(e);e.destroy();this.searchCustomView()},setContentHeight:function(){var e=this.node.getSize();var t=this.searchAreaNode.getSize();var i=e.y-t.y;this.viewAreaNode.setStyle("height",""+i+"px")},createLoadding:function(){this.loadingAreaNode=new Element("div",{styles:this.css.viewLoadingAreaNode}).inject(this.contentAreaNode);new Element("div",{styles:{height:"5px"}}).inject(this.loadingAreaNode);var e=new Element("div",{styles:this.css.viewLoadingNode}).inject(this.loadingAreaNode);new Element("div",{styles:this.css.viewLoadingIconNode}).inject(e);var t=new Element("div",{styles:this.css.viewLoadingTextNode}).inject(e);t.set("text","loading...")},createViewNode:function(e){this.viewAreaNode.empty();this.contentAreaNode=new Element("div",{styles:this.css.contentAreaNode}).inject(this.viewAreaNode);this.viewTable=new Element("table",{styles:this.css.viewTitleTableNode,border:"0px",cellPadding:"0",cellSpacing:"0"}).inject(this.contentAreaNode);this.createLoadding();if(this.json.isTitle!=="no"){this.viewTitleLine=new Element("tr",{styles:this.css.viewTitleLineNode}).inject(this.viewTable);this.selectTitleCell=new Element("td",{styles:this.css.viewTitleCellNode}).inject(this.viewTitleLine);this.selectTitleCell.setStyle("width","10px");if(this.json.titleStyles)this.selectTitleCell.setStyles(this.json.titleStyles);this.entries={};this.viewJson.selectEntryList.each(function(e){this.entries[e.column]=e;if(!e.hideColumn){var t=new Element("td",{styles:this.css.viewTitleCellNode,text:e.displayName}).inject(this.viewTitleLine);var i=MWF.getTextSize(e.displayName,this.css.viewTitleCellNode);t.setStyle("min-width",""+i.x+"px");if(this.json.titleStyles)t.setStyles(this.json.titleStyles)}else{this.hideColumns.push(e.column)}if(e.allowOpen)this.openColumns.push(e.column)}.bind(this));this.lookup(e)}else{this.viewJson.selectEntryList.each(function(e){if(e.hideColumn)this.hideColumns.push(e.column);if(!e.allowOpen)this.openColumns.push(e.column)}.bind(this));this.lookup(e)}},lookup:function(e){this.getLookupAction(function(){if(this.json.application){this.lookupAction.invoke({name:"lookup",async:true,data:e||null,parameter:{view:this.json.name,application:this.json.application},success:function(e){this.viewData=e.data;if(this.viewJson.groupEntry.column){this.gridJson=e.data.groupGrid;this.loadGroupData()}else{this.gridJson=e.data.grid;this.loadData()}if(this.loadingAreaNode){this.loadingAreaNode.destroy();this.loadingAreaNode=null}}.bind(this)})}}.bind(this))},loadData:function(){if(this.gridJson.length){this.gridJson.each(function(e,t){this.items.push(new MWF.xApplication.process.Application.Viewer.Item(this,e,null,t))}.bind(this))}},loadGroupData:function(){if(this.selectTitleCell){this.selectTitleCell.set("html","<span style='font-family: Webdings'>"+"<img src='/x_component_process_Application/$Viewer/"+this.options.style+"/icon/expand.png'/>"+"</span>");this.selectTitleCell.setStyle("cursor","pointer");this.selectTitleCell.addEvent("click",this.expandOrCollapseAll.bind(this))}if(this.gridJson.length){this.gridJson.each(function(e){this.items.push(new MWF.xApplication.process.Application.Viewer.ItemCategory(this,e))}.bind(this));this.expandOrCollapseAll()}},expandOrCollapseAll:function(){var e=this.selectTitleCell.getElement("span");if(e.get("html").indexOf("expand.png")===-1){this.items.each(function(t){t.collapse();e.set("html","<img src='/x_component_process_Application/$Viewer/"+this.options.style+"/icon/expand.png'/>")}.bind(this))}else{this.items.each(function(t,i){window.setTimeout(function(){t.expand()}.bind(this),10*i+5);e.set("html","<img src='/x_component_process_Application/$Viewer/"+this.options.style+"/icon/down.png'/>")}.bind(this))}},getView:function(e){this.getLookupAction(function(){if(this.json.application){this.lookupAction.invoke({name:"getView",async:true,parameter:{view:this.json.viewName,application:this.json.application},success:function(t){this.viewJson=JSON.decode(t.data.data);this.json=Object.merge(this.json,t.data);if(e)e()}.bind(this)})}}.bind(this))},getLookupAction:function(e){if(!this.lookupAction){var t=this;MWF.require("MWF.xDesktop.Actions.RestActions",function(){this.lookupAction=new MWF.xDesktop.Actions.RestActions("",this.options.actionRoot,"");this.lookupAction.getActions=function(e){this.actions=t.options.actions;if(e)e()};if(e)e()}.bind(this))}else{if(e)e()}},hide:function(){this.node.setStyle("display","none")},reload:function(){this.node.setStyle("display","block");if(this.loadingAreaNode)this.loadingAreaNode.setStyle("display","block");this.filterItems.each(function(e){e.destroy()}.bind(this));this.filterItems=[];if(this.viewSearchInputNode)this.viewSearchInputNode.set("text",this.lp.searchKeywork);this.closeCustomSearch();this.viewAreaNode.empty();this.createViewNode({filterList:this.json.filter||null})},getFilter:function(){debugger;var e=[];if(this.searchStatus==="custom"){if(this.filterItems.length){this.filterItems.each(function(t){e.push(t.data)}.bind(this))}}if(this.searchStatus==="default"){var t=this.viewSearchInputNode.get("value");if(t&&t!==this.lp.searchKeywork){this.viewJson.customFilterEntryList.each(function(i){if(i.formatType==="textValue"){var s={path:i.path,value:t,formatType:i.formatType,logic:"or",comparison:"like"};e.push(s)}if(i.formatType==="numberValue"){var o=t.toFloat();if(!isNaN(o)){var s={path:i.path,value:o,formatType:i.formatType,logic:"or",comparison:"like"};e.push(s)}}}.bind(this))}}return e.length?e:null},getData:function(){if(this.selectedItems.length){var e=[];this.selectedItems.each(function(t){e.push(t.data)});return e}else{return[]}}});MWF.xApplication.process.Application.Viewer.Item=new Class({initialize:function(e,t,i,s){this.view=e;this.data=t;this.css=this.view.css;this.isSelected=false;this.prev=i;this.load()},load:function(){this.node=new Element("tr",{styles:this.css.viewContentTrNode});if(this.prev){this.node.inject(this.prev.node,"after")}else{this.node.inject(this.view.viewTable)}this.selectTd=new Element("td",{styles:this.css.viewContentTdNode}).inject(this.node);this.selectTd.setStyles({cursor:"pointer"});if(this.view.json.itemStyles)this.selectTd.setStyles(this.view.json.itemStyles);Object.each(this.data.data,function(e,t){if(this.view.hideColumns.indexOf(t)===-1){var i=new Element("td",{styles:this.css.viewContentTdNode}).inject(this.node);if(t!==this.view.viewJson.groupEntry.column){var s=this.view.entries[t].code?MWF.Macro.exec(this.view.entries[t].code,{value:e,gridData:this.view.gridJson,data:this.view.viewData,entry:this.data}):e;i.set("text",s)}if(this.view.openColumns.indexOf(t)!==-1){this.setOpenWork(i)}if(this.view.json.itemStyles)i.setStyles(this.view.json.itemStyles)}}.bind(this));this.setEvent()},setOpenWork:function(e){e.setStyle("cursor","pointer");e.addEvent("click",this.openWorkAndCompleted.bind(this))},openWorkAndCompleted:function(e){this.view.lookupAction.invoke({name:"listWorkByJob",async:true,parameter:{job:this.data.job},success:function(t){var i=t.data.workCompletedList.length;var s=t.data.workList.length;var o=s+i;if(o===1){if(i){this.openWorkCompleted(t.data.workCompletedList[0].id,e)}else{this.openWork(t.data.workList[0].id,e)}}else if(o>1){var n=this.createWorksArea();t.data.workCompletedList.each(function(e){this.createWorkCompletedNode(e,n)}.bind(this));t.data.workList.each(function(e){this.createWorkNode(e,n)}.bind(this));this.showWorksArea(n,e)}else{}}.bind(this)})},createWorkNode:function(e,t){var i=t.getLast();var s=new Element("div",{styles:this.css.workAreaNode}).inject(i);var o=new Element("div",{styles:this.css.workAreaActionNode,text:this.view.lp.open}).inject(s);o.store("workId",e.id);o.addEvent("click",function(e){this.openWork(e.target.retrieve("workId"),e);this.mask.hide();t.destroy()}.bind(this));var n=new Element("div",{styles:this.css.workAreaLeftNode}).inject(s);var a=new Element("div",{styles:this.css.workAreaTitleNode,text:e.title}).inject(n);var h=new Element("div",{styles:this.css.workAreaContentNode}).inject(n);new Element("div",{styles:this.css.workAreaContentTitleNode,text:this.view.lp.activity+": "}).inject(h);new Element("div",{styles:this.css.workAreaContentTextNode,text:e.activityName}).inject(h);var l=[];this.view.lookupAction.invoke({name:"listTaskByWork",async:true,parameter:{id:e.id},success:function(e){e.data.taskList.each(function(e){l.push(MWF.name.cn(e.person))}.bind(this));new Element("div",{styles:this.css.workAreaContentTitleNode,text:this.view.lp.taskPeople+": "}).inject(h);new Element("div",{styles:this.css.workAreaContentTextNode,text:l.join(", ")}).inject(h)}.bind(this)})},createWorkCompletedNode:function(e,t){var i=t.getLast();var s=new Element("div",{styles:this.css.workAreaNode}).inject(i);var o=new Element("div",{styles:this.css.workAreaActionNode,text:this.view.lp.open}).inject(s);o.store("workId",e.id);o.addEvent("click",function(e){this.mask.hide();t.destroy();this.openWorkCompleted(e.target.retrieve("workId"),e)}.bind(this));var n=new Element("div",{styles:this.css.workAreaLeftNode}).inject(s);var a=new Element("div",{styles:this.css.workAreaTitleNode,text:e.title}).inject(n);var h=new Element("div",{styles:this.css.workAreaContentNode}).inject(n);new Element("div",{styles:this.css.workAreaContentTitleNode,text:this.view.lp.activity+": "}).inject(h);new Element("div",{styles:this.css.workAreaContentTextNode,text:this.view.lp.processCompleted}).inject(h)},createWorksArea:function(){var e=new Element("div",{styles:this.css.worksAreaNode});var t=new Element("div",{styles:this.css.worksAreaTitleNode}).inject(e);var i=new Element("div",{styles:this.css.worksAreaTitleCloseNode}).inject(t);i.addEvent("click",function(e){this.mask.hide();e.target.getParent().getParent().destroy()}.bind(this));var s=new Element("div",{styles:this.css.worksAreaContentNode}).inject(e);return e},showWorksArea:function(e,t){this.mask=new MWF.widget.Mask({style:"desktop",loading:false});this.mask.loadNode(this.view.container);e.inject(this.view.node);this.setWorksAreaPosition(e,t.target)},setWorksAreaPosition:function(e,t){var i=t.getPosition(this.view.container);var s=this.view.container.getSize();var o=this.view.container.getPosition(this.view.container.getOffsetParent());var n=e.getSize();var a=i.x+n.x-s.x;a=a>0?a+20:0;var h=i.y+n.y-s.y;h=h>0?h+5:0;e.position({relativeTo:t,position:"lefttop",edge:"lefttop",offset:{x:0-a,y:0-h}})},openWork:function(e,t){var i={workId:e};layout.desktop.openApplication(t,"process.Work",i)},openWorkCompleted:function(e,t){var i={workCompletedId:e};layout.desktop.openApplication(t,"process.Work",i)},setEvent:function(){if(this.view.json.select==="single"||this.view.json.select==="multi"){this.node.addEvents({mouseover:function(){if(!this.isSelected){var e="checkbox";if(this.view.json.select==="single")e="radiobox";this.selectTd.setStyles({background:"url("+"/x_component_process_Application/$Viewer/default/icon/"+e+".png) center center no-repeat"})}}.bind(this),mouseout:function(){if(!this.isSelected)this.selectTd.setStyles({background:"transparent"})}.bind(this),click:function(){this.select()}.bind(this)})}},select:function(){if(this.isSelected){if(this.view.json.select==="single"){this.unSelectedSingle()}else{this.unSelected()}}else{if(this.view.json.select==="single"){this.selectedSingle()}else{this.selected()}}this.view.fireEvent("select")},selected:function(){this.view.selectedItems.push(this);this.selectTd.setStyles({background:"url("+"/x_component_process_Application/$Viewer/default/icon/checkbox_checked.png) center center no-repeat"});this.node.setStyles(this.css.viewContentTrNode_selected);this.isSelected=true},unSelected:function(){this.view.selectedItems.erase(this);this.selectTd.setStyles({background:"transparent"});this.node.setStyles(this.css.viewContentTrNode);this.isSelected=false},selectedSingle:function(){if(this.view.currentSelectedItem)this.view.currentSelectedItem.unSelectedSingle();this.view.selectedItems=[this];this.view.currentSelectedItem=this;this.selectTd.setStyles({background:"url("+"/x_component_process_Application/$Viewer/default/icon/radiobox_checked.png) center center no-repeat"});this.node.setStyles(this.css.viewContentTrNode_selected);this.isSelected=true},unSelectedSingle:function(){this.view.selectedItems=[];this.view.currentSelectedItem=null;this.selectTd.setStyles({background:"transparent"});this.node.setStyles(this.css.viewContentTrNode);this.isSelected=false}});MWF.xApplication.process.Application.Viewer.ItemCategory=new Class({initialize:function(e,t){this.view=e;this.data=t;this.css=this.view.css;this.items=[];this.loadChild=false;this.load()},load:function(){this.node=new Element("tr",{styles:this.css.viewContentTrNode}).inject(this.view.viewTable);this.selectTd=new Element("td",{styles:this.css.viewContentCategoryTdNode}).inject(this.node);if(this.view.json.itemStyles)this.selectTd.setStyles(this.view.json.itemStyles);this.categoryTd=new Element("td",{styles:this.css.viewContentCategoryTdNode,colspan:this.view.viewJson.selectEntryList.length}).inject(this.node);this.groupColumn=null;for(var e=0;e<this.view.viewJson.selectEntryList.length;e++){if(this.view.viewJson.selectEntryList[e].column===this.view.viewJson.groupEntry.column){this.groupColumn=this.view.viewJson.selectEntryList[e];break}}if(this.groupColumn){var t=this.groupColumn.code?MWF.Macro.exec(this.groupColumn.code,{value:this.data.group,gridData:this.view.gridJson,data:this.view.viewData,entry:this.data}):this.data.group}else{var t=this.data.group}this.categoryTd.set("html","<span style='font-family: Webdings'><img src='/x_component_process_Application/$Viewer/"+this.view.options.style+"/icon/expand.png'/></span> "+t);if(this.view.json.itemStyles)this.categoryTd.setStyles(this.view.json.itemStyles);this.setEvent()},setEvent:function(){this.node.addEvents({click:function(){this.expandOrCollapse()}.bind(this)})},expandOrCollapse:function(){var e=this.node.getElement("span").get("html");if(e.indexOf("expand.png")===-1){this.collapse()}else{this.expand()}},collapse:function(){this.items.each(function(e){e.node.setStyle("display","none")}.bind(this));this.node.getElement("span").set("html","<img src='/x_component_process_Application/$Viewer/"+this.view.options.style+"/icon/expand.png'/>")},expand:function(){this.items.each(function(e){e.node.setStyle("display","table-row")}.bind(this));this.node.getElement("span").set("html","<img src='/x_component_process_Application/$Viewer/"+this.view.options.style+"/icon/down.png'/>");if(!this.loadChild){this.data.list.each(function(e){this.items.push(new MWF.xApplication.process.Application.Viewer.Item(this.view,e,this))}.bind(this));this.loadChild=true}}});MWF.xApplication.process.Application.Viewer.Filter=new Class({initialize:function(e,t,i){this.viewer=e;this.data=t;this.css=this.viewer.css;this.content=i;this.load()},load:function(){this.node=new Element("div",{styles:this.css.viewSearchFilterNode}).inject(this.content);if(this.viewer.filterItems.length){this.logicNode=new Element("div",{styles:this.css.viewSearchFilterSelectAreaNode}).inject(this.node);this.logicSelectNode=new Element("div",{styles:this.css.viewSearchFilterSelectNode,text:this.viewer.lp.and,value:"and"}).inject(this.logicNode);this.logicSelectButtonNode=new Element("div",{styles:this.css.viewSearchFilterSelectButtonNode}).inject(this.logicNode);this.logicNode.addEvents({click:function(){var e=this.logicSelectNode.get("value");if(e==="and"){this.logicSelectButtonNode.setStyle("float","left");this.logicSelectNode.setStyle("float","right");this.logicSelectNode.set({text:this.viewer.lp.or,value:"or"});this.data.logic="or"}else{this.logicSelectButtonNode.setStyle("float","right");this.logicSelectNode.setStyle("float","left");this.logicSelectNode.set({text:this.viewer.lp.and,value:"and"});this.data.logic="and"}this.viewer.searchCustomView()}.bind(this)})}this.titleNode=new Element("div",{styles:this.css.viewSearchFilterTextNode,text:this.data.title}).inject(this.node);this.comparisonTitleNode=new Element("div",{styles:this.css.viewSearchFilterTextNode,text:this.data.comparisonTitle}).inject(this.node);this.valueNode=new Element("div",{styles:this.css.viewSearchFilterTextNode,text:'"'+this.data.value+'"'}).inject(this.node);this.deleteNode=new Element("div",{styles:this.css.viewSearchFilterDeleteNode}).inject(this.node);this.node.addEvents({mouseover:function(){this.node.setStyles(this.css.viewSearchFilterNode_over);this.deleteNode.setStyles(this.css.viewSearchFilterDeleteNode_over)}.bind(this),mouseout:function(){this.node.setStyles(this.css.viewSearchFilterNode);this.deleteNode.setStyles(this.css.viewSearchFilterDeleteNode)}.bind(this)});this.deleteNode.addEvent("click",function(){this.viewer.searchViewRemoveFilter(this)}.bind(this))},destroy:function(){this.node.destroy();MWF.release(this)}});