123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- 'use strict';
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- /**
- * 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([
- // '../renderer/topbottom/TopBottomLabel',
- '../../../../visualizations/renderer/topbottom/TopBottomLabel', '../../../../lib/@waca/dashboard-common/dist/core/APIFactory', '../api/SlotActionsProviderAPI', '../../../../apiHelpers/SlotAPIHelper', '../../../../widgets/livewidget/nls/StringResources'], function (TopBottomLabel, APIFactory, SlotActionsProviderAPI, SlotAPIHelper, stringResources) {
- 'use strict';
- var TOP_OP = 'top';
- var TOP_TYPE = 'topcount';
- var ACTION_ID = 'topKeyDriversAction';
- var ACTION_ICON = 'dashboard-topbottom';
- var ACTION_ITEMS = {
- TOP_5: 'top5',
- TOP_10: 'top10',
- ALL: 'all'
- };
- return function (_TopBottomLabel) {
- _inherits(TopKeyDriversAction, _TopBottomLabel);
- function TopKeyDriversAction(_ref) {
- var content = _ref.content,
- dashboardAPI = _ref.dashboardAPI,
- features = _ref.features;
- _classCallCheck(this, TopKeyDriversAction);
- var _this = _possibleConstructorReturn(this, _TopBottomLabel.call(this));
- _this.content = content;
- _this.dashboard = dashboardAPI;
- _this.icons = features && features['Dashboard.Icons'];
- features.SlotActions.registerProvider('topKeyDriversAction', _this.getAPI());
- return _this;
- }
- TopKeyDriversAction.prototype.getAPI = function getAPI() {
- if (!this._api) {
- this._api = APIFactory.createAPI(this, [SlotActionsProviderAPI]);
- }
- return this._api;
- };
- TopKeyDriversAction.prototype._isActionSupported = function _isActionSupported(dataSlot, mapIndex) {
- if (!this._isFocusModeEnabled()) {
- return false;
- }
- var actions = dataSlot.getDefinition().getProperty('actions');
- if (!actions) {
- return false;
- }
- if (actions.indexOf('TopKeyDriversAction') === -1) {
- return false;
- }
- return !this._isMultiMeasureDataSlot(dataSlot, mapIndex);
- };
- TopKeyDriversAction.prototype._isFocusModeEnabled = function _isFocusModeEnabled() {
- return !this.dashboard.getGlassCoreSvc('.FeatureChecker').checkValue('dashboard', 'FocusMode', 'disabled');
- };
- TopKeyDriversAction.prototype.getViewState = function getViewState(dataSlotId, itemIndex) {
- var dataSlot = this._getVisualization().getSlots().getSlot(dataSlotId);
- if (dataSlot) {
- return {
- height: 140,
- width: 140,
- getCurrentSelectedItem: this._getCurrentSelectedItem.bind(this, dataSlot, itemIndex),
- possibleItems: this._getPossibleItems(dataSlot, itemIndex),
- eventHandler: this
- };
- }
- return null;
- };
- /**
- * Initialize the set of TopKeyDriversAction settings the selected state
- */
- TopKeyDriversAction.prototype.getSlotActionList = function getSlotActionList(dataSlotId, itemIndex) {
- this.dataSlot = this._getVisualization().getSlots().getSlot(dataSlotId);
- this.itemIndex = itemIndex;
- if (this.dataSlot && this._isActionSupported(this.dataSlot, itemIndex)) {
- var actionIcon = this.icons.getIcon(ACTION_ICON);
- return [{
- name: 'show',
- id: 'TopKeyDriversAction',
- text: stringResources.get('toolbarActionTopKeyDrivers'),
- label: stringResources.get('toolbarActionTopKeyDrivers'),
- icon: actionIcon.id,
- type: 'NextView',
- group: ACTION_ID,
- view: {
- module: 'dashboard-analytics/lib/@waca/dashboard-common/dist/ui/dialogs/CommonSelectItemsDialog',
- state: this.getViewState(dataSlotId, itemIndex)
- },
- actions: {
- apply: this.handleSelection.bind(this)
- }
- }];
- }
- return [];
- };
- TopKeyDriversAction.prototype._getCurrentSelectedItem = function _getCurrentSelectedItem(dataSlot, itemIndex) {
- var dataItem = dataSlot.getDataItemList()[itemIndex];
- var state = dataItem.getTopBottom();
- if (state && state.type === TOP_TYPE) {
- return state.value === 5 ? ACTION_ITEMS.TOP_5 : ACTION_ITEMS.TOP_10;
- }
- return ACTION_ITEMS.ALL;
- };
- /**
- * Get the array of possible items to be displayed on the dialog
- * @return array of items to display on dialog
- */
- TopKeyDriversAction.prototype._getPossibleItems = function _getPossibleItems() {
- return [{
- id: ACTION_ITEMS.ALL,
- localizedString: stringResources.get('allKeyDriversLabel')
- }, {
- id: ACTION_ITEMS.TOP_5,
- localizedString: this.getTopBottomLabel({
- limit: {
- op: TOP_OP,
- val: 5
- }
- })
- }, {
- id: ACTION_ITEMS.TOP_10,
- localizedString: this.getTopBottomLabel({
- limit: {
- op: TOP_OP,
- val: 10
- }
- })
- }];
- };
- TopKeyDriversAction.prototype._isMultiMeasureDataSlot = function _isMultiMeasureDataSlot(dataSlot, itemIndex) {
- if (itemIndex === undefined && dataSlot) {
- return SlotAPIHelper.isMultiMeasuresSeriesSlot(dataSlot) || SlotAPIHelper.isMultiMeasuresValueSlot(dataSlot);
- }
- return SlotAPIHelper.isMultiMeasuresSeriesOrValue(dataSlot, itemIndex);
- };
- TopKeyDriversAction.prototype._getVisualization = function _getVisualization() {
- if (!this.visualization) {
- this.visualization = this.content.getFeature('Visualization');
- }
- return this.visualization;
- };
- /**
- * Handler to the item selection.
- * @param {string} selectedItem - identifier of the item selected
- * @see {@link ACTION_ITEMS}
- */
- TopKeyDriversAction.prototype.handleSelection = function handleSelection(selectedItem) {
- var dataItem = this.dataSlot.getDataItemList()[this.itemIndex];
- switch (selectedItem) {
- case ACTION_ITEMS.ALL:
- dataItem.setTopBottom();
- break;
- case ACTION_ITEMS.TOP_5:
- case ACTION_ITEMS.TOP_10:
- dataItem.setTopBottom({
- type: TOP_TYPE,
- value: selectedItem === ACTION_ITEMS.TOP_5 ? 5 : 10
- });
- break;
- default:
- break;
- }
- };
- return TopKeyDriversAction;
- }(TopBottomLabel);
- });
- //# sourceMappingURL=TopKeyDriversAction.js.map
|