From 957d54b4b4a08a0eb806656c7ec2f93dd1a0eeaf Mon Sep 17 00:00:00 2001 From: Ahtsham Raziq Date: Fri, 19 Jan 2018 03:26:35 +0500 Subject: [PATCH] feat(datepicker): disable specified days of week (#2744) --- src/datepicker/datepicker-inner.component.ts | 7 +++++++ src/datepicker/datepicker.component.ts | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/datepicker/datepicker-inner.component.ts b/src/datepicker/datepicker-inner.component.ts index faf5b48094..92cc7f513a 100644 --- a/src/datepicker/datepicker-inner.component.ts +++ b/src/datepicker/datepicker-inner.component.ts @@ -62,6 +62,7 @@ export class DatePickerInnerComponent implements OnInit, OnChanges { @Input() monthColLimit: number; @Input() yearColLimit: number; @Input() dateDisabled: { date: Date; mode: string }[]; + @Input() dayDisabled: number[]; @Input() initDate: Date; @Output() selectionDone: EventEmitter = new EventEmitter(undefined); @@ -380,6 +381,12 @@ export class DatePickerInnerComponent implements OnInit, OnChanges { ); } + if (this.dayDisabled) { + isDateDisabled = + isDateDisabled || + this.dayDisabled.indexOf(date.getDay()) > -1; + } + return ( isDateDisabled || (this.minDate && this.compare(date, this.minDate) < 0) || diff --git a/src/datepicker/datepicker.component.ts b/src/datepicker/datepicker.component.ts index 3ba0c2633f..e1414ad2ae 100644 --- a/src/datepicker/datepicker.component.ts +++ b/src/datepicker/datepicker.component.ts @@ -41,6 +41,7 @@ export const DATEPICKER_CONTROL_VALUE_ACCESSOR: any = { [yearRange]="yearRange" [customClass]="customClass" [dateDisabled]="dateDisabled" + [dayDisabled]="dayDisabled" [onlyCurrentMonth]="onlyCurrentMonth" [shortcutPropagation]="shortcutPropagation" [monthColLimit]="monthColLimit" @@ -98,6 +99,8 @@ export class DatePickerComponent implements ControlValueAccessor { @Input() customClass: { date: Date; mode: string; clazz: string }[]; /** array of disabled dates */ @Input() dateDisabled: { date: Date; mode: string }[]; + /** disabled days of the week from 0-6 (0=Sunday, ..., 6=Saturday) */ + @Input() dayDisabled: number[]; /** currently active date */ @Input()