All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.app.shared.pipes.dataset-search.pipe.ts Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
import { Dataset } from '@model';
import { Pipe, PipeTransform } from '@angular/core';
import { containsAll } from '@shared/tools/array-utils';

@Pipe({
    name: 'dataSetSearch'
})
export class DataSetSearchPipe implements PipeTransform {

    transform(input: any, tags: String[]) {
        if (tags.length === 0) {
            return input;
        }

        return input.filter((item: Dataset) => {
            return (this.tagPresent(tags, item));
        });
    }

    private tagPresent(tags: String[], dataset: Dataset): boolean {
        return containsAll(tags, dataset.tags);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy