'use strict'; /* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: Dashboard *| (C) Copyright IBM Corp. 2018 *| *| US Government Users Restricted Rights - Use, duplication or disclosure *| restricted by GSA ADP Schedule Contract with IBM Corp. *+------------------------------------------------------------------------+ */ define(['./BaseTask', '../../../DynamicFileLoader'], function (BaseTask, DynamicFileLoader) { 'use strict'; var VisViewTask = BaseTask.extend({ process: function process(renderContext) { var widget = this.ownerWidget; if (widget) { // set default layout properties widget.setLayoutProperties({ pannable: false, mobilePannable: false, noRotate: true, maximizable: true }); } if (this._isStepComplete(renderContext, 'visView')) { return Promise.resolve(renderContext); } // If loading the view, run the whole process over. this.getRenderState().firstRenderComplete = false; var viewPath = this._rendererToView(); return this._loadVisView(viewPath).then(function (visView) { if (this._completeStep(renderContext, 'visView', visView)) { // If we've updated the view, need to update it // in the model (ie: remove the old one). this._placeViewIntoDOM(visView, renderContext.widgetSize); } else { // The visview is discarded. We remove it to // make sure we cleanup all event handlers. visView.remove(); } return renderContext; }.bind(this)); }, /** * Mostly exists for unit testing! */ _loadVisView: function _loadVisView(viewPath) { return DynamicFileLoader.load([viewPath]).then(function (modules) { var VisView = modules[0]; var visView = new VisView({ visModel: this.visAPI, logger: this.logger, ownerWidget: this.ownerWidget, dashboardApi: this.dashboardApi, content: this.content }); return visView; }.bind(this)); }, /** * Temporary function to accommodate vis definitions that refer to * RaveRenderer, GridRenderer. Replace 'Renderer" with 'View' * eg....transfrom the name to "RaveView" and "GridView". */ _rendererToView: function _rendererToView() { var theView = this.visAPI.getRenderer(); if (theView.substr(theView.length - 8) === 'Renderer') { return theView.substr(0, theView.length - 8) + 'View'; } return theView; }, /** * When a view is first created, set its preferred size based on its definition * and place the view into the DOM. * @param visView The view that was just created. * @param bounds The view's bounds */ _placeViewIntoDOM: function _placeViewIntoDOM(visView, bounds) { var widget = this.ownerWidget; widget.placeAt(visView); widget.applyCommonProperties(); if (!widget.dataSlotsView) { visView.resize(bounds); } } }); return VisViewTask; }); //# sourceMappingURL=VisViewTask.js.map