VIDA_breakingchanges.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. 'use strict';
  2. /*
  3. *+------------------------------------------------------------------------+
  4. *| Licensed Materials - Property of IBM
  5. *| IBM Cognos Products: BI Dashboard
  6. *| (C) Copyright IBM Corp. 2017
  7. *|
  8. *| US Government Users Restricted Rights - Use, duplication or disclosure
  9. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  10. *+------------------------------------------------------------------------+
  11. */
  12. define(['underscore', '../../../lib/@waca/core-client/js/core-client/ui/core/Class', '../../../lib/@waca/upgrades/UpgradeBase', './utils/WidgetUpgradeUtils'], function (_, Class, UpgradeBase, WidgetUpgradeUtils) {
  13. var HEATMAP_VISID = 'com.ibm.vis.rave2heat';
  14. var Upgrade = Class.extend([UpgradeBase], {
  15. init: function init() {
  16. this.VERSION = 1006;
  17. },
  18. /**
  19. * Perform upgrade
  20. *
  21. * @param {object} spec - spec to perform upgrade on
  22. *
  23. * @return {Promise} Promise to be resolved when upgrade performed
  24. */
  25. up: function up(spec) {
  26. if (!spec) {
  27. return Promise.resolve(spec);
  28. }
  29. if (!WidgetUpgradeUtils.specHasWidgets(spec)) {
  30. return Promise.resolve(spec);
  31. }
  32. _.each(spec.widgets, function (model) {
  33. this.upgradePieChartDonutRadiusProperty(model);
  34. this.upgradeHeatmapAxisLabelProperty(model);
  35. }.bind(this));
  36. return Promise.resolve(spec);
  37. },
  38. upgradePieChartDonutRadiusProperty: function upgradePieChartDonutRadiusProperty(model) {
  39. var pieHasHoleProp = WidgetUpgradeUtils.findProperty('pie.has.hole', model.properties);
  40. if (pieHasHoleProp && pieHasHoleProp.value === true) {
  41. var donutRadius = WidgetUpgradeUtils.findProperty('donutRadius', model.properties);
  42. if (!donutRadius) {
  43. model.properties.push({
  44. id: 'donutRadius',
  45. value: 0.50
  46. });
  47. }
  48. }
  49. },
  50. upgradeHeatmapAxisLabelProperty: function upgradeHeatmapAxisLabelProperty(model) {
  51. if (model.visId === HEATMAP_VISID) {
  52. // Ensure r7 specific properties are set first to ensure it's not overwritten by post-r7 defaults
  53. // r7 has default set to 'bottom' while r8 has default set to 'top'
  54. WidgetUpgradeUtils.setDefaultProperty(model, 'itemAxis.alignment', 'bottom');
  55. // r7 has default set to 'rotate90' while r9 has default set to 'automatic'
  56. WidgetUpgradeUtils.setDefaultProperty(model, 'itemAxis.labels.layoutMode', 'rotate90');
  57. }
  58. },
  59. down: function down(spec) {
  60. // no downgrade at this time; return as is
  61. return Promise.resolve(spec);
  62. }
  63. });
  64. return new Upgrade();
  65. });
  66. //# sourceMappingURL=VIDA_breakingchanges.js.map