• 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.15
/src/dialog/header/dialog-header.component.ts
1
import { Component, Input, Output, EventEmitter, ContentChild, TemplateRef, OnInit, Optional, ElementRef } from '@angular/core';
2
import { ThyDialog } from '../dialog.service';
3
import { ThyDialogContainerComponent } from '../dialog-container.component';
4
import { InputBoolean, ThyTranslate } from 'ngx-tethys/core';
5
import { ThyInternalDialogRef } from '../dialog-ref';
6
import { ThyActionComponent } from 'ngx-tethys/action';
7
import { ThyIconComponent } from 'ngx-tethys/icon';
8
import { NgIf, NgTemplateOutlet } from '@angular/common';
9

10
/**
11
 * 模态框头部组件
12
 * @name thy-dialog-header
13
 * @order 40
14
 */
15
@Component({
1✔
16
    selector: 'thy-dialog-header',
17
    templateUrl: './dialog-header.component.html',
×
18
    // changeDetection: ChangeDetectionStrategy.OnPush,
×
19
    exportAs: 'thyDialogHeader',
20
    host: {
21
        class: 'dialog-header thy-dialog-header',
22
        '[class.thy-dialog-header-lg]': `thySize === 'lg'`,
×
23
        '[class.thy-dialog-header-divided]': `thyDivided`
×
24
    },
×
25
    standalone: true,
×
26
    imports: [NgIf, NgTemplateOutlet, ThyIconComponent, ThyActionComponent]
×
27
})
28
export class DialogHeaderComponent implements OnInit {
29
    /**
×
30
     * 自定义头部模板
31
     */
32
    @ContentChild('dialogHeader')
33
    public headerTemplate: TemplateRef<any>;
34

35
    /**
×
36
     * 标题
×
37
     */
38
    @Input() thyTitle: string;
39

40
    /**
×
41
     * 大小,只有大的详情页场景会使用 lg,左右 padding 缩小至 20px
×
42
     * @type lg | md
×
43
     * @default md
44
     */
45
    @Input() thySize: 'lg' | 'md';
46

47
    /**
×
48
     * 是否显示分割线
×
49
     * @default false
50
     */
51
    @Input() @InputBoolean() thyDivided: boolean;
×
52

53
    /**
54
     * 标题的多语言 Key
1✔
55
     */
56
    @Input()
57
    set thyTitleTranslationKey(key: string) {
58
        if (key && !this.thyTitle) {
59
            this.thyTitle = this.translate.instant(key);
60
        }
1✔
61
    }
62

63
    /**
64
     * 头部图标
65
     */
66
    @Input() thyIcon: string;
67

68
    /**
69
     * 关闭事件
70
     */
1✔
71
    @Output() thyOnClose: EventEmitter<Event> = new EventEmitter<Event>();
72

73
    constructor(
74
        private elementRef: ElementRef,
1✔
75
        private dialog: ThyDialog,
76
        private translate: ThyTranslate,
77
        @Optional() private dialogContainer: ThyDialogContainerComponent
78
    ) {}
79

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

91
        // change in next microtask avoid throw ExpressionChangedAfterItHasBeenCheckedError
92
        // because sub component change parent's HostBinding property (ariaLabelledBy)
93
        Promise.resolve().then(() => {
94
            if (this.dialogContainer) {
95
                this.dialogContainer.ariaLabelledBy = this.thyTitle;
96
            }
97
        });
98
    }
99

100
    close(event?: Event) {
101
        if (this.thyOnClose.observers.length > 0) {
102
            this.thyOnClose.emit(event);
103
        } else {
104
            this.dialog.close();
105
        }
106
    }
107
}
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