VisController.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2013, 2020
  5. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. *
  7. * VisController
  8. * The VisController object is a collection of methods that use the visModel and modify it.
  9. *
  10. */
  11. define(['underscore', './VisActionHelper', './VisRenderSequence', '../../lib/@waca/core-client/js/core-client/ui/core/Events'], function (_, VisActionHelper, VisRenderSequence, Events) {
  12. 'use strict';
  13. var VisController = null; // class declaration
  14. VisController = Events.extend({
  15. init: function init(attributes) {
  16. VisController.inherited('init', this, [attributes]);
  17. this._visModel = attributes.visModel; //TODO: Deprecate this!
  18. this._visAPI = attributes.visAPI;
  19. this._ownerWidget = attributes.ownerWidget;
  20. this._visRenderSequence = new VisRenderSequence(attributes);
  21. this._visSelectionController = attributes.selectionController;
  22. this._visActionHelper = new VisActionHelper(_.extend(attributes, {
  23. selectionController: this._visSelectionController,
  24. content: this._ownerWidget.content
  25. }));
  26. attributes.cbGetActionsForFilter = this._visActionHelper.getActionsForLocalFilter.bind(this._visActionHelper);
  27. attributes.getNewFilterActionForContextColumn = this._visActionHelper.getNewFilterActionForContextColumn;
  28. //CONTROLLER SUB-INTERFACE METHODS
  29. /**
  30. * SELECTIONCONTROLLER API METHODS.....(selection controller methods exposed via visController directly).
  31. */
  32. var sc = this._visSelectionController;
  33. //Main selection API's
  34. this.select = sc.select.bind(sc);
  35. this.getItemKeys = sc.getItemKeys.bind(sc);
  36. //Single column selection API's
  37. this.isItemSelected = sc.isItemSelected.bind(sc);
  38. this.isValueSelected = sc.isValueSelected.bind(sc);
  39. this.getSelectedValues = sc.getSelectedValues.bind(sc);
  40. this.getSelectedTuples = sc.getSelectedTuples.bind(sc);
  41. },
  42. getAPI: function getAPI() {
  43. // Expose the controller as a deprecated feature for nwo
  44. return this;
  45. },
  46. destroy: function destroy() {
  47. if (this._visSelectionController) {
  48. this._visSelectionController.remove();
  49. this._visSelectionController = null;
  50. }
  51. if (this._visActionHelper) {
  52. this._visActionHelper.remove();
  53. delete this._visActionHelper;
  54. }
  55. if (this._visRenderSequence) {
  56. this._visRenderSequence.remove();
  57. delete this._visRenderSequence;
  58. }
  59. },
  60. /**
  61. * @returns an object that handles 'actions' such as those that appear on the contextual toolbar
  62. * like filter and sort changes
  63. */
  64. getActionHelper: function getActionHelper() {
  65. return this._visActionHelper;
  66. },
  67. /**
  68. * @returns The render sequence object which controls the flow of rendering for all visualization types.
  69. */
  70. getRenderSequence: function getRenderSequence() {
  71. return this._visRenderSequence;
  72. }
  73. });
  74. return VisController;
  75. });
  76. //# sourceMappingURL=VisController.js.map