• 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.56
/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 } from 'ngx-tethys/core';
5

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

8
/**
9
 * @private
1✔
10
 */
11
@Directive()
×
12
export class ThyFormCheckBaseComponent 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
    /**
65
     * 是否禁用
×
66
     * @default false
67
     */
68
    @Input()
×
69
    @InputBoolean()
×
70
    set thyDisabled(value: boolean) {
71
        this.setDisabledState(coerceBooleanProperty(value));
72
    }
1✔
73

74
    writeValue(obj: boolean): void {
75
        if (obj !== this._innerValue) {
76
            this._innerValue = obj;
1✔
77
            this._isChecked = !!this._innerValue;
78
        }
79
    }
80

81
    registerOnChange(fn: any): void {
82
        this.onChangeCallback = fn;
83
    }
84

85
    registerOnTouched(fn: any): void {
86
        this.onTouchedCallback = fn;
87
    }
1✔
88

89
    setDisabledState?(isDisabled: boolean): void {
90
        this._disabled = isDisabled;
91
        this.markForCheck();
92
    }
1✔
93

94
    updateValue(value: boolean): void {
95
        this._innerValue = value;
96
        this._isChecked = !!this._innerValue;
97
        this.onChangeCallback(value);
1✔
98
        this.markForCheck();
99
    }
100

101
    constructor(protected thyTranslate: ThyTranslate, protected changeDetectorRef?: ChangeDetectorRef) {}
102

103
    change() {
104
        this.updateValue(!this._innerValue);
105
    }
106

107
    markForCheck() {
108
        if (this.changeDetectorRef) {
109
            this.changeDetectorRef.markForCheck();
110
        }
111
    }
112
}
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