WidgetsPanelView.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: BI Cloud
  5. * (C) Copyright IBM Corp. 2017, 2020
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. define(['../../lib/@waca/core-client/js/core-client/ui/core/View', '../../lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl', '../../lib/@waca/core-client/js/core-client/utils/Deferred', 'jquery', 'react-dom', '../../lib/@waca/dashboard-common/dist/ui/CenterLoadingSpinner'], function (View, PropertyUIControl, Deferred, $, ReactDOM, CenterLoadingSpinner) {
  9. var WidgetsPanelView = View.extend({
  10. init: function init(options) {
  11. WidgetsPanelView.inherited('init', this, arguments);
  12. this.glassContext = options.glassContext;
  13. this.dashboardApi = options.dashboardApi;
  14. this.services = options.services;
  15. this.hooks = {
  16. getEntries: options.getEntries || Promise.resolve({})
  17. };
  18. this.whenIsReadyDfd = new Deferred();
  19. this._initialize();
  20. },
  21. whenIsReady: function whenIsReady() {
  22. return this.whenIsReadyDfd.promise;
  23. },
  24. setFocus: function setFocus() {
  25. this.$el.find('.itemOption:first').focus();
  26. },
  27. remove: function remove() {
  28. if (this._dropZone) {
  29. this._dropZone.remove();
  30. }
  31. WidgetsPanelView.inherited('remove', this, arguments);
  32. },
  33. render: function render() {
  34. var _this = this;
  35. if (!this._$loadingIndicatorBlocker) {
  36. this._$loadingIndicatorBlocker = $('<div></div>');
  37. }
  38. this.$el.empty().addClass(this.className + ' widgetsPanelView');
  39. this.$el.append(this._$loadingIndicatorBlocker);
  40. ReactDOM.render(CenterLoadingSpinner({ size: 'normal', variant: 'circle' }), this._$loadingIndicatorBlocker[0]);
  41. return this.hooks.getEntries().then(this._createPropertyControl.bind(this)).then(this.whenIsReady.bind(this)).then(function () {
  42. _this._dropZone = _this._dndManager.addDropTarget(_this.$el[0], { accepts: _this._accepts.bind(_this) });
  43. });
  44. },
  45. _initialize: function _initialize() {
  46. this._dndManager = this.dashboardApi.getFeature('DashboardDnd.internal');
  47. this.whenIsReadyDfd.resolve();
  48. },
  49. _createPropertyControl: function _createPropertyControl(spec) {
  50. spec.el = this.$el;
  51. spec.primaryUIControl = false;
  52. spec.glassContext = this.glassContext;
  53. var uiControl = new PropertyUIControl(spec);
  54. return Promise.try(function () {
  55. var _this2 = this;
  56. return uiControl.render().then(function () {
  57. //this._ellipsifyLabels();
  58. ReactDOM.unmountComponentAtNode(_this2._$loadingIndicatorBlocker[0]);
  59. _this2._$loadingIndicatorBlocker.remove();
  60. _this2._$loadingIndicatorBlocker = null;
  61. });
  62. }.bind(this));
  63. },
  64. _accepts: function _accepts() {
  65. return true;
  66. }
  67. });
  68. return WidgetsPanelView;
  69. });
  70. //# sourceMappingURL=WidgetsPanelView.js.map