Actionbar.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. tools.each(function(tool){
  92. var flag = true;
  93. if (tool.control){
  94. flag = this.form.businessData.control[tool.control]
  95. }
  96. if (tool.id == "action_processWork"){
  97. if (!this.form.businessData.task){
  98. flag = false;
  99. }
  100. }
  101. if (readonly) if (!tool.read) flag = false;
  102. if (flag){
  103. var actionNode = new Element("div", {
  104. "id": tool.id,
  105. "MWFnodetype": tool.type,
  106. "MWFButtonImage": this.form.path+""+this.form.options.style+"/actionbar/"+tool.img,
  107. "title": tool.title,
  108. "MWFButtonAction": tool.action,
  109. "MWFButtonText": tool.text,
  110. }).inject(node);
  111. if (tool.sub){
  112. var subNode = node.getLast();
  113. this.setToolbars(tool.sub, subNode);
  114. }
  115. }
  116. }.bind(this));
  117. },
  118. runCustomAction: function(bt){
  119. var script = bt.node.retrieve("script");
  120. this.form.Macro.exec(script, this);
  121. },
  122. saveWork: function(){
  123. this.form.saveWork();
  124. },
  125. closeWork: function(){
  126. this.form.closeWork();
  127. },
  128. processWork: function(){
  129. this.form.processWork();
  130. },
  131. resetWork: function(){
  132. this.form.resetWork();
  133. },
  134. retractWork: function(e, ev){
  135. this.form.retractWork(e, ev);
  136. },
  137. rerouteWork: function(e, ev){
  138. this.form.rerouteWork(e, ev);
  139. },
  140. deleteWork: function(){
  141. this.form.deleteWork();
  142. },
  143. printWork: function(){
  144. this.form.printWork();
  145. }
  146. });