@annalib/anna-core 3.2.0 → 3.3.0

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