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

IgniteUI / igniteui-angular / 13548823408

26 Feb 2025 04:36PM CUT coverage: 91.555% (-0.04%) from 91.599%
13548823408

Pull #15223

github

web-flow
Merge 3ac8087aa into 786685675
Pull Request #15223: fix(pivot-grid): added createRow method for grid based events - 19.0

12997 of 15250 branches covered (85.23%)

0 of 18 new or added lines in 2 files covered. (0.0%)

135 existing lines in 23 files now uncovered.

26344 of 28774 relevant lines covered (91.55%)

34046.37 hits per line

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

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

20
let NEXT_ID = 0;
2✔
21

22
@Component({
23
    providers: [
24
        {
25
            provide: NG_VALUE_ACCESSOR,
26
            useExisting: IgxMonthsViewComponent,
27
            multi: true,
28
        },
29
        {
30
            provide: DAY_INTERVAL_TOKEN,
31
            useValue: "month",
32
        },
33
    ],
34
    selector: "igx-months-view",
35
    templateUrl: "months-view.component.html",
36
    imports: [NgFor, IgxCalendarMonthDirective, TitleCasePipe]
37
})
38
export class IgxMonthsViewComponent extends IgxCalendarViewDirective implements ControlValueAccessor {
2✔
39
    #standalone = true;
32✔
40

41
    /**
42
     * Sets/gets the `id` of the months view.
43
     * If not set, the `id` will have value `"igx-months-view-0"`.
44
     * ```html
45
     * <igx-months-view id="my-months-view"></igx-months-view>
46
     * ```
47
     * ```typescript
48
     * let monthsViewId =  this.monthsView.id;
49
     * ```
50
     *
51
     * @memberof IgxMonthsViewComponent
52
     */
53
    @HostBinding("attr.id")
54
    @Input()
55
    public id = `igx-months-view-${NEXT_ID++}`;
32✔
56

57
    /**
58
     * The default css class applied to the component.
59
     *
60
     * @hidden
61
     */
62
    @HostBinding("class.igx-calendar-view")
63
    public readonly viewClass = true;
32✔
64

65
    /**
66
     * @hidden @internal
67
     */
68
    @Input()
69
    @HostBinding("class.igx-calendar-view--standalone")
70
    public get standalone() {
71
        return this.#standalone;
140✔
72
    }
73

74
    public set standalone(value: boolean) {
75
        this.#standalone = value;
32✔
76
    }
77

78
    /**
79
     * Gets the month format option of the months view.
80
     * ```typescript
81
     * let monthFormat = this.monthsView.monthFormat.
82
     * ```
83
     */
84
    @Input()
85
    public get monthFormat(): any {
86
        return this._monthFormat;
100✔
87
    }
88

89
    /**
90
     * Sets the month format option of the months view.
91
     * ```html
92
     * <igx-months-view> [monthFormat]="short'"</igx-months-view>
93
     * ```
94
     *
95
     * @memberof IgxMonthsViewComponent
96
     */
97
    public set monthFormat(value: any) {
98
        this._monthFormat = value;
34✔
99
        this.initFormatter();
34✔
100
    }
101

102
    /**
103
     * Gets/sets whether the view should be rendered
104
     * according to the locale and format, if any.
105
     */
106
    @Input({ transform: booleanAttribute })
107
    public override formatView = true;
32✔
108

109
    /**
110
     * Returns an array of date objects which are then used to
111
     * properly render the month names.
112
     *
113
     * Used in the template of the component
114
     *
115
     * @hidden @internal
116
     */
117
    public get range(): Date[] {
118
        const start = CalendarDay.from(this.date).set({ date: 1, month: 0 });
171✔
119
        const end = start.add(this.dayInterval, 12);
171✔
120

121
        return Array.from(
171✔
122
            calendarRange({ start, end, unit: this.dayInterval }),
123
        ).map((m) => m.native);
2,052✔
124
    }
125

126
    /**
127
     * @hidden
128
     */
129
    private _monthFormat = "short";
32✔
130

131
    constructor(
132
        public el: ElementRef,
32✔
133
        @Inject(DAY_INTERVAL_TOKEN) dayInterval: DayInterval,
134
    ) {
135
        super(dayInterval);
32✔
136
    }
137

138
    /**
139
     * @hidden
140
     */
141
    protected onMouseDown() {
142
        if (this.tabIndex !== -1) {
3!
UNCOV
143
            this.el.nativeElement.focus();
×
144
        }
145
    }
146

147
    /**
148
     * Returns the locale representation of the month in the months view.
149
     *
150
     * @hidden
151
     */
152
    public formattedMonth(value: Date): { long: string; formatted: string } {
153
        const rawFormatter = new Intl.DateTimeFormat(this.locale, {
3,360✔
154
            month: "long",
155
            year: "numeric",
156
        });
157

158
        if (this.formatView) {
3,360✔
159
            return {
3,360✔
160
                long: rawFormatter.format(value),
161
                formatted: this._formatter.format(value),
162
            };
163
        }
164

UNCOV
165
        return {
×
166
            long: rawFormatter.format(value),
167
            formatted: `${value.getMonth()}`,
168
        };
169
    }
170

171
    /**
172
     * @hidden
173
     */
174
    public monthTracker(_: number, item: Date): string {
175
        return `${item.getMonth()}}`;
888✔
176
    }
177

178
    /**
179
     * @hidden
180
     */
181
    protected initFormatter() {
182
        this._formatter = new Intl.DateTimeFormat(this._locale, {
100✔
183
            month: this.monthFormat,
184
        });
185
    }
186
}
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