1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- '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: BI Cloud (C) Copyright IBM Corp. 2019, 2020
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['../../../../widgets/livewidget/nls/StringResources', '../../../../lib/@waca/dashboard-common/dist/core/APIFactory', '../api/SlotActionsProviderAPI'], function (stringResources, APIFactory, SlotActionsProviderAPI) {
- return function () {
- function DeleteAction(options) {
- _classCallCheck(this, DeleteAction);
- this.dashboard = options.dashboardAPI;
- this.content = options.content;
- this.icons = options.features['Dashboard.Icons'];
- options.features.SlotActions.registerProvider('deleteAction', this.getAPI());
- }
- DeleteAction.prototype.getSlotActionList = function getSlotActionList(dataSlotId, itemIndex, options) {
- var dataSlot = this.content.getFeature('Visualization').getSlots().getSlot(dataSlotId);
- var deleteIcon = this.icons.getIcon('TrashIcon');
- if (dataSlot && this._supportAction(dataSlot, itemIndex, options)) {
- return [{
- name: 'delete',
- label: stringResources.get('toolbarDeleteActionText'),
- icon: deleteIcon.id,
- type: 'Button',
- group: 'deleteAction',
- removeThenApplyAction: true,
- actions: {
- apply: this.deleteSlot.bind(this, dataSlot, itemIndex)
- }
- }];
- }
- return [];
- };
- DeleteAction.prototype._supportAction = function _supportAction(dataSlot, itemIndex, options) {
- if (this.dashboard.getMode() !== this.dashboard.MODES.EDIT) {
- return false;
- }
- // Do not support action if excludeAction is true. Currently used by crosstab.
- if (options && options.excludeAction) {
- return false;
- }
- // We do not support delete action when clicking on the legend or on viz labels.
- if (itemIndex === null || itemIndex === undefined) {
- return false;
- }
- var dataItem = dataSlot.getDataItemList()[itemIndex];
- if (dataItem && dataItem.getColumnId() === '_multiMeasuresSeries') {
- return false;
- }
- // We do not support delete action in multiple selections.
- // (eg. selecting multiple columns in crosstab)
- if (Array.isArray(itemIndex)) {
- return false;
- }
- return true;
- };
- DeleteAction.prototype.deleteSlot = function deleteSlot(dataSlot, itemIndex) {
- var dataItem = dataSlot.getDataItemList()[itemIndex];
- var ids = [dataItem.getId()];
- dataSlot.removeDataItems(ids);
- };
- DeleteAction.prototype.getAPI = function getAPI() {
- if (!this._api) {
- this._api = APIFactory.createAPI(this, [SlotActionsProviderAPI]);
- }
- return this._api;
- };
- return DeleteAction;
- }();
- });
- //# sourceMappingURL=DeleteAction.js.map
|