| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 | '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, 2020 * 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', '../../../../lib/@waca/dashboard-common/dist/api/ContentActionsProviderAPI', '../../../../app/ui/dialogs/ConfirmationDialog'], function (APIFactory, ContentActionsProviderAPI, ConfirmationDialog) {	var ResetDashboardAction = function () {		function ResetDashboardAction(_ref) {			var features = _ref.features;			_classCallCheck(this, ResetDashboardAction);			this._dashboard = features.API;			this._dashboardState = features.DashboardState;			this._contentActions = features.ContentActions;			this._icons = features.Icons;		}		ResetDashboardAction.prototype.initialize = function initialize() {			this._api = APIFactory.createAPI(this, [ContentActionsProviderAPI]);			this._contentActions.registerProvider('ResetDashboard', this.getAPI());		};		ResetDashboardAction.prototype.getAPI = function getAPI() {			return this._api;		};		ResetDashboardAction.prototype._isItemVisible = function _isItemVisible() {			var contentView = this._dashboard.getCurrentContentView();			var isThereASavedInst = !!contentView.getSavedInstance();			var isDirty = this._dashboardState.getUiState().dirty;			return isThereASavedInst && isDirty;		};		ResetDashboardAction.prototype._resetDashboard = function _resetDashboard() {			var contentView = this._dashboard.getCurrentContentView();			var savedInstance = contentView.getSavedInstance();			contentView.clearTransientState();			var extOptions = {				isAuthoringMode: false,				clearDirtyFlag: true			};			return contentView.reloadFromJSONSpec(JSON.parse(savedInstance), extOptions);		};		ResetDashboardAction.prototype._onReset = function _onReset() {			var _this = this;			var contentView = this._dashboard.getCurrentContentView();			var stringService = contentView.stringService;			var resetMessage = stringService.get('dashboardResetToast');			var confirmDlg = new ConfirmationDialog('warning', stringService.get('dashboardResetTitle'), stringService.get('dashboardResetMessage'));			confirmDlg.confirm(function () {				return _this._resetDashboard().then(function () {					// After resetting dashboard, the ResetDashboardAction will be destroyed,					// so the action has already been destroyed at this point, and this._dashboard					// is undefined, so we need to get the new dashboard api from the content view					return contentView.getDashboardApi().showToast(resetMessage, {						type: 'success',						preventDuplicates: true					});				});			});		};		ResetDashboardAction.prototype.getContentActionList = function getContentActionList(idList) {			var _this2 = this;			var contentView = this._dashboard.getCurrentContentView();			var stringService = contentView.stringService;			var uiState = this._dashboardState.getUiState();			if (uiState.authoring === false && this._isItemVisible() && uiState.dirty && idList.length === 0) {				return [{					name: 'ResetDashboard',					type: 'Button',					label: stringService.get('dashboardResetTitle'),					icon: this._icons.getIcon('restore').id,					actions: {						apply: function apply() {							return _this2._onReset();						}					}				}];			} else {				return [];			}		};		return ResetDashboardAction;	}();	return ResetDashboardAction;});//# sourceMappingURL=ResetDashboardAction.js.map
 |