StoryPaneView.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: Storytelling
  5. * (C) Copyright IBM Corp. 2014, 2022
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. define(['baglass/core-client/js/core-client/ui/core/View', 'text!./templates/StoryPaneView.html', './FilmStripView', '../nls/StringResources', '../lib/@ba-ui-toolkit/ba-graphics/dist/icons-js/catalog_32'], function (View, Template, FilmStripView, stringResources, svgStoryCatalog) {
  9. var StoryPaneView = View.extend({
  10. templateString: Template,
  11. init: function init(options) {
  12. StoryPaneView.inherited('init', this, arguments);
  13. this.dashboardApi = options.dashboardApi;
  14. this.services = options.services;
  15. this.minimumSize = 200;
  16. },
  17. initialize: function initialize() {
  18. return this._setupEvents();
  19. },
  20. _setupEvents: function _setupEvents() {
  21. var _this = this;
  22. return this.dashboardApi.getDashboardSvc('.LifeCycleManager').then(function (LifeCycleManager) {
  23. LifeCycleManager.registerLifeCycleHandler('post:dashboard.focus', function () {
  24. if (_this.dashboardApi.getCurrentContentView().isAuthorMode()) {
  25. _this.trigger('openPane');
  26. }
  27. });
  28. LifeCycleManager.registerLifeCycleHandler('post:mode.edit', function () {
  29. _this.trigger('openPane');
  30. });
  31. _this.dashboardApi.on('widget:maximize', _this._disableAndSwitchHandlerListener, _this);
  32. _this.dashboardApi.on('widget:restore', _this._restoreHandlerListener, _this);
  33. });
  34. },
  35. _disableAndSwitchHandlerListener: function _disableAndSwitchHandlerListener() {
  36. this.trigger('disableAndSwitchHandle');
  37. },
  38. _restoreHandlerListener: function _restoreHandlerListener() {
  39. this.trigger('restoreHandle');
  40. },
  41. getSplitterOpts: function getSplitterOpts() {
  42. return Promise.resolve({
  43. handleClass: 'storyHandle',
  44. handleIcon: svgStoryCatalog.default.id,
  45. handleOpenTitle: stringResources.get('filmstripHandleOpenLabel'),
  46. handleCloseTitle: stringResources.get('filmstripHandleCloseLabel'),
  47. hidden: false,
  48. view: this,
  49. initialSize: 200,
  50. overrideGlobalMaxSize: 200
  51. });
  52. },
  53. /**
  54. * Renders the StoryPaneView and eventually renders the FilmStripView inside it.
  55. *
  56. * @returns Promise
  57. */
  58. render: function render() {
  59. var sHtml = this.dotTemplate();
  60. this.$el
  61. // the 'blockOnExpandView' class is used when widgets are expanded (in 'focus mode')
  62. .addClass('storytelling blockOnExpandView').html(sHtml);
  63. // Add the first view.
  64. return this._createFilmStrip();
  65. },
  66. remove: function remove() {
  67. if (this.filmStripView) {
  68. this.filmStripView.remove();
  69. }
  70. this.dashboardApi.off('widget:maximize', this._disableAndSwitchHandlerListener, this);
  71. this.dashboardApi.off('widget:restore', this._restoreHandlerListener, this);
  72. StoryPaneView.inherited('remove', this, arguments);
  73. },
  74. _createFilmStrip: function _createFilmStrip() {
  75. var _this2 = this;
  76. var blankNode = document.createElement('div');
  77. this.el.querySelector('.content').appendChild(blankNode);
  78. return Promise.all([this.dashboardApi.getDashboardSvc('.DndManager'), this.dashboardApi.getDashboardSvc('.StoryPaneService')]).then(function (_ref) {
  79. var dndManager = _ref[0],
  80. storyPaneController = _ref[1];
  81. _this2.filmStripView = new FilmStripView({
  82. el: blankNode,
  83. dashboardApi: _this2.dashboardApi,
  84. controller: storyPaneController,
  85. dndManager: dndManager,
  86. glassContext: _this2.services.biGlass.glassContext,
  87. services: _this2.services
  88. });
  89. return _this2.filmStripView.render();
  90. });
  91. }
  92. });
  93. return StoryPaneView;
  94. });
  95. //# sourceMappingURL=StoryPaneView.js.map