Actionbar.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. MWF.require("MWF.widget.Tree", null, false);
  3. MWF.xApplication.process.Xform.Actionbar = MWF.APPActionbar = new Class({
  4. Extends: MWF.APP$Module,
  5. _loadUserInterface: function(){
  6. if (this.form.json.mode == "Mobile"){
  7. this.node.empty();
  8. }else if (COMMON.Browser.Platform.isMobile){
  9. this.node.empty();
  10. }else{
  11. this.toolbarNode = this.node.getFirst("div");
  12. this.toolbarNode.empty();
  13. MWF.require("MWF.widget.Toolbar", function(){
  14. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  15. //alert(this.readonly)
  16. if (this.json.hideSystemTools){
  17. his.setCustomToolbars(this.json.tools, this.toolbarNode);
  18. this.toolbarWidget.load();
  19. }else{
  20. MWF.getJSON(this.form.path+"toolbars.json", function(json){
  21. this.setToolbars(json, this.toolbarNode, this.readonly);
  22. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  23. this.toolbarWidget.load();
  24. }.bind(this), false);
  25. }
  26. // if (this.readonly){
  27. // this.setToolbars(this.json.sysTools.readTools, this.toolbarNode);
  28. //// this.setToolbars(this.json.tools.readTools, this.toolbarNode);
  29. // }else{
  30. // this.setToolbars(this.json.sysTools.editTools, this.toolbarNode);
  31. //// this.setToolbars(this.json.tools.editTools, this.toolbarNode);
  32. // }
  33. // this.setCustomToolbars(this.json.tools, this.toolbarNode);
  34. //
  35. //
  36. // this.toolbarWidget.load();
  37. // var size = this.toolbarNode.getSize();
  38. // this.node.setStyle("height", ""+size.y+"px");
  39. // var nodeSize = this.toolbarNode.getSize();
  40. // this.toolbarNode.setStyles({
  41. // "width": ""+nodeSize.x+"px",
  42. //// "position": "absolute",
  43. // "z-index": 50000
  44. // });
  45. // this.toolbarNode.position({"relativeTo": this.node, "position": "upperLeft", "edge": "upperLeft"});
  46. //
  47. // this.form.node.addEvent("scroll", function(){
  48. // alert("ddd")
  49. // }.bind(this));
  50. }.bind(this));
  51. }
  52. },
  53. setCustomToolbars: function(tools, node){
  54. tools.each(function(tool){
  55. var flag = true;
  56. if (this.readonly){
  57. flag = tool.readShow;
  58. }else{
  59. flag = tool.editShow;
  60. }
  61. if (flag){
  62. flag = true;
  63. if (tool.control){
  64. flag = this.form.businessData.control[tool.control]
  65. }
  66. if (tool.condition){
  67. var hideFlag = this.form.Macro.exec(tool.condition, this);
  68. flag = !hideFlag;
  69. }
  70. if (flag){
  71. var actionNode = new Element("div", {
  72. "id": tool.id,
  73. "MWFnodetype": tool.type,
  74. "MWFButtonImage": this.form.path+""+this.form.options.style+"/actionbar/"+tool.img,
  75. "title": tool.title,
  76. "MWFButtonAction": "runCustomAction",
  77. "MWFButtonText": tool.text,
  78. }).inject(node);
  79. if (tool.actionScript){
  80. actionNode.store("script", tool.actionScript);
  81. }
  82. if (tool.sub){
  83. var subNode = node.getLast();
  84. this.setCustomToolbars(tool.sub, subNode);
  85. }
  86. }
  87. }
  88. }.bind(this));
  89. },
  90. setToolbars: function(tools, node, readonly){
  91. debugger;
  92. tools.each(function(tool){
  93. var flag = true;
  94. if (tool.control){
  95. flag = this.form.businessData.control[tool.control]
  96. }
  97. if (tool.id == "action_processWork"){
  98. if (!this.form.businessData.task){
  99. flag = false;
  100. }
  101. }
  102. if (readonly) if (!tool.read) flag = false;
  103. if (flag){
  104. var actionNode = new Element("div", {
  105. "id": tool.id,
  106. "MWFnodetype": tool.type,
  107. "MWFButtonImage": this.form.path+""+this.form.options.style+"/actionbar/"+tool.img,
  108. "title": tool.title,
  109. "MWFButtonAction": tool.action,
  110. "MWFButtonText": tool.text,
  111. }).inject(node);
  112. if (tool.sub){
  113. var subNode = node.getLast();
  114. this.setToolbars(tool.sub, subNode);
  115. }
  116. }
  117. }.bind(this));
  118. },
  119. runCustomAction: function(bt){
  120. var script = bt.node.retrieve("script");
  121. this.form.Macro.exec(script, this);
  122. },
  123. saveWork: function(){
  124. this.form.saveWork();
  125. },
  126. closeWork: function(){
  127. this.form.closeWork();
  128. },
  129. processWork: function(){
  130. this.form.processWork();
  131. },
  132. resetWork: function(){
  133. this.form.resetWork();
  134. },
  135. retractWork: function(e, ev){
  136. this.form.retractWork(e, ev);
  137. },
  138. rerouteWork: function(e, ev){
  139. this.form.rerouteWork(e, ev);
  140. },
  141. deleteWork: function(){
  142. this.form.deleteWork();
  143. },
  144. printWork: function(){
  145. this.form.printWork();
  146. }
  147. });