Factorisation detail BU et Agence + refacto Agence

pull/9/head
Clement FERRERE 3 years ago
parent bd75ddd3c0
commit 1058fb0a7e
  1. 5
      src/app/app.module.ts
  2. 8
      src/app/components/agence/agence-detail/agence-detail.component.html
  3. 0
      src/app/components/agence/agence-detail/agence-detail.component.scss
  4. 31
      src/app/components/agence/agence-detail/agence-detail.component.ts
  5. 15
      src/app/components/agence/agence-edit/agence-edit.component.html
  6. 9
      src/app/components/agence/agence.component.html
  7. 33
      src/app/components/businessunit/businessunit-detail/businessunit-detail.component.html
  8. 21
      src/app/components/businessunit/businessunit.component.html

@ -15,6 +15,7 @@ import { CollaborateurDetailComponent } from './components/collaborateur/collabo
import { BusinessunitComponent } from './components/businessunit/businessunit.component'; import { BusinessunitComponent } from './components/businessunit/businessunit.component';
import { BusinessunitEditComponent } from './components/businessunit/businessunit-edit/businessunit-edit.component'; import { BusinessunitEditComponent } from './components/businessunit/businessunit-edit/businessunit-edit.component';
import { BusinessunitDetailComponent } from './components/businessunit/businessunit-detail/businessunit-detail.component'; import { BusinessunitDetailComponent } from './components/businessunit/businessunit-detail/businessunit-detail.component';
import { AgenceDetailComponent } from './components/agence/agence-detail/agence-detail.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -24,10 +25,12 @@ import { BusinessunitDetailComponent } from './components/businessunit/businessu
HomeComponent, HomeComponent,
AgenceComponent, AgenceComponent,
AgenceEditComponent, AgenceEditComponent,
AgenceDetailComponent,
CollaborateurDetailComponent, CollaborateurDetailComponent,
BusinessunitComponent, BusinessunitComponent,
BusinessunitEditComponent, BusinessunitEditComponent,
BusinessunitDetailComponent BusinessunitDetailComponent,
], ],
imports: [ imports: [
BrowserModule, BrowserModule,

@ -0,0 +1,8 @@
<div class="row mb-2">
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3">
<label for="agence-name" class="form-label">Nom</label>
<input class="form-control" id="agence-name" [(ngModel)]="agence.name" placeholder="name">
</div>
</div>

@ -0,0 +1,31 @@
import {Component, Input, OnInit} from '@angular/core';
import {Agence} from "../../../interfaces/agence";
import {HttpClient} from "@angular/common/http";
import {AgenceService} from "../../../services/agence.service";
@Component({
selector: 'app-agence-detail',
templateUrl: './agence-detail.component.html',
styleUrls: ['./agence-detail.component.scss']
})
export class AgenceDetailComponent implements OnInit {
agences : Agence[] = [];
@Input()
agence = {} as Agence ;
constructor(
private http : HttpClient,
private agenceService: AgenceService,
) { }
ngOnInit(): void {
this.getAgences();
this.getAgences();
}
getAgences():void {
this.agenceService.getAgences()
.subscribe(agences => this.agences = agences);
}
}

@ -3,21 +3,8 @@
<h2>{{agence.name | uppercase}} </h2> <h2>{{agence.name | uppercase}} </h2>
<div><span>id : </span>{{agence.id}}</div> <div><span>id : </span>{{agence.id}}</div>
<div>
<div class = mb-3>
<table>
<tr>
<th>Name</th>
</tr>
<tr>
<td>
<input id="agence-name" [(ngModel)]="agence.name" placeholder="name">
</td>
</tr>
</table>
</div>
</div>
<app-agence-detail [agence]="agence"></app-agence-detail>
<button (click)="goBack()">Retour</button> <button (click)="goBack()">Retour</button>
<button (click)="save()">Sauvegarder les changements</button> <button (click)="save()">Sauvegarder les changements</button>

@ -21,14 +21,7 @@
<h3>Ajouter une agence : </h3> <h3>Ajouter une agence : </h3>
<div class="row mb-2"> <app-agence-detail [agence]="agence"></app-agence-detail>
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3">
<label for="agence-name" class="form-label">Nom</label>
<input class="form-control" id="agence-name" [(ngModel)]="agence.name" placeholder="name">
</div>
</div>
<button class="add-button" (click)="add(agence)"> <button class="add-button" (click)="add(agence)">
Ajouter une Agence Ajouter une Agence

@ -1,17 +1,20 @@
<div class = mb-3> <div class="row mb-4">
<table>
<tr> <div class="form-group col-12 col-sm-6 col-md-4 col-lg-3">
<th>Name</th> <label for="businessunit-name" class="form-label">Nom</label>
</tr> <input class="form-control" id="businessunit-name" [(ngModel)]="businessunit.name" placeholder="Nom">
<tr> </div>
<td>
<input id="businessunit-name" [(ngModel)]="businessunit.name" placeholder="name"> </div>
</td>
</tr> <div class="row mb-5">
</table>
<div class="form-group col-12 col-md-6">
<label class="form-label">Agence</label>
<select class="form-select" name="agence" id="agence-select" [(ngModel)]="businessunit.agenceId">
<option value="" disabled selected>Choisissez l'agence de cette business Unit</option>
<option *ngFor="let agence of agences" [ngValue]="agence.id">{{agence.name}}</option>
</select>
</div>
<select name="agence" id="agence-select" [(ngModel)]="businessunit.agenceId">
<option value="">-- Choisissez l'agence de cette business Unit --</option>
<option *ngFor="let agence of agences" [ngValue]="agence.id">{{agence.name}}</option>
</select>
</div> </div>

@ -20,26 +20,7 @@
</div> </div>
<h3>Ajouter une Business Unit : </h3> <h3>Ajouter une Business Unit : </h3>
<div class="row mb-4"> <app-businessunit-detail [businessunit]="businessunit"></app-businessunit-detail>
<div class="form-group col-12 col-sm-6 col-md-4 col-lg-3">
<label for="businessunit-name" class="form-label">Nom</label>
<input class="form-control" id="businessunit-name" [(ngModel)]="businessunit.name" placeholder="Nom">
</div>
</div>
<div class="row mb-5">
<div class="form-group col-12 col-md-6">
<label class="form-label">Agence</label>
<select class="form-select" name="agence" id="agence-select" [(ngModel)]="businessunit.agenceId">
<option value="" disabled selected>Choisissez l'agence de cette business Unit</option>
<option *ngFor="let agence of agences" [ngValue]="agence.id">{{agence.name}}</option>
</select>
</div>
</div>
<button class="add-button" (click)="add(businessunit)"> <button class="add-button" (click)="add(businessunit)">
Ajouter une businessunit Ajouter une businessunit

Loading…
Cancel
Save