ConditionalFlyoutView.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. *
  5. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014, 2020
  6. *
  7. * US Government Users Restricted Rights - Use, duplication or disclosure
  8. * restricted by GSA ADP Schedule Contract with IBM Corp.
  9. */
  10. define(['jquery', 'doT', '../../../widgets/livewidget/nls/StringResources', '../../../lib/@waca/dashboard-common/dist/utils/FlyoutContentBase', '../../../data/models/ConditionalPalette', 'text!./templates/ConditionalFlyoutView.html'], function ($, dot, stringResources, FlyoutContentBase, ConditionalPalette, RemoveHandleTemplate) {
  11. 'use strict';
  12. var removeHandleTemplate = dot.template(RemoveHandleTemplate);
  13. var ConditionalFlyoutView = FlyoutContentBase.extend({
  14. init: function init() {
  15. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  16. ConditionalFlyoutView.inherited('init', this, arguments);
  17. this.visModel = options.visModel || options.viewOptions.visModel;
  18. this.widget = options.widget || options.viewOptions.widget;
  19. this.palette = options.palette || options.viewOptions.palette;
  20. this.slider = options.slider || options.viewOptions.slider;
  21. this.icons = options.viewOptions.icons;
  22. this.handlePosition = options.handlePosition || options.viewOptions.handlePosition;
  23. this.isVisible = false;
  24. },
  25. setFocus: function setFocus() {
  26. $('.conditionalFormattingIcon').parent().focus();
  27. },
  28. onPopupShown: function onPopupShown() {
  29. this.isVisible = true;
  30. },
  31. onPopupClosed: function onPopupClosed() {
  32. this.isVisible = false;
  33. },
  34. onDeleteClicked: function onDeleteClicked() {
  35. this.popupParent.close();
  36. var options = ConditionalPalette.createUndoRedoTransactionOptionsId('removeStyle');
  37. this.palette.removeStyle(this.handlePosition, options);
  38. this.visModel.updateConditionalPalette().then(function () {
  39. this.slider.removeHandle(this.handlePosition);
  40. }.bind(this));
  41. },
  42. getRenderedHtml: function getRenderedHtml() {
  43. var trashIcon = this.icons.getIcon('common-remove-trash');
  44. var template = removeHandleTemplate({
  45. remove_slider_handle: stringResources.get('remove_slider_handle'),
  46. trashIcon: trashIcon.id
  47. });
  48. var $deleteButton = $(template).on('primaryaction', this.onDeleteClicked.bind(this));
  49. var markup = '<div class="toolbar"></div>';
  50. var $markup = $(markup).append($deleteButton);
  51. return $markup[0];
  52. }
  53. });
  54. return ConditionalFlyoutView;
  55. });
  56. //# sourceMappingURL=ConditionalFlyoutView.js.map