'use strict'; /* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: Dashboard *| (C) Copyright IBM Corp. 2017, 2019 *| *| US Government Users Restricted Rights - Use, duplication or disclosure *| restricted by GSA ADP Schedule Contract with IBM Corp. *+------------------------------------------------------------------------+ */ define(['../lib/@waca/dashboard-common/dist/glass/controllers/WidgetBaseActionHandler', '../widgets/livewidget/nls/StringResources', '../DynamicFileLoader'], function (BaseClass, stringResources, DynamicFileLoader) { 'use strict'; /** * Glass Action controller which loads visualizations * based on the LiveWidget using the LiveWidgetUIHelper */ var ActionHandler = BaseClass.extend({ getOptions: function getOptions(context) { var view = this._getDashboardView(context); var dashboardApi = view.getDashboardApi(); var options = { className: 'visualizationSlideout', dashboardApi: dashboardApi, services: view.services, // TODO: remove once core is using the dashboardApi title: stringResources.get('visualizationSlideoutTitle'), module: 'dashboard-analytics/visualizationPanel/VisualizationPanelView', getEntries: this.getEntries.bind(this, context) }; return Promise.resolve(options); }, getEntries: function getEntries(context) { return this.createWidgetAddUIHelper(context).then(function (helper) { return helper.getEntries(); }).then(this.getSpecs.bind(this, context)); }, getSpecs: function getSpecs(context, entries) { return this.createWidgetAddUIHelper(context).then(function (helper) { var spec = {}; var options = { onItemClick: function onItemClick(widget, event) { return helper.addWidgetBySelection(widget, event, { selectOptions: { flyout: false } }); }, onItemStartDrag: helper.addWidgetByDrag.bind(helper) }; spec.options = options; spec.items = entries; return spec; }); }, // Private _getDashboardView: function _getDashboardView(context) { return context.glassContext.appController.currentAppView.currentContentView; }, _getUiHelperClass: function _getUiHelperClass() { return DynamicFileLoader.load(['dashboard-analytics/widgets/livewidget/LiveWidgetUIHelper']).then(function (modules) { return modules[0]; }.bind(this)); }, createWidgetAddUIHelper: function createWidgetAddUIHelper(context) { var view = this._getDashboardView(context); return this._getUiHelperClass().then(function (HelperClass) { var helper = new HelperClass({ dashboardApi: view.getDashboardApi(), services: view.services // TODO : remove once the common add ui helper is not using the services. }); helper.panelAttributes = { dashboardApi: view.dashboardApi, cdnUrl: view.getCDNUrl(), ajaxSvc: view.ajaxSvc }; return helper; }); } }); return ActionHandler; }); //# sourceMappingURL=LiveVisualizationActionHandler.js.map