src/app/pipes/templates-filter.pipe.ts
Search the given account array for templates that match the given string.
Name | templatesFilter |
searchAccount |
searchAccount(value: Template, target: string)
|
Defined in src/app/pipes/templates-filter.pipe.ts:46
|
Returns :
any
|
searchDisplayName |
searchDisplayName(value: Template, target: string)
|
Defined in src/app/pipes/templates-filter.pipe.ts:57
|
Returns :
any
|
searchName |
searchName(value: Template, target: string)
|
Defined in src/app/pipes/templates-filter.pipe.ts:36
|
Returns :
any
|
searchTemplate |
searchTemplate(value: Template, target: string)
|
Defined in src/app/pipes/templates-filter.pipe.ts:28
|
Returns :
any
|
transform | |||||||||
transform(input: Template[], targetRaw: string)
|
|||||||||
Defined in src/app/pipes/templates-filter.pipe.ts:15
|
|||||||||
Parameters :
Returns :
Template[]
|
import { Pipe, PipeTransform } from '@angular/core';
import { Template } from '../models';
import { LOCALE } from '../app.constants';
/**
* Search the given account array for templates that match the given string.
*
* @export
* @class TemplatesFilterPipe
*/
@Pipe({
name: 'templatesFilter'
})
export class TemplatesFilterPipe implements PipeTransform {
transform(input: Template[], targetRaw: string): Template[] {
if (
input === null ||
input === undefined ||
targetRaw === null ||
targetRaw === undefined
) {
return input;
}
const target = targetRaw.toLowerCase();
return input.filter(value => this.searchTemplate(value, target));
}
searchTemplate(value: Template, target: string) {
return (
this.searchName(value, target) ||
this.searchAccount(value, target) ||
this.searchDisplayName(value, target)
);
}
searchName(value: Template, target: string) {
return (
value !== null &&
value !== undefined &&
value.name !== null &&
value.name !== undefined &&
value.name.toLowerCase().includes(target)
);
}
searchAccount(value: Template, target: string) {
return (
value !== null &&
value !== undefined &&
value.accountNumber !== null &&
value.accountNumber !== undefined &&
value.accountNumber.length > 0 &&
value.accountNumber.toLowerCase().includes(target)
);
}
searchDisplayName(value: Template, target: string) {
return (
value !== null &&
value !== undefined &&
value.displayName !== null &&
value.displayName !== undefined &&
value.displayName.length > 0 &&
value.displayName.toLowerCase().includes(target)
);
}
}