123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- '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) {
- var MissingOriginalCustomGroupItemId = function (_UpgradeBase) {
- _inherits(MissingOriginalCustomGroupItemId, _UpgradeBase);
- function MissingOriginalCustomGroupItemId() {
- _classCallCheck(this, MissingOriginalCustomGroupItemId);
- var _this = _possibleConstructorReturn(this, _UpgradeBase.call(this));
- _this.VERSION = 1800;
- return _this;
- }
- /**
- * Perform upgrade to add "originalCustomGroupItemId" to the dataItem when it represents a custom group
- * @param {object} spec - spec to perform upgrade on
- * @return {Promise} Promise to be resolved when upgrade performed
- */
- MissingOriginalCustomGroupItemId.prototype.up = function up(spec) {
- if (!spec) {
- return Promise.resolve(spec);
- }
- if (!WidgetUpgradeUtils.specHasWidgets(spec)) {
- return Promise.resolve(spec);
- }
- return this._upgradeWidgets(spec);
- };
- MissingOriginalCustomGroupItemId.prototype.down = function down(spec) {
- // Downgrades are not available in CA
- return Promise.resolve(spec);
- };
- MissingOriginalCustomGroupItemId.prototype._upgradeWidgets = function _upgradeWidgets(spec) {
- var _this2 = this;
- try {
- _.each(spec.widgets, function (model) {
- _this2._upgradeWidgetProperties(model, spec);
- });
- return Promise.resolve(spec);
- } catch (error) {
- throw error;
- }
- };
- MissingOriginalCustomGroupItemId.prototype._getContentSpec = function _getContentSpec(model, spec) {
- var layout = WidgetUpgradeUtils.findLayout([spec.layout], model.id);
- var content = null;
- if (layout) {
- if (!layout.content) {
- layout.content = {};
- }
- content = layout.content;
- }
- return content;
- };
- MissingOriginalCustomGroupItemId.prototype._getContentProps = function _getContentProps(model, spec) {
- var content = this._getContentSpec(model, spec);
- var props = void 0;
- if (content) {
- if (!content.properties) {
- content.properties = {};
- }
- props = content.properties;
- }
- return props;
- };
- MissingOriginalCustomGroupItemId.prototype._upgradeVisGridProps = function _upgradeVisGridProps(model, props) {
- if (model && model.data && model.data.dataViews && model.data.dataViews.length > 0) {
- var gridSettings = model.data.dataViews[0].grid;
- if (gridSettings) {
- props['datagrid.viewOption'] = gridSettings['viewOption'];
- }
- delete model.data.dataViews[0].grid;
- }
- };
- MissingOriginalCustomGroupItemId.prototype._upgradeInfoGraphicProps = function _upgradeInfoGraphicProps(model, props) {
- if (model && model.slotmapping && model.slotmapping.slots && model.slotmapping.slots.length > 0) {
- var dataItemSettings = model.slotmapping.slots[0].dataItemSettings;
- if (dataItemSettings && dataItemSettings.length > 0) {
- var graphic = dataItemSettings[0].graphic;
- if (graphic) {
- props['value.graphic.content'] = graphic.content;
- props['value.graphic.currentScaleOption'] = graphic.currentScaleOption;
- props['value.graphic.fillColor'] = graphic.fillColor;
- props['value.graphic.borderColor'] = graphic.borderColor;
- }
- }
- delete model.slotmapping.slots[0].dataItemSettings;
- }
- };
- MissingOriginalCustomGroupItemId.prototype._upgradeWidgetProperties = function _upgradeWidgetProperties(model, spec) {
- var props = this._getContentProps(model, spec);
- if (props) {
- // Upgrade grid view options to a prop
- this._upgradeVisGridProps(model, props);
- // Upgrade infographic shape props
- this._upgradeInfoGraphicProps(model, props);
- }
- };
- return MissingOriginalCustomGroupItemId;
- }(UpgradeBase);
- return new MissingOriginalCustomGroupItemId();
- });
- //# sourceMappingURL=NewGenSpec.js.map
|