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

atinc / ngx-tethys / 0bbb2cec-209e-4d8a-b1b3-6bc54e05daa6

04 Sep 2023 08:40AM UTC coverage: 15.616% (-74.6%) from 90.2%
0bbb2cec-209e-4d8a-b1b3-6bc54e05daa6

Pull #2829

circleci

cmm-va
fix: add test
Pull Request #2829: fix: add tabIndex

300 of 6386 branches covered (0.0%)

Branch coverage included in aggregate %.

78 of 78 new or added lines in 26 files covered. (100.0%)

2849 of 13779 relevant lines covered (20.68%)

83.41 hits per line

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

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

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

8
/**
9
 * @private
1✔
10
 */
11
@Directive()
×
12
export class ThyFormCheckBaseComponent extends TabIndexDisabledControlValueAccessorMixin implements ControlValueAccessor {
13
    // The internal data model
14
    _innerValue: boolean = null;
×
15

16
    _disabled = false;
17

×
18
    private onTouchedCallback: () => void = noop;
19

20
    private onChangeCallback: (_: any) => void = noop;
×
21

×
22
    _labelText: string;
23

24
    @HostBinding('class.form-check') _isFormCheck = true;
×
25

26
    @HostBinding('class.form-check-inline') _isFormCheckInline = false;
27

28
    @HostBinding('class.form-check-checked') _isChecked = false;
×
29

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

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

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

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

×
64
    disabled = false;
×
65

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

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

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

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

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

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

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

108
    constructor(protected thyTranslate: ThyTranslate, protected changeDetectorRef?: ChangeDetectorRef) {
109
        super();
110
    }
111

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

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