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 { debounceTime } from 'rxjs/internal/operators/debounceTime';
import { SelectObjectDialogComponent } from '../select-object-dialog/select-object-dialog.component';
import { filter } from 'rxjs/operators';
@Component({
selector: 'app-table',
@ -109,11 +110,7 @@ export class TableComponent implements AfterViewInit {
public dialog: MatDialog,
private activatedroute: ActivatedRoute,
private cdRef: ChangeDetectorRef
) {
/*this.filter.includesString =
this.activatedroute.snapshot.queryParamMap.get('filter') || '';*/
//TODO: add filter from url
}
) {}
ngOnInit() {
this.addColumnPropertiesFromGQLSchemaToColumnInfo();
@ -127,6 +124,15 @@ export class TableComponent implements AfterViewInit {
);
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 {

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

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

Loading…
Cancel
Save