LayoutModelShowOverviews.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: Storytelling
  5. * (C) Copyright IBM Corp. 2017, 2019
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. define(['underscore'], function (_) {
  9. return {
  10. init: function init(model, spec /*, boardModel, logger*/) {
  11. if (spec.hasOverview && typeof spec.showOverviews === 'undefined') {
  12. var defaultSpec = {
  13. showStart: true,
  14. showEnd: true
  15. };
  16. model.showOverviews = spec.showOverviews = defaultSpec;
  17. }
  18. },
  19. /**
  20. * Update the showOverviews property of a model. This function will merge the provided showOverviews with the existing ones
  21. * @param model LayoutModel instance to update
  22. * @param showOverviews - object containing the showOverviews that we would like to update
  23. * @returns a payload useful to the LayoutMmodel._callExtensionMethod method
  24. */
  25. update: function update(model, showOverviews) {
  26. if (!showOverviews) {
  27. return null;
  28. }
  29. if (!model.showOverviews) {
  30. model.showOverviews = {};
  31. }
  32. var prev = _.clone(model.showOverviews);
  33. _.extend(model.showOverviews, showOverviews);
  34. return {
  35. event: 'change:showOverviews',
  36. value: showOverviews,
  37. previousValue: prev
  38. };
  39. }
  40. };
  41. });
  42. //# sourceMappingURL=LayoutModelShowOverviews.js.map