rsAppRunMenuActions.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*
  2. IBM Confidential
  3. OCO Source Materials
  4. IBM Cognos Products: rs
  5. (C) Copyright IBM Corp. 2015, 2020
  6. The source code for this program is not published or otherwise divested of its trade secrets, irrespective of what has been deposited with the U.S. Copyright Office.
  7. */
  8. define(['bi/glass/app/plugins/MenuActionInterface'], function(MenuActionInterface) {
  9. 'use strict';
  10. var AuthoringMenu = MenuActionInterface.extend({
  11. onSelectItem: function(context) {
  12. var v_sMenuItem = context.target.itemId;
  13. console.log("rsAppRunMenu.onSelectItem selected item " + v_sMenuItem);
  14. var v_Application = context.glassContext.currentAppView.currentContentView.getAuthoringApplication();
  15. if (!v_Application)
  16. {
  17. return;
  18. }
  19. switch( v_sMenuItem )
  20. {
  21. case "com.ibm.bi.authoring.run_show_run_options":
  22. window.setTimeout( v_Application.ShowRunOptions.bind(v_Application), 0 );
  23. return;
  24. case "com.ibm.bi.viewer.run":
  25. case "com.ibm.bi.viewer.runHtml":
  26. case "com.ibm.bi.viewer.run_html_ar":
  27. case "com.ibm.bi.viewer.runPdf":
  28. var v_oParameters = { Prompt : v_sMenuItem == "com.ibm.bi.viewer.run" };
  29. switch( v_sMenuItem )
  30. {
  31. case "com.ibm.bi.viewer.runHtml":
  32. case "com.ibm.bi.viewer.run_html_ar":
  33. v_oParameters.OutputFormat = "HTML";
  34. break;
  35. case "com.ibm.bi.viewer.runPdf":
  36. v_oParameters.OutputFormat = "PDF";
  37. break;
  38. }
  39. v_Application.SharedState.Call(null, v_sMenuItem.substring(v_sMenuItem.lastIndexOf(".") + 1), v_oParameters);
  40. break;
  41. case "com.ibm.bi.authoring.run_html":
  42. case "com.ibm.bi.authoring.run_pdf":
  43. case "com.ibm.bi.authoring.run_excel2007":
  44. case "com.ibm.bi.authoring.run_excel2007data":
  45. case "com.ibm.bi.authoring.run_csv":
  46. case "com.ibm.bi.authoring.run_html_ar":
  47. case "com.ibm.bi.authoring.run_html_ar_download":
  48. case "com.ibm.bi.authoring.run_xml":
  49. case "com.ibm.bi.viewer.run_excel2007":
  50. case "com.ibm.bi.viewer.run_excel2007data":
  51. case "com.ibm.bi.viewer.run_csv":
  52. case "com.ibm.bi.viewer.run_html_ar_download":
  53. case "com.ibm.bi.viewer.run_xml":
  54. var v_oParameters = { OutputFormat: null };
  55. var v_bViewerAction = v_sMenuItem.indexOf(".viewer.") > 0;
  56. if (v_bViewerAction)
  57. {
  58. v_oParameters.Prompt = false;
  59. }
  60. var v_bRunInNewViewer = v_bViewerAction || v_Application.SharedState.Get("runInAdvancedViewer");
  61. switch(v_sMenuItem)
  62. {
  63. case "com.ibm.bi.authoring.run_html_ar":
  64. v_oParameters.OutputFormat = "HTML";
  65. v_oParameters.Download = "false";
  66. v_oParameters.isApplication = v_Application.SharedState.Get("isActiveReport");
  67. break;
  68. case "com.ibm.bi.authoring.run_html_ar_download":
  69. case "com.ibm.bi.viewer.run_html_ar_download":
  70. v_oParameters.OutputFormat = "HTML";
  71. v_oParameters.Download = "true";
  72. v_oParameters.isApplication = v_Application.SharedState.Get("isActiveReport");
  73. break;
  74. case "com.ibm.bi.authoring.run_html":
  75. v_oParameters.OutputFormat = "HTML";
  76. if (v_bRunInNewViewer)
  77. {
  78. v_oParameters.isViewer = true; // Use viewer instead of editor
  79. }
  80. break;
  81. case "com.ibm.bi.authoring.run_pdf":
  82. v_oParameters.OutputFormat = "PDF";
  83. if (v_bRunInNewViewer)
  84. {
  85. v_oParameters.isViewer = true; // Use viewer instead of editor
  86. }
  87. break;
  88. case "com.ibm.bi.authoring.run_excel2007":
  89. case "com.ibm.bi.viewer.run_excel2007":
  90. v_oParameters.OutputFormat = "spreadsheetML";
  91. if (v_bRunInNewViewer)
  92. {
  93. v_oParameters.Download = "true";
  94. }
  95. break;
  96. case "com.ibm.bi.authoring.run_excel2007data":
  97. case "com.ibm.bi.viewer.run_excel2007data":
  98. v_oParameters.OutputFormat = "xlsxData";
  99. if (v_bRunInNewViewer)
  100. {
  101. v_oParameters.Download = "true";
  102. }
  103. break;
  104. case "com.ibm.bi.authoring.run_csv":
  105. case "com.ibm.bi.viewer.run_csv":
  106. v_oParameters.OutputFormat = "CSV";
  107. if (v_bRunInNewViewer)
  108. {
  109. v_oParameters.Download = "true";
  110. }
  111. break;
  112. case "com.ibm.bi.authoring.run_xml":
  113. case "com.ibm.bi.viewer.run_xml":
  114. v_oParameters.OutputFormat = "XML";
  115. if (v_bRunInNewViewer)
  116. {
  117. v_oParameters.Download = "true";
  118. }
  119. break;
  120. default:
  121. var v_sIdxValue = v_sMenuItem.indexOf("_");
  122. var v_sValue = v_sMenuItem.slice(v_sIdxValue+1);
  123. console.warn("using implicit output format: %s", v_sValue);
  124. }
  125. if (!v_bViewerAction)
  126. {
  127. v_oParameters.isFromRS = true;
  128. }
  129. v_Application.SharedState.Call(null, "runInNewWindow", v_oParameters);
  130. break;
  131. default:
  132. console.warn("Unhandled item: " + v_sMenuItem);
  133. return;
  134. }
  135. v_Application.GlassMenu_onSelectItem(v_sMenuItem);
  136. },
  137. isItemVisible: function(context){
  138. console.log("rsAppRunMenu.isItemVisible");
  139. var v_sMenuItem = context.target.itemId;
  140. console.log("v_sMenuItem: " + v_sMenuItem);
  141. var v_Application = context.glassContext.currentAppView.currentContentView.getAuthoringApplication();
  142. if (!v_Application)
  143. {
  144. return false;
  145. }
  146. var v_bCanRun = v_Application.SharedState.Get("canRun");
  147. var v_bActiveReport = v_Application.SharedState.Get("isActiveReport");
  148. var v_bIsViewer = v_Application.SharedState.Get("isViewer");
  149. switch(v_sMenuItem)
  150. {
  151. case "com.ibm.bi.viewer.run":
  152. case "com.ibm.bi.authoring.refresh":
  153. return false;
  154. case "com.ibm.bi.authoring.run_html_ar":
  155. return v_bActiveReport && v_bCanRun;
  156. case "com.ibm.bi.authoring.run_html_ar_download":
  157. case "com.ibm.bi.viewer.run_html_ar_download":
  158. return v_bActiveReport && v_bCanRun;
  159. case "com.ibm.bi.authoring.run_show_run_options":
  160. case "com.ibm.bi.viewer.run_html_ar":
  161. return v_bCanRun && !v_bIsViewer;
  162. case "com.ibm.bi.authoring.run_csv":
  163. case "com.ibm.bi.viewer.run_csv":
  164. return !v_bActiveReport && v_bCanRun && context.glassContext.hasCapability("canGenerateCSVOutput");
  165. case "com.ibm.bi.viewer.runPdf":
  166. return !v_bActiveReport && v_bCanRun && context.glassContext.hasCapability("canGeneratePDFOutput");
  167. case "com.ibm.bi.authoring.run_pdf":
  168. return !v_bActiveReport && v_bCanRun && context.glassContext.hasCapability("canGeneratePDFOutput");
  169. case "com.ibm.bi.authoring.run_html":
  170. return !v_bActiveReport && v_bCanRun;
  171. case "com.ibm.bi.viewer.runHtml":
  172. return !v_bActiveReport && v_bCanRun;
  173. case "com.ibm.bi.authoring.run_xml":
  174. case "com.ibm.bi.viewer.run_xml":
  175. return !v_bActiveReport && v_bCanRun && context.glassContext.hasCapability("canGenerateXMLOutput");
  176. case "com.ibm.bi.authoring.run_excel2007":
  177. case "com.ibm.bi.authoring.run_excel2007data":
  178. case "com.ibm.bi.viewer.run_excel2007":
  179. case "com.ibm.bi.viewer.run_excel2007data":
  180. return !v_bActiveReport && v_bCanRun && context.glassContext.hasCapability("canGenerateXLSOutput");
  181. default:
  182. return !v_bActiveReport && v_bCanRun;
  183. }
  184. }
  185. });
  186. return AuthoringMenu;
  187. });