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

atinc / ngx-tethys / 3b40a702-4b4d-4ddb-81a7-a96baae6d682

08 Nov 2024 05:40AM UTC coverage: 90.395% (-0.04%) from 90.431%
3b40a702-4b4d-4ddb-81a7-a96baae6d682

push

circleci

why520crazy
Merge branch 'master' into feat-theme

5503 of 6730 branches covered (81.77%)

Branch coverage included in aggregate %.

424 of 431 new or added lines in 171 files covered. (98.38%)

344 existing lines in 81 files now uncovered.

13150 of 13905 relevant lines covered (94.57%)

999.86 hits per line

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

87.23
/src/shared/base-form-check.component.ts
1
import { ControlValueAccessor } from '@angular/forms';
2
import { HostBinding, Input, ChangeDetectorRef, Directive, inject } from '@angular/core';
3
import { ThyTranslate, TabIndexDisabledControlValueAccessorMixin } from 'ngx-tethys/core';
4
import { coerceBooleanProperty } from 'ngx-tethys/util';
5

1✔
6
const noop = () => {};
7

8
/**
9
 * @private
1✔
10
 */
11
@Directive()
565✔
12
export class ThyFormCheckBaseComponent extends TabIndexDisabledControlValueAccessorMixin implements ControlValueAccessor {
13
    protected thyTranslate = inject(ThyTranslate);
14
    protected changeDetectorRef? = inject(ChangeDetectorRef);
24✔
15

16
    // The internal data model
17
    _innerValue: boolean = null;
48✔
18

19
    _disabled = false;
UNCOV
20

×
UNCOV
21
    private onTouchedCallback: () => void = noop;
×
22

23
    private onChangeCallback: (_: any) => void = noop;
24

×
25
    _labelText: string;
26

27
    @HostBinding('class.form-check') _isFormCheck = true;
28

10✔
29
    @HostBinding('class.form-check-inline') _isFormCheckInline = false;
10✔
30

31
    @HostBinding('class.form-check-checked') _isChecked = false;
32

474✔
33
    @HostBinding('class.form-check-inline-no-label-text') get _isNoText() {
34
        return this._isFormCheckInline && !this._labelText;
35
    }
343✔
36

185✔
37
    /**
185✔
38
     * 是否同一行展示
39
     * @default false
40
     */
41
    @Input({ transform: coerceBooleanProperty })
139✔
42
    set thyInline(value: boolean) {
43
        this._isFormCheckInline = value;
44
    }
139✔
45

46
    /**
47
     * Label 展示文本
190✔
48
     */
190✔
49
    @Input()
50
    set thyLabelText(value: string) {
51
        this._labelText = value;
13✔
52
    }
13✔
53

13✔
54
    /**
13✔
55
     * Label 文本多语言 key
56
     */
57
    @Input()
168✔
58
    set thyLabelTextTranslateKey(value: string) {
168✔
59
        if (value) {
168✔
60
            this._labelText = this.thyTranslate.instant(value);
61
        } else {
168✔
62
            this._labelText = '';
168✔
63
        }
168✔
64
    }
168✔
65

168✔
66
    disabled = false;
168✔
67

168✔
68
    /**
168✔
69
     * 是否禁用
70
     * @default false
71
     */
10✔
72
    @Input({ transform: coerceBooleanProperty })
73
    override set thyDisabled(value: boolean) {
74
        this.disabled = value;
203!
75
        this.setDisabledState(this.disabled);
203✔
76
    }
77

78
    override get thyDisabled() {
3✔
79
        return this.disabled;
1✔
80
    }
81

82
    writeValue(obj: boolean): void {
83
        if (obj !== this._innerValue) {
84
            this._innerValue = obj;
85
            this._isChecked = !!this._innerValue;
86
        }
87
    }
88

89
    registerOnChange(fn: any): void {
90
        this.onChangeCallback = fn;
1✔
91
    }
92

93
    registerOnTouched(fn: any): void {
94
        this.onTouchedCallback = fn;
95
    }
96

97
    setDisabledState?(isDisabled: boolean): void {
98
        this._disabled = isDisabled;
99
        this.markForCheck();
100
    }
101

102
    updateValue(value: boolean): void {
103
        this._innerValue = value;
104
        this._isChecked = !!this._innerValue;
105
        this.onChangeCallback(value);
106
        this.markForCheck();
107
    }
108

109
    constructor() {
110
        super();
111
    }
112

113
    change() {
114
        this.updateValue(!this._innerValue);
115
    }
116

117
    markForCheck() {
118
        if (this.changeDetectorRef) {
119
            this.changeDetectorRef.markForCheck();
120
        }
121
    }
122
}
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

© 2026 Coveralls, Inc