12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- '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', '../../../lib/@waca/dashboard-common/dist/api/ContentActionsProviderAPI'], function (APIFactory, stringResources, ContentActionsProviderAPI) {
- var DeveloperWidgetRefreshAction = function () {
- function DeveloperWidgetRefreshAction(_ref) {
- var features = _ref.features;
- _classCallCheck(this, DeveloperWidgetRefreshAction);
- this.dashboard = features.API;
- this.icons = features.Icons;
- features.ContentActions.registerProvider('developerWidgetRefreshAction', this.getAPI());
- }
- DeveloperWidgetRefreshAction.prototype.getAPI = function getAPI() {
- return APIFactory.createAPI(this, [ContentActionsProviderAPI]);
- };
- DeveloperWidgetRefreshAction.prototype.getContentActionList = function getContentActionList(idList) {
- var contentId = idList[0];
- var content = this.dashboard.getCanvas().getContent(contentId);
- var refreshIcon = this.icons.getIcon('refreshIcon');
- if (this._supportAction(idList, content)) {
- return [{
- name: 'developerWidgetRefreshAction',
- label: stringResources.get('toolbarActionRefreshDeveloperWidget'),
- icon: refreshIcon.id,
- type: 'Button',
- actions: {
- apply: this.refreshDeveloperWidget.bind(this, content)
- }
- }];
- }
- return [];
- };
- DeveloperWidgetRefreshAction.prototype._supportAction = function _supportAction(idList, content) {
- if (idList && idList.length != 1) {
- // does not support multi-widget selections (for now?)
- return false;
- }
- if (this.dashboard.getMode() !== this.dashboard.MODES.EDIT) {
- return false;
- }
- if (!this._isDeveloperWidget(content)) {
- return false;
- }
- if (!this._hasPermissions()) {
- return false;
- }
- return true;
- };
- DeveloperWidgetRefreshAction.prototype._isDeveloperWidget = function _isDeveloperWidget(content) {
- var visualization = content.getFeature('Visualization');
- if (!visualization) {
- return false;
- }
- var definition = visualization.getDefinition();
- var isErrorState = !!definition.getState().getError();
- var id = definition.getId();
- if (isErrorState) {
- var error = content.getFeature('state').getError();
- var errorParams = error && error.getParams && error.getParams();
- id = errorParams && errorParams.errorInfo && errorParams.errorInfo.id;
- }
- return id === 'visualizationPreview';
- };
- DeveloperWidgetRefreshAction.prototype._hasPermissions = function _hasPermissions() {
- var userCapabilities = this.dashboard.getGlassCoreSvc('.UserProfile').capabilities;
- return userCapabilities.indexOf('canDevelopVisualizations') !== -1;
- };
- DeveloperWidgetRefreshAction.prototype.refreshDeveloperWidget = function refreshDeveloperWidget(content) {
- content.getFeature('Visualization').getDefinition().refresh();
- this.dashboard.getFeature('UndoRedo').clearStack();
- };
- return DeveloperWidgetRefreshAction;
- }();
- return DeveloperWidgetRefreshAction;
- });
- //# sourceMappingURL=DeveloperWidgetRefreshAction.js.map
|