123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- 'use strict';
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Dashboard
- *| (C) Copyright IBM Corp. 2015, 2020
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define(['../../lib/@waca/baglass/js/baglass/app/ContentView', 'jquery', 'underscore', 'bspopover',
- //We require jquery-ui here to make sure it is loaded so that we can over its slider widget (for range filter and property sheet)
- // There is a conflict between the slider in jquery ui and bootstrap. No on using the jquery version, so we should be fine just by overriding it.
- 'jquery-ui'], function (BaseClass, $, _) {
- var DashboardView = BaseClass.extend({
- init: function init(options) {
- DashboardView.inherited('init', this, arguments);
- this.options = options || {};
- },
- getCDNUrl: function getCDNUrl() {
- //get the dashboard-cdn path and remove any cache busters
- var dashboardCdn = require.toUrl('dashboard-cdn');
- var cdn = '';
- if (dashboardCdn.indexOf('empty:') === -1) {
- cdn = dashboardCdn;
- }
- return cdn + 'dashboard-core/';
- },
- /**
- * Initialize and render the view
- *
- */
- render: function render() {
- // To be implemented by the concrete class
- return Promise.resolve();
- },
- /**
- * Destroy the view and its content
- */
- remove: function remove() {
- this.boardModel && this.boardModel.off();
- DashboardView.inherited('remove', this, arguments);
- },
- /**
- * Get the view title. This function should be implemented by the concrete classes
- */
- getTitle: function getTitle() {
- // To be implementd by the concrete classes
- },
- /**
- * Called by the glass when the view is deactivated (e.g. switching to a different view)
- */
- deactivate: function deactivate() {
- // Close all popover
- $('.popover').popover('hide');
- // Detach the current view node.
- // This should not be necessary, but some views do global jquery searches and we want to avoid access content from differen views
- this.$children = this.$el.children();
- this.$children.detach();
- // Update the state so that we can recreate the dashboard when it is activated.
- var content = this.getContent();
- if (content) {
- _.extend(this.options, content);
- }
- return Promise.resolve();
- },
- /**
- * Called by the glass just before the view is being shown
- */
- activate: function activate() {
- if (this.$children) {
- this.$el.append(this.$children);
- // Force resize in case the window was resize while this view is deactivated.
- setTimeout(function () {
- try {
- $(window).resize();
- } catch (e) {
- // eslint-disable-line no-empty
- }
- }, 100);
- this.$children = null;
- }
- return Promise.resolve();
- },
- clearTransientState: function clearTransientState() {
- this.transientState = {};
- },
- /**
- * Helper function to store some state associated with this view
- */
- setTransientState: function setTransientState(name, value) {
- if (!this.transientState) {
- this.transientState = {};
- }
- this.transientState[name] = value;
- },
- /**
- * Helper function to retrieve some state that was previously set using the setTransientState function
- */
- getTransientState: function getTransientState(name) {
- var value = null;
- if (this.transientState) {
- value = this.transientState[name];
- }
- return value;
- }
- });
- return DashboardView;
- });
- //# sourceMappingURL=BaseView.js.map
|