@annalib/anna-core 3.1.3 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/.browserslistrc +16 -0
  2. package/karma.conf.js +44 -0
  3. package/ng-package.json +14 -0
  4. package/package.json +18 -38
  5. package/src/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.html +22 -0
  6. package/src/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.scss +0 -0
  7. package/src/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.spec.ts +25 -0
  8. package/src/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.ts +16 -0
  9. package/src/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.html +33 -0
  10. package/src/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.scss +0 -0
  11. package/src/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.spec.ts +25 -0
  12. package/src/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.ts +28 -0
  13. package/src/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.html +20 -0
  14. package/src/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.scss +0 -0
  15. package/src/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.spec.ts +25 -0
  16. package/src/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.ts +16 -0
  17. package/src/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.html +3 -0
  18. package/src/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.scss +17 -0
  19. package/src/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.spec.ts +24 -0
  20. package/src/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.ts +20 -0
  21. package/src/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.html +23 -0
  22. package/src/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.scss +0 -0
  23. package/src/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.spec.ts +25 -0
  24. package/src/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.ts +16 -0
  25. package/src/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.html +15 -0
  26. package/src/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.scss +0 -0
  27. package/src/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.spec.ts +25 -0
  28. package/src/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.ts +19 -0
  29. package/src/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.html +14 -0
  30. package/src/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.scss +0 -0
  31. package/src/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.spec.ts +25 -0
  32. package/src/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.ts +16 -0
  33. package/src/lib/anna-core-shared-lib/constants/shared.constant.ts +34 -0
  34. package/src/lib/anna-core-shared-lib/directives/show-ellipsis-text/show-ellipsis-text.directive.ts +19 -0
  35. package/src/lib/anna-core-shared-lib/models/anna-generic-data-type.model.ts +15 -0
  36. package/{lib/anna-core-shared-lib/models/anna-global-dropdown-config.model.d.ts → src/lib/anna-core-shared-lib/models/anna-global-dropdown-config.model.ts} +21 -9
  37. package/{lib/anna-core-shared-lib/models/anna-non-editable-gt-models.d.ts → src/lib/anna-core-shared-lib/models/anna-non-editable-gt-models.ts} +27 -17
  38. package/src/lib/anna-core-shared-lib/models/anna-sort.model.ts +7 -0
  39. package/src/lib/anna-core-shared-lib/models/anna-tooltip.model.ts +44 -0
  40. package/src/lib/anna-core-shared-lib/pipes/annaFilterSearchedText.pipe.ts +26 -0
  41. package/src/lib/anna-core-shared-lib/services/anna-date-time-format.service.ts +202 -0
  42. package/src/lib/anna-core-shared-lib/services/anna-filter.service.ts +507 -0
  43. package/src/lib/anna-core-shared-lib/services/anna-generic-table.service.ts +44 -0
  44. package/src/lib/anna-core-shared-lib/services/anna-global-config.service.ts +170 -0
  45. package/src/lib/anna-core-shared-lib/services/anna-sort.service.ts +179 -0
  46. package/src/lib/anna-core.module.ts +99 -0
  47. package/src/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.html +46 -0
  48. package/src/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.scss +153 -0
  49. package/src/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.spec.ts +24 -0
  50. package/src/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.ts +106 -0
  51. package/src/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.html +129 -0
  52. package/src/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.scss +275 -0
  53. package/src/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.spec.ts +24 -0
  54. package/src/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.ts +412 -0
  55. package/src/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.html +920 -0
  56. package/src/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.scss +596 -0
  57. package/src/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.spec.ts +25 -0
  58. package/src/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.ts +2015 -0
  59. package/src/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.html +10 -0
  60. package/src/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.scss +1 -0
  61. package/src/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.spec.ts +24 -0
  62. package/src/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.ts +70 -0
  63. package/src/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.html +13 -0
  64. package/src/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.scss +88 -0
  65. package/src/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.spec.ts +25 -0
  66. package/src/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.ts +460 -0
  67. package/src/lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/anna-fixed-row-size-table-virtual-scroll-strategy.directive.ts +237 -0
  68. package/{lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/index.d.ts → src/lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/index.ts} +0 -0
  69. package/src/lib/anna-generic-table-lib/directives/anna-virtual-table/anna-virtual-table.directive.ts +204 -0
  70. package/{lib/anna-generic-table-lib/directives/anna-virtual-table/index.d.ts → src/lib/anna-generic-table-lib/directives/anna-virtual-table/index.ts} +0 -0
  71. package/{public-api.d.ts → src/public-api.ts} +28 -0
  72. package/src/test.ts +27 -0
  73. package/tsconfig.lib.json +19 -0
  74. package/tsconfig.lib.prod.json +10 -0
  75. package/tsconfig.spec.json +17 -0
  76. package/annalib-anna-core.d.ts +0 -5
  77. package/esm2020/annalib-anna-core.mjs +0 -5
  78. package/esm2020/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.mjs +0 -15
  79. package/esm2020/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.mjs +0 -35
  80. package/esm2020/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.mjs +0 -15
  81. package/esm2020/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.mjs +0 -22
  82. package/esm2020/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.mjs +0 -15
  83. package/esm2020/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.mjs +0 -21
  84. package/esm2020/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.mjs +0 -15
  85. package/esm2020/lib/anna-core-shared-lib/constants/shared.constant.mjs +0 -34
  86. package/esm2020/lib/anna-core-shared-lib/directives/show-ellipsis-text/show-ellipsis-text.directive.mjs +0 -27
  87. package/esm2020/lib/anna-core-shared-lib/models/anna-generic-data-type.model.mjs +0 -2
  88. package/esm2020/lib/anna-core-shared-lib/models/anna-global-dropdown-config.model.mjs +0 -2
  89. package/esm2020/lib/anna-core-shared-lib/models/anna-non-editable-gt-models.mjs +0 -3
  90. package/esm2020/lib/anna-core-shared-lib/models/anna-sort.model.mjs +0 -2
  91. package/esm2020/lib/anna-core-shared-lib/models/anna-tooltip.model.mjs +0 -30
  92. package/esm2020/lib/anna-core-shared-lib/pipes/annaFilterSearchedText.pipe.mjs +0 -31
  93. package/esm2020/lib/anna-core-shared-lib/services/anna-date-time-format.service.mjs +0 -190
  94. package/esm2020/lib/anna-core-shared-lib/services/anna-filter.service.mjs +0 -419
  95. package/esm2020/lib/anna-core-shared-lib/services/anna-generic-table.service.mjs +0 -48
  96. package/esm2020/lib/anna-core-shared-lib/services/anna-global-config.service.mjs +0 -133
  97. package/esm2020/lib/anna-core-shared-lib/services/anna-sort.service.mjs +0 -147
  98. package/esm2020/lib/anna-core.module.mjs +0 -156
  99. package/esm2020/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.mjs +0 -100
  100. package/esm2020/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.mjs +0 -362
  101. package/esm2020/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.mjs +0 -1684
  102. package/esm2020/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.mjs +0 -67
  103. package/esm2020/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.mjs +0 -357
  104. package/esm2020/lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/anna-fixed-row-size-table-virtual-scroll-strategy.directive.mjs +0 -189
  105. package/esm2020/lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/index.mjs +0 -2
  106. package/esm2020/lib/anna-generic-table-lib/directives/anna-virtual-table/anna-virtual-table.directive.mjs +0 -178
  107. package/esm2020/lib/anna-generic-table-lib/directives/anna-virtual-table/index.mjs +0 -2
  108. package/esm2020/public-api.mjs +0 -44
  109. package/fesm2015/annalib-anna-core.mjs +0 -4160
  110. package/fesm2015/annalib-anna-core.mjs.map +0 -1
  111. package/fesm2020/annalib-anna-core.mjs +0 -4157
  112. package/fesm2020/annalib-anna-core.mjs.map +0 -1
  113. package/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.d.ts +0 -8
  114. package/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.d.ts +0 -16
  115. package/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.d.ts +0 -8
  116. package/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.d.ts +0 -11
  117. package/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.d.ts +0 -8
  118. package/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.d.ts +0 -11
  119. package/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.d.ts +0 -8
  120. package/lib/anna-core-shared-lib/constants/shared.constant.d.ts +0 -32
  121. package/lib/anna-core-shared-lib/directives/show-ellipsis-text/show-ellipsis-text.directive.d.ts +0 -9
  122. package/lib/anna-core-shared-lib/models/anna-generic-data-type.model.d.ts +0 -12
  123. package/lib/anna-core-shared-lib/models/anna-sort.model.d.ts +0 -6
  124. package/lib/anna-core-shared-lib/models/anna-tooltip.model.d.ts +0 -25
  125. package/lib/anna-core-shared-lib/pipes/annaFilterSearchedText.pipe.d.ts +0 -9
  126. package/lib/anna-core-shared-lib/services/anna-date-time-format.service.d.ts +0 -26
  127. package/lib/anna-core-shared-lib/services/anna-filter.service.d.ts +0 -73
  128. package/lib/anna-core-shared-lib/services/anna-generic-table.service.d.ts +0 -14
  129. package/lib/anna-core-shared-lib/services/anna-global-config.service.d.ts +0 -21
  130. package/lib/anna-core-shared-lib/services/anna-sort.service.d.ts +0 -16
  131. package/lib/anna-core.module.d.ts +0 -32
  132. package/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.d.ts +0 -34
  133. package/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.d.ts +0 -70
  134. package/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.d.ts +0 -267
  135. package/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.d.ts +0 -17
  136. package/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.d.ts +0 -141
  137. package/lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/anna-fixed-row-size-table-virtual-scroll-strategy.directive.d.ts +0 -89
  138. package/lib/anna-generic-table-lib/directives/anna-virtual-table/anna-virtual-table.directive.d.ts +0 -45
@@ -0,0 +1,2015 @@
1
+
2
+ // Angular import statements
3
+ import { Component, OnInit, Input, ViewChildren, QueryList, Output, EventEmitter, SimpleChanges, OnChanges, ChangeDetectorRef, ElementRef, AfterViewChecked, ChangeDetectionStrategy } from '@angular/core';
4
+
5
+ // Third party import statements
6
+ import moment from "moment";
7
+ import { Options } from '@angular-slider/ngx-slider';
8
+ import { cloneDeep, isEqual, map, uniq, sortBy } from "lodash-es";
9
+
10
+
11
+ //sub-entries of anna lib import statement
12
+ import { IGtGeneralConfig, IGtTableHeader, IHeaderInfo, ITotalRowInfo } from '../../../anna-core-shared-lib/models/anna-non-editable-gt-models';
13
+ import { AnnaDateTimeFormatService, NgbDateType } from '../../../anna-core-shared-lib/services/anna-date-time-format.service';
14
+ import { IWeekCalendar } from '../../../anna-core-shared-lib/models/anna-global-dropdown-config.model';
15
+ import { GtColumnIconEmittedData, SellerGroupHierarchy } from '../../../anna-core-shared-lib/models/anna-generic-data-type.model';
16
+ import { SortType } from '../../../anna-core-shared-lib/models/anna-sort.model';
17
+ import { radioButtonModel, TooltipModel } from '../../../anna-core-shared-lib/models/anna-tooltip.model';
18
+ import { AnnaSortService } from '../../../anna-core-shared-lib/services/anna-sort.service';
19
+ import { AnnaFilterService } from '../../../anna-core-shared-lib/services/anna-filter.service';
20
+ import { AnnaGenericTableService } from '../../../anna-core-shared-lib/services/anna-generic-table.service';
21
+
22
+
23
+ @Component({
24
+ selector: 'anna-core-non-editable-generic-table-lib',
25
+ templateUrl: './anna-non-editable-generic-table.component.html',
26
+ styleUrls: ['./anna-non-editable-generic-table.component.scss'],
27
+ changeDetection: ChangeDetectionStrategy.OnPush
28
+ })
29
+ export class AnnaNonEditableGenericTableComponent implements OnInit, OnChanges, AfterViewChecked {
30
+
31
+ @Input() showSkeletonLoading: boolean;
32
+ @Input() tableHeaders: IGtTableHeader[];
33
+ @Input() tableData: any[];
34
+ @Input() clonedTableData: any[];
35
+ @Input() numberOfSkeletonRows: number[];
36
+ @Input() numberOfSkeletonColumns: number[][];
37
+ @Input() gtGeneralConfig: IGtGeneralConfig;
38
+ @Input() totalRowInfo?: ITotalRowInfo[];
39
+ @Input() gtDimension: { rowHeight: number, tableHeight: string, headerHeight: number };
40
+ @Input() tableClass: string;
41
+ @Input() maximumRowsWhichCanBeRenderedWithoutScroll: number = 5;
42
+ @Input() limit: number = 30;
43
+ @Input() includeBorderInTableHeight: boolean = true;
44
+ @Input() downloadInProgress: boolean;
45
+ @Input() percentDone: number;
46
+
47
+ @Output() toggleCheckbox = new EventEmitter();
48
+ @Output() toggleRowCheckbox = new EventEmitter();
49
+ @Output() toggleHeaderCheckbox = new EventEmitter();
50
+ @Output() undoIconClicked = new EventEmitter();
51
+ @Output() filterAppliedToTable = new EventEmitter();
52
+ @Output() sortingAppliedToTable = new EventEmitter();
53
+ @Output() rowClicked = new EventEmitter();
54
+ @Output() radioButtonSelected = new EventEmitter();
55
+ @Output() columnFilterOpened = new EventEmitter();
56
+ @Output() columnFilterClosed = new EventEmitter();
57
+ @Output() gtIconClicked = new EventEmitter();
58
+ @Output() gtSVGIconClicked = new EventEmitter();
59
+ @Output() gtTextActionClicked = new EventEmitter();
60
+ @Output() gtViewDetailClicked = new EventEmitter();
61
+ @Output() downloadSpotDetails = new EventEmitter();
62
+
63
+
64
+ tableDataWrapper: any[];
65
+ rowChecked: boolean;
66
+ isAllRowsChecked: boolean;
67
+ noDataWidth: string = "55%";
68
+ markedForCreditStatus: string;
69
+ markedForMGStatus: string;
70
+
71
+ //Sort and Filter
72
+ toolTipdata: any;
73
+ tempTooltipData: any;
74
+ tooltipRadioTextMap: Map<any, any>;
75
+ filterTabObjects: any[];
76
+ tooltip: any;
77
+ clonedTooltipData: any;
78
+ clonedTooltipSelectedMapData: any;
79
+ searchBar: string;
80
+ disableClearAllBtn: boolean = true;
81
+ disableColumnClearAllBtn: boolean = true;
82
+ allSelected = 0;
83
+ showAll: boolean;
84
+ disableCheckboxApply: boolean;
85
+ disableSliderApplyButton: boolean;
86
+ disableTimeApplyButton: boolean;
87
+
88
+ // Slider Filter
89
+ sliderMinValue: number;
90
+ sliderMaxValue: number;
91
+ options: Options = {
92
+ floor: 0,
93
+ ceil: 0,
94
+ step: 0.1
95
+ };
96
+ sliderValue: { min: number, max: number };
97
+ sliderFilterTextBoxStep: string;
98
+ sliderEnteredMinValue: number;
99
+ sliderEnteredMaxValue: number;
100
+
101
+ // Calendar Filter
102
+ calendarMinEnabledDate: NgbDateType;
103
+ calendarMaxEnabledDate: NgbDateType;
104
+ selectedMinDate: NgbDateType;
105
+ selectedMaxDate: NgbDateType;
106
+
107
+ //Week Filter
108
+ multiWeekPickerConfig: IWeekCalendar;
109
+
110
+ //Time Filter
111
+ selectedFromTime: any[];
112
+ selectedToTime: any[];
113
+ clonedSelectedFromTime: any;
114
+ clonedSelectedToTime: any;
115
+ disableTimeFilterApplyBtn: boolean;
116
+ tableColumns: string[] = [];
117
+ totalRowColumns: string[] = null;
118
+ showMultiTimeCheckbox: boolean;
119
+ showZeroTimeCheckbox: boolean;
120
+ showEnterTimeCheckbox: boolean;
121
+ multiTimeCheckboxChecked: boolean;
122
+ zeroTimeCheckboxChecked: boolean;
123
+ enterTimeCheckboxChecked: boolean;
124
+ bindValueFuncCalled: boolean;
125
+
126
+ hierarchyTooltip: { open: () => void; close: () => void; };
127
+ sellerGroupHierarchy: SellerGroupHierarchy[];
128
+ showFilterTooltipTabs: boolean; //Change the Name
129
+
130
+ isScrolledLeft: boolean = false;
131
+ rowBorderWidth: number = 2;
132
+
133
+ showSortComponent: boolean = false;
134
+ showFilterComponent: boolean = false;
135
+ tempSortOrder: SortType = null;
136
+
137
+ tooltipOptions: TooltipModel[];
138
+ clonedTooltipOptions: TooltipModel[];
139
+ disableSelectAll: boolean;
140
+ disableClearAll: boolean;
141
+ searchItem: string;
142
+
143
+ disableCalendarApplyBtn: boolean;
144
+ calendarSelection: any = {fromDate: null , toDate: null};
145
+
146
+ showSliderMinValueError: boolean;
147
+ showSliderMaxValueError: boolean;
148
+ isMinTextBoxEmpty: boolean;
149
+ isMaxTextBoxEmpty: boolean;
150
+ selectedLabel: string;
151
+
152
+ startTimeHourErr: boolean;
153
+ startTimeMinErr: boolean;
154
+ endTimeHourErr: boolean;
155
+ endTimeMinErr: boolean;
156
+
157
+ sameTooltipClicked: boolean;
158
+ showNoDataToDisplay: boolean = false;
159
+ marginTop: string = "";
160
+ @ViewChildren('tableHeader') viewChildTableHeaders: QueryList<ElementRef>;
161
+
162
+ selectedCheckboxOptionsCount: number;
163
+ isFilterChanged: boolean;
164
+ isSortChanged: boolean;
165
+ isDifferenceLessThan25Percent: boolean;
166
+ incorrectSliderInput: boolean;
167
+ start: number = 0;
168
+ end: number = this.limit + this.start;
169
+ renderedData: any[];
170
+ selectedInventoryIdForDownload: number;
171
+ selectedDemographicForDownload: any;
172
+ selectedRowTypeForDownload: string;
173
+ heightOfCheckboxTooltipFilter: number;
174
+
175
+ constructor(
176
+ private cdRef: ChangeDetectorRef,
177
+ private annaSortService: AnnaSortService,
178
+ public annaDateTimeFormatService: AnnaDateTimeFormatService,
179
+ public annaFilterService: AnnaFilterService,
180
+ private annaGenericTableService: AnnaGenericTableService
181
+ ) {
182
+ this.setTooltipRadioNames();
183
+ }
184
+
185
+ ngAfterViewChecked(): void {
186
+ if(this.gtGeneralConfig.component && this.gtGeneralConfig.component.includes("ORDER_LISTING") || this.gtGeneralConfig.component == "DRRLISTING"){
187
+ this.setMarginLeftForFilterIcon();
188
+ }
189
+ }
190
+
191
+ ngOnInit() {
192
+ }
193
+
194
+ ngOnChanges(changes: SimpleChanges) {
195
+ if (this.showSkeletonLoading) {
196
+ this.tableData = this.numberOfSkeletonColumns;
197
+ this.renderedData = this.numberOfSkeletonColumns;
198
+ this.annaFilterService.initialValueMap = new Map();
199
+ }
200
+ else {
201
+ this.setInitialRowsForTable();
202
+ this.disableEnableEachColumnTooltipIcon();
203
+ this.tableColumns = this.tableHeaders.filter(x => x.visible).map(x => x.headerInfo[0].objectKey);
204
+ if(this.tableData && this.tableData.length == 0){
205
+ this.tableData = Array(2).fill(0);
206
+ this.renderedData = cloneDeep(this.tableData);
207
+ this.marginTop = (- this.gtDimension.rowHeight - (this.gtDimension.rowHeight/2)) + 'px';
208
+ this.showNoDataToDisplay = true;
209
+ }
210
+ else{
211
+ this.showNoDataToDisplay = false;
212
+ }
213
+
214
+ this.showSkeletonLoading = false;
215
+ }
216
+
217
+ //setting table column here as well because while showing skeleton loader, we should show table headers.
218
+ if (changes['tableHeaders'] && !isEqual(changes['tableHeaders'].currentValue, changes['tableHeaders'].previousValue)) {
219
+ this.tableColumns = this.tableHeaders.filter(x => x.visible).map(x => x.headerInfo[0].objectKey);
220
+ this.annaSortService.columnSortState = new Map();
221
+ this.setColumnSortStateMap();
222
+ this.setActiveStateObject();
223
+ }
224
+
225
+ if (changes['totalRowInfo'] && changes['totalRowInfo'].currentValue) {
226
+ this.totalRowColumns = this.totalRowInfo.map(x => x.colName);
227
+ }
228
+ this.cdRef.detectChanges();
229
+ }
230
+
231
+
232
+ trackByFn(index: number) {
233
+ return index;
234
+ }
235
+
236
+ setTooltipRadioNames() {
237
+ this.tooltipRadioTextMap = new Map();
238
+ this.tooltipRadioTextMap.set("StartTimeForFilter", "Start Time");
239
+ this.tooltipRadioTextMap.set("EndTimeForFilter", "End Time");
240
+ this.tooltipRadioTextMap.set("start_time_for_filter", "Start Time");
241
+ this.tooltipRadioTextMap.set("end_time_for_filter", "End Time");
242
+ this.tooltipRadioTextMap.set("primaryAEName", "Primary AE");
243
+ this.tooltipRadioTextMap.set("region", "Region");
244
+ this.tooltipRadioTextMap.set("agencyName", "Agency");
245
+ this.tooltipRadioTextMap.set("location", "Location");
246
+ this.tooltipRadioTextMap.set("advertiserName", "Advertiser");
247
+ this.tooltipRadioTextMap.set("productCode", "Product Category");
248
+ this.tooltipRadioTextMap.set("flightStartDate", "Start Date");
249
+ this.tooltipRadioTextMap.set("flightEndDate", "End Date");
250
+ this.tooltipRadioTextMap.set("orderIdAndRevNumber", "STN Order#-Rev#");
251
+ this.tooltipRadioTextMap.set("alternateOrderId", "Alt/Rep Order #");
252
+ this.tooltipRadioTextMap.set("grp", "GRP");
253
+ this.tooltipRadioTextMap.set("cpp", "CPP");
254
+ this.tooltipRadioTextMap.set("imps", "IMPS");
255
+ this.tooltipRadioTextMap.set("cpm", "CPM");
256
+ this.tooltipRadioTextMap.set("offeredMGs", "Offered MG");
257
+ this.tooltipRadioTextMap.set("outstandingPE", "O/S PE");
258
+ this.tooltipRadioTextMap.set("offeredADUs", "Offered ADUs");
259
+ this.tooltipRadioTextMap.set("udDeficitValue", "O/S Aud Delta");
260
+ this.tooltipRadioTextMap.set("startEndTimeMulti", "Time");
261
+ this.tooltipRadioTextMap.set("bookedValue", "Booked");
262
+ this.tooltipRadioTextMap.set("bookedSpots", "Spots");
263
+ this.tooltipRadioTextMap.set("userChanges", "User Changes");
264
+ this.tooltipRadioTextMap.set("buyerChanges", "Buyer Changes");
265
+ this.tooltipRadioTextMap.set("userMG", "User MG");
266
+ this.tooltipRadioTextMap.set("userADUs", "User ADUs");
267
+ this.tooltipRadioTextMap.set("inventoryCode", "Inventory Code");
268
+ this.tooltipRadioTextMap.set("program", "Program");
269
+ this.tooltipRadioTextMap.set("agency", "Agency");
270
+ this.tooltipRadioTextMap.set("advertiser", "Advertiser");
271
+ this.tooltipRadioTextMap.set("startDate", "Start Date");
272
+ this.tooltipRadioTextMap.set("endDate", "End Date");
273
+ this.tooltipRadioTextMap.set("rcvPreempt", "$ Madegood PEs");
274
+ this.tooltipRadioTextMap.set("osPreempt", "$ O/S PEs");
275
+ this.tooltipRadioTextMap.set("rcvUnderDly", "Recovered UD");
276
+ this.tooltipRadioTextMap.set("osUnderDly", "O/s Under Dly");
277
+ this.tooltipRadioTextMap.set("primaryAe", "Primary AE");
278
+ this.tooltipRadioTextMap.set("region", "Region");
279
+ this.tooltipRadioTextMap.set("revCode1", "Rev code 1");
280
+ this.tooltipRadioTextMap.set("orderNoRevNo", "STN Order#-Rev#");
281
+ this.tooltipRadioTextMap.set("revCode2", "Rev code 2");
282
+ this.tooltipRadioTextMap.set("revCode3", "Rev code 3");
283
+ this.tooltipRadioTextMap.set("booked", "$ Booked");
284
+ this.tooltipRadioTextMap.set("spots", "Spots");
285
+ this.tooltipRadioTextMap.set("postedAudPercent", "Posted %");
286
+ this.tooltipRadioTextMap.set("revision", "Revision");
287
+ this.tooltipRadioTextMap.set("buyerOrderId", "ALT/REP Order#");
288
+ this.tooltipRadioTextMap.set("demo","Demo");
289
+ this.tooltipRadioTextMap.set("postedAdu","$ Posted ADUs");
290
+ this.tooltipRadioTextMap.set("scheduledAdu","$ Scheduled ADUs");
291
+ this.tooltipRadioTextMap.set("audienceDeficit","$ O/S Audience");
292
+ this.tooltipRadioTextMap.set("postedAudPercent","Posted Audience %");
293
+ this.tooltipRadioTextMap.set("potentialUnitsValue","POT Units");
294
+ this.tooltipRadioTextMap.set("bookedUnitsValue","Booked Units");
295
+ this.tooltipRadioTextMap.set("bookedAmountWithZeroRatingValue","Total $ Booked");
296
+ this.tooltipRadioTextMap.set("bookedAmountPercentageWithZeroRatingValue","% Against All Demos");
297
+ this.tooltipRadioTextMap.set("bookedAmountWithoutZeroRatingValue","$Booked With Imps(’000)");
298
+ this.tooltipRadioTextMap.set("bookedAmountPercentageWithoutZeroRatingValue", "% Against All Demos");
299
+
300
+ this.tooltipRadioTextMap.set("totalBookedAmountValue","Total $Booked");
301
+ this.tooltipRadioTextMap.set("averageUnitRateValue","AUR");
302
+ this.tooltipRadioTextMap.set("totalBookedAmountWithRatingValue", "$Booked With Rating");
303
+ this.tooltipRadioTextMap.set("averageUnitRateWithRatingValue", "AUR With Rating");
304
+
305
+ this.tooltipRadioTextMap.set("totalBookedAmountWithImpressionValue", "$Booked With IMPS");
306
+ this.tooltipRadioTextMap.set("averageUnitRateWithImpressionValue", "AUR With IMPS");
307
+
308
+ this.tooltipRadioTextMap.set("bookedUnitsWithRatingValue", "Booked Units With Rating");
309
+ this.tooltipRadioTextMap.set("postedUnitsWithRatingValue", "Posted Units With Rating");
310
+
311
+ this.tooltipRadioTextMap.set("bookedUnitsWithImpressionValue", "Booked Units With IMPS");
312
+ this.tooltipRadioTextMap.set("postedUnitsWithImpressionValue", "Posted Units With IMPS");
313
+
314
+ this.tooltipRadioTextMap.set("bookedRatings", "Booked Rating");
315
+ this.tooltipRadioTextMap.set("postedRatings", "Posted Rating");
316
+
317
+ this.tooltipRadioTextMap.set("bookedImpressions", "Booked IMPS");
318
+ this.tooltipRadioTextMap.set("postedImpressions", "Posted IMPS");
319
+
320
+ this.tooltipRadioTextMap.set("bookedAverageRating", "Booked AVG Rating");
321
+ this.tooltipRadioTextMap.set("postedAverageRating", "Posted AVG Rating");
322
+
323
+ this.tooltipRadioTextMap.set("bookedAverageImpression", "Booked AVG IMPS");
324
+ this.tooltipRadioTextMap.set("postedAverageImpression", "Posted AVG IMPS");
325
+
326
+ this.tooltipRadioTextMap.set("bookedCppValue", "Booked CPP");
327
+ this.tooltipRadioTextMap.set("bookedEffectiveCppValue", "Effective CPP");
328
+
329
+ this.tooltipRadioTextMap.set("bookedCpmValue", "Booked CPM");
330
+ this.tooltipRadioTextMap.set("bookedEffectiveCpmValue", "Effective CPM");
331
+
332
+ this.tooltipRadioTextMap.set("orderSource","Order Source");
333
+ this.tooltipRadioTextMap.set("orderCategory","Category");
334
+ this.tooltipRadioTextMap.set("cashOrTrade","C/T");
335
+
336
+ }
337
+
338
+ generateTableDataWrapper() {
339
+ this.showSkeletonLoading = true;
340
+ this.tableDataWrapper = [];
341
+ let rowObject: any;
342
+ let columnName: string;
343
+ let columnObject: { [x: string]: any; };
344
+ let columnObjectKey;
345
+ let keysUsedForTableDisplay: string[];
346
+ let keysUsedForColumn: string[];
347
+ let additionalInfoObject: { [x: string]: any; };
348
+ let additionalKeys;
349
+ this.tableData.forEach((obj: { [x: string]: any; }) => {
350
+ rowObject = {};
351
+ keysUsedForTableDisplay = [];
352
+ for (var colNum in this.tableHeaders) {
353
+ columnObject = {};
354
+ if (!this.tableHeaders[colNum].visible) {
355
+ continue;
356
+ }
357
+ columnName = "";
358
+ keysUsedForColumn = [];
359
+ this.tableHeaders[colNum].headerInfo.forEach((header) => {
360
+ if (header.typeOfBodyData === "STRING") {
361
+ columnObjectKey = header.objectKey;
362
+ columnObject[columnObjectKey] = obj[columnObjectKey];
363
+ keysUsedForTableDisplay.push(columnObjectKey);
364
+ keysUsedForColumn.push(columnObjectKey);
365
+ }
366
+ else if (header.typeOfBodyData === "ICON") {
367
+ columnObjectKey = header.typeOfBodyData;
368
+ columnObject[columnObjectKey] = obj[header.objectKey];
369
+ keysUsedForColumn.push(header.objectKey);
370
+ }
371
+ else if (header.typeOfBodyData === "CHECKBOX") {
372
+ columnObjectKey = header.typeOfBodyData;
373
+ columnObject[columnObjectKey] = obj[header.objectKey];
374
+ keysUsedForColumn.push(header.objectKey);
375
+ }
376
+ })
377
+ for (var i = 0; i < keysUsedForColumn.length; i++) {
378
+ columnName += keysUsedForColumn[i];
379
+ if (i !== keysUsedForColumn.length - 1) {
380
+ columnName += ',';
381
+ }
382
+ }
383
+ rowObject[columnName] = columnObject;
384
+ }
385
+ additionalInfoObject = {};
386
+ additionalKeys = Object.keys(obj).filter(key => !keysUsedForTableDisplay.includes(key));
387
+ additionalKeys.forEach(key => {
388
+ additionalInfoObject[key] = obj[key];
389
+ })
390
+ rowObject.AdditionalInfo = additionalInfoObject;
391
+ this.tableDataWrapper.push(rowObject);
392
+ })
393
+ this.tableData = this.tableDataWrapper;
394
+ this.showSkeletonLoading = false;
395
+ }
396
+
397
+
398
+ selectOrUnselectCheckbox(rowData: any, columnKeys: any, isCheckboxSelected: any) {
399
+ this.toggleCheckbox.emit({ rowData, columnKeys, isCheckboxSelected });
400
+ }
401
+
402
+ selectUnselectAllRows() {
403
+ this.toggleHeaderCheckbox.emit();
404
+ }
405
+
406
+ selectUnselectRow(rowData: any) {
407
+ this.toggleRowCheckbox.emit(rowData);
408
+ }
409
+
410
+ undoCreditedSpot(data: any) {
411
+ this.undoIconClicked.emit({ data, mgOrCredit: "Credit" });
412
+ }
413
+
414
+ undoMgSpot(data: any) {
415
+ this.undoIconClicked.emit({ data, mgOrCredit: "MakeGood" });
416
+ }
417
+
418
+ //Sort and Filter Logic begins!
419
+ closeTooltip() {
420
+ if (this.tooltip && this.tooltip.isOpen()) {
421
+ this.tooltip.close();
422
+ }
423
+ this.tooltip = null;
424
+ this.disableCheckboxApply = false;
425
+ if (!this.bindValueFuncCalled) {
426
+ this.columnFilterClosed.emit();
427
+ }
428
+ }
429
+
430
+ isTooltipActive(header: any[]) {
431
+ return this.annaFilterService.isTooltipActive(header,this.annaSortService.columnSortState);
432
+ }
433
+
434
+ bindTheValueToToolTip(tooltip: any, header: IHeaderInfo) {
435
+
436
+ this.bindValueFuncCalled = true;
437
+ let containerToScroll;
438
+ if (this.gtGeneralConfig.component === "SPOTDETAILS" || this.gtGeneralConfig.component === "DRRLISTING") {
439
+ containerToScroll = document.getElementsByClassName("scrollable-container")[0];
440
+ var mediaQuery = window.matchMedia("(max-width: 1366px)");
441
+ if (mediaQuery.matches) {
442
+ containerToScroll.scroll(0, this.gtGeneralConfig.verticalScrollOffsetForFilterTooltip);
443
+ }
444
+ }
445
+
446
+ // if same tooltip opened close it
447
+ if (tooltip == this.tooltip) {
448
+ this.bindValueFuncCalled = false;
449
+ this.closeTooltip();
450
+ }
451
+ else {
452
+ let enabledHeaders: any[] = [];
453
+ this.checkIfUniqueValuePresentForTheHeader(header,enabledHeaders);
454
+ this.openTooltip(tooltip, enabledHeaders,header);
455
+
456
+ if (window.innerWidth < 1500 && window.innerHeight < 768 && !this.annaFilterService.sliderSet.has(header.filterSortObjectKeys[0])) {
457
+ this.columnFilterOpened.emit();
458
+ }
459
+
460
+ this.showFilterTooltipTabs = header.filterSortObjectKeys.length > 1;
461
+ let activeTab = this.filterTabObjects[0];
462
+ this.populateTooltipDataBasedOnSelectedRadio(activeTab);
463
+ this.bindValueFuncCalled = false;
464
+ }
465
+ }
466
+
467
+ checkIfUniqueValuePresentForTheHeader(header: IHeaderInfo, enabledHeaders: any[]){
468
+ header.filterSortObjectKeys.forEach((item: string | number) => {
469
+ if(item == "period"){
470
+ let uniqStartDate = uniq(this.tableData.map((u: { [x: string]: any; }) => u["startDate"]));
471
+ let uniqEndDate = uniq(this.tableData.map((u:{ [x: string]: any; }) => u["endDate"]));
472
+ if(uniqStartDate.length > 1 || uniqEndDate.length > 1 || this.isTooltipActive([item])){
473
+ enabledHeaders.push(item);
474
+ }
475
+ }
476
+ else if(uniq(this.tableData.map((u:{ [x: string]: any; }) => u[item])).length > 1 || this.isTooltipActive([item])){
477
+ enabledHeaders.push(item);
478
+ }
479
+ });
480
+ }
481
+
482
+ openTooltip(tooltip: any,header: any, columnHeader: IHeaderInfo) {
483
+ this.closeTooltip();
484
+ this.tooltip = tooltip;
485
+ this.tooltip.open();
486
+ //convert key into the header
487
+ this.filterTabObjects = header.map((key: string,index: number) => {
488
+ let value = this.tooltipRadioTextMap.has(key)
489
+ ? this.tooltipRadioTextMap.get(key)
490
+ : key; //change to display name
491
+ return new radioButtonModel(key, value, columnHeader.isSortRequired[index], columnHeader.isFilterRequired[index]);
492
+ });
493
+ }
494
+
495
+ clearColumnFilter() {
496
+ this.annaFilterService.clearColumnFilter();
497
+ this.closeTooltip();
498
+ this.tableData = cloneDeep(this.annaFilterService.filterData(this.clonedTableData, ""));
499
+ this.annaSortService.noSortingAppliedData = this.tableData;
500
+ this.checkIfSortingIsApplied();
501
+ this.filterAppliedToTable.emit(this.tableData);
502
+ this.disableEnableEachColumnTooltipIcon();
503
+ this.annaFilterService.updateStateOfTheCurrentFilterTab(this.annaSortService.columnSortState);
504
+ }
505
+
506
+ populateTooltipDataBasedOnSelectedRadio(activeTab: radioButtonModel) {
507
+
508
+ let header = activeTab.key;
509
+ this.selectedLabel = activeTab.label;
510
+ this.showSortComponent = false;
511
+ this.showFilterComponent = false;
512
+ this.searchItem = null;
513
+
514
+ this.showSortComponent = activeTab.isSortRequired;
515
+ this.showFilterComponent = activeTab.isFilterRequired;
516
+ this.tempSortOrder = null;
517
+ this.isFilterChanged = false;
518
+ this.isSortChanged = false;
519
+
520
+ this.annaFilterService.selectedRadio = header;
521
+ this.disableActiveFilterClearButton();
522
+
523
+ this.createFilterTooltipData(header);
524
+
525
+ }
526
+
527
+ createFilterTooltipData(header: string){
528
+ if(this.showFilterComponent){
529
+ this.disableSliderApplyButton = this.disableCheckboxApply = true;
530
+ this.disableCalendarApplyBtn = this.disableTimeFilterApplyBtn = true;
531
+
532
+ if (this.annaFilterService.calendarSet.has(header)) {
533
+ this.getCalendarData();
534
+ } else if (this.annaFilterService.sliderSet.has(header)) {
535
+ this.getSliderData(header);
536
+ } else if (this.annaFilterService.timeSet.has(header)) {
537
+ this.getTimeFilterData(header);
538
+ } else {
539
+ this.getCheckboxData(header);
540
+ }
541
+ }
542
+ else if(this.showSortComponent){
543
+ this.disableSliderApplyButton = this.disableCheckboxApply = true;
544
+ this.disableCalendarApplyBtn = this.disableTimeFilterApplyBtn = true;
545
+ }
546
+ }
547
+
548
+ disableActiveFilterClearButton(){
549
+ let selectedFilterSet = new Set(this.annaFilterService.appliedFiltersArray);
550
+ let isSortPresent = (this.annaSortService.columnSortState.size > 0 && this.annaSortService.columnSortState.get(this.annaFilterService.selectedRadio) != "DEFAULT");
551
+ this.disableColumnClearAllBtn = selectedFilterSet.has(this.annaFilterService.selectedRadio) || isSortPresent ? false : true;
552
+ }
553
+
554
+ getSliderData(header: string) {
555
+
556
+ this.createOptionsForSlider(header);
557
+ this.setSelectedRangeForSlider(header);
558
+ }
559
+
560
+ createOptionsForSlider(header: string){
561
+
562
+ let translateFunc;
563
+ this.incorrectSliderInput = false;
564
+ this.sliderEnteredMaxValue = this.sliderEnteredMinValue = null;
565
+ this.showSliderMinValueError = this.showSliderMaxValueError = this.isMinTextBoxEmpty = this.isMaxTextBoxEmpty = false;
566
+
567
+ if (this.annaFilterService.sliderCurrencySet.has(header)) {
568
+ translateFunc = "currency";
569
+ }
570
+ else if(header == "postedAudPercent"){
571
+ translateFunc = "percent";
572
+ }
573
+ else {
574
+ translateFunc = "normal";
575
+ }
576
+
577
+ let optionsData = this.annaFilterService.getFilterOptionsData(this.tableData, this.clonedTableData);
578
+ let minValue = this.annaFilterService.returnMaxAndMinValue(optionsData, header, true);
579
+ let maxValue = this.annaFilterService.returnMaxAndMinValue(optionsData, header, false);
580
+
581
+ let obj = this.annaFilterService.setOptionValues(minValue,maxValue);
582
+
583
+ if (translateFunc === "normal") {
584
+ obj.translate = this.annaFilterService.normalTranslateFunction;
585
+ } else if (translateFunc === "percent") {
586
+ obj.translate = this.annaFilterService.percentTranslateFunction;
587
+ } else if (translateFunc === "currency") {
588
+ obj.translate = this.annaFilterService.currencyTranslateFunction;
589
+ }
590
+
591
+ this.options = obj;
592
+ this.options.step = 1;
593
+ this.sliderFilterTextBoxStep = "1";
594
+ if (header !== "WeekNumber") {
595
+ this.options.step = 0.1;
596
+ this.sliderFilterTextBoxStep = "0.1";
597
+ }
598
+ }
599
+
600
+ setSelectedRangeForSlider(header: string){
601
+ if(this.annaFilterService.tooltipSelectedMap.has(header)){
602
+ let selectedObj = this.annaFilterService.tooltipSelectedMap.get(header);
603
+ this.sliderMinValue = selectedObj.min < this.options.floor ? this.options.floor : selectedObj.min;
604
+ this.sliderMaxValue = selectedObj.max < this.options.ceil ? selectedObj.max : this.options.ceil;
605
+ this.sliderEnteredMinValue = this.sliderMinValue;
606
+ this.sliderEnteredMaxValue = this.sliderMaxValue;
607
+ }
608
+ else{
609
+ this.sliderMinValue = this.options.floor;
610
+ this.sliderMaxValue = this.options.ceil;
611
+ }
612
+ this.sliderEnteredMinValue = this.sliderMinValue;
613
+ this.sliderEnteredMaxValue = this.sliderMaxValue;
614
+ }
615
+
616
+
617
+ getCheckboxData(header: string) {
618
+
619
+ let tooltipOptions = this.createListForCheckboxFilter(header);
620
+ let selectedItems = sortBy(tooltipOptions.filter(item => item.isSelected),"label");
621
+ let unselectedItems = sortBy(tooltipOptions.filter(item => !item.isSelected),"label");
622
+
623
+ this.clonedTooltipOptions = [...selectedItems, ...unselectedItems];
624
+
625
+ this.tooltipOptions = cloneDeep(this.clonedTooltipOptions);
626
+
627
+ let margin = 5;
628
+ let dataLength = this.tooltipOptions.length;
629
+ this.heightOfCheckboxTooltipFilter = dataLength > 6 ? 200 : ((26.03 * dataLength) + (margin * dataLength) + margin);
630
+
631
+ this.disableSelectAll = unselectedItems.length == 0;
632
+ this.disableClearAll = selectedItems.length == 0;
633
+ this.selectedCheckboxOptionsCount = selectedItems.length;
634
+ }
635
+
636
+ createListForCheckboxFilter(header: string){
637
+ let optionData = this.annaFilterService.getFilterOptionsData(this.tableData, this.clonedTableData);
638
+ let uniqOptionData = uniq(optionData.map(item => item[header]));
639
+ let tooltipOptions = uniqOptionData.map((item,index) => new TooltipModel(item,index+1));
640
+
641
+ this.selectUnselectListCheckbox(tooltipOptions,header);
642
+ let index = tooltipOptions.findIndex(item => item.value == null);
643
+
644
+ if(index != -1){
645
+ tooltipOptions[index].label = "(Blank)";
646
+ }
647
+
648
+ return tooltipOptions;
649
+ }
650
+
651
+ selectUnselectListCheckbox(tooltipOptions: TooltipModel[],header: string){
652
+
653
+ if(this.annaFilterService.tooltipSelectedMap.has(header)){
654
+ let selectedValueSet = new Set(this.annaFilterService.tooltipSelectedMap.get(header));
655
+ tooltipOptions.forEach(item => item.isSelected = selectedValueSet.has(item.value) ? true : false);
656
+ }
657
+ else{
658
+ tooltipOptions.forEach(item => item.isSelected = true);
659
+ }
660
+
661
+ }
662
+
663
+ getCalendarData() {
664
+ const parsingFormat = "MM/DD/YYYY";
665
+ let minMaxDate = this.createRangeForTheDateFilter();
666
+ this.selectRangeForTheDateFilter(minMaxDate, parsingFormat);
667
+ }
668
+
669
+ createRangeForTheDateFilter(){
670
+
671
+ let optionData = this.annaFilterService.getFilterOptionsData(this.tableData, this.clonedTableData);
672
+
673
+ let minMaxDate;
674
+ //When you want to use startDate and endDate combined as single column then use Period.
675
+ if(this.annaFilterService.selectedRadio == "period"){
676
+ minMaxDate = this.createStartEndDateRange(optionData);
677
+ }
678
+ else{
679
+ minMaxDate = this.annaFilterService.returnMinAndMaxDate(optionData, this.annaFilterService.selectedRadio);
680
+ }
681
+
682
+ return minMaxDate;
683
+
684
+ }
685
+
686
+ createStartEndDateRange(optionData: any[]){
687
+ let minStartDate = this.annaFilterService.returnMinAndMaxDate(optionData, "startDate");
688
+ let maxEndDate = this.annaFilterService.returnMinAndMaxDate(optionData,"endDate");
689
+ return [minStartDate[0],maxEndDate[1]];
690
+ }
691
+
692
+ selectRangeForTheDateFilter(minMaxDate: any[], parsingFormat: string){
693
+ this.calendarMinEnabledDate = this.annaDateTimeFormatService.convertToNgbDate(minMaxDate[0],parsingFormat);
694
+ this.calendarMaxEnabledDate = this.annaDateTimeFormatService.convertToNgbDate(minMaxDate[1],parsingFormat);
695
+
696
+
697
+ if(this.annaFilterService.tooltipSelectedMap.has(this.annaFilterService.selectedRadio)){
698
+ let selectedDateObj = this.annaFilterService.tooltipSelectedMap.get(this.annaFilterService.selectedRadio);
699
+
700
+ if(selectedDateObj.fromDate.isAfter(minMaxDate[0])){
701
+ this.selectedMinDate = this.annaDateTimeFormatService.convertToNgbDate(selectedDateObj.fromDate,parsingFormat);
702
+ }
703
+ else{
704
+ this.selectedMinDate = this.annaDateTimeFormatService.convertToNgbDate(minMaxDate[0],parsingFormat);
705
+ }
706
+
707
+ if(selectedDateObj.toDate.isAfter(minMaxDate[1])){
708
+ this.selectedMaxDate = this.annaDateTimeFormatService.convertToNgbDate(minMaxDate[1],parsingFormat);
709
+ }
710
+ else{
711
+ this.selectedMaxDate = this.annaDateTimeFormatService.convertToNgbDate(selectedDateObj.toDate,parsingFormat);
712
+ }
713
+
714
+ }
715
+ else{
716
+ this.selectedMinDate = cloneDeep(this.calendarMinEnabledDate);
717
+ this.selectedMaxDate = cloneDeep(this.calendarMaxEnabledDate);
718
+ }
719
+
720
+ this.calendarSelection.fromDate = cloneDeep(this.selectedMinDate);
721
+ this.calendarSelection.toDate = cloneDeep(this.selectedMaxDate);
722
+
723
+
724
+ }
725
+
726
+ getTimeFilterData(header: string): void {
727
+
728
+ this.startTimeHourErr = this.startTimeMinErr = this.endTimeHourErr = this.endTimeMinErr = false;
729
+
730
+ if (this.annaFilterService.tooltipSelectedMap.has(header)) {
731
+ this.selectedFromTime = this.annaFilterService.tooltipSelectedMap.get(header).fromTime;
732
+ this.selectedToTime = this.annaFilterService.tooltipSelectedMap.get(header).toTime;
733
+ } else {
734
+ this.setInitialValueMapForTimeFilter(header);
735
+ this.selectedFromTime = this.annaFilterService.initialValueMap.get(header).fromTime;
736
+ this.selectedToTime = this.annaFilterService.initialValueMap.get(header).toTime;
737
+ }
738
+
739
+ if(this.selectedFromTime != undefined || this.selectedToTime != undefined) {
740
+ this.selectedFromTime = this.annaDateTimeFormatService.formatToTwelveHrs(this.selectedFromTime, true);
741
+ this.selectedToTime = this.annaDateTimeFormatService.formatToTwelveHrs(this.selectedToTime, true);
742
+
743
+ this.clonedSelectedFromTime = cloneDeep(this.selectedFromTime);
744
+ this.clonedSelectedToTime = cloneDeep(this.selectedToTime);
745
+ }
746
+ else {
747
+ this.selectedFromTime = ["-", "-", "-"];
748
+ this.selectedToTime = ["-", "-", "-"];
749
+ }
750
+
751
+ if(this.gtGeneralConfig.component === "SPOTDETAILS" || this.gtGeneralConfig.component === "EXCLUDEINVENTORYPOPUP") {
752
+ this.setTimeFilterDataForComponentsOtherThanRatingsPage(header);
753
+ }
754
+ else if(this.gtGeneralConfig.component === "RATING"){
755
+ this.setTimeFilterDataForRatingPageComponent(header);
756
+ }
757
+ }
758
+
759
+ //Need to change this method
760
+ setTimeFilterDataForComponentsOtherThanRatingsPage(header: string){
761
+ this.showMultiTimeCheckbox = false;
762
+ this.showZeroTimeCheckbox = false;
763
+ this.showEnterTimeCheckbox = false;
764
+ this.multiTimeCheckboxChecked = false;
765
+ this.zeroTimeCheckboxChecked = false;
766
+ this.enterTimeCheckboxChecked = false;
767
+
768
+
769
+ let optionsData = this.annaFilterService.getFilterOptionsData(this.tableData, this.clonedTableData);
770
+ let selectedObj;
771
+
772
+ if(this.annaFilterService.tooltipSelectedMap.has(header)){
773
+ selectedObj = this.annaFilterService.tooltipSelectedMap.get(header);
774
+ }
775
+ else{
776
+ selectedObj = this.annaFilterService.initialValueMap.get(header);
777
+ }
778
+
779
+ if(optionsData.findIndex(obj => obj[header] == "0") != -1) {
780
+ this.showZeroTimeCheckbox = true;
781
+ this.zeroTimeCheckboxChecked = selectedObj.includeZeroTime;
782
+ }
783
+
784
+
785
+ if(optionsData.findIndex(obj => obj[header] == "<multi>") != -1) {
786
+ this.showMultiTimeCheckbox = true;
787
+ this.multiTimeCheckboxChecked = selectedObj.includeMulti;
788
+ }
789
+
790
+
791
+ if(this.showZeroTimeCheckbox || this.showMultiTimeCheckbox) {
792
+ this.showEnterTimeCheckbox = true;
793
+ }
794
+
795
+ if(optionsData.findIndex(obj => obj[header] != "<multi>" && obj[header] != "0") != -1) {
796
+ this.enterTimeCheckboxChecked = selectedObj.includeTimeRange;
797
+ }
798
+ }
799
+
800
+ setTimeFilterDataForRatingPageComponent(header: string){
801
+ this.showMultiTimeCheckbox = false;
802
+ this.showZeroTimeCheckbox = false;
803
+ this.showEnterTimeCheckbox = false;
804
+ this.multiTimeCheckboxChecked = false;
805
+ this.zeroTimeCheckboxChecked = false;
806
+ this.enterTimeCheckboxChecked = false;
807
+
808
+ let optionsData = this.annaFilterService.getFilterOptionsData(this.tableData, this.clonedTableData);
809
+ let selectedObj;
810
+
811
+ if(this.annaFilterService.tooltipSelectedMap.has(header)){
812
+ selectedObj = this.annaFilterService.tooltipSelectedMap.get(header);
813
+ }
814
+ else{
815
+ selectedObj = this.annaFilterService.initialValueMap.get(header);
816
+ }
817
+
818
+ if(optionsData.findIndex(obj => obj[header][0] == "0") != -1) {
819
+ this.showZeroTimeCheckbox = true;
820
+ this.zeroTimeCheckboxChecked = selectedObj.includeZeroTime;
821
+ }
822
+
823
+
824
+ if(optionsData.findIndex(obj => obj[header][0] == "<multi>") != -1) {
825
+ this.showMultiTimeCheckbox = true;
826
+ this.multiTimeCheckboxChecked = selectedObj.includeMulti;
827
+ }
828
+
829
+
830
+ if(this.showZeroTimeCheckbox || this.showMultiTimeCheckbox) {
831
+ this.showEnterTimeCheckbox = true;
832
+ }
833
+
834
+ if(optionsData.findIndex(obj => obj[header][0] != "<multi>" && obj[header][0] != "0") != -1) {
835
+ this.enterTimeCheckboxChecked = selectedObj.includeTimeRange;
836
+ }
837
+ }
838
+
839
+ selectOrUnselectMultiTimeCheckbox() {
840
+ this.multiTimeCheckboxChecked = !this.multiTimeCheckboxChecked;
841
+ this.disableTimeFilterApplyButton();
842
+ }
843
+
844
+ selectOrUnselectZeroTimeCheckbox() {
845
+ this.zeroTimeCheckboxChecked = !this.zeroTimeCheckboxChecked;
846
+ this.disableTimeFilterApplyButton();
847
+ }
848
+
849
+ selectOrUnselectEnterTimeCheckbox() {
850
+ this.enterTimeCheckboxChecked = !this.enterTimeCheckboxChecked;
851
+ this.disableTimeFilterApplyButton();
852
+ }
853
+
854
+
855
+ selectUnselectCheckbox(data: TooltipModel) {
856
+ data.isSelected = !data.isSelected;
857
+ let index = this.clonedTooltipOptions.findIndex(item => item.id == data.id);
858
+ this.clonedTooltipOptions[index].isSelected = data.isSelected;
859
+
860
+ let selectedItems = this.tooltipOptions.filter(item => item.isSelected);
861
+ let unselectedItems = this.tooltipOptions.filter(item => !item.isSelected);
862
+
863
+ this.disableClearAll = selectedItems.length == 0;
864
+ this.disableSelectAll = unselectedItems.length == 0;
865
+ this.selectedCheckboxOptionsCount = selectedItems.length;
866
+ this.disableCheckboxFilterApplyButton();
867
+ }
868
+
869
+ minValueChanged(val: string) {
870
+ if (val || val == '0') {
871
+ this.sliderEnteredMinValue = parseInt(val);
872
+ this.isMinTextBoxEmpty = false;
873
+ if (this.isMaxTextBoxEmpty) {
874
+ if (this.sliderEnteredMinValue > this.options.ceil) {
875
+ this.showSliderMinValueError = true;
876
+ this.disableSliderApplyButton = true;
877
+ this.incorrectSliderInput = true;
878
+ } else {
879
+ this.showSliderMinValueError = false;
880
+ this.showSliderMaxValueError = false;
881
+ this.disableSliderApplyButton = false;
882
+ this.incorrectSliderInput = false;
883
+ }
884
+ } else if (this.sliderEnteredMinValue > this.sliderEnteredMaxValue) {
885
+ if(this.isValueInRange(this.sliderEnteredMaxValue)){
886
+ this.showSliderMinValueError = true;
887
+ this.showSliderMaxValueError = false;
888
+ }
889
+ else{
890
+ this.showSliderMaxValueError = true;
891
+ if(this.isValueInRange(this.sliderEnteredMinValue)){
892
+ this.showSliderMinValueError = false;
893
+ }
894
+ else{
895
+ this.showSliderMinValueError = true;
896
+ }
897
+
898
+ }
899
+ this.disableSliderApplyButton = true;
900
+ this.incorrectSliderInput = true;
901
+
902
+ } else if (this.sliderEnteredMinValue < this.options.floor) {
903
+ this.showSliderMinValueError = true;
904
+ this.disableSliderApplyButton = true;
905
+ this.incorrectSliderInput = true;
906
+ } else {
907
+ this.showSliderMinValueError = false;
908
+ this.disableSliderApplyButton = false;
909
+ this.incorrectSliderInput = false;
910
+ }
911
+
912
+ console.log(this.sliderEnteredMinValue);
913
+ } else {
914
+ console.log('inside else condition');
915
+ this.sliderEnteredMinValue = this.options.floor;
916
+ this.isMinTextBoxEmpty = true;
917
+ this.showSliderMinValueError = false;
918
+
919
+ }
920
+ this.showErrorForMinAndMaxValue();
921
+ }
922
+
923
+ maxValueChanged(val: string) {
924
+ if (val || val == "0") {
925
+ this.sliderEnteredMaxValue = parseInt(val);
926
+ this.isMaxTextBoxEmpty = false;
927
+ if (this.isMinTextBoxEmpty) {
928
+ if (this.sliderEnteredMaxValue < this.options.floor) {
929
+ this.showSliderMaxValueError = true;
930
+ this.disableSliderApplyButton = true;
931
+ this.incorrectSliderInput = true;
932
+ } else {
933
+ this.showSliderMaxValueError = false;
934
+ this.showSliderMinValueError = false;
935
+ this.disableSliderApplyButton = false;
936
+ this.incorrectSliderInput = false;
937
+ }
938
+ } else if (this.sliderEnteredMaxValue < this.sliderEnteredMinValue) {
939
+ if(this.isValueInRange(this.sliderEnteredMinValue)){
940
+ this.showSliderMaxValueError = true;
941
+ this.showSliderMinValueError = false;
942
+ }
943
+ else{
944
+ this.showSliderMinValueError = true;
945
+ if(this.isValueInRange(this.sliderEnteredMaxValue)){
946
+ this.showSliderMaxValueError = false;
947
+ }
948
+ else{
949
+ this.showSliderMaxValueError = true;
950
+ }
951
+ }
952
+ this.disableSliderApplyButton = true;
953
+ this.incorrectSliderInput = true;
954
+ // this.showMaxError = true;
955
+ } else if (this.sliderEnteredMaxValue > this.options.ceil) {
956
+ this.showSliderMaxValueError = true;
957
+ this.disableSliderApplyButton = true;
958
+ this.incorrectSliderInput = true;
959
+ } else {
960
+ this.showSliderMaxValueError = false;
961
+ this.disableSliderApplyButton = false;
962
+ this.incorrectSliderInput = false;
963
+ }
964
+ } else {
965
+ this.sliderEnteredMaxValue = this.options.ceil;
966
+ this.isMaxTextBoxEmpty = true;
967
+ this.showSliderMaxValueError = false;
968
+ console.log(this.sliderEnteredMaxValue);
969
+ }
970
+ this.showErrorForMinAndMaxValue();
971
+ }
972
+
973
+ showErrorForMinAndMaxValue(){
974
+ if(this.isMinTextBoxEmpty && this.isMaxTextBoxEmpty){
975
+ this.showSliderMinValueError = true;
976
+ this.showSliderMaxValueError = true;
977
+ this.disableSliderApplyButton = true;
978
+ this.incorrectSliderInput = true;
979
+ }
980
+ this.disableSliderApplyBtn();
981
+ }
982
+
983
+ isValueInRange(val: number){
984
+ return this.options.floor <= val && val <= this.options.ceil;
985
+ }
986
+
987
+ disableSliderApplyBtn(){
988
+ if(this.showFilterComponent && this.showSortComponent){
989
+ let isFilterChanged = this.checkIfSliderTooltipIsFiltered();
990
+ let isSortChanged = this.checkIfSortingChanged();
991
+
992
+ this.disableSliderApplyButton = this.incorrectSliderInput || (!isSortChanged && !isFilterChanged );
993
+ }
994
+ else if(this.showFilterComponent){
995
+ this.disableSliderApplyButton = this.incorrectSliderInput || !this.checkIfSliderTooltipIsFiltered();
996
+ }
997
+ else if(this.showSortComponent){
998
+ this.disableSliderApplyButton = !this.checkIfSortingChanged();
999
+ }
1000
+ }
1001
+
1002
+ sliderValueChange() {
1003
+ this.sliderValue = { min: this.sliderMinValue, max: this.sliderMaxValue };
1004
+ }
1005
+
1006
+ cancelSliderFilter() {
1007
+ this.sliderValue = null;
1008
+ this.closeTooltip();
1009
+ }
1010
+
1011
+ applyFilters() {
1012
+ this.applyListFilters();
1013
+ this.applySortingOnFilteredData();
1014
+ this.emitData();
1015
+ this.setInitialRowsForTable();
1016
+ this.disableEnableEachColumnTooltipIcon();
1017
+ this.annaFilterService.updateStateOfTheCurrentFilterTab(this.annaSortService.columnSortState);
1018
+ this.closeTooltip();
1019
+ }
1020
+
1021
+ applyListFilters(){
1022
+ if(this.showFilterComponent && this.isFilterChanged){
1023
+ let currentSelectedValue = [];
1024
+
1025
+ if(this.tooltipOptions){
1026
+
1027
+ currentSelectedValue = sortBy(this.tooltipOptions.filter(item => item.isSelected).map(item => item.value));
1028
+
1029
+ if(!this.searchItem && currentSelectedValue.length == this.tooltipOptions.length && this.annaFilterService.initialValueMap.has(this.annaFilterService.selectedRadio)){
1030
+ currentSelectedValue = this.annaFilterService.initialValueMap.get(this.annaFilterService.selectedRadio);
1031
+ }
1032
+
1033
+ }
1034
+
1035
+ let blankIndex = currentSelectedValue.findIndex((item: string) => item == null);
1036
+ if(blankIndex != -1){
1037
+ currentSelectedValue = sortBy(currentSelectedValue);
1038
+ }
1039
+
1040
+ this.annaFilterService.reOrderAppliedFiltersState(this.clonedTableData,currentSelectedValue);
1041
+ this.annaFilterService.tooltipSelectedMap.set(this.annaFilterService.selectedRadio, currentSelectedValue);
1042
+ this.tableData = this.annaFilterService.filterData(this.clonedTableData, "");
1043
+ this.annaSortService.noSortingAppliedData = cloneDeep(this.tableData);
1044
+ }
1045
+ }
1046
+
1047
+ applySortingOnFilteredData(){
1048
+ if(this.showSortComponent){
1049
+ if(this.isSortChanged){
1050
+ this.updateSortMap();
1051
+ }
1052
+ else if(this.isFilterChanged){
1053
+ this.checkIfSortingIsApplied();
1054
+ }
1055
+ }
1056
+ else if(this.isFilterChanged){
1057
+ this.checkIfSortingIsApplied();
1058
+ }
1059
+ }
1060
+
1061
+ emitData(){
1062
+ if(this.isFilterChanged && this.isSortChanged){
1063
+ this.filterAppliedToTable.emit(this.tableData);
1064
+ }
1065
+ else if(this.isFilterChanged){
1066
+ this.filterAppliedToTable.emit(this.tableData);
1067
+ }
1068
+ else if(this.isSortChanged){
1069
+ this.sortingAppliedToTable.emit(this.tableData);
1070
+ }
1071
+ }
1072
+
1073
+ applySorting(key: string){
1074
+ if(this.tempSortOrder == "ASC"){
1075
+ this.tableData = cloneDeep(this.annaSortService.sortDataForComponentOtherThanLurAndCsrPage(true,this.tableData,key));
1076
+ }
1077
+ else if(this.tempSortOrder == "DESC"){
1078
+ this.tableData = cloneDeep(this.annaSortService.sortDataForComponentOtherThanLurAndCsrPage(false,this.tableData,key));
1079
+ }
1080
+ else if(this.tempSortOrder == "DEFAULT"){
1081
+ this.tableData = cloneDeep(this.annaSortService.noSortingAppliedData);
1082
+ }
1083
+ }
1084
+
1085
+ revert() {
1086
+ this.tempTooltipData = cloneDeep(this.toolTipdata);
1087
+ this.annaFilterService.tooltipMap.set(this.annaFilterService.selectedRadio, this.tempTooltipData);
1088
+ this.toolTipdata = null;
1089
+ }
1090
+
1091
+ closeCheckboxFilter() {
1092
+ if (this.toolTipdata) {
1093
+ this.revert();
1094
+ }
1095
+ this.closeTooltip();
1096
+ }
1097
+
1098
+ applySliderFilter() {
1099
+
1100
+ this.applySliderFilterOnData();
1101
+ this.applySortingOnFilteredData();
1102
+ this.emitData();
1103
+ this.setInitialRowsForTable();
1104
+ this.annaFilterService.updateStateOfTheCurrentFilterTab(this.annaSortService.columnSortState);
1105
+ this.closeTooltip();
1106
+ }
1107
+
1108
+ applySliderFilterOnData(){
1109
+ if(this.showFilterComponent && this.isFilterChanged){
1110
+ let currentSliderData: {min:any, max: any} = {min: null , max: null};
1111
+
1112
+ // if(this.isMinTextBoxEmpty){
1113
+ // currentSliderData.min = this.options.floor;
1114
+ // currentSliderData.max = this.sliderMaxValue;
1115
+ // }
1116
+ // else if(this.isMaxTextBoxEmpty){
1117
+ // currentSliderData.max = this.options.ceil;
1118
+ // currentSliderData.min = this.sliderMinValue;
1119
+ // }
1120
+ // else{
1121
+ currentSliderData.max = this.sliderEnteredMaxValue;
1122
+ currentSliderData.min = this.sliderEnteredMinValue;
1123
+ // }
1124
+
1125
+ if(currentSliderData.min == this.options.floor && currentSliderData.max == this.options.ceil && this.annaFilterService.initialValueMap.has(this.annaFilterService.selectedRadio) ){
1126
+ currentSliderData = this.annaFilterService.initialValueMap.get(this.annaFilterService.selectedRadio);
1127
+ }
1128
+
1129
+ this.annaFilterService.reOrderAppliedFiltersState(this.clonedTableData,currentSliderData);
1130
+ this.annaFilterService.tooltipSelectedMap.set(this.annaFilterService.selectedRadio,currentSliderData);
1131
+ this.tableData = this.annaFilterService.filterData(this.clonedTableData, "");
1132
+ this.annaSortService.noSortingAppliedData = cloneDeep(this.tableData);
1133
+ this.disableEnableEachColumnTooltipIcon();
1134
+ }
1135
+ }
1136
+
1137
+ cancelInDateFilter() {
1138
+ this.closeTooltip();
1139
+ }
1140
+
1141
+ updateSortMap(){
1142
+ for (let [key, value] of this.annaSortService.columnSortState.entries()) {
1143
+ this.annaSortService.columnSortState.set(key, "DEFAULT");
1144
+ }
1145
+ this.annaSortService.columnSortState.set(this.annaFilterService.selectedRadio, this.tempSortOrder);
1146
+ this.applySorting(this.annaFilterService.selectedRadio);
1147
+ }
1148
+
1149
+ applyDateFilter() {
1150
+
1151
+ this.applyDateFilterOnData();
1152
+ this.applySortingOnFilteredData();
1153
+ this.emitData();
1154
+ this.setInitialRowsForTable();
1155
+ this.annaFilterService.updateStateOfTheCurrentFilterTab(this.annaSortService.columnSortState);
1156
+ this.closeTooltip();
1157
+
1158
+ }
1159
+
1160
+ applyDateFilterOnData(){
1161
+ if(this.showFilterComponent && this.isFilterChanged){
1162
+ let currentSelectedDate = this.calendarSelection;
1163
+
1164
+ let fromDate = {year: currentSelectedDate.fromDate.year,month: currentSelectedDate.fromDate.month,day: currentSelectedDate.fromDate.day};
1165
+ let toDate = {year: currentSelectedDate.toDate.year,month: currentSelectedDate.toDate.month,day: currentSelectedDate.toDate.day};
1166
+
1167
+ if(isEqual(this.calendarMinEnabledDate,fromDate) && isEqual(this.calendarMaxEnabledDate,toDate) && this.annaFilterService.initialValueMap.has(this.annaFilterService.selectedRadio)){
1168
+ currentSelectedDate = this.annaFilterService.initialValueMap.get(this.annaFilterService.selectedRadio);
1169
+ }
1170
+ else{
1171
+ currentSelectedDate.fromDate = moment(this.annaDateTimeFormatService.convertNgbDateToMoment(currentSelectedDate.fromDate));
1172
+ currentSelectedDate.toDate = moment(this.annaDateTimeFormatService.convertNgbDateToMoment(currentSelectedDate.toDate));
1173
+ }
1174
+
1175
+
1176
+ this.annaFilterService.reOrderAppliedFiltersState(this.clonedTableData,currentSelectedDate);
1177
+ this.annaFilterService.tooltipSelectedMap.set(this.annaFilterService.selectedRadio,currentSelectedDate);
1178
+ this.tableData = this.annaFilterService.filterData(this.clonedTableData, "");
1179
+ this.annaSortService.noSortingAppliedData = cloneDeep(this.tableData);
1180
+ this.disableEnableEachColumnTooltipIcon();
1181
+
1182
+ }
1183
+ }
1184
+
1185
+ applyWeekFilter(event: any) {
1186
+
1187
+ }
1188
+
1189
+ incrementHour(arr: any[]) {
1190
+ if (arr[0] == "") {
1191
+ arr[0] = 1;
1192
+ } else if (parseInt(arr[0]) < 12) {
1193
+ arr[0] = parseInt(arr[0]) + 1;
1194
+ } else {
1195
+ arr[0] = 1;
1196
+ }
1197
+ }
1198
+
1199
+ decrementHour(arr: any[]) {
1200
+ if (arr[0] == "") {
1201
+ arr[0] = 12;
1202
+ } else if (parseInt(arr[0]) > 1) {
1203
+ arr[0] = parseInt(arr[0]) - 1;
1204
+ } else {
1205
+ arr[0] = 12;
1206
+ }
1207
+ }
1208
+
1209
+ incrementMinute(arr: any[]) {
1210
+ arr[1] = parseInt(arr[1]) + 15;
1211
+ if (parseInt(arr[1]) == 60) {
1212
+ arr[1] = "00";
1213
+ } else if (parseInt(arr[1]) == 0) {
1214
+ arr[1] = "00";
1215
+ }
1216
+ else if(parseInt(arr[1]) > 60){
1217
+ let res = parseInt(arr[1]) - 60;
1218
+ arr[1] = res < 10 ? `0${res}` : res.toString();
1219
+ }
1220
+ }
1221
+
1222
+ decrementMinute(arr: any) {
1223
+ arr[1] = parseInt(arr[1]) - 15;
1224
+ if (parseInt(arr[1]) < 0) {
1225
+ let res = 60 + parseInt(arr[1]);
1226
+ arr[1] = res;
1227
+ } else if (parseInt(arr[1]) == 0) {
1228
+ arr[1] = "00";
1229
+ }
1230
+ else if(arr[1] < 10){
1231
+ arr[1]= `0${arr[1]}`;
1232
+ }
1233
+ }
1234
+
1235
+ changeStartTimeHour(increment: boolean) {
1236
+ if (increment) {
1237
+ this.incrementHour(this.selectedFromTime);
1238
+ } else {
1239
+ this.decrementHour(this.selectedFromTime);
1240
+ }
1241
+ this.startTimeHourChange(this.selectedFromTime[0].toString());
1242
+ }
1243
+
1244
+ changeEndTimeHour(increment: boolean) {
1245
+ if (increment) {
1246
+ this.incrementHour(this.selectedToTime);
1247
+ } else {
1248
+ this.decrementHour(this.selectedToTime);
1249
+ }
1250
+ this.endTimeHourChange(this.selectedToTime[0].toString());
1251
+ }
1252
+
1253
+ changeEndTimeMinute(increment: boolean) {
1254
+ if (increment) {
1255
+ this.incrementMinute(this.selectedToTime);
1256
+ } else {
1257
+ this.decrementMinute(this.selectedToTime);
1258
+ }
1259
+ this.endTimeMinChange(this.selectedToTime[1].toString());
1260
+ }
1261
+
1262
+ changeStartTimeMinute(increment: boolean) {
1263
+ if (increment) {
1264
+ this.incrementMinute(this.selectedFromTime);
1265
+ } else {
1266
+ this.decrementMinute(this.selectedFromTime);
1267
+ }
1268
+ this.startTimeMinChange(this.selectedFromTime[1].toString());
1269
+ }
1270
+
1271
+ applyTimeFilters() {
1272
+
1273
+ this.applyTimeFilterOnData();
1274
+ this.applySortingOnFilteredData();
1275
+ this.emitData();
1276
+ this.setInitialRowsForTable();
1277
+ this.annaFilterService.updateStateOfTheCurrentFilterTab(this.annaSortService.columnSortState);
1278
+ this.closeTooltip();
1279
+
1280
+ }
1281
+
1282
+ applyTimeFilterOnData(){
1283
+ if(this.showFilterComponent && this.isFilterChanged){
1284
+ let currentSelectedTimeFilter: {fromTime: string, toTime:string, includeMulti: boolean, includeZero: boolean, includeTimeRange: boolean} = {
1285
+ fromTime: null,
1286
+ toTime: null,
1287
+ includeMulti: false,
1288
+ includeZero: false,
1289
+ includeTimeRange: false,
1290
+ };
1291
+
1292
+ let fromTime24HrFormatArr = this.annaDateTimeFormatService.convertTotwentyFourHrsFormat(
1293
+ this.selectedFromTime[0] + ":" + this.selectedFromTime[1] + " " + this.selectedFromTime[2],
1294
+ true
1295
+ );
1296
+ let fromTime24HrFormat = fromTime24HrFormatArr[0] + ":" + fromTime24HrFormatArr[1] + ":00";
1297
+
1298
+ let toTime24HrFormatArr = this.annaDateTimeFormatService.convertTotwentyFourHrsFormat(
1299
+ this.selectedToTime[0] + ":" + this.selectedToTime[1] + " " + this.selectedToTime[2],
1300
+ true
1301
+ );
1302
+ let toTime24HrFormat = toTime24HrFormatArr[0] + ":" + toTime24HrFormatArr[1] + ":00";
1303
+
1304
+ currentSelectedTimeFilter = { fromTime: fromTime24HrFormat, toTime: toTime24HrFormat, includeMulti: this.multiTimeCheckboxChecked,
1305
+ includeZero: this.zeroTimeCheckboxChecked, includeTimeRange: this.enterTimeCheckboxChecked};
1306
+
1307
+ let isFiltered = this.annaFilterService.reOrderAppliedFiltersState(this.clonedTableData,currentSelectedTimeFilter);
1308
+ this.annaFilterService.tooltipSelectedMap.set(this.annaFilterService.selectedRadio,currentSelectedTimeFilter);
1309
+ this.tableData = this.annaFilterService.filterData(this.clonedTableData, "");
1310
+
1311
+ if(!isFiltered){
1312
+ this.annaFilterService.tooltipSelectedMap.delete(this.annaFilterService.selectedRadio);
1313
+ }
1314
+ this.annaSortService.noSortingAppliedData = cloneDeep(this.tableData);
1315
+ this.disableEnableEachColumnTooltipIcon();
1316
+
1317
+ }
1318
+ }
1319
+
1320
+ closeTimeFilter() {
1321
+ this.selectedFromTime = cloneDeep(this.clonedSelectedFromTime);
1322
+ this.selectedToTime = cloneDeep(this.clonedSelectedToTime);
1323
+ this.closeTooltip();
1324
+ }
1325
+
1326
+ disableTimeFilterApplyButton() {
1327
+
1328
+ if(this.showFilterComponent && this.showSortComponent){
1329
+ let isFilterChanged = this.checkIfTimeTooltipIsFiltered();
1330
+ let isSortChanged = this.checkIfSortingChanged();
1331
+ this.disableTimeFilterApplyBtn = !this.validateTimeFilterInput() || (!isSortChanged && !isFilterChanged );
1332
+ }
1333
+ else if(this.showFilterComponent){
1334
+ this.disableTimeFilterApplyBtn = !this.validateTimeFilterInput() || !this.checkIfTimeTooltipIsFiltered();
1335
+ }
1336
+ else if(this.showSortComponent){
1337
+ this.disableTimeFilterApplyBtn = !this.checkIfSortingChanged();
1338
+ }
1339
+
1340
+ }
1341
+
1342
+ validateTimeFilterInput(){
1343
+ if(this.startTimeHourErr || this.startTimeMinErr || this.endTimeHourErr || this.endTimeMinErr){
1344
+ return false;
1345
+ }
1346
+
1347
+ if (!this.multiTimeCheckboxChecked && !this.zeroTimeCheckboxChecked && !this.enterTimeCheckboxChecked) {
1348
+ return false;
1349
+ }
1350
+
1351
+ let timeFormat = "HH:mm:ss";
1352
+
1353
+ let startTime24HrFormatArr = this.annaDateTimeFormatService.convertTotwentyFourHrsFormat(
1354
+ this.selectedFromTime[0] + ":" + this.selectedFromTime[1] + " " + this.selectedFromTime[2],
1355
+ true
1356
+ );
1357
+ let startTime24HrFormat = startTime24HrFormatArr[0] + ":" + startTime24HrFormatArr[1] + ":00";
1358
+ let endTime24HrFormatArr = this.annaDateTimeFormatService.convertTotwentyFourHrsFormat(
1359
+ this.selectedToTime[0] + ":" + this.selectedToTime[1] + " " + this.selectedToTime[2],
1360
+ true
1361
+ );
1362
+ let endTime24HrFormat = endTime24HrFormatArr[0] + ":" + endTime24HrFormatArr[1] + ":00";
1363
+
1364
+ return !(moment(startTime24HrFormat, timeFormat).isAfter(moment(endTime24HrFormat, timeFormat)));
1365
+ }
1366
+
1367
+ sortedData(event: any) {
1368
+ if (event.type == "none") {
1369
+ this.tableData = this.annaFilterService.filterData(this.clonedTableData, "");
1370
+ } else {
1371
+ this.tableData = event.data;
1372
+ }
1373
+ this.sortingAppliedToTable.emit(this.tableData);
1374
+ }
1375
+
1376
+ checkIfSortingIsApplied() {
1377
+ for(let [key,value] of this.annaSortService.columnSortState.entries()){
1378
+ if(value == "ASC"){
1379
+ this.tableData = cloneDeep(this.annaSortService.sortDataForComponentOtherThanLurAndCsrPage(true,this.tableData,key));
1380
+ }
1381
+ else if(value == "DESC"){
1382
+ this.tableData = cloneDeep(this.annaSortService.sortDataForComponentOtherThanLurAndCsrPage(false,this.tableData,key));
1383
+ }
1384
+ }
1385
+ }
1386
+
1387
+
1388
+ disableEnableEachColumnTooltipIcon() {
1389
+ this.tableHeaders.forEach(header => {
1390
+
1391
+ header.headerInfo.forEach(item => {
1392
+ if (item.showTooltipIcon) {
1393
+
1394
+ let values = [];
1395
+ item.disableTooltipIcon = true;
1396
+
1397
+ item.filterSortObjectKeys.forEach(key => {
1398
+
1399
+ if(key == "period"){
1400
+ let uniqStartDate = uniq(this.tableData.map((u: { [x: string]: any; }) => u["startDate"]));
1401
+ let uniqEndDate = uniq(this.tableData.map((u: { [x: string]: any; }) => u["endDate"]));
1402
+
1403
+ item.disableTooltipIcon = (uniqStartDate.length > 1 || uniqEndDate.length > 1) ? false : true;
1404
+ }
1405
+ else{
1406
+ values = this.tableData.map((u: { [x: string]: any; }) => u[key]);
1407
+ if(uniq(values).filter(n => n!=null).length > 1){
1408
+ item.disableTooltipIcon = false;
1409
+ }
1410
+ }
1411
+
1412
+ })
1413
+ }
1414
+
1415
+ });
1416
+ });
1417
+ }
1418
+
1419
+ setMarginLeftForFilterIcon(){
1420
+ let elementArr = this.viewChildTableHeaders.toArray();
1421
+ elementArr.forEach((item) => {
1422
+ let childDivElements = item.nativeElement.children;
1423
+
1424
+ if (childDivElements.length == 2) {
1425
+ let firstParagraphWidth = childDivElements[0].children[0];
1426
+ let secondParagraphWidth = childDivElements[1].children[0];
1427
+
1428
+ if(firstParagraphWidth.offsetWidth > secondParagraphWidth.offsetWidth){
1429
+ let diff = firstParagraphWidth.offsetWidth - secondParagraphWidth.offsetWidth;
1430
+ if(childDivElements[0].children.length == 2){
1431
+ childDivElements[0].children[1].style.marginLeft = 4 + 'px';
1432
+ }
1433
+
1434
+ if(childDivElements[1].children.length == 2){
1435
+
1436
+ childDivElements[1].children[1].style.marginLeft = diff + 4 + 'px';
1437
+ }
1438
+ }
1439
+ else{
1440
+ let diff = secondParagraphWidth.offsetWidth - firstParagraphWidth.offsetWidth;
1441
+ if(childDivElements[0].children.length == 2){
1442
+ childDivElements[0].children[1].style.marginLeft = diff + 4 + 'px';
1443
+ }
1444
+
1445
+ if(childDivElements[1].children.length == 2){
1446
+
1447
+ childDivElements[1].children[1].style.marginLeft = 4 + 'px';
1448
+ }
1449
+ }
1450
+
1451
+ }
1452
+ });
1453
+ }
1454
+
1455
+ dataRowClicked(rowData: any) {
1456
+ this.rowClicked.emit(rowData);
1457
+ }
1458
+
1459
+ radioButtonClicked(data: any, action: string, isDisabled: boolean) {
1460
+ if (!isDisabled) {
1461
+ this.radioButtonSelected.emit({ data, action });
1462
+ }
1463
+ }
1464
+
1465
+ bindTheValueToSellerGroupTooltip(sellerGroupHierarchy: SellerGroupHierarchy[], tooltip: any): void {
1466
+ if (this.hierarchyTooltip && this.hierarchyTooltip.open) {
1467
+ this.hierarchyTooltip.close();
1468
+ }
1469
+ this.sellerGroupHierarchy = sellerGroupHierarchy;
1470
+ this.hierarchyTooltip = tooltip;
1471
+ this.hierarchyTooltip.open();
1472
+ }
1473
+
1474
+ iconClicked(rowData: any,iconClass: string){
1475
+ this.gtIconClicked.emit({data: rowData,iconClass: iconClass});
1476
+ }
1477
+
1478
+ svgIconClicked(data: GtColumnIconEmittedData){
1479
+ this.gtSVGIconClicked.emit(data);
1480
+ }
1481
+
1482
+ textActionClicked(rowData: any,id: number){
1483
+ this.gtTextActionClicked.emit({data:rowData,id});
1484
+ }
1485
+
1486
+ viewDetailsClicked(rowData: any){
1487
+ this.gtViewDetailClicked.emit({data:rowData});
1488
+ }
1489
+
1490
+ setColumnSortStateMap(){
1491
+ this.tableHeaders.forEach(column => {
1492
+ column.headerInfo.forEach( (header) => {
1493
+ if(header.showTooltipIcon && header.isSortRequired){
1494
+ header.isSortRequired.forEach( (item,index) => {
1495
+ if(item){
1496
+ this.annaSortService.columnSortState.set(header.filterSortObjectKeys[index], "DEFAULT");
1497
+ }
1498
+ })
1499
+ }
1500
+ })
1501
+ });
1502
+ }
1503
+
1504
+ storeSortTypeInTempVariable(event: SortType){
1505
+ this.tempSortOrder = event;
1506
+ this.disableApplyButtonOfSelectedFilter();
1507
+ }
1508
+
1509
+ unCheckAllCheckbox(){
1510
+ this.tooltipOptions.forEach(item => {
1511
+ item.isSelected = false;
1512
+ let index = this.clonedTooltipOptions.findIndex(opt => opt.id == item.id);
1513
+ this.clonedTooltipOptions[index].isSelected = false;
1514
+
1515
+ });
1516
+ this.selectedCheckboxOptionsCount = 0;
1517
+ this.disableSelectAll = false;
1518
+ this.disableClearAll = true;
1519
+ this.disableCheckboxApply = true;
1520
+ }
1521
+
1522
+ selectAllCheckbox(){
1523
+ this.tooltipOptions.forEach(item => {
1524
+ item.isSelected = true;
1525
+ let index = this.clonedTooltipOptions.findIndex(opt => opt.id == item.id);
1526
+ this.clonedTooltipOptions[index].isSelected = true;
1527
+ });
1528
+ this.selectedCheckboxOptionsCount = this.tooltipOptions.length;
1529
+ this.disableSelectAll = true;
1530
+ this.disableClearAll = false;
1531
+ this.disableCheckboxFilterApplyButton();
1532
+ }
1533
+
1534
+ searchForTheItem(str: string){
1535
+ if(str){
1536
+ this.tooltipOptions = cloneDeep(this.clonedTooltipOptions.filter(item => item.label.toString().includes(str)));
1537
+
1538
+ this.tooltipOptions.forEach(element => {
1539
+ element.label = this.boldString(element.label,str);
1540
+ });
1541
+
1542
+ if(this.tooltipOptions.length > 0){
1543
+ let unselectedItems = this.tooltipOptions.filter((item) => !item.isSelected);
1544
+ let selectedItems = this.tooltipOptions.filter((item) => item.isSelected);
1545
+ this.disableSelectAll = unselectedItems.length == 0;
1546
+ this.disableClearAll = selectedItems.length == 0;
1547
+ this.selectedCheckboxOptionsCount = selectedItems.length;
1548
+ this.disableCheckboxApply = (selectedItems.length == 0 || !this.checkIfCheckboxTooltipIsFiltered());
1549
+
1550
+ }
1551
+ else{
1552
+ this.selectedCheckboxOptionsCount = 0;
1553
+ this.disableCheckboxApply = true;
1554
+ this.disableClearAll = true;
1555
+ this.disableSelectAll = true;
1556
+ }
1557
+ }
1558
+ else{
1559
+ this.tooltipOptions = cloneDeep(this.clonedTooltipOptions);
1560
+ let unselectedItems = this.tooltipOptions.filter(item => !item.isSelected);
1561
+ let selectedItems = this.tooltipOptions.filter(item => item.isSelected);
1562
+ this.selectedCheckboxOptionsCount = selectedItems.length;
1563
+ this.disableSelectAll = unselectedItems.length == 0;
1564
+ this.disableClearAll = selectedItems.length == 0;
1565
+ this.disableCheckboxFilterApplyButton();
1566
+ }
1567
+ }
1568
+
1569
+ boldString(str: string, find: string){
1570
+ var re = new RegExp(find, 'g');
1571
+ return str.replace(re, '<b>'+find+'</b>');
1572
+ }
1573
+
1574
+ removeBoldElementFromString(originalString: string){
1575
+ let firstRegExp = new RegExp('<b>','g');
1576
+ let secondRegExp = new RegExp('</b>','g');
1577
+
1578
+ let ret = originalString.replace(firstRegExp,'');
1579
+ return ret.replace(secondRegExp,'');
1580
+ }
1581
+
1582
+ clearSearchedItem(){
1583
+ this.searchItem = "";
1584
+ this.searchForTheItem("");
1585
+ }
1586
+
1587
+ calendarDateChanged(event: any){
1588
+ this.calendarSelection = event;
1589
+ this.disableCalendarApplyButton();
1590
+ }
1591
+
1592
+ disableCalendarApplyButton() {
1593
+
1594
+ if(this.showFilterComponent && this.showSortComponent){
1595
+ let isFilterChanged = this.checkIfDateTooltipIsFiltered();
1596
+ let isSortChanged = this.checkIfSortingChanged();
1597
+
1598
+ this.disableCalendarApplyBtn = !(this.calendarSelection.fromDate && this.calendarSelection.toDate) || (!isSortChanged && !isFilterChanged );
1599
+ }
1600
+ else if(this.showFilterComponent){
1601
+ this.disableCalendarApplyBtn = !(this.calendarSelection.fromDate && this.calendarSelection.toDate) || !this.checkIfDateTooltipIsFiltered();
1602
+ }
1603
+ else if(this.showSortComponent){
1604
+ this.disableCalendarApplyBtn = !this.checkIfSortingChanged();
1605
+ }
1606
+
1607
+ }
1608
+
1609
+ setInitialValueMapForTimeFilter(key: string) {
1610
+ let data = this.clonedTableData.filter(
1611
+ (obj) => !["", "-", null, "0", "<multi>"].includes(obj[key]));
1612
+
1613
+ let timeArr = map(data, key);
1614
+ timeArr.sort((a, b) => {
1615
+ return this.annaDateTimeFormatService.sortByTimeAscending(a, b);
1616
+ });
1617
+
1618
+ let obj = {
1619
+ fromTime: timeArr[0],
1620
+ toTime: timeArr[timeArr.length - 1],
1621
+ includeMulti: false,
1622
+ includeZero: false,
1623
+ includeTimeRange: false
1624
+ };
1625
+
1626
+ if (
1627
+ this.gtGeneralConfig.component === "SPOTDETAILS" ||
1628
+ this.gtGeneralConfig.component === "EXCLUDEINVENTORYPOPUP"
1629
+ ) {
1630
+ let includeMulti =
1631
+ this.clonedTableData.findIndex((obj) => obj[key] == "<multi>") !=
1632
+ -1;
1633
+ let includeZero =
1634
+ this.clonedTableData.findIndex((obj) => obj[key] == "0") != -1;
1635
+ let includeTimeRange =
1636
+ this.clonedTableData.findIndex(
1637
+ (obj) => obj[key] != "0" && obj[key] != "<multi>"
1638
+ ) != -1;
1639
+
1640
+ let obj = {
1641
+ fromTime: timeArr[0],
1642
+ toTime: timeArr[timeArr.length - 1],
1643
+ includeMulti: includeMulti,
1644
+ includeZero: includeZero,
1645
+ includeTimeRange: includeTimeRange,
1646
+ };
1647
+ this.annaFilterService.initialValueMap.set(key, obj);
1648
+ }
1649
+ else if (this.gtGeneralConfig.component === "RATING") {
1650
+ this.setInitialValueMapForRatingPageTimeFilter(key);
1651
+ } else {
1652
+ this.annaFilterService.initialValueMap.set(key, obj);
1653
+ }
1654
+ }
1655
+
1656
+ setInitialValueMapForRatingPageTimeFilter(key: string){
1657
+ let includeMulti =
1658
+ this.clonedTableData.findIndex((obj) => obj[key][0] == "<multi>") !=
1659
+ -1;
1660
+ let includeZero =
1661
+ this.clonedTableData.findIndex((obj) => obj[key][0] == "0") != -1;
1662
+ let includeTimeRange =
1663
+ this.clonedTableData.findIndex(
1664
+ (obj) => obj[key][0] != "0" && obj[key][0] != "<multi>"
1665
+ ) != -1;
1666
+
1667
+ let startTimeArr = map(this.clonedTableData, "startTime");
1668
+ let endTimeArr = map(this.clonedTableData, "endTime");
1669
+
1670
+ startTimeArr.sort((a, b) => {
1671
+ return this.annaDateTimeFormatService.sortByTimeAscending(a, b);
1672
+ });
1673
+
1674
+ endTimeArr.sort((a, b) => {
1675
+ return this.annaDateTimeFormatService.sortByTimeDescending(a, b);
1676
+ });
1677
+
1678
+ let obj = {
1679
+ fromTime: startTimeArr[0],
1680
+ toTime: endTimeArr[0],
1681
+ includeMulti: includeMulti,
1682
+ includeZero: includeZero,
1683
+ includeTimeRange: includeTimeRange,
1684
+ };
1685
+ this.annaFilterService.initialValueMap.set(key, obj);
1686
+ }
1687
+
1688
+ startTimeHourChange(val: string){
1689
+ if(val.length == 0 || 1 > parseInt(val) || parseInt(val) > 12){
1690
+ this.startTimeHourErr = true;
1691
+ }
1692
+ else{
1693
+ this.startTimeHourErr = false;
1694
+ }
1695
+ this.disableTimeFilterApplyButton();
1696
+ }
1697
+
1698
+ startTimeMinChange(val: string){
1699
+ if(val.length != 2 || 0 > parseInt(val) || parseInt(val) > 59){
1700
+ this.startTimeMinErr = true;
1701
+ }
1702
+ else{
1703
+ this.startTimeMinErr = false;
1704
+ }
1705
+ this.disableTimeFilterApplyButton();
1706
+ }
1707
+
1708
+ endTimeHourChange(val: string){
1709
+ if(val.length == 0 || 1 > parseInt(val) || parseInt(val) > 12){
1710
+ this.endTimeHourErr = true;
1711
+ }
1712
+ else{
1713
+ this.endTimeHourErr = false;
1714
+ }
1715
+ this.disableTimeFilterApplyButton();
1716
+ }
1717
+
1718
+ endTimeMinChange(val: string){
1719
+ if(val.length != 2 || 0 > parseInt(val) || parseInt(val) > 59){
1720
+ this.endTimeMinErr = true;
1721
+ }
1722
+ else{
1723
+ this.endTimeMinErr = false;
1724
+ }
1725
+ this.disableTimeFilterApplyButton();
1726
+ }
1727
+
1728
+ checkIfCheckboxTooltipIsFiltered(){
1729
+ let currentSelectedValue = [];
1730
+ let previousSelectedValue = [];
1731
+
1732
+ if(this.annaFilterService.tooltipSelectedMap.has(this.annaFilterService.selectedRadio)){
1733
+ previousSelectedValue = this.annaFilterService.tooltipSelectedMap.get(this.annaFilterService.selectedRadio);
1734
+
1735
+ if(!this.annaFilterService.initialValueMap.has(this.annaFilterService.selectedRadio)){
1736
+ let initialValue = sortBy(uniq(this.clonedTableData.map(item => item[this.annaFilterService.selectedRadio])));
1737
+ this.annaFilterService.initialValueMap.set(this.annaFilterService.selectedRadio,initialValue);
1738
+ }
1739
+
1740
+ }
1741
+ else if(this.annaFilterService.initialValueMap.has(this.annaFilterService.selectedRadio)){
1742
+ previousSelectedValue = this.annaFilterService.initialValueMap.get(this.annaFilterService.selectedRadio);
1743
+ }
1744
+ else{
1745
+ previousSelectedValue = sortBy(uniq(this.clonedTableData.map(item => item[this.annaFilterService.selectedRadio])));
1746
+ this.annaFilterService.initialValueMap.set(this.annaFilterService.selectedRadio,previousSelectedValue);
1747
+ }
1748
+
1749
+ if(this.tooltipOptions){
1750
+
1751
+ currentSelectedValue = sortBy(this.tooltipOptions.filter(item => item.isSelected).map(item => item.value));
1752
+
1753
+ if(!this.searchItem && currentSelectedValue.length == this.tooltipOptions.length && this.annaFilterService.initialValueMap.has(this.annaFilterService.selectedRadio)){
1754
+ currentSelectedValue = this.annaFilterService.initialValueMap.get(this.annaFilterService.selectedRadio);
1755
+ }
1756
+
1757
+ }
1758
+
1759
+ let blankIndex = currentSelectedValue.findIndex((item: string) => item == null);
1760
+ if(blankIndex != -1){
1761
+ currentSelectedValue = sortBy(currentSelectedValue);
1762
+ }
1763
+
1764
+ this.isFilterChanged = !isEqual(currentSelectedValue,previousSelectedValue);
1765
+ return this.isFilterChanged;
1766
+ }
1767
+
1768
+ checkIfTimeTooltipIsFiltered(){
1769
+ let currentSelectedTimeFilter: {fromTime: string, toTime:string, includeMulti: boolean, includeZero: boolean, includeTimeRange: boolean} = {
1770
+ fromTime: null,
1771
+ toTime: null,
1772
+ includeMulti: false,
1773
+ includeZero: false,
1774
+ includeTimeRange: false,
1775
+ };
1776
+
1777
+ let previousSelectedTimeFilter;
1778
+
1779
+ if(this.annaFilterService.tooltipSelectedMap.has(this.annaFilterService.selectedRadio)){
1780
+ previousSelectedTimeFilter = this.annaFilterService.tooltipSelectedMap.get(this.annaFilterService.selectedRadio);
1781
+ }
1782
+ else if(this.annaFilterService.initialValueMap.has(this.annaFilterService.selectedRadio)){
1783
+ previousSelectedTimeFilter = this.annaFilterService.initialValueMap.get(this.annaFilterService.selectedRadio);
1784
+ }
1785
+
1786
+ let fromTime24HrFormatArr = this.annaDateTimeFormatService.convertTotwentyFourHrsFormat(
1787
+ this.selectedFromTime[0] + ":" + this.selectedFromTime[1] + " " + this.selectedFromTime[2],
1788
+ true
1789
+ );
1790
+ let fromTime24HrFormat = fromTime24HrFormatArr[0] + ":" + fromTime24HrFormatArr[1] + ":00";
1791
+
1792
+ let toTime24HrFormatArr = this.annaDateTimeFormatService.convertTotwentyFourHrsFormat(
1793
+ this.selectedToTime[0] + ":" + this.selectedToTime[1] + " " + this.selectedToTime[2],
1794
+ true
1795
+ );
1796
+ let toTime24HrFormat = toTime24HrFormatArr[0] + ":" + toTime24HrFormatArr[1] + ":00";
1797
+
1798
+ currentSelectedTimeFilter = { fromTime: fromTime24HrFormat, toTime: toTime24HrFormat, includeMulti: this.multiTimeCheckboxChecked,
1799
+ includeZero: this.zeroTimeCheckboxChecked, includeTimeRange: this.enterTimeCheckboxChecked};
1800
+
1801
+ this.isFilterChanged = !isEqual(previousSelectedTimeFilter, currentSelectedTimeFilter);
1802
+ return this.isFilterChanged;
1803
+ }
1804
+
1805
+ checkIfDateTooltipIsFiltered(){
1806
+ let currentSelectedDate = cloneDeep(this.calendarSelection);
1807
+ let previousSelectedDate: {fromDate: any, toDate: any} = {fromDate: null, toDate: null};
1808
+
1809
+ if(this.annaFilterService.tooltipSelectedMap.has(this.annaFilterService.selectedRadio)){
1810
+ previousSelectedDate = this.annaFilterService.tooltipSelectedMap.get(this.annaFilterService.selectedRadio);
1811
+
1812
+ if(!this.annaFilterService.initialValueMap.has(this.annaFilterService.selectedRadio)){
1813
+ this.setInitialValueMapForDateFilter();
1814
+ }
1815
+
1816
+ }
1817
+ else if(this.annaFilterService.initialValueMap.has(this.annaFilterService.selectedRadio)){
1818
+ previousSelectedDate = this.annaFilterService.initialValueMap.get(this.annaFilterService.selectedRadio);
1819
+ }
1820
+ else{
1821
+ this.setInitialValueMapForDateFilter();
1822
+ previousSelectedDate = this.annaFilterService.initialValueMap.get(this.annaFilterService.selectedRadio);
1823
+ }
1824
+
1825
+ if(currentSelectedDate.fromDate && currentSelectedDate.toDate){
1826
+ let fromDate = {year: currentSelectedDate.fromDate.year,month: currentSelectedDate.fromDate.month,day: currentSelectedDate.fromDate.day};
1827
+ let toDate = {year: currentSelectedDate.toDate.year,month: currentSelectedDate.toDate.month,day: currentSelectedDate.toDate.day};
1828
+
1829
+ if(isEqual(this.calendarMinEnabledDate,fromDate) && isEqual(this.calendarMaxEnabledDate,toDate) && this.annaFilterService.initialValueMap.has(this.annaFilterService.selectedRadio)){
1830
+ currentSelectedDate = this.annaFilterService.initialValueMap.get(this.annaFilterService.selectedRadio);
1831
+ }
1832
+ else{
1833
+ currentSelectedDate.fromDate = moment(this.annaDateTimeFormatService.convertNgbDateToMoment(currentSelectedDate.fromDate));
1834
+ currentSelectedDate.toDate = moment(this.annaDateTimeFormatService.convertNgbDateToMoment(currentSelectedDate.toDate));
1835
+ }
1836
+ this.isFilterChanged = !isEqual(previousSelectedDate,currentSelectedDate);
1837
+ }
1838
+
1839
+ return this.isFilterChanged;
1840
+ }
1841
+
1842
+ setInitialValueMapForDateFilter(){
1843
+ let minMaxDate;
1844
+
1845
+ if(this.annaFilterService.selectedRadio == "period"){
1846
+ let minStartDate = this.annaFilterService.returnMinAndMaxDate(this.clonedTableData, "startDate");
1847
+ let maxEndDate = this.annaFilterService.returnMinAndMaxDate(this.clonedTableData,"endDate");
1848
+ minMaxDate = [minStartDate[0],maxEndDate[1]];
1849
+ }
1850
+ else{
1851
+ minMaxDate = this.annaFilterService.returnMinAndMaxDate(this.clonedTableData,this.annaFilterService.selectedRadio);
1852
+ }
1853
+ let selectedDate = {fromDate: minMaxDate[0], toDate: minMaxDate[1]};
1854
+ this.annaFilterService.initialValueMap.set(this.annaFilterService.selectedRadio, selectedDate);
1855
+ }
1856
+
1857
+ checkIfSliderTooltipIsFiltered(){
1858
+ let currentSliderData: {min:any, max: any} = {min: null , max: null};
1859
+ let previousSliderData: {min:any, max: any} = {min: "", max: ""};
1860
+
1861
+ // if(this.isMinTextBoxEmpty){
1862
+ // currentSliderData.min = this.options.floor;
1863
+ // currentSliderData.max = this.sliderMaxValue;
1864
+ // }
1865
+ // else if(this.isMaxTextBoxEmpty){
1866
+ // currentSliderData.max = this.options.ceil;
1867
+ // currentSliderData.min = this.sliderMinValue;
1868
+ // }
1869
+ // else{
1870
+ currentSliderData.max = this.sliderEnteredMaxValue;
1871
+ currentSliderData.min = this.sliderEnteredMinValue;
1872
+ // }
1873
+
1874
+ if(this.annaFilterService.tooltipSelectedMap.has(this.annaFilterService.selectedRadio)){
1875
+ previousSliderData = this.annaFilterService.tooltipSelectedMap.get(this.annaFilterService.selectedRadio);
1876
+ if(!this.annaFilterService.initialValueMap.has(this.annaFilterService.selectedRadio)){
1877
+ this.setInitialValueMapForSliderFilter();
1878
+ }
1879
+ }
1880
+ else if(this.annaFilterService.initialValueMap.has(this.annaFilterService.selectedRadio)){
1881
+ previousSliderData = this.annaFilterService.initialValueMap.get(this.annaFilterService.selectedRadio);
1882
+ }
1883
+ else{
1884
+ this.setInitialValueMapForSliderFilter();
1885
+ previousSliderData = this.annaFilterService.initialValueMap.get(this.annaFilterService.selectedRadio);
1886
+ }
1887
+
1888
+ if(currentSliderData.min == this.options.floor && currentSliderData.max == this.options.ceil && this.annaFilterService.initialValueMap.has(this.annaFilterService.selectedRadio) ){
1889
+ currentSliderData = this.annaFilterService.initialValueMap.get(this.annaFilterService.selectedRadio);
1890
+ }
1891
+
1892
+ this.isFilterChanged = !isEqual(previousSliderData,currentSliderData);
1893
+ return this.isFilterChanged;
1894
+ }
1895
+
1896
+ setInitialValueMapForSliderFilter(){
1897
+ let minValue = this.annaFilterService.returnMaxAndMinValue(this.clonedTableData, this.annaFilterService.selectedRadio, true);
1898
+ let maxValue = this.annaFilterService.returnMaxAndMinValue(this.clonedTableData, this.annaFilterService.selectedRadio, false);
1899
+ let sliderData = { min: minValue, max: maxValue };
1900
+ this.annaFilterService.initialValueMap.set(this.annaFilterService.selectedRadio, sliderData);
1901
+
1902
+ }
1903
+
1904
+ checkIfSortingChanged(){
1905
+ this.isSortChanged = this.tempSortOrder != null && this.tempSortOrder != this.annaSortService.columnSortState.get(this.annaFilterService.selectedRadio);;
1906
+ console.log(this.isSortChanged);
1907
+ return this.isSortChanged;
1908
+ }
1909
+
1910
+ disableApplyButtonOfSelectedFilter(){
1911
+ let header = this.annaFilterService.selectedRadio;
1912
+
1913
+ if (this.annaFilterService.calendarSet.has(header)) {
1914
+ this.disableCalendarApplyButton();
1915
+ } else if (this.annaFilterService.sliderSet.has(header)) {
1916
+ this.disableSliderApplyBtn();
1917
+ } else if (this.annaFilterService.timeSet.has(header)) {
1918
+ this.disableTimeFilterApplyButton();
1919
+ } else {
1920
+ this.disableCheckboxFilterApplyButton();
1921
+ }
1922
+ }
1923
+
1924
+ disableCheckboxFilterApplyButton(){
1925
+ let selectedItems = this.showFilterComponent ? this.tooltipOptions.filter(item => item.isSelected) : [];
1926
+
1927
+ if(this.showFilterComponent && this.showSortComponent){
1928
+ let isFilterChanged = this.checkIfCheckboxTooltipIsFiltered();
1929
+ let isSortChanged = this.checkIfSortingChanged();
1930
+ this.disableCheckboxApply = selectedItems.length == 0 || (!isSortChanged && !isFilterChanged );
1931
+ }
1932
+ else if(this.showFilterComponent){
1933
+ this.disableCheckboxApply = selectedItems.length == 0 || !this.checkIfCheckboxTooltipIsFiltered();
1934
+ }
1935
+ else if(this.showSortComponent){
1936
+ this.disableCheckboxApply = !this.checkIfSortingChanged();
1937
+ }
1938
+ }
1939
+
1940
+ trackByTooltipModelId(index: number , item: TooltipModel){
1941
+ return item.id;
1942
+ }
1943
+
1944
+ setActiveStateObject(){
1945
+ this.annaFilterService.isFilterSortActive = {};
1946
+ this.tableHeaders.forEach(item => {
1947
+ item.headerInfo.forEach(header => {
1948
+ if(header.showTooltipIcon){
1949
+ let key = header.filterSortObjectKeys.join(',');
1950
+ header.joinedFilterSortObjectKeys = key;
1951
+ this.annaFilterService.isFilterSortActive[key] = false;
1952
+ }
1953
+ })
1954
+ });
1955
+ }
1956
+
1957
+ setIsDifference(value: boolean){
1958
+ this.isDifferenceLessThan25Percent = value;
1959
+ }
1960
+
1961
+ resetIndex(){
1962
+ this.start = 0;
1963
+ this.end = this.limit + this.start;
1964
+ }
1965
+
1966
+ onTableContainerScroll(e: any) {
1967
+ const tableViewHeight = e.target.offsetHeight; // viewport
1968
+ const tableScrollHeight = e.target.scrollHeight; // length of all table
1969
+ const scrollLocation = e.target.scrollTop; // how far user scrolled
1970
+
1971
+ // If the user has scrolled within 150px of the bottom, add more data
1972
+ const buffer = 150;
1973
+ const limit = tableScrollHeight - tableViewHeight - buffer;
1974
+ if (scrollLocation > limit) {
1975
+ let data = this.getTableData(this.start, this.end);
1976
+ this.renderedData = this.renderedData.concat(data);
1977
+ this.updateIndex();
1978
+ }
1979
+ this.tableContainerScrolled(e);
1980
+ }
1981
+
1982
+ getTableData(start: number, end: number) {
1983
+ return this.tableData.filter((value, index) => index >= start && index < end);
1984
+ }
1985
+
1986
+ updateIndex() {
1987
+ this.start = this.end;
1988
+ this.end = this.limit + this.start;
1989
+ }
1990
+
1991
+ setInitialRowsForTable(){
1992
+ this.resetIndex();
1993
+ this.renderedData = this.getTableData(this.start,this.end);
1994
+ this.updateIndex();
1995
+ }
1996
+
1997
+ spotDetailsDownloadClicked(parentChildOrTotalRow: "DATAROW" | "TOTALROW", rowdata?: any ) {
1998
+ if(rowdata){
1999
+ this.selectedInventoryIdForDownload = rowdata.inventoryCodeId;
2000
+ this.selectedDemographicForDownload = rowdata.demographic;
2001
+ } else{
2002
+ this.selectedInventoryIdForDownload = null;
2003
+ this.selectedDemographicForDownload = null;
2004
+ }
2005
+ this.selectedRowTypeForDownload = parentChildOrTotalRow;
2006
+ this.downloadSpotDetails.emit({
2007
+ parentChildOrTotalRow: parentChildOrTotalRow,
2008
+ inventoryCodeId: this.selectedInventoryIdForDownload,
2009
+ demographic: this.selectedDemographicForDownload})
2010
+ }
2011
+
2012
+ tableContainerScrolled(event: any){
2013
+ this.isScrolledLeft = event.target.scrollLeft > 0;
2014
+ }
2015
+ }