TimelineHighlightAction.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. 'use strict';
  2. /*
  3. *+------------------------------------------------------------------------+
  4. *| Licensed Materials - Property of IBM
  5. *| IBM Cognos Products: BI Dashboard
  6. *| (C) Copyright IBM Corp. 2017, 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(['dashboard-analytics/visualizations/interactions/FilterAction', 'jquery', 'underscore'], function (FilterAction, $, _) {
  12. var TimelineHighlightAction = FilterAction.extend({
  13. // TODO: Investigate the removal of pageContextAPI and services
  14. init: function init(visualization, slot, index, pageContextAPI, services, logger, highlightAct) {
  15. this.visualization = visualization;
  16. this.slot = slot;
  17. this.dataItem = slot.getDataItemList()[index];
  18. this.mapIndex = index;
  19. this.pageContextAPI = pageContextAPI;
  20. this.services = services;
  21. this.logger = logger;
  22. this.itemContext = {
  23. uniqueId: this.dataItem.getId(),
  24. itemId: this.dataItem.getColumnId(),
  25. itemName: this.dataItem.getLabel(),
  26. dataType: this.dataItem.getDataType(),
  27. sourceId: this.visualization.getDataSource().getId()
  28. };
  29. this.renderModule = this.getEditorModuleName();
  30. this.highlightAct = highlightAct;
  31. },
  32. removeFilter: function removeFilter(columnId) {
  33. var payload = $.extend(true, [], this.highlightAct.get('payload'));
  34. _.find(this.highlightAct.payload, function (column, index) {
  35. if (column.columnId === columnId) {
  36. // no need to set model if the column includes all already
  37. if (!column.operator) {
  38. return true;
  39. }
  40. var includeAll = {
  41. columnId: payload[index].columnId,
  42. columnLabel: payload[index].columnLabel,
  43. id: payload[index].columnId,
  44. values: []
  45. };
  46. if (payload[index].aggregationType) {
  47. includeAll.aggregationType = payload[index].aggregationType;
  48. }
  49. payload[index] = includeAll;
  50. this.highlightAct.set({
  51. payload: payload
  52. });
  53. return true;
  54. }
  55. }.bind(this));
  56. },
  57. /**
  58. * @override
  59. */
  60. getEditorModuleName: function getEditorModuleName() {
  61. return 'storytelling/views/highlight/TimelineHighlightEditWrapperView';
  62. }
  63. });
  64. return TimelineHighlightAction;
  65. });
  66. //# sourceMappingURL=TimelineHighlightAction.js.map