Skip to content

Commit

Permalink
feat(doc): include docs for DateRangepicker custom format (#5199)
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanAyaz authored and Domainv committed Jun 21, 2019
1 parent 42cc778 commit b845340
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
6 changes: 3 additions & 3 deletions cypress/full/datepicker/custom_date_format_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ describe('Datepicker demo test suite: Custom date format', () => {
"YYYY-MM-DD", "MM/DD/YYYY", "MMMM Do YYYY,h:mm:ss a"`, () => {
const dayToChose = currentDay < 10 ? `0${currentDay}` : currentDay;
const monthToChose = currentMonthNum + 1 < 10 ? `0${currentMonthNum + 1}` : currentMonthNum + 1;
datepicker.isInputHaveAttrs(customFormat, [{ attr: 'formcontrolname', value: 'myDateYMD' }], 0);
datepicker.isInputHaveAttrs(customFormat, [{ attr: 'formcontrolname', value: 'myDateMDY' }], 1);
datepicker.isInputHaveAttrs(customFormat, [{ attr: 'formcontrolname', value: 'myDateFull' }], 2);
datepicker.isInputHaveAttrs(customFormat, [{ attr: 'formcontrolname', value: 'dateYMD' }], 0);
datepicker.isInputHaveAttrs(customFormat, [{ attr: 'formcontrolname', value: 'dateMDY' }], 1);
datepicker.isInputHaveAttrs(customFormat, [{ attr: 'formcontrolname', value: 'dateFull' }], 2);
datepicker.isButtonExist(customFormat, 'Date Picker', 0);
datepicker.isButtonExist(customFormat, 'Date Picker', 1);
datepicker.isButtonExist(customFormat, 'Date Picker', 2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<form [formGroup]="myForm">
<form [formGroup]="form">
<div class="row">
<div class="col-xs-12 col-md-5 col-lg-4 form-group">
<input
class="form-control"
#dpYMD="bsDatepicker"
#datepickerYMD="bsDatepicker"
bsDatepicker
formControlName="myDateYMD"
formControlName="dateYMD"
[bsConfig]="{ dateInputFormat: 'YYYY-MM-DD' }">
</div>
<div class="col-xs-12 col-12 col-md-3 form-group">
<button class="btn btn-success" (click)="dpYMD.toggle()" [attr.aria-expanded]="dpYMD.isOpen">Date Picker</button>
<button class="btn btn-success" (click)="datepickerYMD.toggle()" [attr.aria-expanded]="datepickerYMD.isOpen">Date Picker</button>
</div>
</div>
<br>
Expand All @@ -18,13 +18,13 @@
<div class="col-xs-12 col-md-5 col-lg-4 form-group">
<input
class="form-control"
#dpMDY="bsDatepicker"
#datepickerMDY="bsDatepicker"
bsDatepicker
formControlName="myDateMDY"
formControlName="dateMDY"
[bsConfig]="{ dateInputFormat: 'MM/DD/YYYY' }">
</div>
<div class="col-xs-12 col-12 col-md-3 form-group">
<button class="btn btn-success" (click)="dpMDY.toggle()" [attr.aria-expanded]="dpMDY.isOpen">Date Picker</button>
<button class="btn btn-success" (click)="datepickerMDY.toggle()" [attr.aria-expanded]="datepickerMDY.isOpen">Date Picker</button>
</div>
</div>
<br>
Expand All @@ -33,13 +33,27 @@
<div class="col-xs-12 col-md-5 col-lg-4 form-group">
<input
class="form-control"
#dpFull="bsDatepicker"
#datepickerFull="bsDatepicker"
bsDatepicker
formControlName="myDateFull"
formControlName="dateFull"
[bsConfig]="{ dateInputFormat: 'MMMM Do YYYY, h:mm:ss a' }">
</div>
<div class="col-xs-12 col-12 col-md-3 form-group">
<button class="btn btn-success" (click)="dpFull.toggle()" [attr.aria-expanded]="dpFull.isOpen">Date Picker</button>
<button class="btn btn-success" (click)="datepickerFull.toggle()" [attr.aria-expanded]="datepickerFull.isOpen">Date Picker</button>
</div>
</div>

<div class="row">
<div class="col-xs-12 col-md-5 col-lg-4 form-group">
<input type="text"
class="form-control"
formControlName="dateRange"
#daterangepicker="bsDaterangepicker"
bsDaterangepicker
[bsConfig]="{ rangeInputFormat: 'MMMM Do YYYY, h:mm:ss a' }">
</div>
<div class="col-xs-12 col-12 col-md-3 form-group">
<button class="btn btn-success" (click)="daterangepicker.toggle()" [attr.aria-expanded]="daterangepicker.isOpen">Date Range Picker</button>
</div>
</div>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import { FormControl, FormGroup } from '@angular/forms';
})
export class DemoDatePickerCustomFormatComponent {

myForm = new FormGroup({
myDateYMD: new FormControl(new Date()),
myDateFull: new FormControl(new Date()),
myDateMDY: new FormControl(new Date())
form = new FormGroup({
dateYMD: new FormControl(new Date()),
dateFull: new FormControl(new Date()),
dateMDY: new FormControl(new Date()),
dateRange: new FormControl([new Date(), new Date()])
});
}

0 comments on commit b845340

Please sign in to comment.