123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- 'use strict';
- define(['../lib/@waca/dashboard-common/dist/glass/controllers/WidgetBaseActionHandler', '../widgets/livewidget/nls/StringResources', '../DynamicFileLoader'], function (BaseClass, stringResources, DynamicFileLoader) {
- 'use strict';
-
- 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,
- 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;
- });
- },
-
- _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
- });
- helper.panelAttributes = {
- dashboardApi: view.dashboardApi,
- cdnUrl: view.getCDNUrl(),
- ajaxSvc: view.ajaxSvc
- };
- return helper;
- });
- }
- });
- return ActionHandler;
- });
|