123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- /*
- IBM Confidential
- OCO Source Materials
- IBM Cognos Products: rs
- (C) Copyright IBM Corp. 2015, 2020
- 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.
- */
- define(['bi/glass/app/plugins/MenuActionInterface'], function(MenuActionInterface) {
- 'use strict';
- var AuthoringMenu = MenuActionInterface.extend({
-
- onSelectItem: function(context) {
- var v_sMenuItem = context.target.itemId;
- console.log("rsAppRunMenu.onSelectItem selected item " + v_sMenuItem);
- var v_Application = context.glassContext.currentAppView.currentContentView.getAuthoringApplication();
- if (!v_Application)
- {
- return;
- }
- switch( v_sMenuItem )
- {
- case "com.ibm.bi.authoring.run_show_run_options":
- window.setTimeout( v_Application.ShowRunOptions.bind(v_Application), 0 );
- return;
- case "com.ibm.bi.viewer.run":
- case "com.ibm.bi.viewer.runHtml":
- case "com.ibm.bi.viewer.run_html_ar":
- case "com.ibm.bi.viewer.runPdf":
- var v_oParameters = { Prompt : v_sMenuItem == "com.ibm.bi.viewer.run" };
-
- switch( v_sMenuItem )
- {
- case "com.ibm.bi.viewer.runHtml":
- case "com.ibm.bi.viewer.run_html_ar":
- v_oParameters.OutputFormat = "HTML";
- break;
- case "com.ibm.bi.viewer.runPdf":
- v_oParameters.OutputFormat = "PDF";
- break;
- }
-
- v_Application.SharedState.Call(null, v_sMenuItem.substring(v_sMenuItem.lastIndexOf(".") + 1), v_oParameters);
- break;
- case "com.ibm.bi.authoring.run_html":
- case "com.ibm.bi.authoring.run_pdf":
- case "com.ibm.bi.authoring.run_excel2007":
- case "com.ibm.bi.authoring.run_excel2007data":
- case "com.ibm.bi.authoring.run_csv":
- case "com.ibm.bi.authoring.run_html_ar":
- case "com.ibm.bi.authoring.run_html_ar_download":
- case "com.ibm.bi.authoring.run_xml":
- case "com.ibm.bi.viewer.run_excel2007":
- case "com.ibm.bi.viewer.run_excel2007data":
- case "com.ibm.bi.viewer.run_csv":
- case "com.ibm.bi.viewer.run_html_ar_download":
- case "com.ibm.bi.viewer.run_xml":
- var v_oParameters = { OutputFormat: null };
- var v_bViewerAction = v_sMenuItem.indexOf(".viewer.") > 0;
- if (v_bViewerAction)
- {
- v_oParameters.Prompt = false;
- }
- var v_bRunInNewViewer = v_bViewerAction || v_Application.SharedState.Get("runInAdvancedViewer");
- switch(v_sMenuItem)
- {
- case "com.ibm.bi.authoring.run_html_ar":
- v_oParameters.OutputFormat = "HTML";
- v_oParameters.Download = "false";
- v_oParameters.isApplication = v_Application.SharedState.Get("isActiveReport");
- break;
- case "com.ibm.bi.authoring.run_html_ar_download":
- case "com.ibm.bi.viewer.run_html_ar_download":
- v_oParameters.OutputFormat = "HTML";
- v_oParameters.Download = "true";
- v_oParameters.isApplication = v_Application.SharedState.Get("isActiveReport");
- break;
-
- case "com.ibm.bi.authoring.run_html":
- v_oParameters.OutputFormat = "HTML";
- if (v_bRunInNewViewer)
- {
- v_oParameters.isViewer = true; // Use viewer instead of editor
- }
- break;
- case "com.ibm.bi.authoring.run_pdf":
- v_oParameters.OutputFormat = "PDF";
- if (v_bRunInNewViewer)
- {
- v_oParameters.isViewer = true; // Use viewer instead of editor
- }
- break;
-
- case "com.ibm.bi.authoring.run_excel2007":
- case "com.ibm.bi.viewer.run_excel2007":
- v_oParameters.OutputFormat = "spreadsheetML";
- if (v_bRunInNewViewer)
- {
- v_oParameters.Download = "true";
- }
- break;
-
- case "com.ibm.bi.authoring.run_excel2007data":
- case "com.ibm.bi.viewer.run_excel2007data":
- v_oParameters.OutputFormat = "xlsxData";
- if (v_bRunInNewViewer)
- {
- v_oParameters.Download = "true";
- }
- break;
-
- case "com.ibm.bi.authoring.run_csv":
- case "com.ibm.bi.viewer.run_csv":
- v_oParameters.OutputFormat = "CSV";
- if (v_bRunInNewViewer)
- {
- v_oParameters.Download = "true";
- }
- break;
-
- case "com.ibm.bi.authoring.run_xml":
- case "com.ibm.bi.viewer.run_xml":
- v_oParameters.OutputFormat = "XML";
- if (v_bRunInNewViewer)
- {
- v_oParameters.Download = "true";
- }
- break;
-
- default:
- var v_sIdxValue = v_sMenuItem.indexOf("_");
- var v_sValue = v_sMenuItem.slice(v_sIdxValue+1);
- console.warn("using implicit output format: %s", v_sValue);
- }
- if (!v_bViewerAction)
- {
- v_oParameters.isFromRS = true;
- }
- v_Application.SharedState.Call(null, "runInNewWindow", v_oParameters);
- break;
-
- default:
- console.warn("Unhandled item: " + v_sMenuItem);
- return;
- }
-
- v_Application.GlassMenu_onSelectItem(v_sMenuItem);
- },
-
- isItemVisible: function(context){
- console.log("rsAppRunMenu.isItemVisible");
- var v_sMenuItem = context.target.itemId;
- console.log("v_sMenuItem: " + v_sMenuItem);
-
- var v_Application = context.glassContext.currentAppView.currentContentView.getAuthoringApplication();
- if (!v_Application)
- {
- return false;
- }
- var v_bCanRun = v_Application.SharedState.Get("canRun");
- var v_bActiveReport = v_Application.SharedState.Get("isActiveReport");
- var v_bIsViewer = v_Application.SharedState.Get("isViewer");
-
- switch(v_sMenuItem)
- {
- case "com.ibm.bi.viewer.run":
- case "com.ibm.bi.authoring.refresh":
- return false;
- case "com.ibm.bi.authoring.run_html_ar":
- return v_bActiveReport && v_bCanRun;
-
- case "com.ibm.bi.authoring.run_html_ar_download":
- case "com.ibm.bi.viewer.run_html_ar_download":
- return v_bActiveReport && v_bCanRun;
-
- case "com.ibm.bi.authoring.run_show_run_options":
- case "com.ibm.bi.viewer.run_html_ar":
- return v_bCanRun && !v_bIsViewer;
-
- case "com.ibm.bi.authoring.run_csv":
- case "com.ibm.bi.viewer.run_csv":
- return !v_bActiveReport && v_bCanRun && context.glassContext.hasCapability("canGenerateCSVOutput");
-
- case "com.ibm.bi.viewer.runPdf":
- return !v_bActiveReport && v_bCanRun && context.glassContext.hasCapability("canGeneratePDFOutput");
- case "com.ibm.bi.authoring.run_pdf":
- return !v_bActiveReport && v_bCanRun && context.glassContext.hasCapability("canGeneratePDFOutput");
-
- case "com.ibm.bi.authoring.run_html":
- return !v_bActiveReport && v_bCanRun;
-
- case "com.ibm.bi.viewer.runHtml":
- return !v_bActiveReport && v_bCanRun;
-
- case "com.ibm.bi.authoring.run_xml":
- case "com.ibm.bi.viewer.run_xml":
- return !v_bActiveReport && v_bCanRun && context.glassContext.hasCapability("canGenerateXMLOutput");
-
-
- case "com.ibm.bi.authoring.run_excel2007":
- case "com.ibm.bi.authoring.run_excel2007data":
- case "com.ibm.bi.viewer.run_excel2007":
- case "com.ibm.bi.viewer.run_excel2007data":
- return !v_bActiveReport && v_bCanRun && context.glassContext.hasCapability("canGenerateXLSOutput");
-
- default:
- return !v_bActiveReport && v_bCanRun;
- }
- }
-
- });
- return AuthoringMenu;
- });
|