'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: Dashboard (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([], function () { var VIS_PREVIEW_ID = 'visualizationPreview'; var SCHEMATICS_ID = 'com.ibm.vis.schematicsPreview'; var VIS_IDS = [VIS_PREVIEW_ID, SCHEMATICS_ID]; var CustomVizService = function () { function CustomVizService() { _classCallCheck(this, CustomVizService); } /** * The dashboard was just saved, we need to send a speocial notification for custom visualization. * @param {boolean} options.saveAs Boolean to let us know if it was a saveAs or save operations * @param {object} options.resaveDashboardSpecCallback Callback to re-save the dashboard spec. Used if the model gets updated * @param {object} options.spec * @param {object} options.context context to use to show the warning toast message * @param {object} options.stringResources stringResources to fetch the warning meassage */ CustomVizService.prototype.onDashboardSave = function onDashboardSave(options) { var spec = options.spec, stringResources = options.stringResources; var showToast = options.context.glassContext.appController.showToast; if (this._findVisId(spec.layout.items)) { showToast(stringResources.get('customVizSaveWarning'), { type: 'warning' }); } }; CustomVizService.prototype._findVisId = function _findVisId(items) { for (var i = 0; i < items.length; i++) { var item = items[i]; if (item.items) { return this._findVisId(item.items); } else { if (item.features) { var feature = item.features.Models_internal; if (feature && feature.visId && VIS_IDS.indexOf(feature.visId) !== -1) { return true; } } } } return false; }; return CustomVizService; }(); return CustomVizService; }); //# sourceMappingURL=CustomVizService.js.map