Skip to content

Commit

Permalink
fix(datetimepicker): Fixing the initial rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Godi committed Jun 22, 2017
1 parent d9aa510 commit 4294c80
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/elements/date-time-picker/DateTimePicker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ describe('Elements: NovoDateTimePickerElement', () => {
component = fixture.debugElement.componentInstance;
}));

describe('Method: toggleTimePicker()', () => {
describe('Method: toggleView()', () => {
it('should set the componentTabState', () => {
component.toggleTimePicker('TEST');
component.toggleView('TEST');
expect(component.componentTabState).toEqual('TEST');
});
});
Expand Down
9 changes: 6 additions & 3 deletions src/elements/date-time-picker/DateTimePicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const DATE_TIME_PICKER_VALUE_ACCESSOR = {
template: `
<div class="date-time-container">
<div class="date-time-tabs">
<span class="date-tab" (click)="toggleTimePicker('date')" [@dateTextState]="componentTabState">{{selectedLabel}}</span>
<span class="time-tab" (click)="toggleTimePicker('time')" [@timeTextState]="componentTabState">
<span class="date-tab" (click)="toggleView('date')" [@dateTextState]="componentTabState">{{selectedLabel}}</span>
<span class="time-tab" (click)="toggleView('time')" [@timeTextState]="componentTabState">
<span class="hours" data-automation-id="novo-time-picker-hours">{{hours}}</span>:<span
class="minutes" data-automation-id="novo-time-picker-minutes">{{minutes}}</span>
<span *ngIf="!military" class="meridian">{{meridian}}</span>
Expand Down Expand Up @@ -101,7 +101,7 @@ export class NovoDateTimePickerElement implements ControlValueAccessor {

constructor(public labels: NovoLabelService, private element: ElementRef) { }

toggleTimePicker(tab: string): void {
toggleView(tab: string): void {
this.componentTabState = tab;
}

Expand Down Expand Up @@ -140,6 +140,7 @@ export class NovoDateTimePickerElement implements ControlValueAccessor {
this.setDateLabels(this.model);
this.onModelChange(this.model);
this.onSelect.emit({ date: this.model });
this.toggleView('time');
}

onTimeSelected(event: { hours?: number, minutes?: number, meridian?: string, date?: Date, text?: string }) {
Expand All @@ -159,6 +160,8 @@ export class NovoDateTimePickerElement implements ControlValueAccessor {
this.model = model;
if (Helpers.isEmpty(model)) {
this.model = new Date();
} else if (!isNaN(model)) {
this.model = new Date(model);
}
this.datePickerValue = this.model;
this.timePickerValue = this.model;
Expand Down

0 comments on commit 4294c80

Please sign in to comment.