• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IgniteUI / igniteui-angular / 12195125612

06 Dec 2024 08:00AM CUT coverage: 91.624% (+0.003%) from 91.621%
12195125612

Pull #15149

github

web-flow
Merge 9a551d87c into fe340b4a9
Pull Request #15149: refactor(avatar): remove unused code

12968 of 15199 branches covered (85.32%)

26309 of 28714 relevant lines covered (91.62%)

34014.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

74.73
/projects/igniteui-angular/src/lib/data-operations/filtering-condition.ts
1
/**
2
 * Provides base filtering operations
3
 * Implementations should be Singleton
4
 *
5
 * @export
6
 */
7
export class IgxFilteringOperand {
8
    protected static _instance: IgxFilteringOperand = null;
2✔
9
    public operations: IFilteringOperation[];
10

11
    constructor() {
12
        this.operations = [{
15✔
13
            name: 'null',
14
            isUnary: true,
15
            iconName: 'filter_null',
16
            logic: (target: any) => target === null
66✔
17
        }, {
18
            name: 'notNull',
19
            isUnary: true,
20
            iconName: 'filter_not_null',
21
            logic: (target: any) => target !== null
82✔
22
        }, {
23
            name: 'in',
24
            isUnary: false,
25
            iconName: 'filter_in',
26
            hidden: true,
27
            logic: (target: any, searchVal: Set<any>) => this.findValueInSet(target, searchVal)
343✔
28
        }];
29
    }
30

31
    public static instance(): IgxFilteringOperand {
32
        return this._instance || (this._instance = new this());
23,476✔
33
    }
34

35
    /**
36
     * Returns an array of names of the conditions which are visible in the UI
37
     */
38
    public conditionList(): string[] {
39
        return this.operations.filter(f => !f.hidden).map((element) => element.name);
29,744✔
40
    }
41

42
    /**
43
     * Returns an instance of the condition with the specified name.
44
     *
45
     * @param name The name of the condition.
46
     */
47
    public condition(name: string): IFilteringOperation {
48
        return this.operations.find((element) => element.name === name);
302,834✔
49
    }
50

51
    /**
52
     * Adds a new condition to the filtering operations.
53
     *
54
     * @param operation The filtering operation.
55
     */
56
    public append(operation: IFilteringOperation) {
57
        this.operations.push(operation);
1✔
58
    }
59

60
    /**
61
     * @hidden
62
     */
63
    protected findValueInSet(target: any, searchVal: Set<any>) {
64
        return searchVal.has(target);
327✔
65
    }
66
}
67

68
/* blazorCSSuppress */
69
/**
70
 * Provides filtering operations for booleans
71
 *
72
 * @export
73
 */
74
export class IgxBooleanFilteringOperand extends IgxFilteringOperand {
75
    protected constructor() {
76
        super();
2✔
77
        this.operations = [{
2✔
78
            name: 'all',
79
            isUnary: true,
80
            iconName: 'filter_all',
81
            logic: (_target: boolean) => true
16✔
82
        }, {
83
            name: 'true',
84
            isUnary: true,
85
            iconName: 'filter_true',
86
            logic: (target: boolean) => !!(target && target !== null && target !== undefined)
154✔
87
        }, {
88
            name: 'false',
89
            isUnary: true,
90
            iconName: 'filter_false',
91
            logic: (target: boolean) => !target && target !== null && target !== undefined
68✔
92
        }, {
93
            name: 'empty',
94
            isUnary: true,
95
            iconName: 'filter_empty',
96
            logic: (target: boolean) => target === null || target === undefined
75✔
97
        }, {
98
            name: 'notEmpty',
99
            isUnary: true,
100
            iconName: 'filter_not_empty',
101
            logic: (target: boolean) => target !== null && target !== undefined
14✔
102
        }].concat(this.operations);
103
    }
104
}
105

106
/* blazorCSSuppress */
107
/**
108
 * @internal
109
 * @hidden
110
 */
111
class IgxBaseDateTimeFilteringOperand extends IgxFilteringOperand {
112
    protected constructor() {
113
        super();
6✔
114
        this.operations = [{
6✔
115
            name: 'empty',
116
            isUnary: true,
117
            iconName: 'filter_empty',
118
            logic: (target: Date) => target === null || target === undefined
64✔
119
        }, {
120
            name: 'notEmpty',
121
            isUnary: true,
122
            iconName: 'filter_not_empty',
123
            logic: (target: Date) => target !== null && target !== undefined
38✔
124
        }].concat(this.operations);
125
    }
126

127
    /**
128
     * Splits a Date object into parts
129
     *
130
     * @memberof IgxDateFilteringOperand
131
     */
132
    public static getDateParts(date: Date, dateFormat?: string): IDateParts {
133
        const res = {
834✔
134
            day: null,
135
            hours: null,
136
            milliseconds: null,
137
            minutes: null,
138
            month: null,
139
            seconds: null,
140
            year: null
141
        };
142
        if (!date || !dateFormat) {
834!
143
            return res;
×
144
        }
145
        if (dateFormat.indexOf('y') >= 0) {
834✔
146
            res.year = date.getFullYear();
762✔
147
        }
148
        if (dateFormat.indexOf('M') >= 0) {
834✔
149
            res.month = date.getMonth();
630✔
150
        }
151
        if (dateFormat.indexOf('d') >= 0) {
834✔
152
            res.day = date.getDate();
486✔
153
        }
154
        if (dateFormat.indexOf('h') >= 0) {
834✔
155
            res.hours = date.getHours();
134✔
156
        }
157
        if (dateFormat.indexOf('m') >= 0) {
834✔
158
            res.minutes = date.getMinutes();
134✔
159
        }
160
        if (dateFormat.indexOf('s') >= 0) {
834✔
161
            res.seconds = date.getSeconds();
134✔
162
        }
163
        if (dateFormat.indexOf('f') >= 0) {
834!
164
            res.milliseconds = date.getMilliseconds();
×
165
        }
166
        return res;
834✔
167
    }
168

169
    protected override findValueInSet(target: any, searchVal: Set<any>) {
170
        if (!target) {
×
171
            return false;
×
172
        }
173
        return searchVal.has((target instanceof Date) ? target.toISOString() : target);
×
174
    }
175

176
    protected validateInputData(target: Date) {
177
        if (!(target instanceof Date)) {
527!
178
            throw new Error('Could not perform filtering on \'date\' column because the datasource object type is not \'Date\'.');
×
179
        }
180
    }
181
}
182

183
/* blazorCSSuppress */
184
/**
185
 * Provides filtering operations for Dates
186
 *
187
 * @export
188
 */
189
export class IgxDateFilteringOperand extends IgxBaseDateTimeFilteringOperand {
190
    protected constructor() {
191
        super();
2✔
192
        this.operations = [{
2✔
193
            name: 'equals',
194
            isUnary: false,
195
            iconName: 'filter_equal',
196
            logic: (target: Date, searchVal: Date) => {
197
                if (!target) {
138✔
198
                    return false;
34✔
199
                }
200

201
                this.validateInputData(target);
104✔
202

203
                const targetp = IgxDateFilteringOperand.getDateParts(target, 'yMd');
104✔
204
                const searchp = IgxDateFilteringOperand.getDateParts(searchVal, 'yMd');
104✔
205
                return targetp.year === searchp.year &&
104✔
206
                    targetp.month === searchp.month &&
207
                    targetp.day === searchp.day;
208
            }
209
        }, {
210
            name: 'doesNotEqual',
211
            isUnary: false,
212
            iconName: 'filter_not_equal',
213
            logic: (target: Date, searchVal: Date) => {
214
                if (!target) {
34✔
215
                    return true;
8✔
216
                }
217

218
                this.validateInputData(target);
26✔
219

220
                const targetp = IgxDateFilteringOperand.getDateParts(target, 'yMd');
26✔
221
                const searchp = IgxDateFilteringOperand.getDateParts(searchVal, 'yMd');
26✔
222
                return targetp.year !== searchp.year ||
26✔
223
                    targetp.month !== searchp.month ||
224
                    targetp.day !== searchp.day;
225
            }
226
        }, {
227
            name: 'before',
228
            isUnary: false,
229
            iconName: 'filter_before',
230
            logic: (target: Date, searchVal: Date) => {
231
                if (!target) {
60✔
232
                    return false;
10✔
233
                }
234

235
                this.validateInputData(target);
50✔
236

237
                return target < searchVal;
50✔
238
            }
239
        }, {
240
            name: 'after',
241
            isUnary: false,
242
            iconName: 'filter_after',
243
            logic: (target: Date, searchVal: Date) => {
244
                if (!target) {
72✔
245
                    return false;
12✔
246
                }
247

248
                this.validateInputData(target);
60✔
249

250
                return target > searchVal;
60✔
251
            }
252
        }, {
253
            name: 'today',
254
            isUnary: true,
255
            iconName: 'filter_today',
256
            logic: (target: Date) => {
257
                if (!target) {
58✔
258
                    return false;
14✔
259
                }
260

261
                this.validateInputData(target);
44✔
262

263
                const d = IgxDateFilteringOperand.getDateParts(target, 'yMd');
44✔
264
                const now = IgxDateFilteringOperand.getDateParts(new Date(), 'yMd');
44✔
265
                return d.year === now.year &&
44✔
266
                    d.month === now.month &&
267
                    d.day === now.day;
268
            }
269
        }, {
270
            name: 'yesterday',
271
            isUnary: true,
272
            iconName: 'filter_yesterday',
273
            logic: (target: Date) => {
274
                if (!target) {
42✔
275
                    return false;
10✔
276
                }
277

278
                this.validateInputData(target);
32✔
279

280
                const td = IgxDateFilteringOperand.getDateParts(target, 'yMd');
32✔
281
                const y = ((d) => new Date(d.setDate(d.getDate() - 1)))(new Date());
32✔
282
                const yesterday = IgxDateFilteringOperand.getDateParts(y, 'yMd');
32✔
283
                return td.year === yesterday.year &&
32✔
284
                    td.month === yesterday.month &&
285
                    td.day === yesterday.day;
286
            }
287
        }, {
288
            name: 'thisMonth',
289
            isUnary: true,
290
            iconName: 'filter_this_month',
291
            logic: (target: Date) => {
292
                if (!target) {
26✔
293
                    return false;
6✔
294
                }
295

296
                this.validateInputData(target);
20✔
297

298
                const d = IgxDateFilteringOperand.getDateParts(target, 'yM');
20✔
299
                const now = IgxDateFilteringOperand.getDateParts(new Date(), 'yM');
20✔
300
                return d.year === now.year &&
20✔
301
                    d.month === now.month;
302
            }
303
        }, {
304
            name: 'lastMonth',
305
            isUnary: true,
306
            iconName: 'filter_last_month',
307
            logic: (target: Date) => {
308
                if (!target) {
42✔
309
                    return false;
10✔
310
                }
311

312
                this.validateInputData(target);
32✔
313

314
                const d = IgxDateFilteringOperand.getDateParts(target, 'yM');
32✔
315
                const now = IgxDateFilteringOperand.getDateParts(new Date(), 'yM');
32✔
316
                if (!now.month) {
32!
317
                    now.month = 11;
×
318
                    now.year -= 1;
×
319
                } else {
320
                    now.month--;
32✔
321
                }
322
                return d.year === now.year &&
32✔
323
                    d.month === now.month;
324
            }
325
        }, {
326
            name: 'nextMonth',
327
            isUnary: true,
328
            iconName: 'filter_next_month',
329
            logic: (target: Date) => {
330
                if (!target) {
26✔
331
                    return false;
6✔
332
                }
333

334
                this.validateInputData(target);
20✔
335

336
                const d = IgxDateFilteringOperand.getDateParts(target, 'yM');
20✔
337
                const now = IgxDateFilteringOperand.getDateParts(new Date(), 'yM');
20✔
338
                if (now.month === 11) {
20!
339
                    now.month = 0;
20✔
340
                    now.year += 1;
20✔
341
                } else {
342
                    now.month++;
×
343
                }
344
                return d.year === now.year &&
20✔
345
                    d.month === now.month;
346
            }
347
        }, {
348
            name: 'thisYear',
349
            isUnary: true,
350
            iconName: 'filter_this_year',
351
            logic: (target: Date) => {
352
                if (!target) {
34✔
353
                    return false;
8✔
354
                }
355

356
                this.validateInputData(target);
26✔
357

358
                const d = IgxDateFilteringOperand.getDateParts(target, 'y');
26✔
359
                const now = IgxDateFilteringOperand.getDateParts(new Date(), 'y');
26✔
360
                return d.year === now.year;
26✔
361
            }
362
        }, {
363
            name: 'lastYear',
364
            isUnary: true,
365
            iconName: 'filter_last_year',
366
            logic: (target: Date) => {
367
                if (!target) {
26✔
368
                    return false;
6✔
369
                }
370

371
                this.validateInputData(target);
20✔
372

373
                const d = IgxDateFilteringOperand.getDateParts(target, 'y');
20✔
374
                const now = IgxDateFilteringOperand.getDateParts(new Date(), 'y');
20✔
375
                return d.year === now.year - 1;
20✔
376
            }
377
        }, {
378
            name: 'nextYear',
379
            isUnary: true,
380
            iconName: 'filter_next_year',
381
            logic: (target: Date) => {
382
                if (!target) {
26✔
383
                    return false;
6✔
384
                }
385

386
                this.validateInputData(target);
20✔
387

388
                const d = IgxDateFilteringOperand.getDateParts(target, 'y');
20✔
389
                const now = IgxDateFilteringOperand.getDateParts(new Date(), 'y');
20✔
390
                return d.year === now.year + 1;
20✔
391
            }
392
        }].concat(this.operations);
393
    }
394

395
    protected override findValueInSet(target: any, searchVal: Set<any>) {
396
        if (!target) {
16✔
397
            return false;
4✔
398
        }
399

400
        target = target.toDateString();
12✔
401
        return searchVal.has(target);
12✔
402
    }
403
}
404

405
/* blazorCSSuppress */
406
export class IgxDateTimeFilteringOperand extends IgxBaseDateTimeFilteringOperand {
407
    protected constructor() {
408
        super();
2✔
409
        this.operations = [{
2✔
410
            name: 'equals',
411
            isUnary: false,
412
            iconName: 'filter_equal',
413
            logic: (target: Date, searchVal: Date) => {
414
                if (!target) {
42✔
415
                    return false;
17✔
416
                }
417
                this.validateInputData(target);
25✔
418
                const targetp = IgxDateTimeFilteringOperand.getDateParts(target, 'yMdhms');
25✔
419
                const searchp = IgxDateTimeFilteringOperand.getDateParts(searchVal, 'yMdhms');
25✔
420
                return targetp.year === searchp.year &&
25✔
421
                    targetp.month === searchp.month &&
422
                    targetp.day === searchp.day &&
423
                    targetp.hours === searchp.hours &&
424
                    targetp.minutes === searchp.minutes &&
425
                    targetp.seconds === searchp.seconds;
426
            }
427
        }, {
428
            name: 'doesNotEqual',
429
            isUnary: false,
430
            iconName: 'filter_not_equal',
431
            logic: (target: Date, searchVal: Date) => {
432
                if (!target) {
8✔
433
                    return true;
2✔
434
                }
435
                this.validateInputData(target);
6✔
436
                const targetp = IgxDateTimeFilteringOperand.getDateParts(target, 'yMdhms');
6✔
437
                const searchp = IgxDateTimeFilteringOperand.getDateParts(searchVal, 'yMdhms');
6✔
438
                return targetp.year !== searchp.year ||
6✔
439
                    targetp.month !== searchp.month ||
440
                    targetp.day !== searchp.day ||
441
                    targetp.hours !== searchp.hours ||
442
                    targetp.minutes !== searchp.minutes ||
443
                    targetp.seconds !== searchp.seconds;
444
            }
445
        }, {
446
            name: 'before',
447
            isUnary: false,
448
            iconName: 'filter_before',
449
            logic: (target: Date, searchVal: Date) => {
450
                if (!target) {
×
451
                    return false;
×
452
                }
453

454
                this.validateInputData(target);
×
455

456
                return target < searchVal;
×
457
            }
458
        }, {
459
            name: 'after',
460
            isUnary: false,
461
            iconName: 'filter_after',
462
            logic: (target: Date, searchVal: Date) => {
463
                if (!target) {
×
464
                    return false;
×
465
                }
466

467
                this.validateInputData(target);
×
468

469
                return target > searchVal;
×
470
            }
471
        }, {
472
            name: 'today',
473
            isUnary: true,
474
            iconName: 'filter_today',
475
            logic: (target: Date) => {
476
                if (!target) {
8✔
477
                    return false;
2✔
478
                }
479

480
                this.validateInputData(target);
6✔
481

482
                const d = IgxDateTimeFilteringOperand.getDateParts(target, 'yMd');
6✔
483
                const now = IgxDateTimeFilteringOperand.getDateParts(new Date(), 'yMd');
6✔
484
                return d.year === now.year &&
6✔
485
                    d.month === now.month &&
486
                    d.day === now.day;
487
            }
488
        }, {
489
            name: 'yesterday',
490
            isUnary: true,
491
            iconName: 'filter_yesterday',
492
            logic: (target: Date) => {
493
                if (!target) {
×
494
                    return false;
×
495
                }
496

497
                this.validateInputData(target);
×
498

499
                const td = IgxDateTimeFilteringOperand.getDateParts(target, 'yMd');
×
500
                const y = ((d) => new Date(d.setDate(d.getDate() - 1)))(new Date());
×
501
                const yesterday = IgxDateTimeFilteringOperand.getDateParts(y, 'yMd');
×
502
                return td.year === yesterday.year &&
×
503
                    td.month === yesterday.month &&
504
                    td.day === yesterday.day;
505
            }
506
        }, {
507
            name: 'thisMonth',
508
            isUnary: true,
509
            iconName: 'filter_this_month',
510
            logic: (target: Date) => {
511
                if (!target) {
×
512
                    return false;
×
513
                }
514

515
                this.validateInputData(target);
×
516

517
                const d = IgxDateTimeFilteringOperand.getDateParts(target, 'yM');
×
518
                const now = IgxDateTimeFilteringOperand.getDateParts(new Date(), 'yM');
×
519
                return d.year === now.year &&
×
520
                    d.month === now.month;
521
            }
522
        }, {
523
            name: 'lastMonth',
524
            isUnary: true,
525
            iconName: 'filter_last_month',
526
            logic: (target: Date) => {
527
                if (!target) {
×
528
                    return false;
×
529
                }
530

531
                this.validateInputData(target);
×
532

533
                const d = IgxDateTimeFilteringOperand.getDateParts(target, 'yM');
×
534
                const now = IgxDateTimeFilteringOperand.getDateParts(new Date(), 'yM');
×
535
                if (!now.month) {
×
536
                    now.month = 11;
×
537
                    now.year -= 1;
×
538
                } else {
539
                    now.month--;
×
540
                }
541
                return d.year === now.year &&
×
542
                    d.month === now.month;
543
            }
544
        }, {
545
            name: 'nextMonth',
546
            isUnary: true,
547
            iconName: 'filter_next_month',
548
            logic: (target: Date) => {
549
                if (!target) {
×
550
                    return false;
×
551
                }
552

553
                this.validateInputData(target);
×
554

555
                const d = IgxDateTimeFilteringOperand.getDateParts(target, 'yM');
×
556
                const now = IgxDateTimeFilteringOperand.getDateParts(new Date(), 'yM');
×
557
                if (now.month === 11) {
×
558
                    now.month = 0;
×
559
                    now.year += 1;
×
560
                } else {
561
                    now.month++;
×
562
                }
563
                return d.year === now.year &&
×
564
                    d.month === now.month;
565
            }
566
        }, {
567
            name: 'thisYear',
568
            isUnary: true,
569
            iconName: 'filter_this_year',
570
            logic: (target: Date) => {
571
                if (!target) {
×
572
                    return false;
×
573
                }
574

575
                this.validateInputData(target);
×
576

577
                const d = IgxDateTimeFilteringOperand.getDateParts(target, 'y');
×
578
                const now = IgxDateTimeFilteringOperand.getDateParts(new Date(), 'y');
×
579
                return d.year === now.year;
×
580
            }
581
        }, {
582
            name: 'lastYear',
583
            isUnary: true,
584
            iconName: 'filter_last_year',
585
            logic: (target: Date) => {
586
                if (!target) {
×
587
                    return false;
×
588
                }
589

590
                this.validateInputData(target);
×
591

592
                const d = IgxDateTimeFilteringOperand.getDateParts(target, 'y');
×
593
                const now = IgxDateTimeFilteringOperand.getDateParts(new Date(), 'y');
×
594
                return d.year === now.year - 1;
×
595
            }
596
        }, {
597
            name: 'nextYear',
598
            isUnary: true,
599
            iconName: 'filter_next_year',
600
            logic: (target: Date) => {
601
                if (!target) {
×
602
                    return false;
×
603
                }
604

605
                this.validateInputData(target);
×
606

607
                const d = IgxDateTimeFilteringOperand.getDateParts(target, 'y');
×
608
                const now = IgxDateTimeFilteringOperand.getDateParts(new Date(), 'y');
×
609
                return d.year === now.year + 1;
×
610
            }
611
        }].concat(this.operations);
612
    }
613
}
614

615
/* blazorCSSuppress */
616
export class IgxTimeFilteringOperand extends IgxBaseDateTimeFilteringOperand {
617
    protected constructor() {
618
        super();
2✔
619
        this.operations = [{
2✔
620
            name: 'at',
621
            isUnary: false,
622
            iconName: 'filter_equal',
623
            logic: (target: Date, searchVal: Date) => {
624
                if (!target) {
8✔
625
                    return false;
2✔
626
                }
627
                this.validateInputData(target);
6✔
628
                const targetp = IgxTimeFilteringOperand.getDateParts(target, 'hms');
6✔
629
                const searchp = IgxTimeFilteringOperand.getDateParts(searchVal, 'hms');
6✔
630
                return targetp.hours === searchp.hours &&
6✔
631
                    targetp.minutes === searchp.minutes &&
632
                    targetp.seconds === searchp.seconds;
633
            }
634
        }, {
635
            name: 'not_at',
636
            isUnary: false,
637
            iconName: 'filter_not_equal',
638
            logic: (target: Date, searchVal: Date) => {
639
                if (!target) {
8✔
640
                    return true;
2✔
641
                }
642
                this.validateInputData(target);
6✔
643
                const targetp = IgxTimeFilteringOperand.getDateParts(target, 'hms');
6✔
644
                const searchp = IgxTimeFilteringOperand.getDateParts(searchVal, 'hms');
6✔
645
                return targetp.hours !== searchp.hours ||
6✔
646
                    targetp.minutes !== searchp.minutes ||
647
                    targetp.seconds !== searchp.seconds;
648
            }
649
        }, {
650
            name: 'before',
651
            isUnary: false,
652
            iconName: 'filter_before',
653
            logic: (target: Date, searchVal: Date) => {
654
                if (!target) {
8✔
655
                    return false;
2✔
656
                }
657

658
                this.validateInputData(target);
6✔
659
                const targetn = IgxTimeFilteringOperand.getDateParts(target, 'hms');
6✔
660
                const search = IgxTimeFilteringOperand.getDateParts(searchVal, 'hms');
6✔
661

662
                return targetn.hours < search.hours ? true : targetn.hours === search.hours && targetn.minutes < search.minutes ?
6✔
663
                    true : targetn.hours === search.hours && targetn.minutes === search.minutes && targetn.seconds < search.seconds;
4✔
664
            }
665
        }, {
666
            name: 'after',
667
            isUnary: false,
668
            iconName: 'filter_after',
669
            logic: (target: Date, searchVal: Date) => {
670
                if (!target) {
8✔
671
                    return false;
2✔
672
                }
673

674
                this.validateInputData(target);
6✔
675
                const targetn = IgxTimeFilteringOperand.getDateParts(target, 'hms');
6✔
676
                const search = IgxTimeFilteringOperand.getDateParts(searchVal, 'hms');
6✔
677

678
                return targetn.hours > search.hours ? true : targetn.hours === search.hours && targetn.minutes > search.minutes ?
6✔
679
                    true : targetn.hours === search.hours && targetn.minutes === search.minutes && targetn.seconds > search.seconds;
9✔
680
            }
681
        }, {
682
            name: 'at_before',
683
            isUnary: false,
684
            iconName: 'filter_before',
685
            logic: (target: Date, searchVal: Date) => {
686
                if (!target) {
8✔
687
                    return false;
2✔
688
                }
689

690
                this.validateInputData(target);
6✔
691
                const targetn = IgxTimeFilteringOperand.getDateParts(target, 'hms');
6✔
692
                const search = IgxTimeFilteringOperand.getDateParts(searchVal, 'hms');
6✔
693
                return (targetn.hours === search.hours && targetn.minutes === search.minutes && targetn.seconds === search.seconds) ||
6✔
694
                targetn.hours < search.hours ? true : targetn.hours === search.hours && targetn.minutes < search.minutes ?
11✔
695
                    true : targetn.hours === search.hours && targetn.minutes === search.minutes && targetn.seconds < search.seconds;
1!
696
            }
697
        }, {
698
            name: 'at_after',
699
            isUnary: false,
700
            iconName: 'filter_after',
701
            logic: (target: Date, searchVal: Date) => {
702
                if (!target) {
8✔
703
                    return false;
2✔
704
                }
705

706
                this.validateInputData(target);
6✔
707
                const targetn = IgxTimeFilteringOperand.getDateParts(target, 'hms');
6✔
708
                const search = IgxTimeFilteringOperand.getDateParts(searchVal, 'hms');
6✔
709
                return (targetn.hours === search.hours && targetn.minutes === search.minutes && targetn.seconds === search.seconds) ||
6✔
710
                    targetn.hours > search.hours ? true : targetn.hours === search.hours && targetn.minutes > search.minutes ?
11✔
711
                    true : targetn.hours === search.hours && targetn.minutes === search.minutes && targetn.seconds > search.seconds;
6✔
712
            }
713
        }].concat(this.operations);
714
    }
715

716
    protected override findValueInSet(target: any, searchVal: Set<any>) {
717
        if (!target) {
×
718
            return false;
×
719
        }
720
        return searchVal.has(target.toLocaleTimeString());
×
721
    }
722
}
723

724
/* blazorCSSuppress */
725
/**
726
 * Provides filtering operations for numbers
727
 *
728
 * @export
729
 */
730
export class IgxNumberFilteringOperand extends IgxFilteringOperand {
731
    protected constructor() {
732
        super();
2✔
733
        this.operations = [{
2✔
734
            name: 'equals',
735
            isUnary: false,
736
            iconName: 'filter_equal',
737
            logic: (target: number, searchVal: number) => target === searchVal
1,363✔
738
        }, {
739
            name: 'doesNotEqual',
740
            isUnary: false,
741
            iconName: 'filter_not_equal',
742
            logic: (target: number, searchVal: number) => target !== searchVal
216✔
743
        }, {
744
            name: 'greaterThan',
745
            isUnary: false,
746
            iconName: 'filter_greater_than',
747
            logic: (target: number, searchVal: number) => target > searchVal
635✔
748
        }, {
749
            name: 'lessThan',
750
            isUnary: false,
751
            iconName: 'filter_less_than',
752
            logic: (target: number, searchVal: number) => target < searchVal
97✔
753
        }, {
754
            name: 'greaterThanOrEqualTo',
755
            isUnary: false,
756
            iconName: 'filter_greater_than_or_equal',
757
            logic: (target: number, searchVal: number) => target >= searchVal
100✔
758
        }, {
759
            name: 'lessThanOrEqualTo',
760
            isUnary: false,
761
            iconName: 'filter_less_than_or_equal',
762
            logic: (target: number, searchVal: number) => target <= searchVal
87✔
763
        }, {
764
            name: 'empty',
765
            isUnary: true,
766
            iconName: 'filter_empty',
767
            logic: (target: number) => target === null || target === undefined || isNaN(target)
18✔
768
        }, {
769
            name: 'notEmpty',
770
            isUnary: true,
771
            iconName: 'filter_not_empty',
772
            logic: (target: number) => target !== null && target !== undefined && !isNaN(target)
33✔
773
        }].concat(this.operations);
774
    }
775
}
776

777
/* blazorCSSuppress */
778
/**
779
 * Provides filtering operations for strings
780
 *
781
 * @export
782
 */
783
export class IgxStringFilteringOperand extends IgxFilteringOperand {
784
    protected constructor() {
785
        super();
2✔
786
        this.operations = [{
2✔
787
            name: 'contains',
788
            isUnary: false,
789
            iconName: 'filter_contains',
790
            logic: (target: string, searchVal: string, ignoreCase?: boolean) => {
791
                const search = IgxStringFilteringOperand.applyIgnoreCase(searchVal, ignoreCase);
2,691✔
792
                target = IgxStringFilteringOperand.applyIgnoreCase(target, ignoreCase);
2,691✔
793
                return target.indexOf(search) !== -1;
2,691✔
794
            }
795
        }, {
796
            name: 'doesNotContain',
797
            isUnary: false,
798
            iconName: 'filter_does_not_contain',
799
            logic: (target: string, searchVal: string, ignoreCase?: boolean) => {
800
                const search = IgxStringFilteringOperand.applyIgnoreCase(searchVal, ignoreCase);
23✔
801
                target = IgxStringFilteringOperand.applyIgnoreCase(target, ignoreCase);
23✔
802
                return target.indexOf(search) === -1;
23✔
803
            }
804
        }, {
805
            name: 'startsWith',
806
            isUnary: false,
807
            iconName: 'filter_starts_with',
808
            logic: (target: string, searchVal: string, ignoreCase?: boolean) => {
809
                const search = IgxStringFilteringOperand.applyIgnoreCase(searchVal, ignoreCase);
355✔
810
                target = IgxStringFilteringOperand.applyIgnoreCase(target, ignoreCase);
355✔
811
                return target.startsWith(search);
355✔
812
            }
813
        }, {
814
            name: 'endsWith',
815
            isUnary: false,
816
            iconName: 'filter_ends_with',
817
            logic: (target: string, searchVal: string, ignoreCase?: boolean) => {
818
                const search = IgxStringFilteringOperand.applyIgnoreCase(searchVal, ignoreCase);
44✔
819
                target = IgxStringFilteringOperand.applyIgnoreCase(target, ignoreCase);
44✔
820
                return target.endsWith(search);
44✔
821
            }
822
        }, {
823
            name: 'equals',
824
            isUnary: false,
825
            iconName: 'filter_equal',
826
            logic: (target: string, searchVal: string, ignoreCase?: boolean) => {
827
                const search = IgxStringFilteringOperand.applyIgnoreCase(searchVal, ignoreCase);
373✔
828
                target = IgxStringFilteringOperand.applyIgnoreCase(target, ignoreCase);
373✔
829
                return target === search;
373✔
830
            }
831
        }, {
832
            name: 'doesNotEqual',
833
            isUnary: false,
834
            iconName: 'filter_not_equal',
835
            logic: (target: string, searchVal: string, ignoreCase?: boolean) => {
836
                const search = IgxStringFilteringOperand.applyIgnoreCase(searchVal, ignoreCase);
18✔
837
                target = IgxStringFilteringOperand.applyIgnoreCase(target, ignoreCase);
18✔
838
                return target !== search;
18✔
839
            }
840
        }, {
841
            name: 'empty',
842
            isUnary: true,
843
            iconName: 'filter_empty',
844
            logic: (target: string) => target === null || target === undefined || target.length === 0
57✔
845
        }, {
846
            name: 'notEmpty',
847
            isUnary: true,
848
            iconName: 'filter_not_empty',
849
            logic: (target: string) => target !== null && target !== undefined && target.length > 0
11✔
850
        }].concat(this.operations);
851
    }
852

853
    /**
854
     * Applies case sensitivity on strings if provided
855
     *
856
     * @memberof IgxStringFilteringOperand
857
     */
858
    public static applyIgnoreCase(a: string, ignoreCase: boolean): string {
859
        a = a ?? '';
7,008✔
860
        // bulletproof
861
        return ignoreCase ? ('' + a).toLowerCase() : a;
7,008✔
862
    }
863
}
864

865
/* tsPlainInterface */
866
/* marshalByValue */
867
/**
868
 * Interface describing filtering operations
869
 *
870
 * @export
871
 */
872
export interface IFilteringOperation {
873
    name: string;
874
    isUnary: boolean;
875
    iconName: string;
876
    hidden?: boolean;
877
    /* blazorCSSuppress */
878
    /* blazorAlternateType: FilteringOperationLogicHandler */
879
    logic: (value: any, searchVal?: any, ignoreCase?: boolean) => boolean;
880
}
881

882
/**
883
 * Interface describing Date object in parts
884
 *
885
 * @export
886
 */
887
export interface IDateParts {
888
    year: number;
889
    month: number;
890
    day: number;
891
    hours: number;
892
    minutes: number;
893
    seconds: number;
894
    milliseconds: number;
895
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc