'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. 2019 *| *| 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) { /** * Upgrade VIDA property. Remove title.visible from the old spec and introduce 'itemAxis.title.visible' and 'valueAxis.title.visible' instead. **/ var VIDAPaddingPropUpgrade = function (_UpgradeBase) { _inherits(VIDAPaddingPropUpgrade, _UpgradeBase); function VIDAPaddingPropUpgrade() { _classCallCheck(this, VIDAPaddingPropUpgrade); var _this = _possibleConstructorReturn(this, _UpgradeBase.call(this)); _this.VERSION = 1300; return _this; } /** * Perform upgrade * * @param {object} spec - spec to perform upgrade on * * @return {Promise} Promise to be resolved when upgrade performed */ VIDAPaddingPropUpgrade.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 (model && _this2._isLive(model)) { if (!model.properties) { model.properties = []; } _this2._noPaddingPropertyUpgrade(model); } }); return Promise.resolve(spec); }; // Downgrades are not available in CA VIDAPaddingPropUpgrade.prototype.down = function down(spec) { return Promise.resolve(spec); }; VIDAPaddingPropUpgrade.prototype._isLive = function _isLive(model) { return model && model.type && model.type === 'live'; }; VIDAPaddingPropUpgrade.prototype._noPaddingPropertyUpgrade = function _noPaddingPropertyUpgrade(model) { var deprecatedPropId = ['bar.noPadding']; var deprecatedProp = WidgetUpgradeUtils.findProperty(deprecatedPropId[0], model.properties); var newPropId = ['bar.padding']; var newProp = WidgetUpgradeUtils.findProperty(newPropId[0], model.properties); // clean up the spec poperties by filter out the deprecated props model.properties = _.filter(model.properties, function (prop) { return deprecatedPropId[0] !== prop.id; }); // add new property if not already present if (!newProp) { model.properties.push({ id: newPropId[0], value: deprecatedProp ? !deprecatedProp.value : true }); } }; return VIDAPaddingPropUpgrade; }(UpgradeBase); return new VIDAPaddingPropUpgrade(); }); //# sourceMappingURL=VIDAPaddingPropUpgrade.js.map