'use strict'; /* * Licensed Materials - Property of IBM * IBM Cognos Products: Storytelling * (C) Copyright IBM Corp. 2018, 2019 * * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['gemini/dashboard/glass/controllers/ShareActionHandler', '../../nls/StringResources'], function (DashboardShareActionHandler, StringResources) { var ShareActionHandler; ShareActionHandler = DashboardShareActionHandler.extend({ /** * overridden from dashboard-core to add Storytelling specific information * @override */ execute: function execute(context) { if (context.urlMap.objRef) { var share = { perspective: 'story', objRef: context.urlMap.objRef, action: 'view' }; var view = context.glassContext.appController.getCurrentContentView(); var sceneInfo = view.storyPaneController.getCurrentSceneInfo(); share.sceneId = sceneInfo && sceneInfo.id; share.sceneTime = view.storyPaneController.getCurrentTime(); return share; } else { throw new Error('Unable to resolve share context. Missing objRef.'); } }, /** * overridden from dashboard-core to add Storytelling specific information * @override */ getShareableItems: function getShareableItems(context) { // call parent method to get maps re-rendered for screen capture var view = context.glassContext.appController.getCurrentContentView(); return this.reRenderMaps(view).then(this._getShareableItems.bind(this, context)); }, _getShareableItems: function _getShareableItems(context) { var view = context.glassContext.appController.getCurrentContentView(); var sceneInfo = view.storyPaneController.getCurrentSceneInfo(); var sceneTitle = sceneInfo && sceneInfo.title; var label = sceneTitle ? StringResources.get('screenshot_label_scene', { title: view.getTitle(), sceneTitle: sceneTitle }) : StringResources.get('screenshot_label', { title: view.getTitle() }); var layoutView = view.boardController.layoutController.getLayoutView(sceneInfo.id); if (layoutView) { // scene return Promise.resolve([{ el: layoutView.$el, label: label }]); } // overview return view.boardController.layoutController.getTopLayoutViewWhenReady().then(function (topView) { return [{ el: topView.$el, label: label }]; }); }, /** * Callback when share panel shows. * @param context * @param context.glassContext {Object} The glass context * @param context.slideout {Object} The share panel slideout */ enterShareState: function enterShareState(context) { return Promise.resolve().then(function () { var controller = context.glassContext.appController.getCurrentContentView().storyPaneController; return controller.enterShareState(context.slideout); }); }, /** * Callback when share panel hides. * @param context * @param context.glassContext {Object} The glass context * @param context.slideout {Object} The share panel slideout */ leaveShareState: function leaveShareState(context) { return Promise.resolve().then(function () { var controller = context.glassContext.appController.getCurrentContentView().storyPaneController; return controller.leaveShareState(); }); }, /** * Returns true if export to pdf for storytelling is allowed. * * @param {*} options.glassContext the Glass context */ canExportToPDF: function canExportToPDF() { return true; }, /** * Creates a PDF. * * @param {*} context.glassContext the Glass context * @param {*} pageSize an object representing the page size * @param {*} printFilters print filters. * @return {Promise} */ exportToPDF: function exportToPDF(context, pageSize, printFilters) { var dashboardApi = context.glassContext.appController.getCurrentContentView().getDashboardApi(); var printFeature = dashboardApi.getFeature('Print'); var pageOptions = { pageSize: pageSize, printFilters: printFilters }; var id = dashboardApi.getCanvas().getContent().getId(); return printFeature.print(id, context.glassContext.appController, pageOptions); } }); return ShareActionHandler; }); //# sourceMappingURL=ShareActionHandler.js.map