argos/dmp-admin/src/app/pipes/registry-table-filter.pipe.ts

29 lines
748 B
TypeScript

import * as _ from "lodash";
import {Pipe, PipeTransform} from "@angular/core";
@Pipe({
name: "registryTableFilter"
})
export class RegistryTableFilterPipe implements PipeTransform {
transform(array: any[], query: string): any {
if (query) {
return _.filter(array, row => {
if (row.uri == null) row.uri = "";
if (row.label == null) row.label = "";
if (row.id == null) row.id = "";
return (
row.label.indexOf(query) > -1 ||
//row.version == query ||
row.id.indexOf(query) > -1
)
});
}
return array;
}
}