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

IgniteUI / igniteui-angular / 13416627295

19 Feb 2025 03:46PM CUT coverage: 91.615% (+0.02%) from 91.595%
13416627295

Pull #15246

github

web-flow
Merge 2a114cdda into 10ddb05cf
Pull Request #15246: fix(excel-export): Get correct grid column collection from row island…

12987 of 15218 branches covered (85.34%)

3 of 3 new or added lines in 1 file covered. (100.0%)

380 existing lines in 31 files now uncovered.

26385 of 28800 relevant lines covered (91.61%)

34358.69 hits per line

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

96.0
/projects/igniteui-angular/src/lib/calendar/years-view/years-view.component.ts
1
import {
2
    Component,
3
    Input,
4
    HostBinding,
5
    ElementRef,
6
    Inject,
7
} from "@angular/core";
8
import { IgxCalendarYearDirective } from "../calendar.directives";
9
import { NgFor } from "@angular/common";
10
import {
11
    IgxCalendarViewDirective,
12
    DAY_INTERVAL_TOKEN,
13
} from "../common/calendar-view.directive";
14
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from "@angular/forms";
15
import { CalendarDay } from "../common/model";
16
import type { DayInterval } from "../common/model";
17
import { calendarRange } from "../common/helpers";
18

19
@Component({
20
    providers: [
21
        {
22
            provide: NG_VALUE_ACCESSOR,
23
            useExisting: IgxYearsViewComponent,
24
            multi: true,
25
        },
26
        {
27
            provide: DAY_INTERVAL_TOKEN,
28
            useValue: "year",
29
        },
30
    ],
31
    selector: "igx-years-view",
32
    templateUrl: "years-view.component.html",
33
    imports: [NgFor, IgxCalendarYearDirective]
34
})
35
export class IgxYearsViewComponent extends IgxCalendarViewDirective implements ControlValueAccessor {
2✔
36
    #standalone = true;
11✔
37

38
    /**
39
     * The default css class applied to the component.
40
     *
41
     * @hidden
42
     */
43
    @HostBinding("class.igx-calendar-view")
44
    public readonly viewClass = true;
11✔
45

46
    /**
47
     * @hidden @internal
48
     */
49
    @Input()
50
        @HostBinding('class.igx-calendar-view--standalone')
51
        public get standalone() {
52
        return this.#standalone;
50✔
53
    }
54

55
        public set standalone(value: boolean) {
56
        this.#standalone = value;
11✔
57
    }
58

59
    /**
60
     * @hidden
61
     */
62
    private _yearFormat = "numeric";
11✔
63

64
    /**
65
     * @hidden
66
     */
67
    private _yearsPerPage = 15;
11✔
68

69
    /**
70
     * Gets the year format option of the years view.
71
     * ```typescript
72
     * let yearFormat = this.yearsView.yearFormat.
73
     * ```
74
     */
75
    @Input()
76
    public get yearFormat(): any {
77
        return this._yearFormat;
33✔
78
    }
79

80
    /**
81
     * Sets the year format option of the years view.
82
     * ```html
83
     * <igx-years-view [yearFormat]="numeric"></igx-years-view>
84
     * ```
85
     *
86
     * @memberof IgxYearsViewComponent
87
     */
88
    public set yearFormat(value: any) {
89
        this._yearFormat = value;
11✔
90
        this.initFormatter();
11✔
91
    }
92

93
    /**
94
     * Returns an array of date objects which are then used to properly
95
     * render the years.
96
     *
97
     * Used in the template of the component.
98
     *
99
     * @hidden @internal
100
     */
101
    public get range(): Date[] {
102
        const year = this.date.getFullYear();
72✔
103
        const start = new CalendarDay({
72✔
104
            year: Math.floor(year / this._yearsPerPage) * this._yearsPerPage,
105
            month: this.date.getMonth(),
106
        });
107
        const end = start.add(this.dayInterval, this._yearsPerPage);
72✔
108

109
        return Array.from(calendarRange({ start, end, unit: this.dayInterval })).map(
72✔
110
            (m) => m.native,
1,080✔
111
        );
112
    }
113

114
    constructor(
115
        public el: ElementRef,
11✔
116
        @Inject(DAY_INTERVAL_TOKEN) dayInterval: DayInterval,
117
    ) {
118
        super(dayInterval);
11✔
119
    }
120

121
    /**
122
     * Returns the locale representation of the year in the years view.
123
     *
124
     * @hidden
125
     */
126
    public formattedYear(value: Date): {long: string, formatted: string} {
127
        const rawFormatter = new Intl.DateTimeFormat(this.locale, { year: 'numeric' });
1,500✔
128

129
        if (this.formatView) {
1,500✔
130
            return {
90✔
131
                long: rawFormatter.format(value),
132
                formatted: this._formatter.format(value)
133
            }
134
        }
135

136
        return {
1,410✔
137
            long: rawFormatter.format(value),
138
            formatted: `${value.getFullYear()}`
139
        }
140
    }
141

142
    /**
143
     * @hidden
144
     */
145
    public yearTracker(_: number, item: Date): string {
146
        return `${item.getFullYear()}}`;
450✔
147
    }
148

149
    /**
150
     * @hidden
151
     */
152
    protected initFormatter() {
153
        this._formatter = new Intl.DateTimeFormat(this._locale, {
33✔
154
            year: this.yearFormat,
155
        });
156
    }
157

158
    /**
159
     * @hidden
160
     */
161
    protected onMouseDown() {
162
        if (this.tabIndex !== -1) {
4!
UNCOV
163
            this.el.nativeElement.focus();
×
164
        }
165
    }
166
}
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