cvAppButtonActions.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Licensed Materials - Property of IBM
  2. // IBM Cognos Products: rs
  3. // (C) Copyright IBM Corp. 2015, 2021
  4. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  5. define(['bi/glass/app/plugins/ButtonActionInterface'], function(ButtonActionInterface) {
  6. 'use strict';
  7. var ClassicViewerButtonActionInterface = ButtonActionInterface.extend({
  8. onPress: function(context) {
  9. console.log("cvAppButtonActions pressed");
  10. console.log('context.target.plugin.itemSpec.id: %s', context.target.plugin.itemSpec.id);
  11. var v_sId = context.target.plugin.itemSpec.id;
  12. switch(v_sId)
  13. {
  14. case "com.ibm.bi.classicviewer.editBtn":
  15. this.runAuthoring(context);
  16. break;
  17. case "com.ibm.bi.classicviewer.previousReportBtn":
  18. var v_oCognosViewer = context.glassContext.currentAppView.currentContentView.getCognosViewer();
  19. v_oCognosViewer.rvMainWnd.executePreviousReport(-1);
  20. break;
  21. default:
  22. console.log("Unhandled label: " + v_sId);
  23. }
  24. },
  25. runAuthoring: function(context) {
  26. var v_sStoreId = context.glassContext.currentAppView.currentContentView.getReportStoreId();
  27. var v_oOpenAppViewContent = {
  28. action: 'edit',
  29. cmProperties: { id: v_sStoreId }
  30. };
  31. var v_aParameters = context.glassContext.currentAppView.currentContentView.getParameterValues();
  32. if (v_aParameters && v_aParameters.length > 0) {
  33. v_oOpenAppViewContent.promptParameters = JSON.stringify( v_aParameters );
  34. }
  35. // When drilling, target is opened with closeWindowOnLastView=true
  36. // As a result, if the perspective is closed, the glass actually closes the window.
  37. // Therefore, open the authoring perspective for edit first.
  38. context.glassContext.openAppView("authoring", {content: v_oOpenAppViewContent } )
  39. .then(function() {
  40. context.glassContext.closeAppView("classicviewer", v_sStoreId);
  41. });
  42. }
  43. });
  44. return ClassicViewerButtonActionInterface;
  45. });