• 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

42.86
/src/strength/strength.component.ts
1
import { ThyTranslate } from 'ngx-tethys/core';
2

3
import { Component, forwardRef, HostBinding, Input, OnInit } from '@angular/core';
4
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
5

6
enum ThyStrengthEnum {
7
    highest = 4,
8
    high = 3,
1✔
9
    average = 2,
1✔
10
    low = 1
1✔
11
}
1✔
12

1✔
13
const strengthMap = {
2✔
14
    [ThyStrengthEnum.highest]: {
1✔
15
        level: 'highest',
16
        text: '最高'
17
    },
18
    [ThyStrengthEnum.high]: {
19
        level: 'high',
20
        text: '高'
21
    },
22
    [ThyStrengthEnum.average]: {
23
        level: 'average',
24
        text: '中'
25
    },
26
    [ThyStrengthEnum.low]: {
27
        level: 'low',
28
        text: '低'
29
    }
30
};
31

32
/**
33
 * 程度展示组件
34
 * @name thy-strength
35
 * @order 10
36
 */
37
@Component({
1✔
38
    selector: 'thy-strength',
39
    templateUrl: 'strength.component.html',
×
40
    providers: [
41
        {
42
            provide: NG_VALUE_ACCESSOR,
×
43
            useExisting: forwardRef(() => ThyStrengthComponent),
44
            multi: true
45
        }
×
46
    ],
47
    standalone: true
48
})
×
49
export class ThyStrengthComponent implements OnInit, ControlValueAccessor {
50
    @HostBinding('class.password-strength-container') styleClass = true;
51

×
52
    strengthTitle: string;
53

54
    strength: ThyStrengthEnum;
×
55

×
56
    strengthMap = JSON.parse(JSON.stringify(strengthMap));
×
57

×
58
    /**
×
59
     * 组件标题,描述程度所指类型
60
     */
61
    @Input()
62
    set titleKey(value: string) {
×
63
        this.strengthTitle = this.translate.instant(value);
×
64
    }
×
65

66
    /**
67
     * 程度最高值文本
×
68
     * @default 最高
69
     */
70
    @Input()
×
71
    set highestKey(value: string) {
72
        this.strengthMap[ThyStrengthEnum.highest].text = this.translate.instant(value);
1✔
73
    }
74

75
    /**
1✔
76
     * 程度为高值时展示的文本
77
     * @default 高
78
     */
79
    @Input()
80
    set highKey(value: string) {
81
        this.strengthMap[ThyStrengthEnum.high].text = this.translate.instant(value);
82
    }
83

84
    /**
1✔
85
     * 程度为中值时展示的文本
86
     * @default 中
87
     */
88
    @Input()
89
    set averageKey(value: string) {
90
        this.strengthMap[ThyStrengthEnum.average].text = this.translate.instant(value);
91
    }
×
92

93
    /**
94
     * 程度为低值时展示的文本
95
     * @default 低
96
     */
97
    @Input()
98
    set lowKey(value: string) {
99
        this.strengthMap[ThyStrengthEnum.low].text = this.translate.instant(value);
100
    }
101

102
    private _onChange = Function.prototype;
103

104
    private _onTouched = Function.prototype;
105

106
    constructor(public translate: ThyTranslate) {}
107

108
    ngOnInit() {}
109

110
    writeValue(value: ThyStrengthEnum) {
111
        this.strength = value;
112
        this._onChange(value);
113
        this._onTouched();
114
    }
115

116
    registerOnChange(fn: (value: any) => any): void {
117
        this._onChange = fn;
118
    }
119

120
    registerOnTouched(fn: () => any): void {
121
        this._onTouched = fn;
122
    }
123
}
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