Skip to content

Commit e70d0ee

Browse files
committed
feat(elastic-filter-time): enhance time filter functionality and update UI interactions
Signed-off-by: Manuel Abascal <mjabascal10@gmail.com>
1 parent e0c5e70 commit e70d0ee

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

frontend/src/app/shared/components/utm/filters/elastic-filter-time/elastic-filter-time.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252
<input style="width: 60px" [(ngModel)]="lastTime" class="form-control last-time cursor-pointer" [max]="maxTimeValue()" min="1" type="number">
5353
</div>
5454

55-
<ng-select [(ngModel)]="timeUnit" [clearable]="true"
55+
<ng-select [(ngModel)]="timeUnit"
56+
[clearable]="false"
5657
[items]="times"
5758
[searchable]="false"
58-
autofocus
5959
bindLabel="label"
6060
class="mr-2 w-100">
6161
</ng-select>
@@ -85,7 +85,7 @@
8585
</div>
8686
</div>
8787
<div class="mt-2">
88-
<span (click)="isCollapsed = !isCollapsed" class="font-weight-semibold p-2 cursor-pointer">
88+
<span (click)="onCustomRange()" class="font-weight-semibold p-2 cursor-pointer">
8989
<i [ngClass]="isCollapsed?'icon-arrow-up32':'icon-arrow-right32'"></i>
9090
Custom range
9191
</span>

frontend/src/app/shared/components/utm/filters/elastic-filter-time/elastic-filter-time.component.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ export class ElasticFilterTimeComponent implements OnInit, OnChanges, OnDestroy
195195
this.timeFilterChange.emit({
196196
timeFrom: resolveUTCDate(this.dateFrom), timeTo: resolveUTCDate(this.dateTo)
197197
});
198+
199+
this.maxDateFrom = null;
200+
this.maxDateTo = null;
201+
198202
}
199203
}
200204
}
@@ -221,11 +225,13 @@ export class ElasticFilterTimeComponent implements OnInit, OnChanges, OnDestroy
221225

222226
// Function called every time the 'timeFrom' date is changed
223227
onTimeFromChange() {
228+
this.maxDateFrom = null;
224229
this.updateMaxDates('from'); // Update maxDates when timeFrom changes
225230
}
226231

227232
// Function called every time the 'timeTo' date is changed
228233
onTimeToChange() {
234+
this.maxDateTo = null;
229235
this.updateMaxDates('to'); // Update maxDates when timeTo changes
230236
}
231237

@@ -263,7 +269,7 @@ export class ElasticFilterTimeComponent implements OnInit, OnChanges, OnDestroy
263269
return false;
264270
}
265271

266-
isDirty(){
272+
isDirty() {
267273
return this.rangeTimeFrom !== undefined && this.rangeTimeTo !== undefined;
268274
}
269275

@@ -287,6 +293,14 @@ export class ElasticFilterTimeComponent implements OnInit, OnChanges, OnDestroy
287293
}
288294
}
289295

296+
onCustomRange() {
297+
this.isCollapsed = !this.isCollapsed;
298+
if (this.isCollapsed) {
299+
this.maxDateFrom = null;
300+
this.maxDateTo = null;
301+
}
302+
}
303+
290304
ngOnDestroy(): void {
291305
this.timeFilterBehavior.$time.next(null);
292306
this.destroy$.next();

0 commit comments

Comments
 (0)