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

32 lines
1.1 KiB
TypeScript

import * as _ from "lodash";
import {Pipe, PipeTransform} from "@angular/core";
@Pipe({
name: "dmpTableFilter"
})
export class DmpTableFilterPipe 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.project == null || row.project.label==null) row.project = {"label":""};
if(row.profile == null || row.profile.label==null) row.profile = {"label":""};
if (row.id == null) row.id = "";
return (
row.project.label.indexOf(query) > -1 ||
row.label.indexOf(query) > -1 ||
row.profile.label.indexOf(query) > -1 ||
row.profileData.indexOf(query) > -1 ||
//row.version == query ||
row.id.indexOf(query) > -1
)
});
}
return array;
}
}