Skip to content

Commit

Permalink
Merge pull request #41 from hmcts/RDM-2468
Browse files Browse the repository at this point in the history
RDM-2468: Date field error correction
  • Loading branch information
agilks authored Aug 31, 2018
2 parents 0db9f90 + e4c5043 commit ecbd269
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
4 changes: 4 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## RELEASE NOTES

### Version 1.2.4 - August 31 2018
**RDM-2468** Bug:
- Date field error correction

### Version 1.2.3 - August 24 2018
- New publishing key

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmcts/ccd-case-ui-toolkit",
"version": "1.2.3",
"version": "1.2.4",
"description": "Case UI Toolkit",
"main": "./dist/index.umd.js",
"module": "./dist/index.js",
Expand Down
19 changes: 17 additions & 2 deletions src/components/form/date-input/date-input.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class DateInputComponent implements ControlValueAccessor, Validator, OnIn
@Input()
public formControl: FormControl;

public isTouched: boolean = false;
public displayDay: string = null;
public displayMonth: string = null;
public displayYear: string = null;
Expand Down Expand Up @@ -173,9 +174,23 @@ export class DateInputComponent implements ControlValueAccessor, Validator, OnIn
this.propagateChange(this.rawValue);
}

public inputFocus() {
this.isTouched = false;
this.touch();
}

public inputBlur() {
this.formControl.markAsTouched();
this.propagateChange(this.rawValue);
this.isTouched = true;
this.touch();
}

public touch() {
if (this.isTouched) {
this.formControl.markAsTouched();
this.propagateChange(this.rawValue);
} else {
this.formControl.markAsUntouched();
}
}

public dayId() {
Expand Down
18 changes: 12 additions & 6 deletions src/components/form/date-input/date-input.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
[value]="displayDay"
(change)="dayChange(dayInput.value)"
(keyup)="dayChange(dayInput.value)"
(blur)="inputBlur()">
(blur)="inputBlur()"
(focus)="inputFocus()">
</div>

<div class="form-group form-group-month">
Expand All @@ -23,7 +24,8 @@
[value]="displayMonth"
(change)="monthChange(monthInput.value)"
(keyup)="monthChange(monthInput.value)"
(blur)="inputBlur()">
(blur)="inputBlur()"
(focus)="inputFocus()">
</div>

<div class="form-group form-group-year">
Expand All @@ -36,7 +38,8 @@
[value]="displayYear"
(change)="yearChange(yearInput.value)"
(keyup)="yearChange(yearInput.value)"
(blur)="inputBlur()">
(blur)="inputBlur()"
(focus)="inputFocus()">
</div>

<div class="form-group form-group-hour" *ngIf="isDateTime">
Expand All @@ -49,7 +52,8 @@
[value]="displayHour"
(change)="hourChange(hourInput.value)"
(keyup)="hourChange(hourInput.value)"
(blur)="inputBlur()">
(blur)="inputBlur()"
(focus)="inputFocus()">
</div>

<div class="form-group form-group-minute" *ngIf="isDateTime">
Expand All @@ -62,7 +66,8 @@
[value]="displayMinute"
(change)="minuteChange(minuteInput.value)"
(keyup)="minuteChange(minuteInput.value)"
(blur)="inputBlur()">
(blur)="inputBlur()"
(focus)="inputFocus()">
</div>

<div class="form-group form-group-second" *ngIf="isDateTime">
Expand All @@ -75,7 +80,8 @@
[value]="displaySecond"
(change)="secondChange(secondInput.value)"
(keyup)="secondChange(secondInput.value)"
(blur)="inputBlur()">
(blur)="inputBlur()"
(focus)="inputFocus()">
</div>

</div>

0 comments on commit ecbd269

Please sign in to comment.