123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- <div class="container" *ngIf="userFormGrp">
- <ng-container *ngIf="userState">
- <ng-container *ngIf="userState.msgState == msg.FORM_LOADING">
- msg.FORM_LOADING
- </ng-container>
-
- <ng-container *ngIf="userState.msgState == msg.FORM_LOAD_ERR">
- <div class="alert-danger container">
- {{ msg.FORM_LOAD_ERR }}
- </div>
- </ng-container>
-
- <ng-container *ngIf="userState.msgState == msg.FORM_LOAD_ERR">
- <div class="alert-danger container">
- {{ msg.FORM_LOAD_ERR }}
- </div>
- </ng-container>
-
- <ng-container *ngIf="userState.msgState == msg.FORM_LOADED">
- <div class="card mt-3">
- <div class="card-header bg-light">
- User informations to modify: <b>ID of user:
- {{ userState.currentUser?.id }}</b>
- </div>
- <div class="card-body">
- <form
- [formGroup]="userFormGrp"
- (ngSubmit)="onUserUpdate(); userFormGrp.reset()"
- >
- <div class="row">
- <div class="col card">
- <div class="col-md-auto mb-3">
- <label for="id">Firstname</label>
- <input
- type="text"
- class="form-control"
- formControlName="firstname"
- [ngClass]="{
- 'is-invalid':
- userFormGrp.controls['firstname'].touched &&
- !userFormGrp.controls['firstname'].valid
- }"
- />
-
- <div class="invalid-feedback">
- <span
- *ngIf="userFormGrp.controls['firstname'].errors?.['required']"
- >required</span
- >
- <span
- *ngIf="userFormGrp.controls['firstname'].errors?.['minlength']"
- >min nbr chars 3</span
- >
- <span
- *ngIf="userFormGrp.controls['firstname'].errors?.['maxlength']"
- >max nbr chars 20</span
- >
- </div>
- </div>
-
- <div class="col-md-auto mb-3">
- <label for="id">Lastname</label>
- <input
- type="text"
- class="form-control"
- formControlName="lastname"
- [ngClass]="{
- 'is-invalid':
- userFormGrp.controls['lastname'].touched &&
- !userFormGrp.controls['lastname'].valid
- }"
- />
-
- <div class="invalid-feedback">
- <span
- *ngIf="userFormGrp.controls['lastname'].errors?.['required']"
- >required</span
- >
- <span
- *ngIf="userFormGrp.controls['lastname'].errors?.['minlength']"
- >min nbr char 3</span
- >
- <span
- *ngIf="userFormGrp.controls['lastname'].errors?.['maxlength']"
- >max nbr char 20</span
- >
- </div>
- </div>
-
- <div class="col-md-auto mb-3">
- <label for="email">Email</label>
- <input
- type="text"
- class="form-control"
- formControlName="email"
- [ngClass]="{
- 'is-invalid':
- userFormGrp.controls['email'].touched &&
- !userFormGrp.controls['email'].valid
- }"
- />
-
- <div class="invalid-feedback">
- <span
- *ngIf="userFormGrp.controls['email'].errors?.['required']"
- >
- required
- </span>
- <span
- *ngIf="userFormGrp.controls['email'].errors?.['email']"
- >
- not valid
- </span>
- </div>
- </div>
- </div>
-
- <div class="col card">
- <div formGroupName="address">
- <div class="col-md-auto mb-3">
- <label for="numRue">Street number</label>
- <input
- type="number"
- class="form-control"
- formControlName="numRue"
- [ngClass]="{
- 'is-invalid':
- userFormGrp.controls['address'].get('numRue')
- ?.touched &&
- !userFormGrp.controls['address'].get('numRue')?.valid
- }"
- />
- <div class="invalid-feedback">
- <span
- *ngIf="userFormGrp.controls['address'].get('numRue')?.errors?.['required']"
- >required</span
- >
- <span
- *ngIf="userFormGrp.controls['address'].get('numRue')?.errors?.['min']"
- >street num >0
- </span>
- </div>
- </div>
-
- <div class="col-md-auto mb-3">
- <label for="nomRue">Street Name</label>
- <input
- type="text"
- class="form-control"
- formControlName="nomRue"
- [ngClass]="{
- 'is-invalid':
- userFormGrp.controls['address'].get('nomRue')
- ?.touched &&
- !userFormGrp.controls['address'].get('nomRue')?.valid
- }"
- />
- <div class="invalid-feedback">
- <span
- *ngIf="userFormGrp.controls['address'].get('nomRue')?.errors?.['required']"
- >required</span
- >
- <span
- *ngIf="userFormGrp.controls['address'].get('nomRue')?.errors?.['minlength']"
- >min chars 3
- </span>
- <span
- *ngIf="userFormGrp.controls['address'].get('nomRue')?.errors?.['maxlength']"
- >max chars 15
- </span>
- </div>
- </div>
-
- <div class="col-md-auto mb-3">
- <label for="bp">PB</label>
- <input
- type="number"
- class="form-control"
- formControlName="bp"
- [ngClass]="{
- 'is-invalid':
- userFormGrp.controls['address'].get('bp')?.touched &&
- !userFormGrp.controls['address'].get('bp')?.valid
- }"
- />
- <div class="invalid-feedback">
- <span
- *ngIf="userFormGrp.controls['address'].get('bp')?.errors?.['required']"
- >required</span
- >
- <span
- *ngIf="userFormGrp.controls['address'].get('bp')?.errors?.['min']"
- >pb >0
- </span>
- </div>
- </div>
-
- <div class="col-md-auto mb-3">
- <label for="city">City</label>
- <input
- type="text"
- class="form-control"
- formControlName="ville"
- [ngClass]="{
- 'is-invalid':
- userFormGrp.controls['address'].get('ville')
- ?.touched &&
- !userFormGrp.controls['address'].get('vile')?.valid
- }"
- />
- <div class="invalid-feedback">
- <span
- *ngIf="userFormGrp.controls['address'].get('ville')?.errors?.['required']"
- >required</span
- >
- <span
- *ngIf="userFormGrp.controls['address'].get('ville')?.errors?.['minlength']"
- >min chars 3
- </span>
- <span
- *ngIf="userFormGrp.controls['address'].get('ville')?.errors?.['maxlength']"
- >max chars 15
- </span>
- </div>
- </div>
-
- <div class="col-md-auto mb-3">
- <label for="pays">Country</label>
- <input
- type="text"
- class="form-control"
- formControlName="pays"
- [ngClass]="{
- 'is-invalid':
- userFormGrp.controls['address'].get('pays')
- ?.touched &&
- !userFormGrp.controls['address'].get('pays')?.valid
- }"
- />
- <div class="invalid-feedback">
- <span
- *ngIf="userFormGrp.controls['address'].get('pays')?.errors?.['required']"
- >required</span
- >
- <span
- *ngIf="userFormGrp.controls['address'].get('pays')?.errors?.['minlength']"
- >min chars 3
- </span>
- <span
- *ngIf="userFormGrp.controls['address'].get('pays')?.errors?.['maxlength']"
- >max chars 15
- </span>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <div class="text-center col-md-auto mt-3">
- <button
- class="btn btn-outline-primary"
- type="submit"
- [disabled]="!userFormGrp.valid"
- >
- update
- </button>
- </div>
- </form>
- </div>
- </div>
- </ng-container>
-
- <ng-container *ngIf="userState.msgState == msg.UPDATED">
- <div class="alert-success container p-3 m-3" style="width: 30em">
- <span> {{ msg.UPDATED }}</span>
- <button class="btn btn-success" (click)="onUpdateOk()">OK</button>
- </div>
- </ng-container>
-
- </ng-container>
- </div>
|