CSuppressMenu.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /****************************************************************
  2. ** Licensed Materials - Property of IBM
  3. **
  4. ** BI and PM: qs
  5. **
  6. ** (C) Copyright IBM Corp. 2001, 2015
  7. **
  8. ** US Government Users Restricted Rights - Use, duplication or
  9. ** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10. *****************************************************************/
  11. // Copyright (C) 2008 Cognos ULC, an IBM Company. All Rights Reserved.
  12. // Cognos and the Cognos logo are trademarks of Cognos ULC (formerly Cognos Incorporated) in the United States and/or other countries. IBM and the IBM logo are trademarks of International Business Machines Corporation in the United States, or other countries, or both. Other company, product, or service names may be trademarks or service marks of others.
  13. function CSuppressMenu(oParent, aListSuppressionLabels, aCrosstabSuppressionLabels, aSuppressionValues, sWebRoot, sMenuItemStyle)
  14. {
  15. this.m_parent = oParent;
  16. if(typeof this.m_parent === "object" && typeof this.m_parent.add === "function") {
  17. this.m_parent.add(this);
  18. }
  19. this.m_aListSuppressionLabels = aListSuppressionLabels;
  20. this.m_aCrosstabSuppressionLabels = aCrosstabSuppressionLabels;
  21. this.m_aSuppressionValues = aSuppressionValues;
  22. this.m_sWebRoot = sWebRoot;
  23. this.m_style = sMenuItemStyle;
  24. this.m_id = "suppressMenu";
  25. this.m_action = null;
  26. this.m_oSuppress = new CSuppress();
  27. };
  28. CSuppressMenu.prototype = new CMenuItem();
  29. CSuppressMenu.prototype.draw = function ()
  30. {
  31. this.m_oSuppress = new CSuppress();
  32. if (! this.m_oSuppress.isNullSuppressionAllowed())
  33. {
  34. return "";
  35. }
  36. var html = '<div>';
  37. var bIsCrosstab = this.m_oSuppress.moMQManager.hasPivottedColumns();
  38. var aSuppressionLabels =
  39. (bIsCrosstab)
  40. ? this.m_aCrosstabSuppressionLabels
  41. : this.m_aListSuppressionLabels;
  42. html += this.getTableTag();
  43. var sSuppressionType = this.m_oSuppress.getType();
  44. var iTypeIndex = 0;
  45. for (iTypeIndex = 0; iTypeIndex < aSuppressionLabels.length; iTypeIndex++)
  46. {
  47. var aSuppressionTypes = Array ();
  48. var sOptionSelectedColumn = "";
  49. var bSuppressTypeEnabled = false;
  50. if (bIsCrosstab)
  51. {
  52. aSuppressionTypes = Array ("SUPPRESS_OFF", "SUPPRESS_ROWS_AND_COLUMNS", "SUPPRESS_ROWS", "SUPPRESS_COLUMNS");
  53. switch (sSuppressionType)
  54. {
  55. case "SUPPRESS_OFF":
  56. bSuppressTypeEnabled = (iTypeIndex === 0);
  57. break;
  58. case "SUPPRESS_ROWS_AND_COLUMNS":
  59. bSuppressTypeEnabled = (iTypeIndex === 1);
  60. break;
  61. case "SUPPRESS_ROWS":
  62. bSuppressTypeEnabled = (iTypeIndex === 2);
  63. break;
  64. case "SUPPRESS_COLUMNS":
  65. bSuppressTypeEnabled = (iTypeIndex === 3);
  66. break;
  67. default:
  68. break;
  69. }
  70. if (! this.m_oSuppress.isMultiEdgeNullSuppressionAllowed())
  71. {
  72. if (iTypeIndex === 1)
  73. {
  74. continue;
  75. }
  76. else if (sSuppressionType === "SUPPRESS_ROWS" && iTypeIndex === 3)
  77. {
  78. continue;
  79. }
  80. else if (sSuppressionType === "SUPPRESS_COLUMNS" && iTypeIndex === 2)
  81. {
  82. continue;
  83. }
  84. }
  85. }
  86. else
  87. {
  88. aSuppressionTypes = Array ("SUPPRESS_OFF", "SUPPRESS_ROWS");
  89. switch (sSuppressionType)
  90. {
  91. case "SUPPRESS_OFF":
  92. bSuppressTypeEnabled = (iTypeIndex === 0);
  93. break;
  94. case "SUPPRESS_ROWS":
  95. bSuppressTypeEnabled = (iTypeIndex === 1);
  96. break;
  97. default:
  98. break;
  99. }
  100. }
  101. var sOnMouseDown = '';
  102. if (bSuppressTypeEnabled)
  103. {
  104. sOptionSelectedColumn += '<img border="0" src="' + this.m_sWebRoot + '/qs/images/toolbar/icon_circle.gif">'
  105. }
  106. else
  107. {
  108. sOnMouseDown = 'goApplicationManager.getFeatureManager().launchFeature(\'Suppress\', new Array(\'SELECT_TYPE\', \'' + aSuppressionTypes[iTypeIndex] + '\'))';
  109. }
  110. html += '<tr>';
  111. html += '<td style="padding:3px; vertical-align: middle;" onmousedown="' + sOnMouseDown + '">' + sOptionSelectedColumn + '</td>';
  112. html += '<td style="padding:2px; vertical-align: middle;" nowrap="true" onmousedown="' + sOnMouseDown + '">' + aSuppressionLabels[iTypeIndex] + '</td>';
  113. html += '</tr>';
  114. }
  115. if (this.m_oSuppress.isAccessToNullSuppressionOptionsAllowed())
  116. {
  117. html += '<tr><td colspan="2"><hr size="1" /></td></tr>';
  118. var sOnMouseDown = 'goApplicationManager.getFeatureManager().launchFeature(\'Suppress\')';
  119. html += '<tr>';
  120. html += '<td></td>';
  121. html += '<td style="padding:2px; vertical-align: middle;" nowrap="true" onmousedown="' + sOnMouseDown + '">' + this.m_aSuppressionValues[0] + '</td>';
  122. html += '</td></tr>'
  123. }
  124. html += '</table>';
  125. html += '</div>';
  126. return html;
  127. };
  128. CSuppressMenu.prototype.getTableTag = function ()
  129. {
  130. var html = '<table border="0"';
  131. if (this.isEnabled())
  132. {
  133. if (this.isInMenu())
  134. {
  135. html += ' hideFocus="true" ';
  136. }
  137. html += ' tabIndex="0" accessKey="1"';
  138. }
  139. html += ' width="100%" ';
  140. html += 'class="';
  141. if(typeof this.getStyle() == "object")
  142. {
  143. if(this.isEnabled())
  144. {
  145. html += this.getStyle().getNormalState();
  146. }
  147. else
  148. {
  149. html += this.getStyle().getDisabledState();
  150. }
  151. }
  152. html += '" ';
  153. html += 'id="';
  154. html += this.getId();
  155. html += '" cellpadding="0" cellspacing="0">';
  156. return html;
  157. };
  158. CSuppressMenu.prototype.onkeydown = function (evt)
  159. {
  160. if (typeof goApplicationManager === "object")
  161. {
  162. goApplicationManager.getFeatureManager().launchFeature('Suppress');
  163. }
  164. };