123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- '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 Dashboard
- *| (C) Copyright IBM Corp. 2020
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define(['underscore', '../../../lib/@waca/upgrades/UpgradeBase', './utils/WidgetUpgradeUtils'], function (_, UpgradeBase, WidgetUpgradeUtils) {
- var MULTI_MEASURE_SERIES = '_multiMeasuresSeries';
- var DatasetScopeMultiMeasure = function (_UpgradeBase) {
- _inherits(DatasetScopeMultiMeasure, _UpgradeBase);
- function DatasetScopeMultiMeasure() {
- _classCallCheck(this, DatasetScopeMultiMeasure);
- var _this = _possibleConstructorReturn(this, _UpgradeBase.call(this));
- _this.VERSION = 1802;
- return _this;
- }
- /**
- * Perform upgrade
- *
- * @param {object} spec - spec to perform upgrade on
- *
- * @return {Promise} Promise to be resolved when upgrade performed
- */
- DatasetScopeMultiMeasure.prototype.up = function up(spec) {
- var _this2 = this;
- if (!spec) {
- return Promise.resolve(spec);
- }
- if (!WidgetUpgradeUtils.specHasWidgets(spec)) {
- return Promise.resolve(spec);
- }
- _.each(spec.widgets, function (model) {
- if (WidgetUpgradeUtils.isLiveWidgetModel(model)) {
- _this2._removeSlotPointer(model);
- _this2._updateSlotmappingDataItem(model);
- _this2._updateDataViewDataItem(model);
- }
- });
- return Promise.resolve(spec);
- };
- // Downgrades are not available in CA
- DatasetScopeMultiMeasure.prototype.down = function down(spec) {
- return Promise.resolve(spec);
- };
- // New implementation can compute this anyway
- DatasetScopeMultiMeasure.prototype._removeSlotPointer = function _removeSlotPointer(model) {
- if (model.slotmapping && model.slotmapping.multiMeasureSlot) {
- delete model.slotmapping.multiMeasureSlot;
- }
- };
- // New implementation can have 1 multi-measure per dataset
- DatasetScopeMultiMeasure.prototype._updateSlotmappingDataItem = function _updateSlotmappingDataItem(model) {
- model.slotmapping && model.slotmapping.slots && model.slotmapping.slots.forEach(function (slot) {
- slot.dataItems && slot.dataItems.forEach(function (dataItem, index) {
- if (dataItem === MULTI_MEASURE_SERIES) {
- // all multimeasures prior to this upgrader belonged to the 'data' dataset
- slot.dataItems[index] = MULTI_MEASURE_SERIES + '_' + 'data';
- }
- });
- });
- };
- // New implementation can have 1 multi-measure per dataset
- DatasetScopeMultiMeasure.prototype._updateDataViewDataItem = function _updateDataViewDataItem(model) {
- if (model.data && !_.isEmpty(model.data.dataViews)) {
- // no multi-layer vis prior to this upgrader had multi-measure support
- model.data.dataViews.forEach(function (dataview) {
- dataview && dataview.dataItems && dataview.dataItems.forEach(function (dataItem) {
- if (dataItem.id === MULTI_MEASURE_SERIES) {
- // all multimeasures prior to this upgrader belonged to the 'data' dataset
- dataItem.id = MULTI_MEASURE_SERIES + '_data';
- }
- });
- });
- }
- };
- return DatasetScopeMultiMeasure;
- }(UpgradeBase);
- return new DatasetScopeMultiMeasure();
- });
- //# sourceMappingURL=DatasetScopeMultiMeasure.js.map
|