commit
						307f1343a5
					
				
					 13 changed files with 251 additions and 18 deletions
				
			
		| 
						 | 
				
			
			@ -10,6 +10,7 @@ import { PageDashboardComponent } from './pages/page-dashboard/page-dashboard.co
 | 
			
		|||
import { PageDeleteMemberComponent } from './pages/page-delete-member/page-delete-member.component';
 | 
			
		||||
import { PageForgotPasswordComponent } from './pages/page-forgot-password/page-forgot-password.component';
 | 
			
		||||
import { PageMenuSemaineComponent } from './pages/page-menu-semaine/page-menu-semaine.component';
 | 
			
		||||
import { PageModifierContactComponent } from './pages/page-modifier-contact/page-modifier-contact.component';
 | 
			
		||||
import { PageNotFoundComponent } from './pages/page-not-found/page-not-found.component';
 | 
			
		||||
import { PageRepertoireComponent } from './pages/page-repertoire/page-repertoire.component';
 | 
			
		||||
import { PageResetPasswordComponent } from './pages/page-reset-password/page-reset-password.component';
 | 
			
		||||
| 
						 | 
				
			
			@ -19,6 +20,7 @@ import { PageUpdateMemberComponent } from './pages/page-update-member/page-updat
 | 
			
		|||
 | 
			
		||||
const routes: Routes = [
 | 
			
		||||
  { path: '', redirectTo: 'accueil', pathMatch: 'full' },
 | 
			
		||||
  { path: 'modifier-contact/:id', component: PageModifierContactComponent },
 | 
			
		||||
  { path: 'compte', component: PageAccountComponent },
 | 
			
		||||
  { path: 'accueil', component: PageAccueilComponent },
 | 
			
		||||
  { path: 'ajout-membre', component: PageAddMemberComponent },
 | 
			
		||||
| 
						 | 
				
			
			@ -33,8 +35,7 @@ const routes: Routes = [
 | 
			
		|||
  { path: 'to-do-list', component: PageToDoListComponent },
 | 
			
		||||
  { path: 'modifier-membre', component: PageUpdateMemberComponent },
 | 
			
		||||
  { path: 'ajouter-contact', component: PageAjoutContactComponent },
 | 
			
		||||
  { path: 'modifier-contact', component: PageAjoutContactComponent },
 | 
			
		||||
  { path: 'creation-team', component : PageCreationTeamComponent},
 | 
			
		||||
  { path: 'creation-team', component: PageCreationTeamComponent },
 | 
			
		||||
  { path: '**', component: PageNotFoundComponent },
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
<div class="container">
 | 
			
		||||
    <div class="row">
 | 
			
		||||
        <div class="col-sm">  
 | 
			
		||||
            <button class="w-100 btn btn-lg btn-rounded btn-secondary">
 | 
			
		||||
            <button routerLink="../modifier-contact/{{personne.id}}"  class="w-100 btn btn-lg btn-rounded btn-secondary">
 | 
			
		||||
                Modifier
 | 
			
		||||
            </button>
 | 
			
		||||
        </div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,8 +1,10 @@
 | 
			
		|||
export interface Contact {
 | 
			
		||||
  id: string;
 | 
			
		||||
  nom: string;
 | 
			
		||||
  prenom: string;
 | 
			
		||||
  telephone: string;
 | 
			
		||||
  email: string;
 | 
			
		||||
  adresse: string;
 | 
			
		||||
  dateNaissance: Date;
 | 
			
		||||
  team: any;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -73,7 +73,7 @@
 | 
			
		|||
                <label for="floatingInputfirstName">Adresse</label>
 | 
			
		||||
            </div>
 | 
			
		||||
 | 
			
		||||
            <button class="w-100 btn btn-lg btn-success" 
 | 
			
		||||
            <button class="w-100 btn btn-lg btn-secondary" 
 | 
			
		||||
                    type="submit" 
 | 
			
		||||
                    [disabled]="ajoutContactForm.invalid">Valider</button>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,3 +24,8 @@
 | 
			
		|||
  border-bottom-right-radius: 0;
 | 
			
		||||
  border-bottom-left-radius: 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.btn-secondary {
 | 
			
		||||
  color: #fff;
 | 
			
		||||
  background-color: #5a1e63 !important;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,7 +26,7 @@ export class PageAjoutContactComponent implements OnInit {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  ngOnInit(): void {
 | 
			
		||||
    // *********************************pensser a changer group car déprécié********************************
 | 
			
		||||
    // *********************************pensser à changer group car déprécié********************************
 | 
			
		||||
    this.ajoutContactForm = this.fb.group({
 | 
			
		||||
      lastNameFc: new FormControl('', [Validators.required]),
 | 
			
		||||
      firstNameFc: new FormControl('', [Validators.required]),
 | 
			
		||||
| 
						 | 
				
			
			@ -52,12 +52,14 @@ export class PageAjoutContactComponent implements OnInit {
 | 
			
		|||
    const adresseValue = this.ajoutContactForm.value['adresseFc'];
 | 
			
		||||
 | 
			
		||||
    const contact: Contact = {
 | 
			
		||||
      id: '',
 | 
			
		||||
      nom: lastNameValue,
 | 
			
		||||
      prenom: firstNameValue,
 | 
			
		||||
      telephone: telephoneValue,
 | 
			
		||||
      email: emailValue,
 | 
			
		||||
      dateNaissance: dateNaissanceValue,
 | 
			
		||||
      adresse: adresseValue,
 | 
			
		||||
      team: { id: '1' }, // changer l'id quand la personne est logé => recuperer l'id de la team du membre
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    if (contact.nom !== '') {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1 +1,83 @@
 | 
			
		|||
<p>page-modifier-contact works!</p>
 | 
			
		||||
<div>
 | 
			
		||||
    <app-header></app-header>
 | 
			
		||||
    <app-side-bar></app-side-bar>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<div class="modifContact-form text-center">
 | 
			
		||||
    <main class="form-modifContact">
 | 
			
		||||
        <form  (ngSubmit)="onSubmit()" [formGroup]="modifContactForm">
 | 
			
		||||
            <h1>Modifier ce contact</h1>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            <div class="form-floating">
 | 
			
		||||
                <input type="text" 
 | 
			
		||||
                        class="form-control" 
 | 
			
		||||
                        id="floatingInputlastName" 
 | 
			
		||||
                        placeholder="" 
 | 
			
		||||
                        name="lastName" 
 | 
			
		||||
                        formControlName="lastNameFc" value= "{{ listContactInfo.nom }}">
 | 
			
		||||
                <label for="floatingInputlastName">Nom</label>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="form-floating">
 | 
			
		||||
                <input type="text" 
 | 
			
		||||
                        class="form-control" 
 | 
			
		||||
                        id="floatingInputfirstName" 
 | 
			
		||||
                        placeholder="" 
 | 
			
		||||
                        name="firstName" 
 | 
			
		||||
                        formControlName="firstNameFc" value= "{{ listContactInfo.prenom }}">
 | 
			
		||||
                <label for="floatingInputfirstName">Prénom</label>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="form-floating">
 | 
			
		||||
                <input type="text" 
 | 
			
		||||
                        class="form-control" 
 | 
			
		||||
                        id="floatingInputTelephone" 
 | 
			
		||||
                        placeholder="" 
 | 
			
		||||
                        name="telephone" 
 | 
			
		||||
                        formControlName="telephoneFc" value= "{{ listContactInfo.telephone }}">
 | 
			
		||||
                <label for="floatingInputfirstName">Téléphone</label>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="form-floating">
 | 
			
		||||
                <input type="email" 
 | 
			
		||||
                        class="form-control" 
 | 
			
		||||
                        id="floatingInput" 
 | 
			
		||||
                        placeholder="" 
 | 
			
		||||
                        name="email" 
 | 
			
		||||
                        formControlName="emailFc" value= "{{ listContactInfo.email }}">
 | 
			
		||||
                <label for="floatingInput">Adresse email</label>
 | 
			
		||||
            </div>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            <div class="form-floating">
 | 
			
		||||
                <input type="date" 
 | 
			
		||||
                        class="form-control" 
 | 
			
		||||
                        id="floatingInputdateNaissance" 
 | 
			
		||||
                        placeholder="" 
 | 
			
		||||
                        name="dateNaissance" 
 | 
			
		||||
                        formControlName="dateNaissanceFc" value= "{{ listContactInfo.dateNaissance }}">
 | 
			
		||||
                <label for="floatingInputfirstName">Date de naissance</label>
 | 
			
		||||
            </div>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            <div class="form-floating">
 | 
			
		||||
                <input type="text" 
 | 
			
		||||
                        class="form-control" 
 | 
			
		||||
                        id="floatingInputAdresse" 
 | 
			
		||||
                        placeholder="" 
 | 
			
		||||
                        name="adresse" 
 | 
			
		||||
                        formControlName="adresseFc" value= "{{ listContactInfo.adresse }}">
 | 
			
		||||
                <label for="floatingInputfirstName">Adresse</label>
 | 
			
		||||
            </div>
 | 
			
		||||
 | 
			
		||||
            <button class="w-100 btn btn-lg btn-secondary" 
 | 
			
		||||
                    type="submit" 
 | 
			
		||||
                    [disabled]="modifContactForm.invalid">Valider</button>
 | 
			
		||||
 | 
			
		||||
        </form>
 | 
			
		||||
    </main>
 | 
			
		||||
</div> 
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,31 @@
 | 
			
		|||
.login-form {
 | 
			
		||||
  height: 100vh;
 | 
			
		||||
  padding-top: 40px;
 | 
			
		||||
  background-color: #f5f5f5;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.form-modifContact {
 | 
			
		||||
  width: 100%;
 | 
			
		||||
  max-width: 330px;
 | 
			
		||||
  padding: 15px;
 | 
			
		||||
  margin: auto;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.form-modifContact .checkbox {
 | 
			
		||||
  font-weight: 400;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.form-modifContact .form-floating:focus-within {
 | 
			
		||||
  z-index: 2;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.form-modifContact input[type="email"] {
 | 
			
		||||
  margin-bottom: -1px;
 | 
			
		||||
  border-bottom-right-radius: 0;
 | 
			
		||||
  border-bottom-left-radius: 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.btn-secondary {
 | 
			
		||||
  color: #fff;
 | 
			
		||||
  background-color: #5a1e63 !important;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,15 +1,98 @@
 | 
			
		|||
import { Component, OnInit } from '@angular/core';
 | 
			
		||||
import {
 | 
			
		||||
  FormBuilder,
 | 
			
		||||
  FormControl,
 | 
			
		||||
  FormGroup,
 | 
			
		||||
  Validators,
 | 
			
		||||
} from '@angular/forms';
 | 
			
		||||
import { ActivatedRoute, Router } from '@angular/router';
 | 
			
		||||
import { Contact } from '../../models/contact';
 | 
			
		||||
import { RepertoireService } from '../../services/repertoire.service';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-page-modifier-contact',
 | 
			
		||||
  templateUrl: './page-modifier-contact.component.html',
 | 
			
		||||
  styleUrls: ['./page-modifier-contact.component.scss']
 | 
			
		||||
  styleUrls: ['./page-modifier-contact.component.scss'],
 | 
			
		||||
})
 | 
			
		||||
export class PageModifierContactComponent implements OnInit {
 | 
			
		||||
  public modifContactForm: FormGroup;
 | 
			
		||||
  public contactInfo: FormGroup;
 | 
			
		||||
  public listContactInfo: any;
 | 
			
		||||
  public personneid: any;
 | 
			
		||||
 | 
			
		||||
  constructor() { }
 | 
			
		||||
 | 
			
		||||
  ngOnInit(): void {
 | 
			
		||||
  constructor(
 | 
			
		||||
    private repertoireService: RepertoireService,
 | 
			
		||||
    private router: Router,
 | 
			
		||||
    private fb: FormBuilder,
 | 
			
		||||
    private route: ActivatedRoute
 | 
			
		||||
  ) {
 | 
			
		||||
    this.modifContactForm = new FormGroup({});
 | 
			
		||||
    this.contactInfo = this.initForm();
 | 
			
		||||
    this.listContactInfo = '';
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  ngOnInit(): void {
 | 
			
		||||
    this.personneid = this.route.snapshot.paramMap.get('id'); // récupère l'id du contact à modifier
 | 
			
		||||
    console.log(this.personneid);
 | 
			
		||||
 | 
			
		||||
    this.repertoireService
 | 
			
		||||
      .getContactById(this.personneid)
 | 
			
		||||
      .subscribe((listContactInfo: any) => {
 | 
			
		||||
        console.log(listContactInfo);
 | 
			
		||||
        this.listContactInfo = listContactInfo;
 | 
			
		||||
      });
 | 
			
		||||
 | 
			
		||||
    // *********************************pensser à changer group car déprécié********************************
 | 
			
		||||
    this.modifContactForm = this.fb.group({
 | 
			
		||||
      lastNameFc: new FormControl('', [Validators.required]),
 | 
			
		||||
      firstNameFc: new FormControl('', [Validators.required]),
 | 
			
		||||
      telephoneFc: new FormControl('', [Validators.required]),
 | 
			
		||||
      emailFc: new FormControl('', [
 | 
			
		||||
        Validators.email,
 | 
			
		||||
        Validators.required,
 | 
			
		||||
        Validators.pattern(/^([\w\.\-_]+)?\w+@[\w-_]+(\.\w+){1,}/gim),
 | 
			
		||||
      ]), // chercher une meilleure regex
 | 
			
		||||
      dateNaissanceFc: new FormControl('', [Validators.required]),
 | 
			
		||||
      adresseFc: new FormControl('', [Validators.required]),
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //Méthode qui initialise les champs du formulaire avec les infos de la BDD
 | 
			
		||||
  private initForm(contact?: Contact): FormGroup {
 | 
			
		||||
    return this.fb.group({
 | 
			
		||||
      firstName: [contact ? contact.nom : ''],
 | 
			
		||||
      lastName: [contact ? contact.prenom : ''],
 | 
			
		||||
      telephone: [contact ? contact.telephone : ''],
 | 
			
		||||
      email: [contact ? contact.email : ''],
 | 
			
		||||
      dateNaissance: [contact ? contact.dateNaissance : ''],
 | 
			
		||||
      adresse: [contact ? contact.adresse : ''],
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //Méthode qui envoie les champs modifiés pour mise à jour
 | 
			
		||||
  public onSubmit(): void {
 | 
			
		||||
    console.log('value : ', this.modifContactForm.value);
 | 
			
		||||
    console.log('form : ', this.modifContactForm);
 | 
			
		||||
    const firstNameValue = this.modifContactForm.value['firstNameFc'];
 | 
			
		||||
    const lastNameValue = this.modifContactForm.value['lastNameFc'];
 | 
			
		||||
    const telephoneValue = this.modifContactForm.value['telephoneFc'];
 | 
			
		||||
    const emailValue = this.modifContactForm.value['emailFc'];
 | 
			
		||||
    const dateNaissanceValue = this.modifContactForm.value['dateNaissanceFc'];
 | 
			
		||||
    const adresseValue = this.modifContactForm.value['adresseFc'];
 | 
			
		||||
 | 
			
		||||
    const contact: Contact = {
 | 
			
		||||
      id: this.personneid,
 | 
			
		||||
      nom: lastNameValue,
 | 
			
		||||
      prenom: firstNameValue,
 | 
			
		||||
      telephone: telephoneValue,
 | 
			
		||||
      email: emailValue,
 | 
			
		||||
      dateNaissance: dateNaissanceValue,
 | 
			
		||||
      adresse: adresseValue,
 | 
			
		||||
      team: { id: this.listContactInfo.team.id },
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    this.repertoireService.updateContact(contact).subscribe((resp) => {
 | 
			
		||||
      this.router.navigate(['repertoire/']);
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +1,11 @@
 | 
			
		|||
<app-header></app-header>
 | 
			
		||||
 | 
			
		||||
<div>
 | 
			
		||||
 
 | 
			
		||||
 | 
			
		||||
<p> Page introuvable</p>
 | 
			
		||||
<a routerLink="" routerLinkActive="!active"><br><br>
 | 
			
		||||
    Je retourne à l'accueil<br><br><br><br><br><br><br><br><br><br><br><br></a>
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,6 @@
 | 
			
		|||
import { Component, OnInit } from '@angular/core';
 | 
			
		||||
import { ActivatedRoute, Router } from '@angular/router';
 | 
			
		||||
import { Contact } from 'src/app/models/contact';
 | 
			
		||||
import { RepertoireService } from 'src/app/services/repertoire.service';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
| 
						 | 
				
			
			@ -9,12 +11,19 @@ import { RepertoireService } from 'src/app/services/repertoire.service';
 | 
			
		|||
export class PageRepertoireComponent implements OnInit {
 | 
			
		||||
  public listContact: any[];
 | 
			
		||||
  public listFull: any[];
 | 
			
		||||
  public listContactInfo: any;
 | 
			
		||||
  public personneid: any;
 | 
			
		||||
  keyword: any;
 | 
			
		||||
  openDetails: any;
 | 
			
		||||
 | 
			
		||||
  constructor(private repertoireService: RepertoireService) {
 | 
			
		||||
  constructor(
 | 
			
		||||
    private repertoireService: RepertoireService,
 | 
			
		||||
    private router: Router,
 | 
			
		||||
    private route: ActivatedRoute
 | 
			
		||||
  ) {
 | 
			
		||||
    this.listContact = [];
 | 
			
		||||
    this.listFull = [];
 | 
			
		||||
    this.listContactInfo = '';
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  ngOnInit(): void {
 | 
			
		||||
| 
						 | 
				
			
			@ -23,6 +32,16 @@ export class PageRepertoireComponent implements OnInit {
 | 
			
		|||
      this.listContact = listContact;
 | 
			
		||||
      this.listFull = listContact;
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    this.personneid = this.route.snapshot.paramMap.get('id');
 | 
			
		||||
    console.log(this.personneid);
 | 
			
		||||
 | 
			
		||||
    this.repertoireService
 | 
			
		||||
      .getContactById(this.personneid)
 | 
			
		||||
      .subscribe((listContactInfo: any) => {
 | 
			
		||||
        console.log(listContactInfo);
 | 
			
		||||
        this.listContactInfo = listContactInfo;
 | 
			
		||||
      });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Méthode pour récuper ce qui est saisi dans l'input
 | 
			
		||||
| 
						 | 
				
			
			@ -47,4 +66,8 @@ export class PageRepertoireComponent implements OnInit {
 | 
			
		|||
    console.log(personne);
 | 
			
		||||
    this.openDetails = personne;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // this.repertoireService.deleteContact(contact).subscribe((resp) => {
 | 
			
		||||
  //   this.router.navigate(['repertoire/']);
 | 
			
		||||
  // });
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,17 +21,21 @@ export class RepertoireService {
 | 
			
		|||
    return this.http.get(`${this.apiUrl}/contacts/team/1`);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getContactById(id: any): Observable<any> {
 | 
			
		||||
    return this.http.get(`${this.apiUrl}/contacts/` + id);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  addContact(contact: Contact): Observable<any> {
 | 
			
		||||
    console.log(contact);
 | 
			
		||||
 | 
			
		||||
    return this.http.post(`${this.apiUrl}/contacts/add`, contact);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  deleteContact() {
 | 
			
		||||
    return this.http.delete(`${this.apiUrl}/contacts/delete`);
 | 
			
		||||
  deleteContact(contact: Contact): Observable<any> {
 | 
			
		||||
    return this.http.delete(`${this.apiUrl}/contacts/delete/1`);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // updateContact(){
 | 
			
		||||
  //   return this.http.put(`${this.apiUrl}/contacts/update/1`);
 | 
			
		||||
  // }
 | 
			
		||||
  updateContact(contact: Contact): Observable<any> {
 | 
			
		||||
    return this.http.put(`${this.apiUrl}/contacts/update/1`, contact);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 11 KiB  | 
		Loading…
	
	Add table
		
		Reference in a new issue