-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(datepicker): Allow to disable specific dates (#5046)
* feat(datepicker): Allow to disable specific dates * feat(datepicker): Move isDisabledDate outside of chronos * feat(datepicker): Add datesDisabled to inline datepicker * feat(datepicker): Add datesDisabled to daterangepicker * feat(datepicker): Update demo for datesDisabled * feat(datepicker): Add test for flag days calendar * feat(datepicker): update docs for datesDisabled * feat(datepicker): Fix typo * feat(datepicker): Add demo for datesDisabled with daterangepicker
- Loading branch information
1 parent
af59314
commit 5633d2d
Showing
18 changed files
with
183 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
demo/src/app/components/+datepicker/demos/disable-dates/disable-dates.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div class="row"> | ||
<div class="col-xs-12 col-12 col-md-4 form-group"> | ||
<input type="text" | ||
placeholder="Datepicker" | ||
class="form-control" | ||
bsDatepicker | ||
[datesDisabled]="disabledDates"> | ||
</div> | ||
<div class="col-xs-12 col-12 col-md-4 form-group"> | ||
<input type="text" | ||
placeholder="Daterangepicker" | ||
class="form-control" | ||
bsDaterangepicker | ||
[datesDisabled]="disabledDates"> | ||
</div> | ||
</div> |
12 changes: 12 additions & 0 deletions
12
demo/src/app/components/+datepicker/demos/disable-dates/disable-dates.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'demo-datepicker-datesdisabled', | ||
templateUrl: './disable-dates.html' | ||
}) | ||
export class DemoDatepickerDatesDisabledComponent { | ||
disabledDates = [ | ||
new Date('2019-02-05'), | ||
new Date('2019-02-09') | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { flagDaysCalendar } from './flag-days-calendar'; | ||
|
||
describe('flag-days-calendar:', () => { | ||
|
||
it('should flag days as disabled when they are part of the datesDisabled', () => { | ||
const weekViewModel = { | ||
month: new Date('2019-02-01'), | ||
weeks: [ | ||
{ | ||
days: [ | ||
{ date: new Date('2019-02-07'), label: '2019-02-07' }, | ||
{ date: new Date('2019-02-08'), label: '2019-02-08' }, | ||
{ date: new Date('2019-02-09'), label: '2019-02-09' } | ||
]} | ||
], | ||
weekNumbers: [], | ||
weekdays: [], | ||
monthTitle: '', | ||
yearTitle: '' | ||
}; | ||
const datesDisabled = [ | ||
new Date('2019-02-07'), | ||
new Date('2019-02-09') | ||
]; | ||
const result = flagDaysCalendar(weekViewModel, { | ||
datesDisabled, | ||
isDisabled: false, | ||
minDate: new Date('2019-01-01'), | ||
maxDate: new Date('2019-12-31'), | ||
daysDisabled: [], | ||
hoveredDate: new Date('2019-02-06'), | ||
selectedDate: new Date('2019-02-05'), | ||
selectedRange: [], | ||
displayMonths: 1, | ||
monthIndex: 1 | ||
}); | ||
|
||
expect(result.weeks[0].days.find(day => day.label === '2019-02-07').isDisabled).toBe(true); | ||
expect(result.weeks[0].days.find(day => day.label === '2019-02-08').isDisabled).toBe(false); | ||
expect(result.weeks[0].days.find(day => day.label === '2019-02-09').isDisabled).toBe(true); | ||
}); | ||
}); |
Oops, something went wrong.