'use strict'; /* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: Dashboard *| (C) Copyright IBM Corp. 2018 *| *| US Government Users Restricted Rights - Use, duplication or disclosure *| restricted by GSA ADP Schedule Contract with IBM Corp. *+------------------------------------------------------------------------+ */ define(['./OpenActionHandler', '../../../app/util/ErrorUtils'], function (BaseClass, Utils) { var ActionHandler = BaseClass.extend({ /** * This class is a last effort to open a dashboard/story that has no tags. We go to the server to get the spec and look at it. * Once all the specs are updated on the server (trough a CM upgrade) we can remove this file. */ _getTargetPerspective: function _getTargetPerspective(id, context) { return this._getSpec(id, context).then(function (spec) { return spec.timeline ? 'story' : 'dashboard'; }); }, _hasValidTags: function _hasValidTags(item) { // if we get here we should have no tags. If we do then it's not a type we understand return !item.tags || !item.tags.length; }, /** * This function is only used to determine if it is a dashboard or story * In case of an error fetching the spec, we will always resolve so that we default to a dashboard. * Error cases will be handled later when the dashboard is about to open. */ _getSpec: function _getSpec(id, context) { return context.glassContext.getSvc('.Content').then(function (contentSvc) { return new Promise(function (resolve, reject) { var itemURL = contentSvc.getBaseObjectsURL() + '/' + id; var options = { dataType: 'json', data: { 'fields': 'specification' }, MRUInfo: {} }; contentSvc.get(itemURL, options).then(function (response) { var specAsString = response.data && response.data.length && response.data[0].specification; if (specAsString) { try { resolve(JSON.parse(specAsString)); } catch (err) { reject(err); } } else { resolve(contentSvc.get(itemURL + '/content')); } }).fail(function (deferred, request) { Utils.showError(context.glassContext, request, id); resolve({}); }); }); }); } }); return ActionHandler; }); //# sourceMappingURL=LegacyOpenActionHandler.js.map