Skip to content

Commit 3db435a

Browse files
committed
Reformat gt-search pipe
1 parent a6bd1bd commit 3db435a

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

@angular-generic-table/core/pipes/gt-search.pipe.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Pipe, PipeTransform } from '@angular/core';
2-
import {GtConfigField} from '../interfaces/gt-config-field';
2+
import { GtConfigField } from '../interfaces/gt-config-field';
33
import { GtRow } from '../interfaces/gt-row';
4-
import {GtConfigSetting} from '../interfaces/gt-config-setting';
5-
import {GtInformation} from '../interfaces/gt-information';
4+
import { GtConfigSetting } from '../interfaces/gt-config-setting';
5+
import { GtInformation } from '../interfaces/gt-information';
66

77

88
@Pipe({
@@ -11,8 +11,8 @@ import {GtInformation} from '../interfaces/gt-information';
1111
export class GtSearchPipe<R extends GtRow> implements PipeTransform {
1212

1313
/** Return property */
14-
private getProperty = function(array: Array<any>, key: string){
15-
for (let i = 0; i < array.length; i++){
14+
private getProperty = function (array: Array<any>, key: string) {
15+
for (let i = 0; i < array.length; i++) {
1616
if (array[i].objectKey === key) {
1717
return array[i];
1818
}
@@ -22,7 +22,7 @@ export class GtSearchPipe<R extends GtRow> implements PipeTransform {
2222
transform(allRows: any, searchTerms: string, gtInfo: GtInformation, settings: Array<GtConfigSetting>, fields: Array<GtConfigField<R, any>>, refreshData: number): any {
2323

2424
// if no search terms are defined...
25-
if (!searchTerms || searchTerms.replace(/"/g, '').length === 0){
25+
if (!searchTerms || searchTerms.replace(/"/g, '').length === 0) {
2626

2727
// ...return all rows
2828
const length = allRows === null ? 0 : allRows.length;
@@ -33,17 +33,17 @@ export class GtSearchPipe<R extends GtRow> implements PipeTransform {
3333
const searchFunction: any = {};
3434
const fieldsTemp: Array<any> = [];
3535

36-
for (let k = 0; k < fields.length; k++){
36+
for (let k = 0; k < fields.length; k++) {
3737
const field = fields[k];
3838

3939
// check if field should be included in global search
4040
const include = this.getProperty(settings, field.objectKey).search === false ? false : true;
4141

4242
// if include...
43-
if (include){
43+
if (include) {
4444

4545
// ...and if search function is defined...
46-
if (typeof field.search === 'function' ) {
46+
if (typeof field.search === 'function') {
4747
// ...add it as search function for field
4848
searchFunction[field.objectKey] = field.search;
4949
}
@@ -62,26 +62,26 @@ export class GtSearchPipe<R extends GtRow> implements PipeTransform {
6262
searchTerms = typeof searchTerms === 'undefined' ? '' : searchTerms;
6363
const searchTermsArray = searchTerms.toLowerCase().match(/(".*"|[^\s]+)/g);
6464

65-
for (let i = 0; i < allRows.length; i++){
65+
for (let i = 0; i < allRows.length; i++) {
6666
const row = allRows[i];
6767
let string = '';
6868

69-
for (let j = 0; j < fieldsTemp.length; j++){
69+
for (let j = 0; j < fieldsTemp.length; j++) {
7070
const separator = j === 0 ? '' : ' & ';
7171
string += searchFunction[fieldsTemp[j].objectKey] ? separator + searchFunction[fieldsTemp[j].objectKey](row, j) : separator + row[fieldsTemp[j].objectKey];
7272
}
7373
string = string.toLowerCase();
7474
let match: Boolean = true;
7575

76-
for (let k = 0; k < searchTermsArray.length; k++){
76+
for (let k = 0; k < searchTermsArray.length; k++) {
7777
const term = searchTermsArray[k].replace(/"/g, '');
7878
match = string.indexOf(term) !== -1;
7979

80-
if (!match){
80+
if (!match) {
8181
break;
8282
}
8383
}
84-
if (match){
84+
if (match) {
8585
filteredRows.push(row);
8686
}
8787
}

0 commit comments

Comments
 (0)