4 changed files with 72 additions and 2 deletions
@ -0,0 +1,35 @@ |
|||||
|
import {SearchFilter} from "./SearchFilter"; |
||||
|
import {MatPaginator} from "@angular/material/paginator"; |
||||
|
import {ParamMap} from "@angular/router"; |
||||
|
|
||||
|
export class ReportSearchFilter extends SearchFilter { |
||||
|
ids: number[]|null = []; |
||||
|
|
||||
|
|
||||
|
override createQuery(paginator: MatPaginator | undefined): { [p: string]: any } { |
||||
|
let q:{[param: string]: any} = super.createQuery(paginator); |
||||
|
q["ids"] = this.ids?this.ids.join(","):null; |
||||
|
return q; |
||||
|
} |
||||
|
|
||||
|
override fromQuery(param: ParamMap, paginator: MatPaginator | undefined) { |
||||
|
try {if (param.get("ids")) { // @ts-ignore
|
||||
|
this.ids = param.get("ids")?.split(",");}}catch (e) {} |
||||
|
|
||||
|
super.fromQuery(param, paginator); |
||||
|
} |
||||
|
|
||||
|
addReportIdToSearch(id: number) { |
||||
|
if (this.ids == null) |
||||
|
this.ids = []; |
||||
|
if (this.ids.indexOf(id) == -1) |
||||
|
this.ids.push(id) |
||||
|
this.updated = true; |
||||
|
} |
||||
|
|
||||
|
removeReportIdFromSearch(id: number) { |
||||
|
if (this.ids == null) return; |
||||
|
this.ids = this.ids.filter(v => v !== id); |
||||
|
this.updated = true; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
import {Component, Input} from "@angular/core"; |
||||
|
import {ReportSearchFilter} from "../../../entities/search/ReportSearchFilter"; |
||||
|
|
||||
|
@Component({ |
||||
|
selector: "app-filter-mat-chip-reportid", |
||||
|
template: ` |
||||
|
<div *ngIf="filter && filter.ids != null"> |
||||
|
<mat-chip |
||||
|
*ngFor="let reportId of filter.ids" |
||||
|
(removed)="filter.removeReportIdFromSearch(reportId)" |
||||
|
>ReportId: {{reportId}} |
||||
|
<button matChipRemove> |
||||
|
<mat-icon>cancel</mat-icon> |
||||
|
</button> |
||||
|
</mat-chip> |
||||
|
</div>` |
||||
|
}) |
||||
|
export class FilterMatChipReportId { |
||||
|
|
||||
|
@Input("filter") |
||||
|
filter: ReportSearchFilter|undefined; |
||||
|
} |
||||
Loading…
Reference in new issue