Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,8 @@
"@angular-eslint/schematics:library": {
"setParserOptionsProject": true
}
},
"cli": {
"analytics": "72cac722-7e39-4ef7-9942-e52e4c3ee79e"
}
}
35 changes: 20 additions & 15 deletions src/app/pets/pet-add/pet-add.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,26 @@ <h2>
</div>
</div>

<div class="form-group has-feedback" [class.has-success]="birthDate.dirty && birthDate.valid"
[class.has-error]="birthDate.dirty && !birthDate.valid">
<label class="col-sm-2 control-label">Birth Date</label>
<div class="col-sm-10">
<input matInput [matDatepicker]="birthDateDatepicker" required [ngModel]="pet.birthDate | date:'yyyy-MM-dd'"
name="birthDate" #birthDate="ngModel">
<mat-datepicker-toggle matSuffix [for]="birthDateDatepicker"></mat-datepicker-toggle>
<mat-datepicker #birthDateDatepicker></mat-datepicker>
<span class="glyphicon form-control-feedback" [class.glyphicon-ok]="birthDate.valid"
[class.glyphicon-remove]="!birthDate.valid" aria-hidden="true"></span>
<span class="help-block"
*ngIf="birthDate.dirty && birthDate.hasError('required')">BirthDate is required</span>

</div>
</div>
<div class="form-group has-feedback" [class.has-success]="birthDate.dirty && birthDate.valid"
[class.has-error]="birthDate.dirty && !birthDate.valid">
<label class="col-sm-2 control-label">Birth Date</label>
<div class="col-sm-10">
<input matInput [matDatepicker]="birthDateDatepicker" [max]="maxDate" required
[ngModel]="pet.birthDate | date:'yyyy-MM-dd'"
name="birthDate" #birthDate="ngModel">

<mat-datepicker-toggle matSuffix [for]="birthDateDatepicker"></mat-datepicker-toggle>
<mat-datepicker #birthDateDatepicker></mat-datepicker>

<span class="help-block" *ngIf="birthDate.dirty && birthDate.errors?.matDatepickerMax">
Birth date cannot be in the future
</span>

<span class="help-block" *ngIf="birthDate.dirty && birthDate.hasError('required')">
BirthDate is required
</span>
</div>
</div>
<div class="control-group">
<div class="form-group has-feedback" [class.has-success]="type.dirty && type.valid"
[class.has-error]="type.dirty && !type.valid">
Expand Down
2 changes: 2 additions & 0 deletions src/app/pets/pet-add/pet-add.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export class PetAddComponent implements OnInit {
petTypes: PetType[];
addedSuccess = false;
errorMessage: string;
maxDate=new Date();


constructor(private ownerService: OwnerService, private petService: PetService,
private petTypeService: PetTypeService, private router: Router, private route: ActivatedRoute) {
Expand Down