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

atinc / ngx-tethys / 68ef226c-f83e-44c1-b8ed-e420a83c5d84

28 May 2025 10:31AM UTC coverage: 10.352% (-80.0%) from 90.316%
68ef226c-f83e-44c1-b8ed-e420a83c5d84

Pull #3460

circleci

pubuzhixing8
chore: xxx
Pull Request #3460: refactor(icon): migrate signal input #TINFR-1476

132 of 6823 branches covered (1.93%)

Branch coverage included in aggregate %.

10 of 14 new or added lines in 1 file covered. (71.43%)

11648 existing lines in 344 files now uncovered.

2078 of 14525 relevant lines covered (14.31%)

6.69 hits per line

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

7.89
/src/dialog/header/dialog-header.component.ts
1
import {
2
    Component,
3
    Input,
4
    Output,
5
    EventEmitter,
6
    TemplateRef,
7
    OnInit,
8
    ElementRef,
9
    inject,
10
    input,
11
    contentChild,
12
    computed,
13
    Signal
14
} from '@angular/core';
15
import { ThyDialog } from '../dialog.service';
16
import { ThyDialogContainer } from '../dialog-container.component';
17
import { ThyTranslate } from 'ngx-tethys/core';
1✔
18
import { ThyInternalDialogRef } from '../dialog-ref';
UNCOV
19
import { ThyAction } from 'ngx-tethys/action';
×
UNCOV
20
import { ThyIcon } from 'ngx-tethys/icon';
×
UNCOV
21
import { NgTemplateOutlet } from '@angular/common';
×
UNCOV
22
import { coerceBooleanProperty } from 'ngx-tethys/util';
×
UNCOV
23

×
UNCOV
24
/**
×
UNCOV
25
 * 模态框头部组件
×
UNCOV
26
 * @name thy-dialog-header
×
UNCOV
27
 * @order 40
×
UNCOV
28
 */
×
UNCOV
29
@Component({
×
UNCOV
30
    selector: 'thy-dialog-header',
×
UNCOV
31
    templateUrl: './dialog-header.component.html',
×
32
    // changeDetection: ChangeDetectionStrategy.OnPush,
UNCOV
33
    exportAs: 'thyDialogHeader',
×
UNCOV
34
    host: {
×
35
        class: 'dialog-header thy-dialog-header',
36
        '[class.thy-dialog-header-lg]': `thySize() === 'lg'`,
UNCOV
37
        '[class.thy-dialog-header-divided]': `thyDivided()`
×
38
    },
39
    imports: [NgTemplateOutlet, ThyIcon, ThyAction]
40
})
41
export class ThyDialogHeader implements OnInit {
42
    private elementRef = inject(ElementRef);
UNCOV
43
    private dialog = inject(ThyDialog);
×
UNCOV
44
    private translate = inject(ThyTranslate);
×
45
    private dialogContainer = inject(ThyDialogContainer, { optional: true })!;
46

47
    /**
UNCOV
48
     * 自定义头部模板
×
UNCOV
49
     */
×
UNCOV
50
    public readonly headerTemplate = contentChild<TemplateRef<any>>('dialogHeader');
×
51

52
    /**
53
     * 标题
54
     */
UNCOV
55
    readonly thyTitle = input<string>();
×
UNCOV
56

×
57
    /**
58
     * 大小,只有大的详情页场景会使用 lg,左右 padding 缩小至 20px
UNCOV
59
     * @type lg | md
×
60
     */
61
    readonly thySize = input<'lg' | 'md'>('md');
62

1✔
63
    /**
64
     * 是否显示分割线
65
     */
66
    readonly thyDivided = input(false, { transform: coerceBooleanProperty });
67

68
    /**
69
     * 标题的多语言 Key
70
     */
71
    readonly thyTitleTranslationKey = input<string>();
72

1✔
73
    readonly title: Signal<string> = computed(() => {
74
        const title = this.thyTitle();
75
        const titleTranslationKey = this.thyTitleTranslationKey();
76
        return title || (titleTranslationKey && this.translate.instant(titleTranslationKey));
77
    });
78

79
    /**
80
     * 头部图标
81
     */
82
    readonly thyIcon = input<string>();
83

84
    /**
85
     * 关闭事件
86
     */
87
    @Output() thyOnClose: EventEmitter<Event> = new EventEmitter<Event>();
88

89
    ngOnInit() {
90
        if (!this.dialogContainer) {
91
            // When this directive is included in a dialog via TemplateRef (rather than being
92
            // in a Component), the ThyDialogContainerComponent isn't available via injection because embedded
93
            // views cannot be given a custom injector. Instead, we look up the ThyDialogContainerComponent by
94
            // ID. This must occur in `onInit`, as the ID binding for the dialog container won't
95
            // be resolved at constructor time.
96
            const dialogRef = this.dialog.getClosestDialog(this.elementRef.nativeElement) as ThyInternalDialogRef<any>;
97
            this.dialogContainer = dialogRef ? dialogRef.containerInstance : null;
98
        }
99

100
        // change in next microtask avoid throw ExpressionChangedAfterItHasBeenCheckedError
101
        // because sub component change parent's HostBinding property (ariaLabelledBy)
102
        Promise.resolve().then(() => {
103
            if (this.dialogContainer) {
104
                this.dialogContainer.ariaLabelledBy = this.title();
105
            }
106
        });
107
    }
108

109
    close(event?: Event) {
110
        if (this.thyOnClose.observers.length > 0) {
111
            this.thyOnClose.emit(event);
112
        } else {
113
            this.dialog.close();
114
        }
115
    }
116
}
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