123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- '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, 2021
- *|
- *| 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 Legend property - Change the Font Size. Currently we have four values for Font size. We will now have only 3 values. This script will check for the current user defined value (if any), and map it to the right value.
- **/
- var VIDALegendFontSizeMappingUpgrade = function (_UpgradeBase) {
- _inherits(VIDALegendFontSizeMappingUpgrade, _UpgradeBase);
- function VIDALegendFontSizeMappingUpgrade() {
- _classCallCheck(this, VIDALegendFontSizeMappingUpgrade);
- var _this = _possibleConstructorReturn(this, _UpgradeBase.call(this));
- _this.VERSION = 1400;
- return _this;
- }
- /**
- * Perform upgrade
- *
- * @param {object} spec - spec to perform upgrade on
- *
- * @return {Promise} Promise to be resolved when upgrade performed
- */
- VIDALegendFontSizeMappingUpgrade.prototype.up = function up(spec) {
- var _this2 = this;
- if (!WidgetUpgradeUtils.specHasWidgets(spec)) {
- return Promise.resolve(spec);
- }
- _.each(spec.widgets, function (model) {
- if (model && WidgetUpgradeUtils.isLiveWidgetModel(model) && model.properties) {
- _this2._legendFontSizeMappingUpgrade(model);
- }
- });
- return Promise.resolve(spec);
- };
- // Downgrades are not available in CA
- VIDALegendFontSizeMappingUpgrade.prototype.down = function down(spec) {
- return Promise.resolve(spec);
- };
- /**
- * If font size property is defined, then check the defined size and map it to the right value. Here is the mapping:
- * 12px -> 11px
- * 14px -> 14px
- * 16px, 24px -> 16px
- * If no font size is defined (default is 11px), then don't do anything
- * @param {object} model
- */
- VIDALegendFontSizeMappingUpgrade.prototype._legendFontSizeMappingUpgrade = function _legendFontSizeMappingUpgrade(model) {
- var fontSizePropName = 'widget.legend.font';
- var fontSizePropOfWidget = WidgetUpgradeUtils.findProperty(fontSizePropName, model.properties);
- if (fontSizePropOfWidget && fontSizePropOfWidget.value !== null) {
- var fontSize = fontSizePropOfWidget.value.trim();
- var fontMap = {
- '12px': '11px',
- '24px': '16px'
- };
- var mappedValue = fontMap[fontSize];
- //except for 14px and 16px, remap the Legend font size
- if (mappedValue) {
- //filter out the font size prop from the model properties so that the new prop can be pushed
- model.properties = _.filter(model.properties, function (prop) {
- return fontSizePropName !== prop.id;
- });
- model.properties.push({
- id: fontSizePropName,
- value: mappedValue
- });
- }
- }
- };
- return VIDALegendFontSizeMappingUpgrade;
- }(UpgradeBase);
- return new VIDALegendFontSizeMappingUpgrade();
- });
- //# sourceMappingURL=VIDALegendFontSizeMappingUpgrade.js.map
|