This commit is contained in:
k.struzhkin 2021-07-29 12:37:11 +03:00
parent e2a1bea3be
commit 689498600b
3 changed files with 7 additions and 3 deletions

View File

@ -9,7 +9,7 @@
[ngxMatDatetimePicker]="pickerFrom" [ngxMatDatetimePicker]="pickerFrom"
formControlName="from" formControlName="from"
/> />
<mat-datepicker-toggle matSuffix [for]="pickerFrom" dataformatas=""></mat-datepicker-toggle> <mat-datepicker-toggle matSuffix [for]="pickerFrom"></mat-datepicker-toggle>
<ngx-mat-datetime-picker showSeconds="true" #pickerFrom></ngx-mat-datetime-picker> <ngx-mat-datetime-picker showSeconds="true" #pickerFrom></ngx-mat-datetime-picker>
</mat-form-field> </mat-form-field>
<mat-form-field floatLabel="always" appearance="fill" class="date-picker"> <mat-form-field floatLabel="always" appearance="fill" class="date-picker">

View File

@ -1,4 +1,4 @@
import { Component, EventEmitter, Output } from '@angular/core'; import { AfterViewChecked, Component, EventEmitter, Output } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms'; import { FormBuilder, FormGroup } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { debounceTime, map, take } from 'rxjs/operators'; import { debounceTime, map, take } from 'rxjs/operators';
@ -34,7 +34,10 @@ export class HistoryDataSearchComponent {
private searchFieldService: SearchFieldService private searchFieldService: SearchFieldService
) { ) {
this.form.valueChanges.pipe(debounceTime(600), map(removeEmptyProperties)).subscribe((v) => { this.form.valueChanges.pipe(debounceTime(600), map(removeEmptyProperties)).subscribe((v) => {
this.router.navigate([location.pathname], { queryParams: v }); const params = Object.create(v);
params.from = new Date(v.from).toISOString();
params.to = new Date(v.to).toISOString();
this.router.navigate([location.pathname], { queryParams: params });
this.valueChanges.emit(v); this.valueChanges.emit(v);
}); });
this.route.queryParams.pipe(take(1)).subscribe((v) => this.form.patchValue(v)); this.route.queryParams.pipe(take(1)).subscribe((v) => this.form.patchValue(v));

View File

@ -10,6 +10,7 @@ export class SearchFieldService {
todayFromTime(): Date { todayFromTime(): Date {
const now = new Date(); const now = new Date();
now.setDate(now.getDate() - 1);
now.setHours(0, 0, 0, 0); now.setHours(0, 0, 0, 0);
return now; return now;
} }