• 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

9.52
/src/calendar/calendar-header.component.ts
1
import { DateRangeItemInfo, ThyDateRange } from 'ngx-tethys/date-range';
2
import { endOfMonth, FunctionProp, getMonth, getUnixTime, getYear, startOfMonth, TinyDate } from 'ngx-tethys/util';
3

4
import { JsonPipe, NgTemplateOutlet } from '@angular/common';
5
import { ChangeDetectorRef, Component, effect, HostBinding, inject, input, OnInit, output, Signal, TemplateRef } from '@angular/core';
6
import { FormsModule } from '@angular/forms';
7
import { ThyButton } from 'ngx-tethys/button';
8
import { DateHelperService } from 'ngx-tethys/date-picker';
9
import { injectLocale, ThyCalendarLocale } from 'ngx-tethys/i18n';
10

11
/**
12
 * 日历头部操作栏组件
13
 * @name thy-calendar-header
14
 * @order 20
15
 */
16
@Component({
17
    selector: 'thy-calendar-header',
1✔
18
    templateUrl: './calendar-header.component.html',
UNCOV
19
    imports: [ThyDateRange, FormsModule, ThyButton, NgTemplateOutlet, JsonPipe]
×
UNCOV
20
})
×
UNCOV
21
export class ThyCalendarHeader implements OnInit {
×
UNCOV
22
    private cdr = inject(ChangeDetectorRef);
×
UNCOV
23
    private dateHelper = inject(DateHelperService);
×
UNCOV
24
    public locale: Signal<ThyCalendarLocale> = injectLocale('calendar');
×
UNCOV
25

×
UNCOV
26
    @HostBinding('class.thy-calendar-full-header-container') className = true;
×
UNCOV
27

×
UNCOV
28
    /**
×
UNCOV
29
     * 当前选中日期
×
30
     */
31
    readonly currentDate = input<TinyDate>();
32

33
    /**
34
     *         自定义渲染右侧操作项
35
     */
36
    readonly operationRender = input<FunctionProp<TemplateRef<any>>>();
37

38
    /**
39
     * 日期选择范围(年)发生变化的回调
40
     */
UNCOV
41
    readonly yearChange = output<number>();
×
UNCOV
42

×
43
    /**
44
     * 日期选择范围(月)发生变化的回调
45
     */
46
    readonly monthChange = output<number>();
UNCOV
47

×
UNCOV
48
    /**
×
49
     * 日期选择范围(日期)发生变化的回调
50
     */
UNCOV
51
    readonly dateRangeChange = output<DateRangeItemInfo>();
×
UNCOV
52

×
53
    public pickerFormat = this.locale().yearMonthFormat;
54

UNCOV
55
    public dateRanges: DateRangeItemInfo[] = [
×
UNCOV
56
        {
×
UNCOV
57
            key: 'month',
×
UNCOV
58
            text: this.dateHelper.format(new TinyDate().nativeDate, this.pickerFormat),
×
59
            begin: getUnixTime(startOfMonth(new TinyDate().getTime())),
60
            end: getUnixTime(endOfMonth(new TinyDate().getTime())),
UNCOV
61
            timestamp: {
×
UNCOV
62
                interval: 1,
×
UNCOV
63
                unit: 'month'
×
UNCOV
64
            }
×
65
        }
66
    ];
UNCOV
67

×
UNCOV
68
    public date: DateRangeItemInfo;
×
UNCOV
69

×
UNCOV
70
    private _currentDate: TinyDate;
×
UNCOV
71

×
72
    public isCurrent: boolean;
73

74
    constructor() {
75
        effect(() => {
76
            this.setDate();
77
        });
UNCOV
78
    }
×
79

80
    ngOnInit(): void {}
UNCOV
81

×
UNCOV
82
    onChangeMonth(month: DateRangeItemInfo) {
×
83
        const currentMonth = TinyDate.fromUnixTime(month.end).getMonth();
84
        this.monthChange.emit(currentMonth);
85
    }
UNCOV
86

×
87
    onChangeYear(year: DateRangeItemInfo) {
×
88
        const currentYear = TinyDate.fromUnixTime(year.begin).getFullYear();
89
        this.yearChange.emit(currentYear);
1✔
90
    }
1✔
91

92
    onChangeRange(dateRange: DateRangeItemInfo) {
93
        this.isCurrentDate(this._currentDate);
94
        this.onChangeYear(dateRange);
95
        this.onChangeMonth(dateRange);
96
        this.dateRangeChange.emit(dateRange);
97
    }
98

99
    backToday() {
1✔
100
        this._currentDate = new TinyDate();
101
        this.date = { ...this.dateRanges[0] };
102
        this.onChangeRange(this.date);
103
        this.cdr.detectChanges();
104
    }
105

106
    setDate() {
107
        const currentDate = this.currentDate();
108
        this.isCurrentDate(currentDate);
109
        if (this.isCurrent) {
110
            this._currentDate = currentDate;
111
            const dateRange = {
112
                ...this.dateRanges[0],
113
                key: 'exception',
114
                text: this._currentDate.format(this.pickerFormat),
115
                begin: getUnixTime(startOfMonth(this._currentDate.getTime())),
116
                end: getUnixTime(endOfMonth(this._currentDate.getTime()))
117
            };
118
            this.date = dateRange;
119
        } else {
120
            this._currentDate = new TinyDate();
121
            this.date = { ...this.dateRanges[0] };
122
        }
123
    }
124

125
    isCurrentDate(currentDate: TinyDate) {
126
        this.isCurrent =
127
            currentDate.getMonth() !== getMonth(new TinyDate().getTime()) || currentDate.getYear() !== getYear(new TinyDate().getTime());
128
    }
129
}
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