'use strict'; /* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: Storytelling *| (C) Copyright IBM Corp. 2018, 2020 *| *| US Government Users Restricted Rights - Use, duplication or disclosure *| restricted by GSA ADP Schedule Contract with IBM Corp. *+------------------------------------------------------------------------+ */ 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) { var CreateStoryView = BaseView.extend({ templateString: template, events: { 'primaryaction .createButton': 'createStoryView', 'primaryaction .cancelButton': 'onCancelClick' }, init: function init(options) { CreateStoryView.inherited('init', this, arguments); this.ui_appbar = options.ui_appbar !== false; this.boardName = stringResources.get('defaultStoryName'); }, render: function render() { this.$el.empty(); var html = this.dotTemplate({ createStoryTitle: stringResources.get('createStoryTitle'), transitionStyleTitle: stringResources.get('transitionStyleTitle'), createButton: stringResources.get('createButton'), cancelButton: stringResources.get('cancelButton') }); this.storyLayoutPickerView = new StoryLayoutPickerView({ action: this.createStoryView.bind(this) }); this.storyLayoutPickerView.render(); this.$el.html(html); this.$el.find('.transitionStyleTitle').after(this.storyLayoutPickerView.el); return Promise.resolve(); }, getUrl: function getUrl() { return null; }, getIcon: function getIcon() { return 'common-catalog'; }, getTitle: function getTitle() { return stringResources.get('createStoryViewTitle'); }, onCancelClick: function onCancelClick() { this.close(); }, createStoryView: function createStoryView() { return this.storyLayoutPickerView.getSelectedLayoutSpec().then(function (_ref) { var layout = _ref.layout; return this._openStory(this._getStorySpec(layout)); }.bind(this)); }, _getStorySpec: function _getStorySpec(navLayout) { return { name: this.boardName, layout: navLayout.layout, theme: 'defaultTheme', timeline: this._getTimeline(navLayout.widgets), widgets: navLayout.widgets, _meta: { bundleID: null } }; }, _getTimeline: function _getTimeline(widgets) { var episodes = []; Object.keys(widgets).forEach(function (widgetId) { episodes.push({ 'id': widgetId, 'type': 'widget', 'acts': [{ 'id': UniqueId.get('act_'), 'timer': 0, 'action': 'show' }, { 'id': UniqueId.get('act_'), 'timer': 5000, 'action': 'hide' }] }); }); return { id: UniqueId.get('timeline_'), episodes: episodes }; }, _openStory: function _openStory(spec) { var id = spec._meta.bundleID; return this.glassContext.appController.openAppView('story', { content: { id: UniqueId.get('dashboard_'), boardId: id, boardSpec: spec, isAuthoringMode: true, ui_appbar: this.ui_appbar, containerAppOptions: this.containerAppOptions } }).then(function (view) { return view.onViewRendered(); }).then(function () { this.close(); }.bind(this)); }, close: function close() { this.glassContext.appController.closeAppView('createStory'); } }); return CreateStoryView; }); //# sourceMappingURL=CreateStoryView.js.map