123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- 'use strict';
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2019
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['jquery', 'underscore', '../VisView', '../../../util/DashboardFormatter', '../kpi/KpiView', '../infographic/InfographicView', '../../../DynamicFileLoader', '../../../lib/@waca/dashboard-common/dist/utils/MemUtil'], function ($, _, VisView, Formatter, KpiView, InfographicView, DynamicFileLoader, MemUtil) {
- 'use strict';
- var SummaryProxyView = VisView.extend({
- className: '',
- init: function init(options) {
- var _this = this;
- SummaryProxyView.inherited('init', this, arguments);
- this._content = options.content;
- this._colorsService = this.dashboardApi.getFeature('Colors');
- this._visualizationAPI = this._content.getFeature('Visualization');
- var proxiedOptions = _.extend({}, options, { proxiedView: true });
- this._kpiView = new KpiView(proxiedOptions);
- this._infographicView = new InfographicView(proxiedOptions);
- this.updateActiveView();
- ['resize', 'animate', '_renderIconView', 'removeIconView', 'getDescription', 'onVisible', 'renderIconView'].forEach(function (property) {
- _this._createProxyFunction(property);
- });
- },
- /**
- * expose this to summaryPropertyCallbacks
- */
- getSubView: function getSubView(name) {
- if (name === 'kpiView') {
- return this._kpiView;
- } else if (name === 'infographicView') {
- return this._infographicView;
- }
- },
- _createProxyFunction: function _createProxyFunction(functionName) {
- this[functionName] = function () {
- return this._activeView[functionName].apply(this._activeView, arguments);
- };
- },
- reveal: function reveal() {
- if (this._activeView && this._activeView.summaryReveal) {
- this._activeView.summaryReveal();
- }
- },
- remove: function remove() {
- var finalRemove = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
- // todo livewidget_cleanup -- it is weird that we pass a finalRemove
- // It seems to be used to delayed the destruction of a vipr widget
- // but we could handle this in a better way
- this._kpiView.remove(finalRemove);
- this._infographicView.remove(finalRemove);
- if (finalRemove) {
- MemUtil.destroy(this);
- }
- },
- /**
- * Loads and creates the control. Returns a promise which is resolved when the control
- * is created and ready to render
- */
- whenVisControlReady: function whenVisControlReady() {
- var _this2 = this;
- //Initialize proxied view controls
- var controlPromises = [this._kpiView.whenVisControlReady(), this._infographicView.whenVisControlReady()];
- return Promise.all(controlPromises).then(function () {
- if (_this2.visControl) {
- return _this2.visControl;
- } else {
- return DynamicFileLoader.load(['dashboard-analytics/visualizations/renderer/summary/control/SummaryControl']).then(function (modules) {
- var VisControl = modules[0];
- _this2.visControl = new VisControl({
- domNode: _this2.$el[0]
- });
- return _this2.visControl;
- });
- }
- });
- },
- placeAt: function placeAt(element) {
- this._containingElement = element;
- if (this._activeView) {
- this._activeView.placeAt(element);
- }
- },
- updateActiveView: function updateActiveView() {
- if (this._activeView) {
- this._activeView.$el.detach();
- }
- var isInfographic = this.isInfographic(true);
- if (isInfographic) {
- this._activeView = this._infographicView;
- } else {
- this._activeView = this._kpiView;
- }
- this.$el = this._activeView.$el;
- if (this._containingElement) {
- this._activeView.placeAt(this._containingElement);
- }
- },
- getActiveView: function getActiveView() {
- return this._activeView;
- },
- render: function render(renderInfo) {
- this.updateActiveView();
- return this._activeView.render(renderInfo);
- },
- isInfographic: function isInfographic() {
- var updateValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
- if (this._isInfographic === undefined || updateValue) {
- var graphicData = this.content.getPropertyValue('value.graphic.content');
- this._isInfographic = !!graphicData;
- }
- return this._isInfographic;
- },
- getDecoratorAPI: function getDecoratorAPI() {
- if (this._activeView.getDecoratorAPI) {
- return this._activeView.getDecoratorAPI();
- } else {
- return null;
- }
- }
- });
- return SummaryProxyView;
- });
- //# sourceMappingURL=SummaryProxyView.js.map
|