RemoveShapeAction.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /**
  4. * Licensed Materials - Property of IBM
  5. * IBM Business Analytics (C) Copyright IBM Corp. 2019
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. define(['../../../../widgets/livewidget/nls/StringResources', '../../../../lib/@waca/dashboard-common/dist/core/APIFactory', '../api/SlotActionsProviderAPI'], function (stringResources, APIFactory, SlotActionsProviderAPI) {
  9. return function () {
  10. function RemoveShapeAction(_ref) {
  11. var content = _ref.content,
  12. features = _ref.features;
  13. _classCallCheck(this, RemoveShapeAction);
  14. this.content = content;
  15. if (features) {
  16. features.SlotActions.registerProvider('removeShapeAction', this.getAPI());
  17. }
  18. }
  19. RemoveShapeAction.prototype.getSlotActionList = function getSlotActionList(dataSlotId, itemIndex) {
  20. if (this._supportAction()) {
  21. return [{
  22. name: 'removeShapeAction',
  23. label: stringResources.get('toolbarActionRmvShape'),
  24. icon: 'dashboard-shapeOff',
  25. type: 'Button',
  26. removeThenApplyAction: true,
  27. actions: {
  28. apply: this.removeShape.bind(this, dataSlotId, itemIndex)
  29. }
  30. }];
  31. }
  32. return [];
  33. };
  34. RemoveShapeAction.prototype._supportAction = function _supportAction() {
  35. return this.content.getPropertyValue('value.graphic.content') && this.content.getPropertyNameList().indexOf('value.graphic.content') !== -1;
  36. };
  37. RemoveShapeAction.prototype.removeShape = function removeShape() {
  38. this.content.setPropertyValue('value.graphic.content', null);
  39. };
  40. RemoveShapeAction.prototype.getAPI = function getAPI() {
  41. if (!this._api) {
  42. this._api = APIFactory.createAPI(this, [SlotActionsProviderAPI]);
  43. }
  44. return this._api;
  45. };
  46. return RemoveShapeAction;
  47. }();
  48. });
  49. //# sourceMappingURL=RemoveShapeAction.js.map