Skip to content

Commit

Permalink
feat(month picker): fix build error #3126
Browse files Browse the repository at this point in the history
  • Loading branch information
SAndreeva committed Feb 8, 2019
1 parent e19ca0b commit c5f73a2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ <h2 class="igx-calendar__header-date">
[selection]="selection"
[disabledDates]="disabledDates"
[specialDates]="specialDates"
(onViewChnaged)="viewChanged($event)"
(onDateSelection)="childClicked($event)">
</igx-days-view>
</div>
Expand Down
15 changes: 9 additions & 6 deletions projects/igniteui-angular/src/lib/calendar/calendar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { IgxYearsViewComponent } from './years-view/years-view.component';
import { IgxMonthsViewComponent } from './months-view/months-view.component';
import { KEYS } from '../core/utils';
import { ICalendarDate, IGX_CALENDAR_COMPONENT } from './calendar';
import { ICalendarDate } from './calendar';

let NEXT_ID = 0;

Expand All @@ -43,10 +43,6 @@ let NEXT_ID = 0;
multi: true,
provide: NG_VALUE_ACCESSOR,
useExisting: IgxCalendarComponent
},
{
provide: IGX_CALENDAR_COMPONENT,
useExisting: IgxCalendarComponent
}
],
animations: [
Expand Down Expand Up @@ -328,7 +324,7 @@ export class IgxCalendarComponent extends IgxDaysViewComponent {
*@hidden
*/
constructor(public elementRef: ElementRef) {
super(null);
super();
}

/**
Expand Down Expand Up @@ -440,6 +436,13 @@ export class IgxCalendarComponent extends IgxDaysViewComponent {
this.onSelection.emit(this.selectedDates);
}

/**
* @hidden
*/
public viewChanged(event) {
this.viewDate = this.calendarModel.timedelta(event, 'month', 0);
}

/**
* @hidden
*/
Expand Down
7 changes: 0 additions & 7 deletions projects/igniteui-angular/src/lib/calendar/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,3 @@ export class Calendar {
return date.getFullYear() > year;
}
}


export const IGX_CALENDAR_COMPONENT = 'IgxCalendarComponentToken';

export interface IgxCalendarBase {
viewDate: Date;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import {
QueryList,
HostBinding,
forwardRef,
DoCheck,
Inject,
Optional
DoCheck
} from '@angular/core';
import { ICalendarDate, Calendar, WEEKDAYS, isDateInRanges, IGX_CALENDAR_COMPONENT, IgxCalendarBase } from '../../calendar';
import { ICalendarDate, Calendar, WEEKDAYS, isDateInRanges } from '../../calendar';
import { trigger, transition, useAnimation } from '@angular/animations';
import { slideInLeft, slideInRight } from '../../animations/main';
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';
Expand Down Expand Up @@ -314,6 +312,12 @@ export class IgxDaysViewComponent implements ControlValueAccessor, DoCheck {
@Output()
public onDateSelection = new EventEmitter<ICalendarDate>();

/**
* @hidden
*/
@Output()
public onViewChnaged = new EventEmitter<Date>();

/**
* @hidden
*/
Expand Down Expand Up @@ -430,7 +434,7 @@ export class IgxDaysViewComponent implements ControlValueAccessor, DoCheck {
/**
* @hidden
*/
constructor(@Optional() @Inject(IGX_CALENDAR_COMPONENT) public calendar: IgxCalendarBase) {
constructor() {
this.calendarModel = new Calendar();

this.calendarModel.firstWeekDay = this.weekStart;
Expand Down Expand Up @@ -648,16 +652,15 @@ export class IgxDaysViewComponent implements ControlValueAccessor, DoCheck {

this._nextDate.setDate(this._nextDate.getDate() - 7);

this.animationAction = 'prev';
this.isKeydownTrigger = true;
if (this.calendar) {
this.calendar.viewDate = this.calendarModel.timedelta(this._nextDate, 'month', 0);
}
this.animationAction = 'prev';

this.callback = (items?, next?) => {
const day = items.find((item) => item.date.date.getTime() === next.getTime()).nativeElement;
this.focusPreviousUpDate(day, true);
};

this.onViewChnaged.emit(this._nextDate);
}
}

Expand Down Expand Up @@ -685,16 +688,15 @@ export class IgxDaysViewComponent implements ControlValueAccessor, DoCheck {

this._nextDate.setDate(this._nextDate.getDate() + 7);

this.animationAction = 'next';
this.isKeydownTrigger = true;
if (this.calendar) {
this.calendar.viewDate = this.calendarModel.timedelta(this._nextDate, 'month', 0);
}
this.animationAction = 'next';

this.callback = (items?, next?) => {
const day = items.find((item) => item.date.date.getTime() === next.getTime()).nativeElement;
this.focusNextDownDate(day, true);
};

this.onViewChnaged.emit(this._nextDate);
}
}

Expand All @@ -720,16 +722,15 @@ export class IgxDaysViewComponent implements ControlValueAccessor, DoCheck {
const dayItem = dates[dates.indexOf(node)];
this._nextDate = new Date(dayItem.date.date);

this.animationAction = 'prev';
this.isKeydownTrigger = true;
if (this.calendar) {
this.calendar.viewDate = this.calendarModel.timedelta(this._nextDate, 'month', 0);
}
this.animationAction = 'prev';

this.callback = (items?, next?) => {
const day = items.find((item) => item.date.date.getTime() === next.getTime()).nativeElement;
this.focusPreviousDate(day);
};

this.onViewChnaged.emit(this._nextDate);
}
}

Expand All @@ -756,16 +757,15 @@ export class IgxDaysViewComponent implements ControlValueAccessor, DoCheck {
const dayItem = dates[dates.indexOf(node)];
this._nextDate = new Date(dayItem.date.date);

this.animationAction = 'next';
this.isKeydownTrigger = true;
if (this.calendar) {
this.calendar.viewDate = this.calendarModel.timedelta(this._nextDate, 'month', 0);
}
this.animationAction = 'next';

this.callback = (items?, next?) => {
const day = items.find((item) => item.date.date.getTime() === next.getTime()).nativeElement;
this.focusNextDate(day);
};

this.onViewChnaged.emit(this._nextDate);
}
}

Expand Down

0 comments on commit c5f73a2

Please sign in to comment.