SwapRowsAndColumnsAction.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2001, 2012
  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. function SwapRowsAndColumnsAction()
  13. {
  14. this.m_sAction = "SwapRowsAndColumns";
  15. }
  16. SwapRowsAndColumnsAction.prototype = new ModifyReportAction();
  17. SwapRowsAndColumnsAction.prototype.getUndoHint = function()
  18. {
  19. return RV_RES.IDS_JS_SWAP_ROWS_AND_COLUMNS;
  20. };
  21. /**
  22. * List of display types that do not support SwapRowsAndColumns
  23. */
  24. SwapRowsAndColumnsAction.M_oDisplayTypeIsUnsupported = {
  25. winLossChart : true,
  26. progressiveChart : true,
  27. list : true
  28. };
  29. SwapRowsAndColumnsAction.prototype.canSwap = function()
  30. {
  31. if( this.reportHasOneObjectOnly())
  32. {
  33. return this.isCurrentObject_singlePart_SupportedChartOrCrosstab();
  34. }
  35. else
  36. {
  37. return this.isSelectedObject_SupportedChartOrCrosstab();
  38. }
  39. };
  40. SwapRowsAndColumnsAction.prototype.reportHasOneObjectOnly = function()
  41. {
  42. var oRAPReportInfo = this.m_oCV.getRAPReportInfo();
  43. if (oRAPReportInfo) {
  44. return ( oRAPReportInfo.getContainerCount() == 1 );
  45. }
  46. return false;
  47. };
  48. SwapRowsAndColumnsAction.prototype.isSelectedObject_SupportedChartOrCrosstab = function()
  49. {
  50. var reportInfo = this.getSelectedReportInfo();
  51. return (reportInfo && !SwapRowsAndColumnsAction.M_oDisplayTypeIsUnsupported[reportInfo.displayTypeId]);
  52. };
  53. SwapRowsAndColumnsAction.prototype.isCurrentObject_singlePart_SupportedChartOrCrosstab = function()
  54. {
  55. var oRAPReportInfo = this.m_oCV.getRAPReportInfo();
  56. if (oRAPReportInfo) {
  57. if (oRAPReportInfo.getContainerCount() === 1) {
  58. var displayTypeId = oRAPReportInfo.getContainerFromPos(0).displayTypeId;
  59. if (displayTypeId && !SwapRowsAndColumnsAction.M_oDisplayTypeIsUnsupported[ displayTypeId ] ) {
  60. return true;
  61. }
  62. }
  63. }
  64. return false;
  65. };
  66. SwapRowsAndColumnsAction.prototype.keepRAPCache = function()
  67. {
  68. return false;
  69. };
  70. SwapRowsAndColumnsAction.prototype.updateMenu = function(jsonSpec)
  71. {
  72. jsonSpec.visible = this.ifContainsInteractiveDataContainer();
  73. if (! jsonSpec.visible)
  74. {
  75. return jsonSpec;
  76. }
  77. jsonSpec.disabled = !this.canSwap();
  78. jsonSpec.iconClass = jsonSpec.disabled ? 'disabledSwap' : 'swap';
  79. return jsonSpec;
  80. };