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

atinc / ngx-tethys / #55

30 Jul 2025 07:08AM UTC coverage: 9.866% (-80.4%) from 90.297%
#55

push

why520crazy
feat(empty): add setMessage for update display text #TINFR-2616

92 of 6794 branches covered (1.35%)

Branch coverage included in aggregate %.

2014 of 14552 relevant lines covered (13.84%)

6.15 hits per line

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

10.64
/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()
×
12
export class ThyFormCheckBaseComponent extends TabIndexDisabledControlValueAccessorMixin implements ControlValueAccessor {
13
    protected thyTranslate = inject(ThyTranslate);
14
    protected changeDetectorRef? = inject(ChangeDetectorRef);
×
15

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

19
    _disabled = false;
20

×
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

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

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

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

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

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

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

×
66
    disabled = false;
×
67

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

78
    override get thyDisabled() {
1✔
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