Skip to content

Commit 6147718

Browse files
committed
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular into update-10-1
2 parents f360ae3 + b82a97c commit 6147718

File tree

16 files changed

+297
-20
lines changed

16 files changed

+297
-20
lines changed

CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@
22

33
All notable changes for each version of this project will be documented in this file.
44
## 10.2.0
5-
- IgxInputGroup
5+
6+
### General
7+
- `IgxInputGroup`
68
- **Breaking Chage** - Removed `fluent`, `fluent_search`, `bootstrap`, and `indigo` as possible values for the `type` input property.
79
- **Behavioral Change** - The styling of the input group is now dictated by the theme being used. The remaining `types` - `line`, `border`, and `box` will only have effect on the styling when used with the `material` theme. The `search` type will affect styling when used with all themes. Changing the theme at runtime will not change the styling of the input group, a page refresh is required.
810

9-
## 10.2.0
10-
1111
### New Features
1212
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
1313
- When triggering an export of the grid via the toolbar and the export takes more than 500 milliseconds, the export button becomes disabled and an indeterminate progress bar is shown at the bottom of the toolbar until the export is finished.
1414
- ` IGX_INPUT_GROUP_TYPE` injection token
1515
- Allows for setting an input group `type` on a global level, so all input-group instances, including components using such an instance as a template will have their input group type set to the one specified by the token. It can be overridden on a component level by explicitly setting a `type`.
1616
- ` IgxExcelExporterService`
1717
- Added `worksheetName` property to the `IgxExcelExporterOptions`, that allows setting the name of the worksheet.
18+
- `IgxTimePicker`
19+
- Added a custom label functionality.
1820

1921
## 10.1.0
2022

projects/igniteui-angular/src/lib/calendar/calendar-helper-utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ export class HelperTestFunctions {
99
public static MODAL_OVERLAY_CSSCLASS = 'igx-overlay__wrapper--modal';
1010

1111
public static CALENDAR_CSSCLASS = '.igx-calendar';
12+
public static CALENDAR_WEEK_NUMBER_CLASS = '.igx-calendar__date--week-number';
13+
public static CALENDAR_WEEK_NUMBER_ITEM_CLASS = '.igx-calendar__date-content--week-number';
14+
public static CALENDAR_WEEK_NUMBER_LABEL_CLASS = '.igx-calendar__label--week-number';
1215
public static CALENDAR_HEADER_CSSCLASS = '.igx-calendar__header';
1316
public static CALENDAR_HEADER_YEAR_CSSCLASS = '.igx-calendar__header-year';
1417
public static CALENDAR_HEADER_DATE_CSSCLASS = '.igx-calendar__header-date';

projects/igniteui-angular/src/lib/calendar/calendar.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ <h2 class="igx-calendar__header-date">
5757
[disabledDates]="disabledDates"
5858
[specialDates]="specialDates"
5959
[hideOutsideDays]="hideOutsideDays"
60+
[showWeekNumbers]="showWeekNumbers"
6061
(onViewChanging)="viewChanging($event)"
6162
(onDateSelection)="childClicked($event)">
6263
</igx-days-view>

projects/igniteui-angular/src/lib/calendar/calendar.component.spec.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ describe('IgxCalendar - ', () => {
337337
// 6 weeks + week header
338338
expect(calendarRows.length).toEqual(7);
339339

340-
// 7 calendar rows * 7 elements in each
340+
// 6 calendar rows * 7 elements in each
341341
expect(
342342
dom.queryAll(By.css(`${HelperTestFunctions.CALENDAR_ROW_CSSCLASS} > igx-day-item`)).length
343343
).toEqual(42);
@@ -360,6 +360,45 @@ describe('IgxCalendar - ', () => {
360360
expect(calendarHeader).toBeFalsy();
361361
});
362362

363+
it('Should properly render calendar DOM with week numbers enabled', () => {
364+
const today = new Date(Date.now());
365+
calendar.viewDate = today;
366+
calendar.showWeekNumbers = true;
367+
fixture.detectChanges();
368+
369+
const calendarRows = dom.queryAll(By.css(HelperTestFunctions.CALENDAR_ROW_CSSCLASS));
370+
expect(calendarRows.length).toEqual(7);
371+
372+
// 6 calendar rows * 8 elements in each
373+
expect(
374+
dom.queryAll(By.css(`${HelperTestFunctions.CALENDAR_ROW_CSSCLASS} > igx-day-item`)).length +
375+
dom.queryAll(By.css(`${HelperTestFunctions.CALENDAR_ROW_CSSCLASS} >
376+
${HelperTestFunctions.CALENDAR_WEEK_NUMBER_CLASS}`)).length
377+
).toEqual(48);
378+
expect(
379+
dom.queryAll(By.css(`${HelperTestFunctions.CALENDAR_ROW_CSSCLASS} > span`)).length +
380+
dom.queryAll(By.css(`${HelperTestFunctions.CALENDAR_ROW_CSSCLASS} > ${HelperTestFunctions.CALENDAR_WEEK_NUMBER_LABEL_CLASS}`)).length
381+
).toEqual(8);
382+
383+
});
384+
385+
it('Week numbers should appear as first column', () => {
386+
const firstWeekOfTheYear = new Date(2020, 0, 5);
387+
calendar.viewDate = firstWeekOfTheYear;
388+
calendar.showWeekNumbers = true;
389+
fixture.detectChanges();
390+
391+
const calendarRows = dom.queryAll(By.css(`${HelperTestFunctions.CALENDAR_ROW_CSSCLASS}`));
392+
393+
const maxWeeks = 52;
394+
calendarRows.forEach((row, idx) => {
395+
const firstRowItem = row.nativeElement.children[0];
396+
idx === 0 ?
397+
expect(firstRowItem.firstChild.innerText).toEqual('Wk') :
398+
expect(firstRowItem.firstChild.innerText).toEqual((idx === 1 ? maxWeeks : idx - 1).toString());
399+
});
400+
});
401+
363402
it('Calendar DOM structure - year view | month view', () => {
364403
dom.queryAll(By.css(HelperTestFunctions.CALENDAR_DATE_CSSCLASS))[0].nativeElement.click();
365404
fixture.detectChanges();

projects/igniteui-angular/src/lib/calendar/calendar.component.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,17 @@ export class IgxCalendarComponent extends IgxMonthPickerBaseDirective implements
150150
this._monthsViewNumber = val;
151151
}
152152

153+
/**
154+
* Show/hide week numbers
155+
*
156+
* @example
157+
* ```html
158+
* <igx-calendar [showWeekNumbers]="true"></igx-calendar>
159+
* ``
160+
*/
161+
@Input()
162+
public showWeekNumbers = false;
163+
153164
/**
154165
* Apply the different states for the transitions of animateChange
155166
* @hidden

projects/igniteui-angular/src/lib/calendar/calendar.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,14 @@ export class Calendar {
354354
return this.timedelta(date, TimeDeltaInterval.Year, -1);
355355
}
356356

357+
public getWeekNumber(date: Date) {
358+
const firstJan = new Date(date.getFullYear(), 0, 1).getTime();
359+
const today = new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
360+
const dayInMilSeconds = 86400000;
361+
const dayOfYear = ((today - firstJan + 1) / dayInMilSeconds);
362+
return Math.ceil(dayOfYear / 7);
363+
}
364+
357365
private generateICalendarDate(date: Date, year: number, month: number): ICalendarDate {
358366
return {
359367
date,

projects/igniteui-angular/src/lib/calendar/days-view/days-view.component.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
<div class="igx-calendar__body-row">
2+
<div *ngIf="showWeekNumbers" class="igx-calendar__label igx-calendar__label--week-number">
3+
<span>Wk</span>
4+
</div>
25
<span *ngFor="let dayName of generateWeekHeader()" class="igx-calendar__label">
36
{{ dayName | titlecase }}
47
</span>
58
</div>
69

710
<div *ngFor="let week of getCalendarMonth; last as isLast; index as i; trackBy: rowTracker"
811
class="igx-calendar__body-row">
12+
<div class="igx-calendar__date igx-calendar__date--week-number" *ngIf="showWeekNumbers">
13+
<span class="igx-calendar__date-content igx-calendar__date-content--week-number">
14+
{{getWeekNumber(week[0].date)}}
15+
</span>
16+
</div>
17+
<!-- <igx-week-number-item *ngIf="showWeekNumbers">{{getWeekNumber(week[0].date)}}</igx-week-number-item> -->
918
<igx-day-item
1019
*ngFor="let day of week; trackBy: dateTracker"
1120
[date]="day"

projects/igniteui-angular/src/lib/calendar/days-view/days-view.component.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective implements Do
5454
@Input()
5555
public changeDaysView = false;
5656

57+
/**
58+
* Show/hide week numbers
59+
*
60+
* @example
61+
* ```html
62+
* <igx-days-view [showWeekNumbers]="true"></igx-days-view>
63+
* ``
64+
*/
65+
@Input()
66+
public showWeekNumbers: boolean;
67+
5768
/**
5869
* @hidden
5970
*/
@@ -125,6 +136,15 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective implements Do
125136
}
126137
}
127138

139+
/**
140+
* Returns the week number by date
141+
*
142+
* @hidden
143+
*/
144+
public getWeekNumber(date): number {
145+
return this.calendarModel.getWeekNumber(date);
146+
}
147+
128148
/**
129149
* Returns the locale representation of the date in the days view.
130150
*

projects/igniteui-angular/src/lib/core/styles/components/calendar/_calendar-component.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
@extend %cal-value--label !optional;
4646
}
4747

48+
@include e(label, 'week-number') {
49+
@extend %label--week-number !optional;
50+
}
51+
4852
@include e(date) {
4953
@extend %cal-value !optional;
5054

@@ -54,6 +58,10 @@
5458
}
5559
}
5660

61+
@include e(date, 'week-number') {
62+
@extend %cal-value-date--week-number !optional;
63+
}
64+
5765
@include e(date, 'inactive') {
5866
@extend %cal-value !optional;
5967
@extend %cal-value--inactive !optional;
@@ -143,6 +151,10 @@
143151
@extend %cal-value-content !optional;
144152
}
145153

154+
@include e(date-content, 'week-number') {
155+
@extend %cal-value-content--week-number !optional;
156+
}
157+
146158
@include e(year) {
147159
@extend %cal-value !optional;
148160
@extend %cal-value--year !optional;

0 commit comments

Comments
 (0)