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

atinc / ngx-tethys / d9ae709b-3c27-4b69-b125-b8b80b54f90b

pending completion
d9ae709b-3c27-4b69-b125-b8b80b54f90b

Pull #2757

circleci

mengshuicmq
fix: fix code review
Pull Request #2757: feat(color-picker): color-picker support disabled (#INFR-8645)

98 of 6315 branches covered (1.55%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

2392 of 13661 relevant lines covered (17.51%)

83.12 hits per line

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

15.15
/src/shared/option/group/option-group.component.ts
1
import { Component, HostBinding, Input, OnInit, ContentChildren, QueryList, NgZone, OnDestroy, AfterContentInit } from '@angular/core';
2
import { Observable, defer, Subject, merge, combineLatest } from 'rxjs';
3
import { ThyOptionVisibleChangeEvent, ThyOptionComponent } from '../option.component';
4
import { take, switchMap, startWith, takeUntil, reduce, debounceTime, map } from 'rxjs/operators';
5
import { THY_OPTION_GROUP_COMPONENT } from '../option.token';
6
import { InputBoolean } from 'ngx-tethys/core';
7

8
/**
9
 * @private
10
 */
11
@Component({
12
    selector: 'thy-option-group',
13
    templateUrl: './option-group.component.html',
1✔
14
    providers: [
15
        {
×
16
            provide: THY_OPTION_GROUP_COMPONENT,
17
            useExisting: ThySelectOptionGroupComponent
18
        }
×
19
    ],
×
20
    standalone: true
×
21
})
×
22
export class ThySelectOptionGroupComponent implements OnDestroy, AfterContentInit {
×
23
    _hidden = false;
×
24
    @Input()
×
25
    @InputBoolean()
26
    @HostBinding(`class.disabled`)
×
27
    thyDisabled: boolean;
28

29
    @HostBinding('class.thy-option-item-group') _isOptionGroup = true;
30

×
31
    @HostBinding('class.thy-select-option-group-hidden')
×
32
    get hidden(): boolean {
33
        return this._hidden;
34
    }
35

×
36
    @Input() thyGroupLabel: string;
×
37

38
    @ContentChildren(ThyOptionComponent) options: QueryList<ThyOptionComponent>;
×
39

×
40
    _destroy$: Subject<void> = new Subject<void>();
×
41

42
    optionVisibleChanges: Observable<ThyOptionVisibleChangeEvent> = defer(() => {
43
        if (this.options) {
×
44
            return merge(...this.options.map(option => option.visibleChange));
×
45
        }
46
        return this._ngZone.onStable.asObservable().pipe(
47
            take(1),
×
48
            switchMap(() => this.optionVisibleChanges)
49
        );
50
    }) as Observable<ThyOptionVisibleChangeEvent>;
51

×
52
    constructor(private _ngZone: NgZone) {}
53

54
    ngAfterContentInit() {
55
        this.options.changes.pipe(startWith(null), takeUntil(this._destroy$)).subscribe(() => {
×
56
            this._resetOptions();
×
57
        });
58
    }
1✔
59

60
    _resetOptions() {
61
        const changedOrDestroyed$ = merge(this.options.changes, this._destroy$);
1✔
62
        merge(...this.options.map(option => option.visibleChange))
63
            .pipe(
64
                takeUntil(changedOrDestroyed$),
65
                debounceTime(10),
66
                map((event: ThyOptionVisibleChangeEvent) => {
67
                    const hasOption = this.options.find(option => {
68
                        if (!option.hidden) {
69
                            return true;
1✔
70
                        }
71
                    });
72
                    if (hasOption) {
73
                        return false;
1✔
74
                    } else {
75
                        return true;
76
                    }
77
                })
78
            )
79
            .subscribe((data: boolean) => {
80
                this._hidden = data;
81
            });
82
    }
83

84
    ngOnDestroy() {
85
        this._destroy$.next();
86
        this._destroy$.complete();
87
    }
88
}
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