123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- 'use strict';
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: CA
- *| (C) Copyright IBM Corp. 2018
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define(['../../lib/@waca/core-client/js/core-client/ui/core/Class', '../../widgets/livewidget/nls/StringResources', 'underscore'], function (BaseClass, StringResources, _) {
- 'use strict';
- /**
- * Class to open content dialog and to pick a drill through target.
- */
- var SelectDrillTargetActionHandler = BaseClass.extend({
- init: function init(dashboardApi) {
- SelectDrillTargetActionHandler.inherited('init', this, arguments);
- this.dashboardApi = dashboardApi;
- },
- /**
- * This method will show an open dialog to select a drill target.
- */
- selectTarget: function selectTarget(context) {
- var _this = this;
- context = context || {};
- if (!context.handlers || !context.handlers.onSelect) {
- throw new Error('onSelect handler must be provided');
- }
- var typesToOpen = ['report', 'reportView', 'exploration'];
- var options = {
- 'typesToOpen': typesToOpen,
- 'dataManipulationCallback': this._filterOutExploration.bind(this),
- 'extraUrlParameters': ['base'],
- 'multiSelect': false,
- 'dialogTitle': StringResources.get('selectTargetDialogTitle'),
- 'primaryBtnText': StringResources.get('dlg_ok'),
- 'onOpenCallback': function onOpenCallback(selectedItems) {
- _this._addDrillTarget(context.handlers.onSelect, selectedItems);
- }
- };
- this.dashboardApi.prepareGlassOptions(options);
- try {
- return this._selectTargetFromOpenDialog(options);
- } catch (error) {
- throw new Error(error);
- }
- },
- /**
- * The open dialog should contain dashboards, stories and reports.
- * However, the 'typesToOpen' value 'exploration' includes explorations, dashboards and stories.
- * Filtering manually here is the only way offered by ContentNav to achieve this.
- */
- _filterOutExploration: function _filterOutExploration(response) {
- if (response.data && response.data.length) {
- response.data = response.data.filter(function (result) {
- return !result.tags || result.type !== 'exploration' || result.tags.indexOf('dashboard') !== -1 || result.tags.indexOf('story') !== -1;
- });
- }
- },
- _selectTargetFromOpenDialog: function _selectTargetFromOpenDialog(options) {
- return this.dashboardApi.getGlassSvc('.ContentDialogFactory').then(function (dialogFactory) {
- return new Promise(function (resolve, reject) {
- var openDialog = dialogFactory.createOpenDialog(_extends({}, options, {
- resolve: resolve,
- reject: reject
- }));
- openDialog.open();
- });
- });
- },
- /**
- * @param selectedItems - an array of CM object items. When multiSelect is false, the array has only one selected item
- */
- _addDrillTarget: function _addDrillTarget(callback, selectedItems) {
- // There is only 1 selected item in this function because multiSelect is set to false
- var selectedItem = selectedItems[0];
- var perspective = 'authoring';
- if (selectedItem.type === 'exploration') {
- perspective = selectedItem.tags.indexOf('story') !== -1 ? 'story' : 'dashboard';
- }
- var drillTarget = {
- 'assetId': selectedItem.id,
- 'name': selectedItem.defaultName,
- 'type': selectedItem.type,
- 'searchPath': selectedItem.searchPath,
- 'isOlapPackage': selectedItem.userInterfaces && _.indexOf(selectedItem.userInterfaces, 'analysisStudio') >= 0,
- 'modificationTime': selectedItem.modificationTime,
- 'perspective': perspective
- };
- callback(drillTarget);
- }
- });
- return SelectDrillTargetActionHandler;
- });
- //# sourceMappingURL=SelectDrillTargetActionHandler.js.map
|