src/app/pipes/templates-filter.pipe.ts
Search the given template array for templates that match the given string.
name | templatesFilter |
searchEmail | ||||||
searchEmail(value: , target: )
|
||||||
Defined in src/app/pipes/templates-filter.pipe.ts:45
|
||||||
Parameters :
Returns :
boolean
|
searchName | ||||||
searchName(value: , target: )
|
||||||
Defined in src/app/pipes/templates-filter.pipe.ts:35
|
||||||
Parameters :
Returns :
boolean
|
searchPhone | ||||||
searchPhone(value: , target: )
|
||||||
Defined in src/app/pipes/templates-filter.pipe.ts:56
|
||||||
Parameters :
Returns :
boolean
|
searchTemplate | |||||||||
searchTemplate(value: Template, target: )
|
|||||||||
Defined in src/app/pipes/templates-filter.pipe.ts:27
|
|||||||||
Parameters :
Returns :
boolean
|
transform | |||||||||
transform(input: Template[], targetRaw: string)
|
|||||||||
Defined in src/app/pipes/templates-filter.pipe.ts:15
|
|||||||||
Parameters :
Returns :
[]
|
import { Pipe, PipeTransform } from '@angular/core';
import { Template } from '../models';
import { LOCALE } from '../app.constants';
/**
* Search the given template array for templates that match the given string.
*
* @export
* @class TemplatesFilterPipe
*/
@Pipe({
name: 'templatesFilter'
})
export class TemplatesFilterPipe {
transform(input: Template[], targetRaw: string): Template[] {
if (
input === null ||
input === undefined ||
targetRaw === null ||
targetRaw === undefined
)
return input;
let target = targetRaw.toLowerCase();
return input.filter(value => this.searchTemplate(value, target));
}
searchTemplate(value: Template, target) {
return (
this.searchName(value, target) ||
this.searchEmail(value, target) ||
this.searchPhone(value, target)
);
}
searchName(value, target) {
return (
value !== null &&
value !== undefined &&
value.name !== null &&
value.name !== undefined &&
value.name.toLowerCase().indexOf(target) > -1
);
}
searchEmail(value, target) {
return (
value !== null &&
value !== undefined &&
value.p2PPayToEmailAddress !== null &&
value.p2PPayToEmailAddress !== undefined &&
value.p2PPayToEmailAddress.length > 0 &&
value.p2PPayToEmailAddress.toLowerCase().indexOf(target) > -1
);
}
searchPhone(value, target) {
return (
value !== null &&
value !== undefined &&
value.p2PPayToPhoneNumber !== null &&
value.p2PPayToPhoneNumber !== undefined &&
value.p2PPayToPhoneNumber.length > 0 &&
value.p2PPayToPhoneNumber.toLowerCase().indexOf(target) > -1
);
}
}