Skip to content

Commit

Permalink
Add dogs
Browse files Browse the repository at this point in the history
  • Loading branch information
PauMAVA committed May 18, 2024
1 parent 81a56b6 commit d621caa
Show file tree
Hide file tree
Showing 17 changed files with 969 additions and 8 deletions.
10 changes: 9 additions & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ import { UserDeleteComponent } from './user/user-delete/user-delete.component';
import { ShelterListComponent } from './shelter/shelter-list/shelter-list.component'
import {ShelterCreateComponent} from "./shelter/shelter-create/shelter-create.component";
import { CatListComponent } from './pet/cat/cat-list/cat-list.component';
import { DogListComponent } from './pet/dog/dog-list/dog-list.component';
import { CatCreateComponent } from './pet/cat/cat-create/cat-create.component';
import { CatDetailComponent } from './pet/cat/cat-detail/cat-detail.component';
import { CatEditComponent } from './pet/cat/cat-edit/cat-edit.component';
import { CatDeleteComponent } from './pet/cat/cat-delete/cat-delete.component';
import { DogListComponent } from './pet/dog/dog-list/dog-list.component';
import { DogCreateComponent } from './pet/dog/dog-create/dog-create.component';
import { DogDetailComponent } from './pet/dog/dog-detail/dog-detail.component';
import { DogEditComponent } from './pet/dog/dog-edit/dog-edit.component';
import { DogDeleteComponent } from './pet/dog/dog-delete/dog-delete.component';

const routes: Routes = [
{ path: 'users/create', component: UserRegisterComponent},
Expand All @@ -34,6 +38,10 @@ const routes: Routes = [
{ path: 'cats/:id/edit', component: CatEditComponent, canActivate: [LoggedInGuard]},
{ path: 'cats/:id/delete', component: CatDeleteComponent, canActivate: [LoggedInGuard]},
{ path: 'dogs', component: DogListComponent, canActivate: [LoggedInGuard]},
{ path: 'dogs/create', component: DogCreateComponent, canActivate: [LoggedInGuard]},
{ path: 'dogs/:id', component: DogDetailComponent, canActivate: [LoggedInGuard]},
{ path: 'dogs/:id/edit', component: DogEditComponent, canActivate: [LoggedInGuard]},
{ path: 'dogs/:id/delete', component: DogDeleteComponent, canActivate: [LoggedInGuard]},
];

@NgModule({
Expand Down
12 changes: 11 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@ import {ShelterListComponent} from "./shelter/shelter-list/shelter-list.componen
import {ShelterCreateComponent} from "./shelter/shelter-create/shelter-create.component";
import {ShelterDetailComponent} from "./shelter/shelter-detail/shelter-detail.component";
import { CatListComponent } from './pet/cat/cat-list/cat-list.component';
import { DogListComponent } from './pet/dog/dog-list/dog-list.component';
import { CatService } from './pet/cat/cat.service';
import { DogService } from './pet/dog/dog.service';
import { CatCreateComponent } from './pet/cat/cat-create/cat-create.component';
import { CatDetailComponent } from './pet/cat/cat-detail/cat-detail.component';
import { CatEditComponent } from './pet/cat/cat-edit/cat-edit.component';
import { CatDeleteComponent } from './pet/cat/cat-delete/cat-delete.component';
import { CatSearchComponent } from './pet/cat/cat-search/cat-search.component';
import { DogListComponent } from './pet/dog/dog-list/dog-list.component';
import { DogCreateComponent } from './pet/dog/dog-create/dog-create.component';
import { DogDetailComponent } from './pet/dog/dog-detail/dog-detail.component';
import { DogDeleteComponent } from './pet/dog/dog-delete/dog-delete.component';
import { DogEditComponent } from './pet/dog/dog-edit/dog-edit.component';
import { DogSearchComponent } from './pet/dog/dog-search/dog-search.component';

@NgModule({
declarations: [
Expand All @@ -60,6 +65,11 @@ import { CatSearchComponent } from './pet/cat/cat-search/cat-search.component';
CatEditComponent,
CatSearchComponent,
DogListComponent,
DogCreateComponent,
DogDetailComponent,
DogDeleteComponent,
DogEditComponent,
DogSearchComponent,
],
imports: [
BrowserModule,
Expand Down
4 changes: 4 additions & 0 deletions src/app/pet/dog/dog-create/dog-create.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.form-error {
color: red;
font-size: x-small;
}
198 changes: 198 additions & 0 deletions src/app/pet/dog/dog-create/dog-create.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
<form
id="dog-form"
(ngSubmit)="onSubmit()"
#form="ngForm"
[formGroup]="dogForm"
>
<fieldset>
<div class="row">
<div class="form-group mb-3 col-6">
<label class="control-label required-label" for="name">Name</label>
<input
id="name"
name="name"
formControlName="name"
type="text"
class="form-control"
[(ngModel)]="dog.name"
/>
<div class="form-error" *ngIf="name.errors?.['required']">
Name is required
</div>
</div>

<div class="form-group mb-3 col-6">
<label class="control-label required-label" for="chip">Chip</label>
<input
id="chip"
name="chip"
formControlName="chip"
type="text"
class="form-control"
[(ngModel)]="dog.chip"
/>
<div class="form-error" *ngIf="chip.errors?.['required']">
Chip is required
</div>
</div>

<div class="form-group mb-3 col-6">
<label class="control-label required-label" for="dateOfBirth">Date of birth</label>
<input
id="dateOfBirth"
name="dateOfBirth"
formControlName="dateOfBirth"
type="date"
class="form-control"
[(ngModel)]="dog.dateOfBirth"
/>
<div class="form-error" *ngIf="dateOfBirth.errors?.['required']">
Date of birth is required
</div>
<div
class="form-error"
*ngIf="dateOfBirth.errors?.['invalidDate'] && !dateOfBirth.errors?.['required']"
>
Invalid date
</div>
</div>

<div class="form-group mb-3 col-6">
<label class="control-label required-label" for="colour">Colour</label>
<input
id="colour"
name="colour"
formControlName="colour"
type="color"
class="form-control"
[(ngModel)]="dog.colour"
/>
<div class="form-error" *ngIf="colour.errors?.['required']">
Colour is required
</div>
<div
class="form-error"
*ngIf="colour.errors?.['invalidColour'] && !colour.errors?.['required']"
>
Invalid date
</div>
</div>

<div class="form-group mb-3 col-6">
<label class="control-label required-label" for="size">Size</label>
<select
id="size"
name="size"
formControlName="size"
class="form-control"
[(ngModel)]="dog.size"
>
<option value="1">Small</option>
<option value="2">Average</option>
<option value="3">Large</option>
<option value="4">Extra Large</option>
</select>
<div class="form-error" *ngIf="size.errors?.['required']">
Size is required
</div>
<div
class="form-error"
*ngIf="size.errors?.['invalidNumber'] && !size.errors?.['required']"
>
Size is invalid
</div>
</div>

<div class="form-group mb-3 col-6">
<label class="control-label required-label" for="sex">Sex</label>
<select
id="sex"
name="sex"
formControlName="sex"
class="form-control"
[(ngModel)]="dog.sex"
>
<option value="male">Male</option>
<option value="female">Female</option>
</select>
<div class="form-error" *ngIf="sex.errors?.['required']">
Sex is required
</div>
<div
class="form-error"
*ngIf="sex.errors?.['invalidSex'] && !sex.errors?.['required']"
>
Sex is invalid
</div>
</div>

<div class="form-group mb-3 col-6">
<label class="control-label required-label" for="name">Race</label>
<input
id="race"
name="race"
formControlName="race"
type="text"
class="form-control"
[(ngModel)]="dog.race"
/>
<div class="form-error" *ngIf="race.errors?.['required']">
Race is required
</div>
</div>

<div class="form-group mb-3 col-6">
<label class="control-label required-label" for="dangerous">Dangerous</label>
<input
id="dangerous"
name="dangerous"
formControlName="dangerous"
type="checkbox"
clasS="ms-3"
[(ngModel)]="dog.dangerous"
/>
</div>

<div class="form-group mb-3 col-6">
<label class="control-label required-label" for="barkingLevel">Barking Level</label>
<select
id="barkingLevel"
name="barkingLevel"
formControlName="barkingLevel"
class="form-control"
[(ngModel)]="dog.barkingLevel"
>
<option value="1">No barking</option>
<option value="2">Low barking</option>
<option value="3">Average barking</option>
<option value="4">Loud barking</option>
</select>
<div class="form-error" *ngIf="barkingLevel.errors?.['required']">
Barking level is required
</div>
</div>

</div>

<!-- Save and back buttons -->
<div class="form-group fa-pull-right mt-3">
<button
id="listBtn"
type="button"
[routerLink]="['/dogs']"
class="btn btn-outline-primary pull-right"
>
Back
</button>
<button
id="submit"
type="submit"
[disabled]="!form.form.valid"
class="btn btn-success ms-3"
>
<i class="fa fa-plus-circle me-2"></i>
Create
</button>
</div>
</fieldset>
</form>
Loading

0 comments on commit d621caa

Please sign in to comment.