WidgetTitleUpgradeHelper.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. 2020
  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', './TextWidgetTypesUpgradeHelper'], function (_, TextWidgetTypesUpgradeHelper) {
  16. var LIVE_WIDGET_TYPE = 'live';
  17. var THEME_DEFAULT = 'defaultTheme';
  18. var WidgetTitleUpgradeHelper = function (_TextWidgetTypesUpgra) {
  19. _inherits(WidgetTitleUpgradeHelper, _TextWidgetTypesUpgra);
  20. function WidgetTitleUpgradeHelper() {
  21. _classCallCheck(this, WidgetTitleUpgradeHelper);
  22. return _possibleConstructorReturn(this, _TextWidgetTypesUpgra.apply(this, arguments));
  23. }
  24. /**
  25. * Upgrade the widget title (<1083) to keep the old default font family by replacing its css class.
  26. * @override
  27. */
  28. WidgetTitleUpgradeHelper.prototype._upgradeWidgets = function _upgradeWidgets(spec) {
  29. var _this2 = this;
  30. try {
  31. _.each(spec.widgets, function (model) {
  32. if (model.type === LIVE_WIDGET_TYPE) {
  33. _this2._upgradeWidgetTitle(spec.theme, model);
  34. }
  35. });
  36. } catch (error) {
  37. throw error;
  38. }
  39. };
  40. WidgetTitleUpgradeHelper.prototype._upgradeWidgetTitle = function _upgradeWidgetTitle() {
  41. var theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : THEME_DEFAULT;
  42. var model = arguments[1];
  43. if (!model.titleHtml) {
  44. return;
  45. }
  46. var table = model.titleHtml.translationTable;
  47. if (table) {
  48. for (var lang in table) {
  49. table[lang] = this._upgradeContent(theme, table[lang]);
  50. }
  51. } else if (typeof model.titleHtml === 'string') {
  52. model.titleHtml = this._upgradeContent(theme, model.titleHtml);
  53. }
  54. };
  55. return WidgetTitleUpgradeHelper;
  56. }(TextWidgetTypesUpgradeHelper);
  57. return WidgetTitleUpgradeHelper;
  58. });
  59. //# sourceMappingURL=WidgetTitleUpgradeHelper.js.map