Skip to content

Calendar multi view mode #5666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 78 commits into from
Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
72de46f
feat(calendar): calendar multi view #4282
hanastasov Apr 10, 2019
3cb4e27
merge master
hanastasov May 10, 2019
36cf089
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Jul 30, 2019
c095f22
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Aug 6, 2019
7ffba6d
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Aug 8, 2019
d752ee1
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Aug 15, 2019
04edfd1
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Aug 20, 2019
cd7a1e7
feat(calendar): multiview kboard navigation #4282
hanastasov Aug 20, 2019
ca93213
feat(calendar): add default month view #4282
hanastasov Aug 20, 2019
727d3ac
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Aug 20, 2019
083d7ea
feat(calendar): dayViews just be public #4282
hanastasov Aug 20, 2019
c44e00f
feat(calendar): set viewDate for per view #4282
hanastasov Aug 20, 2019
bbbccba
feat(calendar): dynamically set month views #4282
hanastasov Aug 21, 2019
907efab
feat(calendar): fix bug in focusing prev day #4282
hanastasov Aug 21, 2019
eec448e
fix(calendar): home/end find 1st/last view #4282
hanastasov Aug 21, 2019
fd5f1f7
style(calendar): add style for hidden days #4282
hanastasov Aug 21, 2019
a0f4114
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Aug 21, 2019
6a4a371
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Aug 22, 2019
5c3b7ed
merge master
hanastasov Aug 22, 2019
ddef2bb
feat(calendar): add multiview to picker #4282
hanastasov Aug 23, 2019
8ab8c29
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Aug 26, 2019
7ea5743
fix(calendar): calendar sample typo #4282
hanastasov Aug 26, 2019
7fa2c6a
style(calendar): align month headers #4282
hanastasov Aug 28, 2019
d93b6ef
style(calendar): style month headers #4282
hanastasov Aug 28, 2019
3ddc822
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Aug 28, 2019
d15f2ae
style(calendar): select outside days #4282
hanastasov Aug 30, 2019
d5b413b
style(calendar): expose style class for day #4282
hanastasov Sep 3, 2019
a599c4d
merge master
hanastasov Sep 3, 2019
662ed9b
style(calendar): add space between views #4282
hanastasov Sep 4, 2019
7c88365
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Sep 4, 2019
8815ac0
Merge branch 'master' into ha-mutliview-calendar-2
hanastasov Sep 4, 2019
65c3e58
style(calendar): fix lint in theme files #4282
hanastasov Sep 4, 2019
c99cf11
Merge branch 'ha-mutliview-calendar-2' of https://github.com/IgniteUI…
hanastasov Sep 4, 2019
8e6d7f6
fix(calendar): fix multiselection bug #4282
hanastasov Sep 4, 2019
4342be6
feat(calendar): set hideOutsideDays input #4282
hanastasov Sep 5, 2019
0239d7c
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Sep 9, 2019
8464b1f
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Sep 9, 2019
2e006ff
fix(calendar): edge case and test kb navig #4282
hanastasov Sep 10, 2019
6ed20d7
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Sep 11, 2019
d26af79
fix(calendar): fix custom sbheader templates #4282
hanastasov Sep 11, 2019
7bc95a5
fix(calendar): keep track of months changes #4282
hanastasov Sep 11, 2019
74eeda2
fix(calendar): keep track of month changes #4282
hanastasov Sep 11, 2019
280e443
Merge branch 'master' into ha-mutliview-calendar-2
hanastasov Sep 12, 2019
e417a64
Merge branch 'master' into ha-mutliview-calendar-2
hanastasov Sep 12, 2019
24f153a
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Sep 12, 2019
47f63cc
build(calendar): fix npm lint error #4282
hanastasov Sep 12, 2019
f4a75a6
Merge branch 'ha-mutliview-calendar-2' of https://github.com/IgniteUI…
hanastasov Sep 12, 2019
bdbfa47
Merge branch 'master' into ha-mutliview-calendar-2
hanastasov Sep 12, 2019
17f8568
fix(calendar): unsubscribe from changes #4282
hanastasov Sep 12, 2019
e7d7c24
Merge branch 'ha-mutliview-calendar-2' of https://github.com/IgniteUI…
hanastasov Sep 12, 2019
b4d199f
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Sep 12, 2019
18c5a61
refactor(calendar): refactor and clean #4282
hanastasov Sep 12, 2019
8f9980c
fix(calendar): remove redundant paramater #4282
hanastasov Sep 12, 2019
08b5093
docs(calendar): update readme files #4282
hanastasov Sep 12, 2019
89c589a
Merge branch 'master' into ha-mutliview-calendar-2
hanastasov Sep 12, 2019
d4fa2c9
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Sep 13, 2019
1a16ff7
perf(calendar): multi and range selection #4282
hanastasov Sep 13, 2019
ca5ca54
Merge branch 'ha-mutliview-calendar-2' of https://github.com/IgniteUI…
hanastasov Sep 13, 2019
978dd57
fix(calendar): check for range selection #4282
hanastasov Sep 13, 2019
b883778
fix(calendar): treat value type accordingly #4282
hanastasov Sep 13, 2019
6c0ec08
fix(calendar): exclude disabled dates #4282
hanastasov Sep 13, 2019
825b2e2
refactor(calendar): remove circ dependency #4282
hanastasov Sep 16, 2019
444aed7
Merge branch 'master' into ha-mutliview-calendar-2
hanastasov Sep 16, 2019
cc58e30
fix(calendar): fix selection bugs clear code #4282
hanastasov Sep 17, 2019
4283443
Merge branch 'ha-mutliview-calendar-2' of https://github.com/IgniteUI…
hanastasov Sep 17, 2019
237163e
style(month-picker): alighn m-picker header #4282
hanastasov Sep 17, 2019
644d6e8
test(calendar): dont test duplicated getter #4282
hanastasov Sep 17, 2019
e36bea7
fix(calendar): dont recalculate next date #4282
hanastasov Sep 17, 2019
81e6264
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Sep 17, 2019
5c06ef5
Merge branch 'master' into ha-mutliview-calendar-2
rkaraivanov Sep 17, 2019
0566413
Merge branch 'master' into ha-mutliview-calendar-2
hanastasov Sep 17, 2019
f371d65
fix(calendar): fix coloring inactive days #4282
hanastasov Sep 17, 2019
956c1a2
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
hanastasov Sep 17, 2019
7687a76
Merge branch 'ha-mutliview-calendar-2' of https://github.com/IgniteUI…
hanastasov Sep 17, 2019
5b569fe
fix(calendar): fix single selecetion error #4282
hanastasov Sep 17, 2019
866557b
fix(calendar): make tslint happy #4282
hanastasov Sep 17, 2019
b9689a1
Merge branch 'master' into ha-mutliview-calendar-2
zdrawku Sep 17, 2019
d2a5386
style(calendar): fix style in rang selection #4282
hanastasov Sep 17, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions projects/igniteui-angular/src/lib/calendar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ A multiple selection calendar with different locale and templating for the subhe
</igx-calendar>
```

A calendar displaying more than one month in the view and hiding the days that are outside of the current month
```html
<igx-calendar monthsViewNumber="2" [hideOutsideDays]="'true'">
</igx-calendar>
```

The **igxCalendar** implements the `ControlValueAccessor` interface, providing two-way data-binding
and the expected behavior when used both in Template-driven or Reactive Forms.

Expand All @@ -65,8 +71,8 @@ When the **igxCalendar** component is focused:
- `PageDown` will move to the next month.
- `Shift + PageUp` will move to the previous year.
- `Shift + PageDown` will move to the next year.
- `Home` will focus the first day of the current month that is into view.
- `End` will focus the last day of the current month that is into view.
- `Home` will focus the first day of the current month (or first month if more months are displayed) hat is into view.
- `End` will focus the last day of the current month ((or last month if more months are displayed)) that is into view.
- `Tab` will navigate through the subheader buttons;

When `prev` or `next` month buttons (in the subheader) are focused:
Expand All @@ -82,6 +88,7 @@ When a day inside the current month is focused:
- Arrow keys will navigate through the days.
- Arrow keys will allow navigation to previous/next month as well.
- `Enter` will select the currently focused day.
- When more than one month view is displayed, navigating with the arrow keys should move to next/previous month after navigating from first/last day in current month.

When a month inside the months view is focused:
- Arrow keys will navigate through the months.
Expand Down Expand Up @@ -154,6 +161,13 @@ The default values are listed below.
{ day: false, month: true, year: false }
```

- `monthViewsNumber: number`
Controls the number of month views displayed. Default is 1.

- `hideOusideDays: boolean`
Controls the visibility of the dates that do not belong to the current month.


### Outputs

- `onSelection(): Date | Date[]`
Expand Down
29 changes: 27 additions & 2 deletions projects/igniteui-angular/src/lib/calendar/calendar-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ export class IgxCalendarBase implements ControlValueAccessor {
* Otherwise it is an array of `Date` objects.
*/
public set value(value: Date | Date[]) {
if (!value || !!value && (value as Date[]).length === 0) {
return;
}

this.selectDate(value);
}

Expand Down Expand Up @@ -210,6 +214,20 @@ export class IgxCalendarBase implements ControlValueAccessor {
this._specialDates = value;
}

/**
* Sets/gets whether the outside dates (dates that are out of the current month) will be hidden.
* Default value is `false`.
* ```html
* <igx-calendar [hideOutsideDays] = "true"></igx-calendar>
* ```
* ```typescript
* let hideOutsideDays = this.calendar.hideOutsideDays;
* ```
*/

@Input()
public hideOutsideDays = false;

/**
* Emits an event when a date is selected.
* Provides reference the `selectedDates` property.
Expand Down Expand Up @@ -379,7 +397,14 @@ export class IgxCalendarBase implements ControlValueAccessor {
*/
private selectMultiple(value: Date | Date[]) {
if (Array.isArray(value)) {
this.selectedDates = this.selectedDates.concat(value.map(v => this.getDateOnly(v)));
const newDates = value.map(v => this.getDateOnly(v).getTime());
const selDates = this.selectedDates.map(v => this.getDateOnly(v).getTime());

if (JSON.stringify(newDates) === JSON.stringify(selDates)) {
return;
}

this.selectedDates = Array.from(new Set([...newDates, ...selDates])).map(v => new Date(v));
} else {
const valueDateOnly = this.getDateOnly(value);
const newSelection = [];
Expand All @@ -395,7 +420,7 @@ export class IgxCalendarBase implements ControlValueAccessor {
this.selectedDates = this.selectedDates.concat(newSelection);
}
}

this.selectedDates.sort((a: Date, b: Date) => a.valueOf() - b.valueOf());
this._onChangeCallback(this.selectedDates);
}

Expand Down
53 changes: 31 additions & 22 deletions projects/igniteui-angular/src/lib/calendar/calendar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<span>{{ getFormattedDate().monthday }}</span>
</ng-template>

<ng-template let-result #defaultMonth>
<ng-template let-result #defaultMonth let-obj>
<span tabindex="0" #monthsBtn (keydown)="activeViewYearKB($event)" (click)="activeViewYear()"
class="igx-calendar-picker__date">
{{ formattedMonth(viewDate) }}
{{ formattedMonth(getViewDate(obj.index)) }}
</span>
<span tabindex="0" #yearsBtn (keydown)="activeViewDecadeKB($event)" (click)="activeViewDecade()"
class="igx-calendar-picker__date">
{{ formattedYear(viewDate) }}
{{ formattedYear(getViewDate(obj.index)) }}
</span>
</ng-template>

Expand All @@ -26,33 +26,42 @@ <h2 class="igx-calendar__header-date">
(swipeleft)="nextMonth()">
<div class="igx-calendar-picker">
<div tabindex="0" class="igx-calendar-picker__prev" #prevMonthBtn
igxCalendarScrollMonth [startScroll]="startPrevMonthScroll" [stopScroll]="stopMonthScroll">
igxCalendarScrollMonth [startScroll]="startPrevMonthScroll" [stopScroll]="stopMonthScroll" [ngStyle]="{
'min-width.%': 100/(monthsViewNumber*7),
'left': 0
}">
<igx-icon fontSet="material">keyboard_arrow_left</igx-icon>
</div>
<div>
<ng-container *ngTemplateOutlet="subheaderTemplate ? subheaderTemplate : defaultMonth; context: context">
<div *ngFor="let view of dayViews; index as i;" [style.width.%]="100/monthsViewNumber">
<ng-container *ngTemplateOutlet="subheaderTemplate ? subheaderTemplate : defaultMonth; context: getContext(i)">
</ng-container>
</div>
<div tabindex="0" class="igx-calendar-picker__next" #nextMonthBtn
igxCalendarScrollMonth [startScroll]="startNextMonthScroll" [stopScroll]="stopMonthScroll">
<div tabindex="0" class="igx-calendar-picker__next" #nextMonthBtn
igxCalendarScrollMonth [startScroll]="startNextMonthScroll" [stopScroll]="stopMonthScroll" [ngStyle]="{
'min-width.%': 100/(monthsViewNumber*7),
'right': 0
}">
<igx-icon fontSet="material">keyboard_arrow_right</igx-icon>
</div>
</div>

<igx-days-view [changeDaysView]="true" #days
[animationAction]="monthAction"
[locale]="locale"
[value]="value"
[viewDate]="viewDate"
[weekStart]="weekStart"
[formatOptions]="formatOptions"
[formatViews]="formatViews"
[selection]="selection"
[disabledDates]="disabledDates"
[specialDates]="specialDates"
(onViewChanged)="viewChanged($event)"
(onDateSelection)="childClicked($event)">
</igx-days-view>
<div style="display: flex">
<igx-days-view *ngFor="let view of dayViews; index as i;" [changeDaysView]="true" #days
[animationAction]="monthAction"
[locale]="locale"
[value]="value"
[viewDate]="getViewDate(i)"
[weekStart]="weekStart"
[formatOptions]="formatOptions"
[formatViews]="formatViews"
[selection]="selection"
[disabledDates]="disabledDates"
[specialDates]="specialDates"
[hideOutsideDays]="hideOutsideDays"
(onViewChanged)="viewChanged($event)"
(onDateSelection)="childClicked($event)">
</igx-days-view>
</div>
</div>

<igx-months-view *ngIf="isYearView" [@animateView]="activeView" #months
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,6 @@ describe('IgxCalendar', () => {

selectedDates.forEach(d => {
expect(d.selected).toBe(true);
expect(d.isSelectedCSS).toBe(true);
});

const notSelectedDates = calendar.daysView.dates.toArray().filter(d => {
Expand All @@ -1051,7 +1050,6 @@ describe('IgxCalendar', () => {

notSelectedDates.forEach(d => {
expect(d.selected).toBe(false);
expect(d.isSelectedCSS).toBe(false);
});
});
});
Expand All @@ -1070,7 +1068,6 @@ describe('IgxCalendar', () => {

specialDates.forEach(d => {
expect(d.isSpecial).toBe(true);
expect(d.isSpecialCSS).toBe(true);
});

let disabledDates = calendar.daysView.dates.toArray().filter(d => {
Expand Down Expand Up @@ -1098,7 +1095,6 @@ describe('IgxCalendar', () => {

specialDates.forEach(d => {
expect(d.isSpecial).toBe(true);
expect(d.isSpecialCSS).toBe(true);
});

disabledDates = calendar.daysView.dates.toArray().filter(d => {
Expand Down Expand Up @@ -1804,6 +1800,8 @@ describe('IgxCalendar', () => {
fixture.detectChanges();

UIInteractions.simulateKeyDownEvent(document.activeElement, 'ArrowLeft');
fixture.detectChanges();
await wait(400);
UIInteractions.simulateKeyDownEvent(document.activeElement, 'ArrowLeft');
UIInteractions.simulateKeyDownEvent(document.activeElement, 'ArrowLeft');
UIInteractions.simulateKeyDownEvent(document.activeElement, 'ArrowLeft');
Expand All @@ -1818,6 +1816,8 @@ describe('IgxCalendar', () => {
fixture.detectChanges();

UIInteractions.simulateKeyDownEvent(document.activeElement, 'ArrowLeft');
fixture.detectChanges();
await wait(400);
UIInteractions.simulateKeyDownEvent(document.activeElement, 'ArrowLeft');
fixture.detectChanges();
await wait(400);
Expand Down Expand Up @@ -1851,6 +1851,8 @@ describe('IgxCalendar', () => {
fixture.detectChanges();

UIInteractions.simulateKeyDownEvent(document.activeElement, 'ArrowDown');
fixture.detectChanges();
await wait(400);
UIInteractions.simulateKeyDownEvent(document.activeElement, 'ArrowDown');
fixture.detectChanges();
await wait(400);
Expand All @@ -1859,6 +1861,8 @@ describe('IgxCalendar', () => {
expect(date.nativeElement).toBe(document.activeElement);

UIInteractions.simulateKeyDownEvent(document.activeElement, 'ArrowDown');
fixture.detectChanges();
await wait(400);
UIInteractions.simulateKeyDownEvent(document.activeElement, 'ArrowDown');
fixture.detectChanges();
await wait(400);
Expand Down Expand Up @@ -1892,6 +1896,8 @@ describe('IgxCalendar', () => {
fixture.detectChanges();

UIInteractions.simulateKeyDownEvent(document.activeElement, 'ArrowDown');
fixture.detectChanges();
await wait(400);
UIInteractions.simulateKeyDownEvent(document.activeElement, 'ArrowRight');
UIInteractions.simulateKeyDownEvent(document.activeElement, 'ArrowRight');
fixture.detectChanges();
Expand Down Expand Up @@ -2060,7 +2066,6 @@ class DateTester {
static testDatesSpeciality(dates: IgxDayItemComponent[], special: boolean): void {
for (const date of dates) {
expect(date.isSpecial).toBe(special);
expect(date.isSpecialCSS).toBe(special);
}
}
}
Expand Down
Loading