ViewExplorer.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. MWF.require("MWF.widget.Mask", null, false);
  2. MWF.xDesktop.requireApp("process.Application", "WorkExplorer", null, false);
  3. MWF.xDesktop.requireApp("process.Application", "Viewer", null, false);
  4. MWF.xApplication.process.Application.ViewExplorer = new Class({
  5. Extends: MWF.xApplication.process.Application.WorkExplorer,
  6. Implements: [Options, Events],
  7. initialize: function(node, actions, options){
  8. this.setOptions(options);
  9. this.setTooltip();
  10. this.path = "/x_component_process_Application/$WorkExplorer/";
  11. this.cssPath = "/x_component_process_Application/$WorkExplorer/"+this.options.style+"/css.wcss";
  12. this._loadCss();
  13. this.actions = actions;
  14. this.node = $(node);
  15. this.items=[];
  16. },
  17. load: function(){
  18. this.loadFilterNode();
  19. this.loadContentNode();
  20. },
  21. loadFilterNode: function(){
  22. this.filterNode = new Element("div", {"styles": this.css.viewFilterNode}).inject(this.node);
  23. this.filterNode.setStyle("padding", "0px 10px");
  24. this.exportNode = new Element("div", {"styles": this.css.exportViewNode, "text": this.app.lp.exportExcel}).inject(this.filterNode);
  25. this.exportNode.addEvent("click", function(e){
  26. this.exportView();
  27. }.bind(this));
  28. this.viewListAreaNode = new Element("div", {"styles": this.css.viewFilterListAreaNode}).inject(this.filterNode);
  29. this.viewListTitleNode = new Element("div", {"styles": this.css.viewFilterListTitleNode, "text": this.app.lp.view}).inject(this.viewListAreaNode);
  30. this.viewListNode = new Element("div", {"styles": this.css.viewFilterListNode}).inject(this.viewListAreaNode);
  31. this.loadViewList();
  32. },
  33. exportView: function(){
  34. if (this.currentViewer){
  35. var filterData = this.currentViewer.getFilter();
  36. this.actions.exportView(this.currentViewer.json.application, this.currentViewer.json.id, {"filter": filterData});
  37. }
  38. },
  39. loadViewList: function(){
  40. this.actions.listView(this.app.options.id, function(json){
  41. if (json.data.length){
  42. json.data.each(function(process){
  43. this.loadViewListNode(process);
  44. }.bind(this));
  45. if (this.currentViewNode){
  46. this.currentViewNode.click();
  47. }else{
  48. if (this.items[0]) this.items[0].click();
  49. }
  50. }else{
  51. this.filterNode.destroy();
  52. var noElementNode = new Element("div", {
  53. "styles": this.css.noElementNode,
  54. "text": this.app.lp.noView
  55. }).inject(this.elementContentNode);
  56. }
  57. }.bind(this));
  58. },
  59. loadViewListNode: function(view){
  60. var viewNode = new Element("div", {"styles": this.css.filterViewNode}).inject(this.viewListNode);
  61. viewNode.set("text", view.name);
  62. viewNode.store("view", view);
  63. this.items.push(viewNode);
  64. if (this.app.status){
  65. if (this.app.status.viewName){
  66. if (view.name === this.app.status.viewName) this.currentViewNode = viewNode;
  67. }
  68. }
  69. var _self = this;
  70. viewNode.addEvent("click", function(){
  71. _self.loadViewData(this);
  72. });
  73. viewNode.makeLnk({
  74. "par": this._getLnkPar(view)
  75. });
  76. },
  77. loadViewData: function(node, viewObj){
  78. if (this.currentViewer) this.currentViewer.hide();
  79. if (node){
  80. this.items.each(function(item){
  81. item.setStyles(this.css.filterViewNode);
  82. }.bind(this));
  83. node.setStyles(this.css.filterViewNode_current);
  84. var viewer = node.retrieve("viewer");
  85. if (viewer){
  86. this.currentViewer = viewer;
  87. viewer.reload();
  88. }else{
  89. var view = (viewObj) ? viewObj : node.retrieve("view");
  90. viewer = new MWF.xApplication.process.Application.Viewer(this.elementContentNode, view);
  91. this.currentViewer = viewer;
  92. }
  93. }
  94. },
  95. loadContentNode: function(){
  96. this.elementContentNode = new Element("div", {
  97. "styles": this.css.elementContentNode
  98. }).inject(this.node);
  99. this.setContentSize();
  100. this.setContentSizeFun = this.setContentSize.bind(this);
  101. this.app.addEvent("resize", this.setContentSizeFun);
  102. },
  103. createWorkListHead: function(){},
  104. setContentSize: function(){
  105. //var toolbarSize = this.toolbarNode.getSize();
  106. var nodeSize = this.node.getSize();
  107. var pt = this.elementContentNode.getStyle("padding-top").toFloat();
  108. var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();
  109. var filterSize = this.filterNode.getSize();
  110. var height = nodeSize.y-pt-pb-filterSize.y;
  111. this.elementContentNode.setStyle("height", ""+height+"px");
  112. this.elementContentNode.fireEvent("resize");
  113. },
  114. createSearchElementNode: function(){
  115. return false;
  116. },
  117. _getLnkPar: function(view){
  118. return {
  119. "icon": this.path+this.options.style+"/viewIcon/lnk.png",
  120. "title": view.name,
  121. "par": "process.Application#{\"navi\": 2, \"id\": \""+this.app.options.id+"\", \"viewName\": \""+view.name+"\", \"hideMenu\": true}"
  122. };
  123. }
  124. });