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

atinc / ngx-tethys / 3033f133-0f0d-43eb-a07d-e1848354018a

07 Mar 2024 01:58AM UTC coverage: 90.58% (-0.02%) from 90.604%
3033f133-0f0d-43eb-a07d-e1848354018a

Pull #3022

circleci

web-flow
feat(schematics): improve schematics for select and custom-select in template #INFR-11735 (#3047)
Pull Request #3022: feat: upgrade ng to 17 #INFR-11427 (#3021)

5422 of 6642 branches covered (81.63%)

Branch coverage included in aggregate %.

328 of 338 new or added lines in 193 files covered. (97.04%)

141 existing lines in 29 files now uncovered.

13502 of 14250 relevant lines covered (94.75%)

982.04 hits per line

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

85.71
/src/shared/option/group/option-group.component.ts
1
import {
2
    Component,
3
    HostBinding,
4
    Input,
5
    ContentChildren,
6
    QueryList,
7
    NgZone,
8
    OnDestroy,
9
    AfterContentInit,
10
    ChangeDetectorRef
11
} from '@angular/core';
12
import { Observable, defer, Subject, merge } from 'rxjs';
1✔
13
import { ThyOptionVisibleChangeEvent, ThyOption } from '../option.component';
14
import { take, switchMap, startWith, takeUntil, debounceTime, map } from 'rxjs/operators';
43✔
15
import { THY_OPTION_GROUP_COMPONENT } from '../option.token';
16
import { InputBoolean } from 'ngx-tethys/core';
17

8✔
18
/**
8✔
19
 * @private
8✔
20
 */
8✔
21
@Component({
8✔
22
    selector: 'thy-option-group',
8✔
UNCOV
23
    templateUrl: './option-group.component.html',
×
24
    providers: [
×
25
        {
UNCOV
26
            provide: THY_OPTION_GROUP_COMPONENT,
×
27
            useExisting: ThySelectOptionGroup
28
        }
29
    ],
30
    standalone: true
8✔
31
})
8✔
32
export class ThySelectOptionGroup implements OnDestroy, AfterContentInit {
33
    _hidden = false;
34
    @Input()
35
    @InputBoolean()
8✔
36
    @HostBinding(`class.disabled`)
11✔
37
    thyDisabled: boolean;
38

5✔
39
    @HostBinding('class.thy-option-item-group') _isOptionGroup = true;
10✔
40

1✔
41
    @HostBinding('class.thy-select-option-group-hidden')
42
    get hidden(): boolean {
43
        return this._hidden;
5✔
44
    }
1✔
45

46
    @Input() thyGroupLabel: string;
47

4✔
48
    @ContentChildren(ThyOption) options: QueryList<ThyOption>;
49

50
    _destroy$: Subject<void> = new Subject<void>();
51

5✔
52
    optionVisibleChanges: Observable<ThyOptionVisibleChangeEvent> = defer(() => {
5✔
53
        if (this.options) {
54
            return merge(...this.options.map(option => option.visibleChange));
55
        }
56
        return this._ngZone.onStable.asObservable().pipe(
8✔
57
            take(1),
8✔
58
            switchMap(() => this.optionVisibleChanges)
59
        );
1✔
60
    }) as Observable<ThyOptionVisibleChangeEvent>;
61

62
    constructor(private _ngZone: NgZone, private cdr: ChangeDetectorRef) {}
63

1✔
64
    ngAfterContentInit() {
65
        this.options.changes.pipe(startWith(null), takeUntil(this._destroy$)).subscribe(() => {
66
            this._resetOptions();
67
        });
68
    }
69

70
    _resetOptions() {
71
        const changedOrDestroyed$ = merge(this.options.changes, this._destroy$);
1✔
72
        merge(...this.options.map(option => option.visibleChange))
73
            .pipe(
74
                takeUntil(changedOrDestroyed$),
75
                debounceTime(10),
1✔
76
                map((event: ThyOptionVisibleChangeEvent) => {
77
                    const hasOption = this.options.find(option => {
78
                        if (!option.hidden) {
79
                            return true;
80
                        }
81
                    });
82
                    if (hasOption) {
83
                        return false;
84
                    } else {
85
                        return true;
86
                    }
87
                })
88
            )
89
            .subscribe((data: boolean) => {
90
                this._hidden = data;
91
                this.cdr.markForCheck();
92
            });
93
    }
94

95
    ngOnDestroy() {
96
        this._destroy$.next();
97
        this._destroy$.complete();
98
    }
99
}
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