Skip to content
Snippets Groups Projects
Commit b5a689d3 authored by Maxime MAKHLOUFI's avatar Maxime MAKHLOUFI Committed by Gaëlle FOURNIER
Browse files

19716 - Probative value - Fix date search filters

parent 7b6bbfef
No related branches found
No related tags found
No related merge requests found
...@@ -28,17 +28,17 @@ ...@@ -28,17 +28,17 @@
<tr class="vitamui-table-row"> <tr class="vitamui-table-row">
<td class="clickable" (click)="probativeValueClick.emit(probativeValue)"> <td class="clickable" (click)="probativeValueClick.emit(probativeValue)">
<i class="vitamui-icon vitamui-icon-probativeValue vitamui-row-icon status-badge" <i class="vitamui-icon vitamui-icon-probativeValue vitamui-row-icon status-badge"
[ngClass]="{'status-badge-green': probativeVlaueStatus(probativeValue) == 'OK', 'status-badge-grey':probativeVlaueStatus(probativeValue) == 'STARTED', [ngClass]="{'status-badge-green': probativeValueStatus(probativeValue) == 'OK', 'status-badge-grey':probativeValueStatus(probativeValue) == 'STARTED',
'status-badge-orange': probativeVlaueStatus(probativeValue) == 'WARNING', 'status-badge-red': probativeVlaueStatus(probativeValue) == 'KO' || probativeVlaueStatus(probativeValue) == 'FATAL' }"></i> 'status-badge-orange': probativeValueStatus(probativeValue) == 'WARNING', 'status-badge-red': probativeValueStatus(probativeValue) == 'KO' || probativeValueStatus(probativeValue) == 'FATAL' }"></i>
</td> </td>
<td class="clickable" (click)="probativeValueClick.emit(probativeValue)">{{ probativeValue?.id }}</td> <td class="clickable" (click)="probativeValueClick.emit(probativeValue)">{{ probativeValue?.id }}</td>
<td class="clickable" (click)="probativeValueClick.emit(probativeValue)">{{ probativeValue?.dateTime | date: 'dd/MM/yyyy' }} <td class="clickable" (click)="probativeValueClick.emit(probativeValue)">{{ probativeValue?.dateTime | date: 'dd/MM/yyyy' }}
</td> </td>
<td class="clickable" (click)="probativeValueClick.emit(probativeValue)" <td class="clickable" (click)="probativeValueClick.emit(probativeValue)"
[ngClass]="{'text-green': probativeVlaueStatus(probativeValue) == 'OK', 'text-grey':probativeVlaueStatus(probativeValue) == 'STARTED', [ngClass]="{'text-green': probativeValueStatus(probativeValue) == 'OK', 'text-grey':probativeValueStatus(probativeValue) == 'STARTED',
'text-orange': probativeVlaueStatus(probativeValue) == 'WARNING', 'text-red': probativeVlaueStatus(probativeValue) == 'KO' || probativeVlaueStatus(probativeValue) == 'FATAL' }"> 'text-orange': probativeValueStatus(probativeValue) == 'WARNING', 'text-red': probativeValueStatus(probativeValue) == 'KO' || probativeValueStatus(probativeValue) == 'FATAL' }">
{{ probativeVlaueStatus(probativeValue) }}</td> {{ probativeValueStatus(probativeValue) }}</td>
<td class="clickable" (click)="probativeValueClick.emit(probativeValue)">{{ probativeVlaueMessage(probativeValue) }}</td> <td class="clickable" (click)="probativeValueClick.emit(probativeValue)">{{ probativeValueMessage(probativeValue) }}</td>
</tr> </tr>
</ng-container> </ng-container>
</tbody> </tbody>
......
...@@ -7,6 +7,11 @@ import {ProbativeValueService} from '../probative-value.service'; ...@@ -7,6 +7,11 @@ import {ProbativeValueService} from '../probative-value.service';
const FILTER_DEBOUNCE_TIME_MS = 400; const FILTER_DEBOUNCE_TIME_MS = 400;
export class ProbativeValueFilters {
startDate: string;
endDate: string;
}
@Component({ @Component({
selector: 'app-probative-value-list', selector: 'app-probative-value-list',
templateUrl: './probative-value-list.component.html', templateUrl: './probative-value-list.component.html',
...@@ -23,6 +28,16 @@ export class ProbativeValueListComponent extends InfiniteScrollTable<any> implem ...@@ -23,6 +28,16 @@ export class ProbativeValueListComponent extends InfiniteScrollTable<any> implem
// tslint:disable-next-line:variable-name // tslint:disable-next-line:variable-name
private _searchText: string; private _searchText: string;
@Input('filters')
set filters(filters: ProbativeValueFilters) {
console.log('Filters: ', filters);
this._filters = filters;
this.filterChange.next(filters);
}
// tslint:disable-next-line:variable-name
private _filters: ProbativeValueFilters;
loaded = false; loaded = false;
orderBy = '#id'; orderBy = '#id';
...@@ -30,6 +45,7 @@ export class ProbativeValueListComponent extends InfiniteScrollTable<any> implem ...@@ -30,6 +45,7 @@ export class ProbativeValueListComponent extends InfiniteScrollTable<any> implem
private readonly searchChange = new Subject<string>(); private readonly searchChange = new Subject<string>();
private readonly orderChange = new Subject<string>(); private readonly orderChange = new Subject<string>();
private readonly filterChange = new Subject<any>();
@Output() probativeValueClick = new EventEmitter<any>(); @Output() probativeValueClick = new EventEmitter<any>();
...@@ -46,29 +62,39 @@ export class ProbativeValueListComponent extends InfiniteScrollTable<any> implem ...@@ -46,29 +62,39 @@ export class ProbativeValueListComponent extends InfiniteScrollTable<any> implem
DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE,
this.orderBy, this.orderBy,
Direction.ASCENDANT, Direction.ASCENDANT,
JSON.stringify(this.buildProbativeVlaueCriteriaFromSearch()))) JSON.stringify(this.buildProbativeValueCriteriaFromSearch())))
.subscribe((data: any[]) => { .subscribe((data: any[]) => {
this.dataSource = data; this.dataSource = data;
}); });
const searchCriteriaChange = merge(this.searchChange, this.orderChange) const searchCriteriaChange = merge(this.searchChange, this.orderChange, this.filterChange)
.pipe(debounceTime(FILTER_DEBOUNCE_TIME_MS)); .pipe(debounceTime(FILTER_DEBOUNCE_TIME_MS));
searchCriteriaChange.subscribe(() => { searchCriteriaChange.subscribe(() => {
const query: any = this.buildProbativeVlaueCriteriaFromSearch(); const query: any = this.buildProbativeValueCriteriaFromSearch();
console.log('query: ', query); console.log('query: ', query);
const pageRequest = new PageRequest(0, DEFAULT_PAGE_SIZE, this.orderBy, this.direction, JSON.stringify(query)); const pageRequest = new PageRequest(0, DEFAULT_PAGE_SIZE, this.orderBy, this.direction, JSON.stringify(query));
this.search(pageRequest); this.search(pageRequest);
}); });
} }
buildProbativeVlaueCriteriaFromSearch() { buildProbativeValueCriteriaFromSearch() {
const criteria: any = {}; const criteria: any = {};
criteria.evTypeProc = 'AUDIT'; criteria.evTypeProc = 'AUDIT';
criteria.evType = 'EXPORT_PROBATIVE_VALUE'; criteria.evType = 'EXPORT_PROBATIVE_VALUE';
if (this._searchText !== undefined && this._searchText.length > 0) { if (this._searchText !== undefined && this._searchText.length > 0) {
criteria['#id'] = this._searchText; criteria['#id'] = this._searchText;
} }
if (this._filters) {
if (this._filters.startDate) {
criteria.evDateTime_Start = this._filters.startDate;
}
if (this._filters.endDate) {
criteria.evDateTime_End = this._filters.endDate;
}
}
return criteria; return criteria;
} }
...@@ -76,23 +102,24 @@ export class ProbativeValueListComponent extends InfiniteScrollTable<any> implem ...@@ -76,23 +102,24 @@ export class ProbativeValueListComponent extends InfiniteScrollTable<any> implem
this.updatedData.unsubscribe(); this.updatedData.unsubscribe();
} }
searchProbativeVlaueOrdered() { searchProbativeValueOrdered() {
this.search(new PageRequest(0, DEFAULT_PAGE_SIZE, this.orderBy, Direction.ASCENDANT)); const query: any = this.buildProbativeValueCriteriaFromSearch();
this.search(new PageRequest(0, DEFAULT_PAGE_SIZE, this.orderBy, Direction.ASCENDANT, JSON.stringify(query)));
} }
emitOrderChange() { emitOrderChange() {
this.orderChange.next(); this.orderChange.next();
} }
probativeVlaueStatus(probativeVlaue: any): string { probativeValueStatus(probativeValue: any): string {
return (probativeVlaue.events !== undefined && probativeVlaue.events.length !== 0) ? return (probativeValue.events !== undefined && probativeValue.events.length !== 0) ?
probativeVlaue.events[probativeVlaue.events.length - 1].outcome : probativeValue.events[probativeValue.events.length - 1].outcome :
probativeVlaue.outcome; probativeValue.outcome;
} }
probativeVlaueMessage(probativeVlaue: any): string { probativeValueMessage(probativeValue: any): string {
return (probativeVlaue.events !== undefined && probativeVlaue.events.length !== 0) ? return (probativeValue.events !== undefined && probativeValue.events.length !== 0) ?
probativeVlaue.events[probativeVlaue.events.length - 1].outMessage : probativeValue.events[probativeValue.events.length - 1].outMessage :
probativeVlaue.outMessage; probativeValue.outMessage;
} }
} }
<mat-sidenav-container [autosize]="true" [hasBackdrop]="false"> <mat-sidenav-container [autosize]="true" [hasBackdrop]="false">
<mat-sidenav #panel mode="side" position="end" [fixedInViewport]="true"> <mat-sidenav #panel mode="side" position="end" [fixedInViewport]="true">
<app-probative-value-preview *ngIf="openedItem" (previewClose)="closePanel()" [probativeValue]="openedItem"></app-probative-value-preview> <app-probative-value-preview *ngIf="openedItem" (previewClose)="closePanel()" [probativeValue]="openedItem">
</mat-sidenav> </app-probative-value-preview>
</mat-sidenav>
<mat-sidenav-content> <mat-sidenav-content>
<div class="vitamui-header"> <div class="vitamui-header">
<div class="vitamui-container"> <div class="vitamui-container">
<vitamui-common-navbar [appId]="appId" (tenantSelect)="changeTenant($event)" [hideCustomerMenu]="true"></vitamui-common-navbar> <vitamui-common-navbar [appId]="appId" (tenantSelect)="changeTenant($event)" [hideCustomerMenu]="true">
</vitamui-common-navbar>
<h2> <h2>
Rechercher mes <strong>Relevés de valeur probante</strong> Rechercher mes <strong>Relevés de valeur probante</strong>
...@@ -17,14 +19,16 @@ ...@@ -17,14 +19,16 @@
<div class="controls"> <div class="controls">
<div class="search-bar-filters"> <div class="search-bar-filters">
<vitamui-common-search-bar #searchBar name="probativeVlaue-search" (search)="onSearchSubmit($event)" <vitamui-common-search-bar #searchBar name="probativeValue-search"
placeholder="Identifiant de relevé, identifiant d'UA" i18n-placeholder="@@probativeValueSearchPlaceholder"> (search)="onSearchSubmit($event)" placeholder="Identifiant de relevé, identifiant d'UA"
i18n-placeholder="@@probativeValueSearchPlaceholder">
</vitamui-common-search-bar> </vitamui-common-search-bar>
<div class="reset-filters" (click)="resetFilters()">Effacer les filtres et la recherche</div> <div class="reset-filters" (click)="resetFilters()">Effacer les filtres et la recherche</div>
</div> </div>
<div class="actions"> <div class="actions">
<button class="btn secondary" (click)="openCreateProbativeVlaueDialog()"> <button class="btn secondary" (click)="openCreateProbativeValueDialog()">
<i class="vitamui-icon vitamui-icon-probativeVlaue btn-create"></i> <span>Lancer un relevé</span> <i class="vitamui-icon vitamui-icon-probativeValue btn-create"></i> <span>Lancer un
relevé</span>
</button> </button>
</div> </div>
...@@ -65,8 +69,9 @@ ...@@ -65,8 +69,9 @@
</div> </div>
</div> </div>
<div class="vitamui-body vitamui-container"> <div class="vitamui-body vitamui-container">
<app-probative-value-list (probativeValueClick)="showProbativeValue($event)" [search]="search"></app-probative-value-list> <app-probative-value-list (probativeValueClick)="showProbativeValue($event)" [search]="search"
[filters]="filters"></app-probative-value-list>
</div> </div>
</mat-sidenav-content> </mat-sidenav-content>
</mat-sidenav-container> </mat-sidenav-container>
\ No newline at end of file
...@@ -20,7 +20,7 @@ export class ProbativeValueComponent extends SidenavPage<Event> implements OnIni ...@@ -20,7 +20,7 @@ export class ProbativeValueComponent extends SidenavPage<Event> implements OnIni
filters: any = {}; filters: any = {};
@ViewChild(SearchBarComponent, {static: true}) searchBar: SearchBarComponent; @ViewChild(SearchBarComponent, {static: true}) searchBar: SearchBarComponent;
@ViewChild(ProbativeValueListComponent, {static: true}) probativeVlaueListComponent: ProbativeValueListComponent; @ViewChild(ProbativeValueListComponent, {static: true}) probativeValueListComponent: ProbativeValueListComponent;
constructor( constructor(
public dialog: MatDialog, public dialog: MatDialog,
...@@ -35,12 +35,20 @@ export class ProbativeValueComponent extends SidenavPage<Event> implements OnIni ...@@ -35,12 +35,20 @@ export class ProbativeValueComponent extends SidenavPage<Event> implements OnIni
endDate: null endDate: null
}); });
this.dateRangeFilterForm.valueChanges.subscribe((value) => { this.dateRangeFilterForm.controls.startDate.valueChanges.subscribe(value => {
this.filters.dateRange = value; this.filters.startDate = value;
this.probativeValueListComponent.filters = this.filters;
});
this.dateRangeFilterForm.controls.endDate.valueChanges.subscribe((value: Date) => {
if (value) {
value.setDate(value.getDate() + 1);
}
this.filters.endDate = value;
this.probativeValueListComponent.filters = this.filters;
}); });
} }
openCreateProbativeVlaueDialog() { openCreateProbativeValueDialog() {
const dialogRef = this.dialog.open(ProbativeValueCreateComponent, { const dialogRef = this.dialog.open(ProbativeValueCreateComponent, {
panelClass: 'vitamui-modal', panelClass: 'vitamui-modal',
disableClose: true disableClose: true
...@@ -53,10 +61,10 @@ export class ProbativeValueComponent extends SidenavPage<Event> implements OnIni ...@@ -53,10 +61,10 @@ export class ProbativeValueComponent extends SidenavPage<Event> implements OnIni
} }
private refreshList() { private refreshList() {
if (!this.probativeVlaueListComponent) { if (!this.probativeValueListComponent) {
return; return;
} }
this.probativeVlaueListComponent.searchProbativeVlaueOrdered(); this.probativeValueListComponent.searchProbativeValueOrdered();
} }
onSearchSubmit(search: string) { onSearchSubmit(search: string) {
...@@ -86,6 +94,6 @@ export class ProbativeValueComponent extends SidenavPage<Event> implements OnIni ...@@ -86,6 +94,6 @@ export class ProbativeValueComponent extends SidenavPage<Event> implements OnIni
} }
changeTenant(tenantIdentifier: number) { changeTenant(tenantIdentifier: number) {
this.router.navigate(['..', tenantIdentifier], { relativeTo: this.route }); this.router.navigate(['..', tenantIdentifier], {relativeTo: this.route});
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment