diff --git a/components/datepicker/datepicker-inner.ts b/components/datepicker/datepicker-inner.ts index 773066f100..de0523ba8c 100644 --- a/components/datepicker/datepicker-inner.ts +++ b/components/datepicker/datepicker-inner.ts @@ -91,9 +91,8 @@ export class DatePickerInner implements OnInit { private onlyCurrentMonth:boolean; @Input() private shortcutPropagation:boolean; - // todo: change type during implementation @Input() - private customClass:any; + private customClass:Array<{date:Date, mode:string, clazz:string}>; // todo: change type during implementation @Input() private dateDisabled:any; @@ -232,15 +231,25 @@ export class DatePickerInner implements OnInit { private createDateObject(date:Date, format:string):any { let dateObject:any = {}; dateObject.date = date; + dateObject.date.setHours(0, 0, 0, 0); dateObject.label = this.dateFilter(date, format); dateObject.selected = this.compare(date, this.selectedDate) === 0; dateObject.disabled = this.isDisabled(date); dateObject.current = this.compare(date, new Date()) === 0; - // todo: do it - // dateObject.customClass = this.customClass({date: date, mode: this.datepickerMode}) || {}; + dateObject.customClass = this.getCustomClassForDate(dateObject.date); return dateObject; } + private getCustomClassForDate(date:Date) { + if (!this.customClass) { + return ''; + } + var customClassObject:{date:Date, mode:string, clazz:string} = this.customClass.find(customClass => { + return customClass.date.valueOf() === date.valueOf() && customClass.mode === this.datepickerMode; + }, this); + return customClassObject === undefined ? '' : customClassObject.clazz; + }; + private isDisabled(date:Date):boolean { // todo: implement dateDisabled attribute return ((this.minDate && this.compare(date, this.minDate) < 0) || diff --git a/components/datepicker/datepicker.ts b/components/datepicker/datepicker.ts index 8600cec23f..524370c655 100644 --- a/components/datepicker/datepicker.ts +++ b/components/datepicker/datepicker.ts @@ -64,12 +64,11 @@ export class DatePicker implements ControlValueAccessor { @Input() public yearRange:number; @Input() public onlyCurrentMonth:boolean; @Input() public shortcutPropagation:boolean; + @Input() public customClass:Array<{date:Date, mode:string, clazz:string}>; @Input() public get activeDate():Date { return this._activeDate || this._now; } // todo: change type during implementation - public customClass:any; - // todo: change type during implementation @Input() public dateDisabled:any; constructor(@Self() public cd:NgModel) { diff --git a/components/datepicker/daypicker.ts b/components/datepicker/daypicker.ts index e478f251e5..6990ec9710 100644 --- a/components/datepicker/daypicker.ts +++ b/components/datepicker/daypicker.ts @@ -12,9 +12,8 @@ const TEMPLATE_OPTIONS:any = { `, WEEK_ROW: ` {{ weekNumbers[index] }} - -