CreateStoryView.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. 'use strict';
  2. /*
  3. *+------------------------------------------------------------------------+
  4. *| Licensed Materials - Property of IBM
  5. *| IBM Cognos Products: Storytelling
  6. *| (C) Copyright IBM Corp. 2018, 2020
  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(['gemini/dashboard/glass/BaseView', './StoryLayoutPickerView', 'storytelling/nls/StringResources', 'text!storytelling/glass/templates/CreateStoryView.html', 'baglass/core-client/js/core-client/utils/UniqueId'], function (BaseView, StoryLayoutPickerView, stringResources, template, UniqueId) {
  13. var CreateStoryView = BaseView.extend({
  14. templateString: template,
  15. events: {
  16. 'primaryaction .createButton': 'createStoryView',
  17. 'primaryaction .cancelButton': 'onCancelClick'
  18. },
  19. init: function init(options) {
  20. CreateStoryView.inherited('init', this, arguments);
  21. this.ui_appbar = options.ui_appbar !== false;
  22. this.boardName = stringResources.get('defaultStoryName');
  23. },
  24. render: function render() {
  25. this.$el.empty();
  26. var html = this.dotTemplate({
  27. createStoryTitle: stringResources.get('createStoryTitle'),
  28. transitionStyleTitle: stringResources.get('transitionStyleTitle'),
  29. createButton: stringResources.get('createButton'),
  30. cancelButton: stringResources.get('cancelButton')
  31. });
  32. this.storyLayoutPickerView = new StoryLayoutPickerView({
  33. action: this.createStoryView.bind(this)
  34. });
  35. this.storyLayoutPickerView.render();
  36. this.$el.html(html);
  37. this.$el.find('.transitionStyleTitle').after(this.storyLayoutPickerView.el);
  38. return Promise.resolve();
  39. },
  40. getUrl: function getUrl() {
  41. return null;
  42. },
  43. getIcon: function getIcon() {
  44. return 'common-catalog';
  45. },
  46. getTitle: function getTitle() {
  47. return stringResources.get('createStoryViewTitle');
  48. },
  49. onCancelClick: function onCancelClick() {
  50. this.close();
  51. },
  52. createStoryView: function createStoryView() {
  53. return this.storyLayoutPickerView.getSelectedLayoutSpec().then(function (_ref) {
  54. var layout = _ref.layout;
  55. return this._openStory(this._getStorySpec(layout));
  56. }.bind(this));
  57. },
  58. _getStorySpec: function _getStorySpec(navLayout) {
  59. return {
  60. name: this.boardName,
  61. layout: navLayout.layout,
  62. theme: 'defaultTheme',
  63. timeline: this._getTimeline(navLayout.widgets),
  64. widgets: navLayout.widgets,
  65. _meta: {
  66. bundleID: null
  67. }
  68. };
  69. },
  70. _getTimeline: function _getTimeline(widgets) {
  71. var episodes = [];
  72. Object.keys(widgets).forEach(function (widgetId) {
  73. episodes.push({
  74. 'id': widgetId,
  75. 'type': 'widget',
  76. 'acts': [{
  77. 'id': UniqueId.get('act_'),
  78. 'timer': 0,
  79. 'action': 'show'
  80. }, {
  81. 'id': UniqueId.get('act_'),
  82. 'timer': 5000,
  83. 'action': 'hide'
  84. }]
  85. });
  86. });
  87. return {
  88. id: UniqueId.get('timeline_'),
  89. episodes: episodes
  90. };
  91. },
  92. _openStory: function _openStory(spec) {
  93. var id = spec._meta.bundleID;
  94. return this.glassContext.appController.openAppView('story', {
  95. content: {
  96. id: UniqueId.get('dashboard_'),
  97. boardId: id,
  98. boardSpec: spec,
  99. isAuthoringMode: true,
  100. ui_appbar: this.ui_appbar,
  101. containerAppOptions: this.containerAppOptions
  102. }
  103. }).then(function (view) {
  104. return view.onViewRendered();
  105. }).then(function () {
  106. this.close();
  107. }.bind(this));
  108. },
  109. close: function close() {
  110. this.glassContext.appController.closeAppView('createStory');
  111. }
  112. });
  113. return CreateStoryView;
  114. });
  115. //# sourceMappingURL=CreateStoryView.js.map