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

atinc / ngx-tethys / 2b0c2344-6c9c-4127-9e80-38f3934d3178

16 Nov 2024 09:49AM UTC coverage: 90.353% (+0.005%) from 90.348%
2b0c2344-6c9c-4127-9e80-38f3934d3178

push

circleci

minlovehua
feat: i18n structure

5521 of 6758 branches covered (81.7%)

Branch coverage included in aggregate %.

13193 of 13954 relevant lines covered (94.55%)

996.88 hits per line

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

88.37
/src/date-picker/lib/calendar/calendar-header.component.ts
1
import { Directive, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, inject } from '@angular/core';
2

3
import { ThyPanelMode } from '../../standard-types';
4
import { TinyDate } from 'ngx-tethys/util';
5
import { DateHelperService } from '../../date-helper.service';
6
import { useLocale } from 'ngx-tethys/i18n';
7

8
export interface PanelSelector {
9
    className: string;
1✔
10
    title?: string;
11
    label: string;
214✔
12
    onClick?(): void;
214✔
13
}
214✔
14

214✔
15
/**
214✔
16
 * @private
214✔
17
 */
214✔
18
@Directive()
214✔
19
export abstract class CalendarHeader implements OnInit, OnChanges {
214✔
20
    dateHelper = inject(DateHelperService);
21
    locale = useLocale();
22

214!
23
    @Input() showSuperPreBtn: boolean = true;
×
24
    @Input() showSuperNextBtn: boolean = true;
25
    @Input() showPreBtn: boolean = true;
214✔
26
    @Input() showNextBtn: boolean = true;
27
    @Input() value: TinyDate;
28
    @Output() readonly valueChange = new EventEmitter<TinyDate>();
430✔
29
    @Output() readonly panelModeChange = new EventEmitter<ThyPanelMode>();
426✔
30

31
    abstract getSelectors(): PanelSelector[];
32

33
    prefixCls = 'thy-calendar';
6✔
34
    selectors: PanelSelector[];
35

36
    ngOnInit(): void {
7✔
37
        if (!this.value) {
38
            this.value = new TinyDate();
39
        }
3✔
40
        this.selectors = this.getSelectors();
41
    }
42

6✔
43
    ngOnChanges(changes: SimpleChanges): void {
44
        if (changes.value) {
45
            this.render();
12✔
46
        }
47
    }
48

12✔
49
    superPrevious(): void {
12!
50
        this.gotoYear(-1);
51
    }
52

466!
53
    superNext(): void {
466✔
54
        this.gotoYear(1);
55
    }
56

57
    previous(): void {
9✔
58
        this.gotoMonth(-1);
59
    }
60

13✔
61
    next(): void {
62
        this.gotoMonth(1);
63
    }
40!
64

40✔
65
    changePanel(mode: ThyPanelMode, value?: TinyDate): void {
40✔
66
        this.panelModeChange.emit(mode);
40✔
67
    }
68

69
    selectorClick(event: Event, selector: PanelSelector) {
70
        event.stopPropagation();
1,104✔
71
        return selector ? selector.onClick() : null;
72
    }
1✔
73

74
    private render(): void {
75
        if (this.value) {
76
            this.selectors = this.getSelectors();
77
        }
78
    }
79

80
    private gotoMonth(amount: number): void {
81
        this.changeValue(this.value.addMonths(amount));
82
    }
1✔
83

84
    private gotoYear(amount: number): void {
85
        this.changeValue(this.value.addYears(amount));
86
    }
87

88
    public changeValue(value: TinyDate): void {
89
        if (this.value !== value) {
90
            this.value = value;
91
            this.valueChange.emit(this.value);
92
            this.render();
93
        }
94
    }
95

96
    formatDateTime(format: string): string {
97
        return this.dateHelper.format(this.value.nativeDate, format);
98
    }
99
}
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