SaveAsReportAction.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2013
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or
  8. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *|
  10. *+------------------------------------------------------------------------+
  11. */
  12. /**
  13. * This Action allows end user to save the report inside a report viewer widget
  14. * to an stand alone Cognos Report Object outside of Cognos workspace
  15. * */
  16. function SaveAsReportAction(){
  17. _progressDisplay = null;
  18. };
  19. SaveAsReportAction.prototype = new CognosViewerAction();
  20. SaveAsReportAction.prototype.onSaveCallback = function(){
  21. if (!this._progressDisplay) {
  22. dojo["require"]("bux.dialogs.InformationDialog"); //@lazyload
  23. this._progressDisplay = new bux.dialogs.Working(BUXMSG.CPN.IDS_CPN_SAVING);
  24. this._progressDisplay.startup();
  25. this._progressDisplay.show();
  26. }
  27. };
  28. SaveAsReportAction.prototype.afterSaveCallback = function(){
  29. if (this._progressDisplay) {
  30. this._progressDisplay.destroy();
  31. this._progressDisplay = null;
  32. }
  33. };
  34. SaveAsReportAction.prototype.execute = function( ){
  35. this.getCognosViewer().executeAction( 'RemoveAllDataFilter', { callback : {method: this.doSaveAs, object: this} } );
  36. };
  37. SaveAsReportAction.prototype.updateMenu = function(jsonSpec){
  38. jsonSpec.visible = this.hasEnvUISpec();
  39. return jsonSpec;
  40. };
  41. SaveAsReportAction.prototype.hasEnvUISpec = function(){
  42. if(this.m_oCV){
  43. var sSpec = this.m_oCV.envParams["ui.spec"];
  44. return (sSpec && sSpec.length >0);
  45. }
  46. return false;
  47. };
  48. SaveAsReportAction.prototype.doSaveAs = function(strippedReportSpec){
  49. dojo["require"]("bux.dialogs.FileDialog");
  50. dojo["require"]("bux.iwidget.canvas.ReportIOHandler");
  51. this.m_cv = this.getCognosViewer();
  52. var sReportSpec = strippedReportSpec;
  53. var sObjectClass = this.m_cv.envParams["ui.objectClass"];
  54. var onCallback = this.onSaveCallback;
  55. var afterCallback = this.afterSaveCallback;
  56. var oSaveAsDlgParams = {
  57. filter:"content-report", //Only returns report objects in the file dialog
  58. title: RV_RES.IDS_JS_SAVE_AS_FDG_TITLE,
  59. sMainActionButtonLabel: RV_RES.IDS_JS_OK,
  60. "class": "bux-fileDialog"
  61. };
  62. var oIOHandler = new bux.iwidget.canvas.ReportIOHandler(sReportSpec, sObjectClass, onCallback, afterCallback, oSaveAsDlgParams);
  63. oIOHandler._doSaveAs();
  64. };