Add filter from router param

master
Max Ehrlicher-Schmidt 4 years ago
parent c53285f11b
commit f98ca428f2

@ -23,6 +23,7 @@ import { ActivatedRoute } from '@angular/router';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { debounceTime } from 'rxjs/internal/operators/debounceTime'; import { debounceTime } from 'rxjs/internal/operators/debounceTime';
import { SelectObjectDialogComponent } from '../select-object-dialog/select-object-dialog.component'; import { SelectObjectDialogComponent } from '../select-object-dialog/select-object-dialog.component';
import { filter } from 'rxjs/operators';
@Component({ @Component({
selector: 'app-table', selector: 'app-table',
@ -109,11 +110,7 @@ export class TableComponent implements AfterViewInit {
public dialog: MatDialog, public dialog: MatDialog,
private activatedroute: ActivatedRoute, private activatedroute: ActivatedRoute,
private cdRef: ChangeDetectorRef private cdRef: ChangeDetectorRef
) { ) {}
/*this.filter.includesString =
this.activatedroute.snapshot.queryParamMap.get('filter') || '';*/
//TODO: add filter from url
}
ngOnInit() { ngOnInit() {
this.addColumnPropertiesFromGQLSchemaToColumnInfo(); this.addColumnPropertiesFromGQLSchemaToColumnInfo();
@ -127,6 +124,15 @@ export class TableComponent implements AfterViewInit {
); );
this.resetFilters(); this.resetFilters();
const routeFilter = this.activatedroute.snapshot.queryParams;
for (const filterName of Object.keys(routeFilter)) {
if (this.filters.columnFilters[filterName]) {
this.filters.columnFilters[filterName].value = routeFilter[filterName];
this.filters.columnFilters[filterName].isSet = true;
this.filters.columnFilters[filterName].options.exact = true;
}
}
} }
ngAfterViewInit(): void { ngAfterViewInit(): void {

@ -270,9 +270,6 @@ export class BikeComponent implements OnInit {
); );
}, },
linkToTable: (element) => '/table/equipments', linkToTable: (element) => '/table/equipments',
linkToTableParams: (bike) => {
return { filter: bike.name };
},
propertyNameOfUpdateInput: 'equipmentIds', propertyNameOfUpdateInput: 'equipmentIds',
}, },
{ {
@ -291,7 +288,7 @@ export class BikeComponent implements OnInit {
editableReferences: false, editableReferences: false,
linkToTable: () => '/table/timeFrames', linkToTable: () => '/table/timeFrames',
linkToTableParams: (bike) => { linkToTableParams: (bike) => {
return { filter: bike.name }; return { "cargoBike.name": bike.name};
}, },
}, },
{ {
@ -324,7 +321,7 @@ export class BikeComponent implements OnInit {
editableReferences: false, editableReferences: false,
linkToTable: () => '/table/engagements', linkToTable: () => '/table/engagements',
linkToTableParams: (bike) => { linkToTableParams: (bike) => {
return { filter: bike.name }; return { "cargoBike.name": bike.name};
}, },
}, },
]; ];

@ -184,7 +184,7 @@ export class LendingStationComponent implements OnInit {
editableReferences: false, editableReferences: false,
linkToTable: () => '/table/timeFrames', linkToTable: () => '/table/timeFrames',
linkToTableParams: (lendingStation) => { linkToTableParams: (lendingStation) => {
return { filter: lendingStation.name }; return { "lendingStation.name": lendingStation.name};
}, },
}, },
]; ];

Loading…
Cancel
Save