Skip to content

Commit

Permalink
Merge branch 'hotfix/0.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
fetrarij committed May 7, 2018
2 parents ed5e21e + ba7e911 commit 2f7fad5
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
2 changes: 2 additions & 0 deletions demo/src/app/reactive-form/reactive-form.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ <h4>Reactive forms: with validators</h4>
<br>
<strong>Form values:</strong> {{form.value | json}}
<br>
<strong>start date is touched? </strong> {{form.get('start').touched}}
<br>

<button class="btn btn-default" (click)="startReset()">Clear start date</button>
<button class="btn btn-default" (click)="endReset()">Clear end date</button>
Expand Down
17 changes: 17 additions & 0 deletions demo/src/app/reactive-form/reactive-form.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,21 @@ describe('ReactiveFormComponent', () => {
expect(component.form.value.end.format(format)).toBe(tomorrow.format(format));
});
});
it('select start date and start date shoule be touched - reset it and start date should be untouched', () => {
fixture.whenStable().then(() => {
// open start date input
fixture.debugElement.queryAll(By.css(opener))[0].nativeElement.click();
fixture.detectChanges();
dateTag(yesterday).click();
fixture.detectChanges();
// start date input is now touched
expect(component.form.controls['start'].touched).toBeTruthy();
// click on reset
const btn = fixture.debugElement.query(By.css('button')).nativeElement;
btn.click();
fixture.detectChanges();
// start date input is now untouched
expect(component.form.controls['start'].touched).toBeFalsy();
});
});
});
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"name": "ng2-eonasdan-datetimepicker",
"version": "0.1.1",
"version": "0.1.2",
"description": "Angular2+ component for bootstrap-datetimepicker library.",
"keywords": [
"angular2",
"angular4",
"angular5",
"ng2",
"datepicker",
"bootstrap",
"datetimepicker",
"eonasdan",
"component",
"directive"
],
Expand Down
7 changes: 6 additions & 1 deletion src/datetimepicker.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,16 @@ export class DateTimePickerDirective implements OnInit, OnDestroy, DoCheck {
set value(val) {
this._value = val;
this._onChange(val);
this._onTouched();
if (val) {
this._onTouched();
}
this.changeDetector.markForCheck();
}

writeValue(value) {
if (!value) {
this.value = null;
}
this.value = value;
this.setDpValue(value);
}
Expand Down

0 comments on commit 2f7fad5

Please sign in to comment.