DataShapeSlotsView.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. 'use strict';
  2. /*
  3. *+------------------------------------------------------------------------+
  4. *| Licensed Materials - Property of IBM
  5. *| IBM Cognos Products: BI Dashboard
  6. *| (C) Copyright IBM Corp. 2016, 2019
  7. *| US Government Users Restricted Rights - Use, duplication or disclosure
  8. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *+------------------------------------------------------------------------+
  10. */
  11. define(['jquery', './DataSlotsView', '../../../lib/@waca/baglass/js/baglass/utils/Utils', '../../../lib/@waca/core-client/js/core-client/utils/Utils', '../../../widgets/livewidget/nls/StringResources'], function ($, SlotsView, Utils, UtilsClient, resources) {
  12. 'use strict';
  13. var DataShapeSlotsView = SlotsView.extend({
  14. init: function init() {
  15. DataShapeSlotsView.inherited('init', this, arguments);
  16. },
  17. onDrop: function onDrop(dragObject, dropNode) {
  18. this._clearToolbar();
  19. this._dismissCoachMark();
  20. $(dropNode).removeClass('draggedOn');
  21. if (dragObject.widgetType && dragObject.widgetType === 'shape') {
  22. this.widget.onAddShapeWidget({
  23. shapeModel: dragObject.widgetSpec.model,
  24. dropNode: dropNode
  25. });
  26. } else {
  27. DataShapeSlotsView.inherited('onDrop', this, arguments);
  28. }
  29. },
  30. /**
  31. * trigger to close the coach mark popover.
  32. * The coach mark will be dismissed for the user.
  33. * Because click anywhere on the screen closes coachmark and dropping shape requires to click shape panel
  34. * the coachmark is the shape drop coachmark
  35. */
  36. _dismissCoachMark: function _dismissCoachMark() {
  37. $('.coachMarkPopover .coachMarkClose').trigger('primaryaction');
  38. },
  39. _preserveData: function _preserveData(slot, mapping) {
  40. if (mapping && slot.mapping) {
  41. if (slot.mapping.graphic) {
  42. mapping.graphic = slot.mapping.graphic;
  43. }
  44. if (slot.mapping.shapeDropEnabled) {
  45. mapping.shapeDropEnabled = slot.mapping.shapeDropEnabled;
  46. }
  47. }
  48. },
  49. /**
  50. * a helper method to render a coachmark for dropping shape and expand the content automatically
  51. */
  52. _addDropShapeCoachMark: function _addDropShapeCoachMark() {
  53. var $target = this.$el.find('.listitem.columnName');
  54. var options = {
  55. id: $target.attr('data-column-id'),
  56. $el: $target,
  57. title: resources.get('toolbarActionToggleShapeDropTitle'),
  58. contents: resources.get('toolbarActionToggleShapeDropText'),
  59. showPopover: true
  60. };
  61. this.dashboardApi.prepareGlassOptions(options);
  62. Utils.addCoachmark(options);
  63. },
  64. /**
  65. * a helper method to open the shape panel by searching glass plugin and trigger a click event
  66. */
  67. _openShapePanel: function _openShapePanel() {
  68. var plugin = this.dashboardApi.findGlassPlugin('com.ibm.bi.dashboard.widgetsPanel');
  69. if (plugin && !plugin.$el.hasClass('pushed')) {
  70. plugin.$el.trigger('click');
  71. }
  72. }
  73. });
  74. return DataShapeSlotsView;
  75. });
  76. //# sourceMappingURL=DataShapeSlotsView.js.map