123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- 'use strict';
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * 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(['../../../../lib/@waca/dashboard-common/dist/core/APIFactory', '../../../../widgets/livewidget/nls/StringResources', '../../dataPointActions/api/DataPointActionsProviderAPI', '../../../../lib/@waca/dashboard-common/dist/api/ContentActionsProviderAPI'], function (APIFactory, StringResources, DataPointActionsProviderAPI, ContentActionsProviderAPI) {
- var ContextualGridAction = function () {
- function ContextualGridAction(_ref) {
- var dashboardAPI = _ref.dashboardAPI,
- content = _ref.content,
- features = _ref.features;
- _classCallCheck(this, ContextualGridAction);
- this.dashboard = dashboardAPI || features && features.API;
- this.icons = features.Icons || features['Dashboard.Icons'];
- if (content) {
- // dataPointAction will pass in the content api
- this.content = content;
- if (features) {
- features.DataPointActions.registerProvider('contextualGridAction', this.getAPI());
- }
- } else {
- features && features.ContentActions.registerProvider('contextualGridAction', this.getAPI());
- }
- }
- /**
- * dataPoint actions
- * @param {*} selections
- * @param {*} options
- */
- ContextualGridAction.prototype.getDataPointActionList = function getDataPointActionList(selections, options) {
- var content = this.content;
- var bShowAllOptions = !options.noFilters;
- if (bShowAllOptions && this.dashboard.getMode() === this.dashboard.MODES.EDIT) {
- return this._getContributionList(content, true);
- }
- return [];
- };
- ContextualGridAction.prototype._supportAction = function _supportAction(idList, content) {
- var enableShowDataOfViz = this._isInteractionEnabled('showData') && this.dashboard.getMode() === this.dashboard.MODES.EDIT;
- if (idList && idList.length > 1 || !enableShowDataOfViz) {
- //contexualGrid does not support multi-widget Selections
- return false;
- } else {
- var state = content.getFeature('state');
- if (state.getError()) {
- //don't show data when widget is in error state
- return false;
- }
- }
- return true;
- };
- /**
- * widgetAction interface
- * @param {*} idList
- */
- ContextualGridAction.prototype.getContentActionList = function getContentActionList(idList) {
- var contentId = idList[0];
- var content = this.dashboard.getCanvas().getContent(contentId);
- if (this._supportAction(idList, content)) {
- return this._getContributionList(content, false);
- } else {
- return [];
- }
- };
- ContextualGridAction.prototype._isSupportedFromVisDefinition = function _isSupportedFromVisDefinition(content) {
- var visualization = content.getFeature('Visualization');
- if (!visualization) {
- //todo: the dashboard-feature loader should support to wait content-Visualization feature is ready.
- return false;
- }
- var definition = visualization.getDefinition();
- var supportsDataBehindTheViz = false;
- if (definition.getProperty('isMultilayersWidget') || definition.getProperty('noDataQuery') || this.dashboard.getApplicationName() === 'dashboardTemplate') {
- supportsDataBehindTheViz = false;
- } else {
- supportsDataBehindTheViz = true;
- }
- return supportsDataBehindTheViz;
- };
- /**
- * pop up data trays if the data tray is not open. If it is open, keep it open
- * @return Promise
- */
- ContextualGridAction.prototype._popUpDataTray = function _popUpDataTray() {
- var canvasExtensions = this.dashboard.getDashboardCoreSvc('.CanvasExtensions');
- if (canvasExtensions) {
- var splitter = canvasExtensions.splitPaneView.getSplitter();
- var handleIndex = this.dashboard.getApplicationName() === 'story' ? 1 : 0;
- return splitter.toggleItem(handleIndex, true /* always show */, { sender: 'showDataBehindVisAction' });
- } else {
- return Promise.resolve();
- }
- };
- ContextualGridAction.prototype._getContributionList = function _getContributionList(content, shouldCloseOnActionApplied) {
- if (this._isSupportedFromVisDefinition(content)) {
- var tooltipId = 'showDataBehindVizLabel';
- var commonQuerySubject = this.icons.getIcon('common-querySubject');
- return [{
- name: 'contextualGridAction',
- label: StringResources.get(tooltipId),
- icon: commonQuerySubject.id,
- type: 'Button',
- group: 'ShowDataBehindVizAction',
- closeOnActionApplied: shouldCloseOnActionApplied,
- actions: {
- apply: this._popUpDataTray.bind(this)
- }
- }];
- }
- return [];
- };
- /**
- * Check whether a particular interaction is enabled.
- * Perspective drives this config.
- *
- * @param {string} name - interaction name
- *
- * @return {boolean} TRUE if interaction is enabled and FALSE if not
- */
- ContextualGridAction.prototype._isInteractionEnabled = function _isInteractionEnabled(name) {
- var config = this.dashboard.getAppConfig('interactions') || {};
- if (config.hasOwnProperty(name) && [false, 'false'].indexOf(config[name]) !== -1) {
- return false;
- }
- return true;
- };
- ContextualGridAction.prototype.getAPI = function getAPI() {
- //todo: we need to implement WidgetAciontsProvider as well once it is ready
- return APIFactory.createAPI(this, [DataPointActionsProviderAPI, ContentActionsProviderAPI]);
- };
- return ContextualGridAction;
- }();
- return ContextualGridAction;
- });
- //# sourceMappingURL=ContextualGridAction.js.map
|