'use strict'; /** * Licensed Materials - Property of IBM * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014, 2018 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /** * * View to swap the Live Widget Visualization * Options * { * showTitles: boolean, // Whether to show the titles for the available/recommended visualizations * visualizations: { * recommended: [], // Array of visualizations to place in recommended section * other: [] // Array of visualizations to put in other section * }, * currentVis: String, // The id of the currently selected visualization * widget: Live Widget, // The widget that is creating the vischanger view * inFocusView: bool // If the widget is in focus view, will render titles and not limit selections * } * **/ define(['../../../lib/@waca/core-client/js/core-client/ui/core/View', '../../../lib/@waca/dashboard-common/dist/utils/Flyout', '../nls/StringResources', 'jquery', 'underscore', '../../../lib/@waca/core-client/js/core-client/utils/JQueryExt'], function (BaseView, Flyout, resources, $, _) { var View = BaseView.extend({ init: function init(options) { View.inherited('init', this, arguments); this.visualizations = {}; _.extend(this, options || {}); }, /** * Flyout is closing and has already destoyed itself, cleanup our member variables and view */ onPopupDone: function onPopupDone() { this.flyout = null; this._cleanup(); }, /** * Clean up the props of this object (flyout and vis changer flyout view) */ _cleanup: function _cleanup() { if (this.flyout) { this.flyout.destroy(); } this.flyout = null; if (this.visChangerFlyoutView) { this.visChangerFlyoutView.removeDialog(); } this.visChangerFlyoutView = null; }, /** * When we remove the object we want to cleanup its elements. * @returns {object} this */ remove: function remove() { this._cleanup(); View.inherited('remove', this, arguments); return this; }, setFocus: function setFocus() { this.$('.vis').first().focus(); }, /** * Render the flyout and all the flyout view. * @param {object} currentVis - id, widget */ render: function render(options) { _.extend(this, options || {}); this.setElement($('
')); // Initialize the elements, open the flyout and render. this._initializeElements(); this.flyout.open('.allVisualizations'); if (!this.visChangerFlyoutView) { this.visChangerFlyoutView = this.dashboard.getFeature('changeVisTypeAction'); } var dialogOptions = { currentVis: this.currentVis, content: this.dashboard.getCanvas().getContent(this.widgetId), el: this.el, selectVisCB: this._selectVis.bind(this), // CB for when vis has changed dashboard: this.dashboard }; return this.visChangerFlyoutView.openDialog(options, dialogOptions); }, /** * Hide flyout and clean up. */ _hideFlyout: function _hideFlyout() { this.$el.trigger($.Event('keyup', { keyCode: 27 })); // Trigger escape keypress to hide the toolbar this._cleanup(); }, /** * Callback method for when the vis changer flyout view changes a vis. */ _selectVis: function _selectVis() { this._hideFlyout(); }, getRenderedHtml: function getRenderedHtml() { var $content = $('
'); $content.append(this.$el); return $content; }, _getFlyout: function _getFlyout(options) { return new Flyout(options); }, /** * Initialize the elements needed to render the vis changer */ _initializeElements: function _initializeElements() { this._cleanup(); var options = { viewInstance: this, selector: '.allVisualizations', content: this.el, popoverClass: 'visChangerPopover', placement: 'top', maxHt: 400, trigger: 'manual', modal: true }; this.flyout = this._getFlyout(options); } }); return View; }); //# sourceMappingURL=VisChangerView.js.map