'use strict'; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * 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(['underscore', 'dashboard-analytics/visualizations/renderer/filter/FilterLabelHelper', './TimelineHighlightAction'], function (_, FilterLabelHelper, TimelineHighlightAction) { var TimelineHighlightFlyoutController = function () { function TimelineHighlightFlyoutController(options) { _classCallCheck(this, TimelineHighlightFlyoutController); this.highlightAct = options.highlightAct; this.launchView = options.launchView; this.launchPoint = options.launchPoint; this.backButtonCallback = options.show; this.dashboardApi = options.dashboardApi; this.pageContextAPI = options.pageContextAPI; this.services = options.services; this.logger = this.dashboardApi.getGlassCoreSvc('.Logger'); this.stringResources = this.dashboardApi.getDashboardCoreSvc('.StringResources'); this.content = options.content; this.visualization = options.visualization; this.filterLabelHelper = new FilterLabelHelper({ dataSource: this.visualization.getDataSource(), 'timelineFilter': 'timelineFilter', 'filterLineEnabled': this._isFilterLineEnabled, 'filterLineDeleteEnabled': this._isFilterLineDeleteEnabled, dashboardApi: this.dashboardApi }); } TimelineHighlightFlyoutController.prototype.onEditTimelineFilter = function onEditTimelineFilter(event, dataId) { this.editTimelineFilter(dataId, event.currentTarget); }; TimelineHighlightFlyoutController.prototype.onRemoveTimelineFilter = function onRemoveTimelineFilter(event, dataId) { event.stopPropagation(); var matchingSlotDataItem = _.find(this.visualization.getSlots().getMappingInfoList(), function (mapping) { return mapping.dataItem.getColumnId() === dataId; }); var slot = matchingSlotDataItem.slot; var index = matchingSlotDataItem.indexInSlot; var timelineHighlightAction = new TimelineHighlightAction(this.visualization, slot, index, this.pageContextAPI, this.services, this.logger, this.highlightAct); timelineHighlightAction.removeFilter(dataId); }; TimelineHighlightFlyoutController.prototype.getItemActions = function getItemActions() { return this._generateFilterListItems(this.highlightAct.get('payload')); }; TimelineHighlightFlyoutController.prototype._generateFilterListItems = function _generateFilterListItems(timelineFilters) { var _this = this; var listItems = this.filterLabelHelper.generateFilterListItems(timelineFilters); listItems.forEach(function (item) { item.editLabel = _this.stringResources.get('editTimelineHighlight'); item.deleteLabel = _this.stringResources.get('deleteTimelineHighlight'); item.editAction = _this.onEditTimelineFilter.bind(_this); item.deleteAction = _this.onRemoveTimelineFilter.bind(_this); }); return listItems; }; TimelineHighlightFlyoutController.prototype.editTimelineFilter = function editTimelineFilter(columnId, node) { if (!node) { return Promise.resolve(); } var filterEntry = [_.findWhere(this.highlightAct.get('payload'), { columnId: columnId })]; var matchingSlotDataItem = _.find(this.visualization.getSlots().getMappingInfoList(), function (mapping) { return mapping.dataItem.getColumnId() === columnId; }); var slot = matchingSlotDataItem.slot; var dataItem = matchingSlotDataItem.dataItem; var index = matchingSlotDataItem.indexInSlot; var timelineHighlightAction = new TimelineHighlightAction(this.visualization, slot, index, this.pageContextAPI, this.services, this.logger, this.highlightAct); var dialogModule = timelineHighlightAction.getEditorModuleName(); var viewOptions = { columnId: columnId, filterSpec: filterEntry, highlightAct: this.highlightAct, columnTitle: dataItem.getLabel(), title: this.stringResources.get('timelineHighlightTitle'), slot: slot, dashboardApi: this.dashboardApi, pageContextAPI: this.pageContextAPI, services: this.services, itemContext: timelineHighlightAction.itemContext }; var interactivityController = this.content.getFeature('InteractivityController.deprecated'); return interactivityController.getActionHelper().renderFilterDialog(dialogModule, viewOptions, this.launchPoint, this.launchView, this.backButtonCallback); }; TimelineHighlightFlyoutController.prototype._isFilterLineDeleteEnabled = function _isFilterLineDeleteEnabled(filter) { return Boolean(filter.values.length); }; TimelineHighlightFlyoutController.prototype._isFilterLineEnabled = function _isFilterLineEnabled() { return true; }; return TimelineHighlightFlyoutController; }(); return TimelineHighlightFlyoutController; }); //# sourceMappingURL=TimelineHighlightFlyoutController.js.map