VIDA_ClippingUpgrade.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. 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; }
  4. 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; }
  5. /*
  6. *+------------------------------------------------------------------------+
  7. *| Licensed Materials - Property of IBM
  8. *| IBM Cognos Products: BI Dashboard
  9. *| (C) Copyright IBM Corp. 2018
  10. *|
  11. *| US Government Users Restricted Rights - Use, duplication or disclosure
  12. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  13. *+------------------------------------------------------------------------+
  14. */
  15. define(['underscore', '../../../lib/@waca/upgrades/UpgradeBase', './utils/WidgetUpgradeUtils'], function (_, UpgradeBase, WidgetUpgradeUtils) {
  16. /**
  17. * Turn off all Vida level truncation for existing content so upgraded content
  18. * renders similarily after upgrade.
  19. **/
  20. var VIDA_ClippingUpgrade = function (_UpgradeBase) {
  21. _inherits(VIDA_ClippingUpgrade, _UpgradeBase);
  22. function VIDA_ClippingUpgrade() {
  23. _classCallCheck(this, VIDA_ClippingUpgrade);
  24. var _this = _possibleConstructorReturn(this, _UpgradeBase.call(this));
  25. _this.VERSION = 1019;
  26. return _this;
  27. }
  28. /**
  29. * Perform upgrade
  30. *
  31. * @param {object} spec - spec to perform upgrade on
  32. *
  33. * @return {Promise} Promise to be resolved when upgrade performed
  34. */
  35. VIDA_ClippingUpgrade.prototype.up = function up(spec) {
  36. var _this2 = this;
  37. if (!spec) {
  38. return Promise.resolve(spec);
  39. }
  40. if (!WidgetUpgradeUtils.specHasWidgets(spec)) {
  41. return Promise.resolve(spec);
  42. }
  43. /*
  44. * Cycle through all widgets and, if they are live widgets, upgrade the clipping.
  45. */
  46. _.each(spec.widgets, function (model) {
  47. if (model && WidgetUpgradeUtils.isLiveWidgetModel(model)) {
  48. if (!model.properties) {
  49. model.properties = [];
  50. }
  51. _this2._vidaClippingUpgrade(model);
  52. }
  53. });
  54. return Promise.resolve(spec);
  55. };
  56. VIDA_ClippingUpgrade.prototype._isLive = function _isLive(model) {
  57. return model && model.type && model.type === 'live';
  58. };
  59. // Downgrades are not available in CA
  60. VIDA_ClippingUpgrade.prototype.down = function down(spec) {
  61. return Promise.resolve(spec);
  62. };
  63. VIDA_ClippingUpgrade.prototype._vidaClippingUpgrade = function _vidaClippingUpgrade(model) {
  64. // Turn off clipping/truncation for existing content.
  65. model.properties.push({
  66. id: 'widget.data.truncate',
  67. value: false
  68. });
  69. };
  70. return VIDA_ClippingUpgrade;
  71. }(UpgradeBase);
  72. return new VIDA_ClippingUpgrade();
  73. });
  74. //# sourceMappingURL=VIDA_ClippingUpgrade.js.map