forked from FuelInteractive/fuel-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(DateRangePicker): Fixes, cleanup and separate date-range-picker …
…to its own component
- Loading branch information
Showing
8 changed files
with
143 additions
and
88 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
This file was deleted.
Oops, something went wrong.
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,79 @@ | ||
<div class="input-group" (click)="showCalendar($event)"> | ||
<input type="text" class="form-control" | ||
[(ngModel)]="inputStartDate" | ||
#dateField1 | ||
/> | ||
<span class="input-group-addon" [class.input-group-addon-focus]="dateField1.focus"> | ||
<i class="fa fa-calendar"></i> | ||
</span> | ||
</div> | ||
|
||
<div class="input-group" (click)="showCalendar($event)"> | ||
<input type="text" class="form-control" | ||
[(ngModel)]="inputEndDate" | ||
#dateField2 | ||
/> | ||
<span class="input-group-addon" [class.input-group-addon-focus]="dateField2.focus"> | ||
<i class="fa fa-calendar"></i> | ||
</span> | ||
</div> | ||
|
||
<div class="date-picker-overlay" aria-hidden="true" | ||
*ngIf="calendarDisplayed" | ||
(click)="hideCalendar()"> | ||
</div> | ||
|
||
<section class="date-picker-component" *ngIf="calendarDisplayed"> | ||
<div class="" role="document" | ||
[style.top.px]="calendarY" | ||
[style.left.px]="calendarX"> | ||
<div class="container p-a-0"> | ||
<header> | ||
<button type="button" class="btn btn-secondary pull-left" | ||
(click)="scrollPrevMonth()"> | ||
<i class="fa fa-chevron-left"></i> | ||
</button> | ||
<input type="text" class="form-control text-xs-center" | ||
id="startDate" [(ngModel)]="inputDate" /> | ||
<input type="text" class="form-control text-xs-center" | ||
id="endDate" [(ngModel)]="inputDate" /> | ||
<button type="button" class="btn btn-secondary pull-right" | ||
(click)="scrollNextMonth()"> | ||
<i class="fa fa-chevron-right"></i> | ||
</button> | ||
<table class="table m-b-0 days-of-week"> | ||
<tbody> | ||
<tr> | ||
<th>S</th> | ||
<th>M</th> | ||
<th>T</th> | ||
<th>W</th> | ||
<th>T</th> | ||
<th>F</th> | ||
<th>S</th> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</header> | ||
<section class="calendar-container m-a-0"> | ||
<infinite-scroller | ||
(next)="addNextMonth()" | ||
(prev)="addPrevMonth()" | ||
height="300" | ||
distance="100" | ||
hideScrollbar="true"> | ||
<date-picker-calendar scroll-item | ||
*ngFor="#month of calendarMonths #i=index" | ||
[id]="i" | ||
[minDate]="minDate" [maxDate]="maxDate" | ||
[dateFilter]="dateFilter" | ||
[currentMonth]="month" | ||
[(selectedDate)]="selectedDate" | ||
(selectedDate)="hideCalendar()"> | ||
{{i}} | ||
</date-picker-calendar> | ||
</infinite-scroller> | ||
</section> | ||
</div> | ||
</div> | ||
</section> |
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 |
---|---|---|
@@ -1,17 +1,52 @@ | ||
import {Component, View, Input, Output} from 'angular2/core'; | ||
import {EventEmitter, ElementRef, ViewChildren, QueryList} from 'angular2/core'; | ||
import {CORE_DIRECTIVES, FORM_DIRECTIVES} from 'angular2/common'; | ||
import {DateRange} from '../../utilities/DateUtils.ts'; | ||
import {Component, View, Input, Output} from "angular2/core"; | ||
import {EventEmitter, ElementRef, ViewChildren, QueryList} from "angular2/core"; | ||
import {CORE_DIRECTIVES, FORM_DIRECTIVES} from "angular2/common"; | ||
import {DateRange} from "../../utilities/DateUtils"; | ||
import {DatePickerMobile} from "./DatePickerMobile"; | ||
import {DatePickerCalendar} from "./DatePickerCalendar"; | ||
import {InfiniteScroller, INFINITE_SCROLLER_PROVIDERS} from "../InfiniteScroller/InfiniteScroller"; | ||
|
||
@Component({ | ||
selector: 'date-range-picker' | ||
selector: "date-range-picker" | ||
}) | ||
@View({ | ||
styleUrls: ['components/DatePicker/DateRangePicker.css'], | ||
styleUrls: ['components/DatePicker/DatePickerMobile.css'], | ||
templateUrl: 'components/DatePicker/DateRangePicker.html', | ||
directives: [] | ||
directives: [DatePickerCalendar, INFINITE_SCROLLER_PROVIDERS, CORE_DIRECTIVES, FORM_DIRECTIVES] | ||
}) | ||
export class DateRangePicker { | ||
@Output() startDateChange = new EventEmitter(); | ||
export class DateRangePicker extends DatePickerMobile { | ||
@Output() valueChange = new EventEmitter(); | ||
@Input() | ||
set value(value: any) { | ||
this._selectedDate = this.handleRangeInput(value).start; | ||
} | ||
|
||
private _inputStartDate: string = ""; | ||
get inputStartDate(): string {return this._inputStartDate}; | ||
set inputDate(value: string) { | ||
this._inputStartDate = value; | ||
this._selectedDate = new Date(value); | ||
} | ||
|
||
private _inputEndDate: string = ""; | ||
get inputEndDate(): string {return this._inputEndDate}; | ||
set inputEndDate(value: string) { | ||
this._inputEndDate = value; | ||
this._selectedDate = new Date(value); | ||
} | ||
|
||
constructor(modal: ElementRef) { | ||
super(modal); | ||
/*this.modal = modal.nativeElement; | ||
this.selectedDate = new Date(); | ||
if(this.selectedDate < this._minDate) | ||
this.selectedDate = this._minDate;*/ | ||
} | ||
|
||
handleRangeInput(value: any): DateRange { | ||
if(value instanceof DateRange) | ||
return value; | ||
else | ||
throw "DateRangePicker error: input is not of type DateRange"; | ||
} | ||
} |
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