SelectionFilterSwitchAction.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2014
  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 SelectionFilterSwitchAction()
  13. {
  14. this.m_sAction = "SelectionFilterSwitch";
  15. }
  16. SelectionFilterSwitchAction.prototype = new CognosViewerAction();
  17. SelectionFilterSwitchAction.prototype.updateMenu = function(jsonSpec)
  18. {
  19. //jsonSpec.visible = true;
  20. if (this.getCognosViewer().getViewerWidget().isSelectionFilterEnabled())
  21. {
  22. jsonSpec.disabled = false;
  23. jsonSpec.checked = true;
  24. jsonSpec.iconClass = 'selectionFilterEnabled';
  25. jsonSpec.label = RV_RES.IDS_JS_SELECTION_FILTER_SWITCH_DISABLE;
  26. }
  27. else
  28. {
  29. jsonSpec.disabled = false;
  30. jsonSpec.checked = false;
  31. jsonSpec.iconClass = 'selectionFilter';
  32. jsonSpec.label = RV_RES.IDS_JS_SELECTION_FILTER_SWITCH;
  33. }
  34. return jsonSpec;
  35. };
  36. SelectionFilterSwitchAction.prototype.execute = function()
  37. {
  38. var oCV = this.getCognosViewer();
  39. var oVWidget = oCV.getViewerWidget();
  40. var oldSwitch = oVWidget.isSelectionFilterEnabled();
  41. // Turning off, so we need to clear the filters before we actually flip the switch in our code
  42. // since our code checks the boolean before sending the event
  43. if (oldSwitch) {
  44. if (oVWidget.selectionFilterSent()) {
  45. oVWidget.clearSelectionFilter();
  46. }
  47. }
  48. oVWidget.toggleSelectionFilterSwitch();
  49. oVWidget.updateToolbar();
  50. oVWidget.onContextMenu({}); //Populates context menu payload with correct state.
  51. // Turning on
  52. if (!oldSwitch) {
  53. if (oVWidget.somethingSelected()) {
  54. oVWidget.broadcastSelectionFilter();
  55. }
  56. }
  57. oVWidget.updateDrillThroughLinks();
  58. oVWidget.fireEvent("com.ibm.bux.widget.modified", null, {'modified':true});
  59. };