PropertiesPaneDOM.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /**
  4. * Licensed Materials - Property of IBM
  5. * IBM Business Analytics (C) Copyright IBM Corp. 2019, 2020
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. /**
  9. * @class SlideoutDOM
  10. * @hideconstructor
  11. * @classdesc API class that is used to manage Slideout functionality
  12. * (including the corrsponding view) across API calls
  13. */
  14. define(['../../../lib/@waca/dashboard-common/dist/core/APIFactory', 'underscore', './PropertiesPaneDOMAPI'], function (APIFactory, _, PropertiesPaneDOMAPI) {
  15. var PropertiesPaneDOM = function () {
  16. function PropertiesPaneDOM(_ref) {
  17. var features = _ref.features;
  18. _classCallCheck(this, PropertiesPaneDOM);
  19. this._dashboard = features.API;
  20. this._properties = features.PropertiesPane;
  21. this._slideout = features.InAppSlideoutDOM;
  22. this._api = null;
  23. }
  24. PropertiesPaneDOM.prototype.getAPI = function getAPI() {
  25. return this._api;
  26. };
  27. PropertiesPaneDOM.prototype.getProviderId = function getProviderId() {
  28. return this._properties.getProviderId();
  29. };
  30. PropertiesPaneDOM.prototype.initialize = function initialize() {
  31. this._api = APIFactory.createAPI(this, [PropertiesPaneDOMAPI]);
  32. this._slideout.registerView(this._properties.getProviderId(), this._api);
  33. };
  34. PropertiesPaneDOM.prototype.getPropertiesView = function getPropertiesView() {
  35. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  36. this._renderNode = options.parentNode;
  37. var viewRenderedPromise = void 0;
  38. var propertiesManager = this._dashboard.getFeature('propertiesManager');
  39. if (options.isChild) {
  40. viewRenderedPromise = propertiesManager.updateChildPropertiesView(options);
  41. } else {
  42. var selectedContentIds = this._getSelectedContentIds();
  43. var contentId = void 0;
  44. if (selectedContentIds && selectedContentIds.length > 0) {
  45. contentId = selectedContentIds[0];
  46. }
  47. viewRenderedPromise = propertiesManager.getPropertiesView(contentId);
  48. }
  49. return viewRenderedPromise;
  50. };
  51. PropertiesPaneDOM.prototype._getSelectedContentIds = function _getSelectedContentIds() {
  52. return this._dashboard.getCanvas().getSelectedContentList().map(function (content) {
  53. return content.getId();
  54. });
  55. };
  56. PropertiesPaneDOM.prototype.getRenderNode = function getRenderNode() {
  57. return this._renderNode;
  58. };
  59. PropertiesPaneDOM.prototype.render = function render(theOptions) {
  60. var propertiesManager = this._dashboard.getFeature('propertiesManager');
  61. var options = propertiesManager.getMostRecentChildOptions(theOptions);
  62. return this.getPropertiesView(options).then(function (view) {
  63. if (options && options.childPanelId) {
  64. view.$el.get(0).dataset.childPanelId = options.childPanelId;
  65. }
  66. return view.$el.get(0);
  67. });
  68. };
  69. PropertiesPaneDOM.prototype.close = function close() {
  70. var propertiesManager = this._dashboard.getFeature('propertiesManager');
  71. if (propertiesManager) {
  72. propertiesManager.closeAllChild();
  73. }
  74. this._renderNode = null;
  75. };
  76. PropertiesPaneDOM.prototype.destroy = function destroy() {
  77. this.close();
  78. this._api = null;
  79. this._dashboard = null;
  80. this._properties = null;
  81. this._slideout = null;
  82. };
  83. return PropertiesPaneDOM;
  84. }();
  85. return PropertiesPaneDOM;
  86. });
  87. //# sourceMappingURL=PropertiesPaneDOM.js.map