Merge pull request #76 from AlineRinquin/formulaire-evenement
calendrier : ajout du formulaire d'ajout de evenement
This commit is contained in:
commit
03a3cd0351
@ -22,6 +22,7 @@ import { PageUpdateMemberComponent } from './pages/page-update-member/page-updat
|
|||||||
import { PageSupportComponent } from './pages/page-support/page-support.component';
|
import { PageSupportComponent } from './pages/page-support/page-support.component';
|
||||||
import { FooterComponent } from './components/footer/footer.component';
|
import { FooterComponent } from './components/footer/footer.component';
|
||||||
import { AuthGuard } from './auth.guard';
|
import { AuthGuard } from './auth.guard';
|
||||||
|
import { PageAjoutEvenementsComponent } from './pages/page-ajout-evenements/page-ajout-evenements.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: '', redirectTo: 'accueil', pathMatch: 'full' },
|
{ path: '', redirectTo: 'accueil', pathMatch: 'full' },
|
||||||
@ -45,6 +46,7 @@ const routes: Routes = [
|
|||||||
{ path: 'ajouter-contact', canActivate: [AuthGuard], component: PageAjoutContactComponent },
|
{ path: 'ajouter-contact', canActivate: [AuthGuard], component: PageAjoutContactComponent },
|
||||||
{ path: 'creation-team', canActivate: [AuthGuard], component: PageCreationTeamComponent },
|
{ path: 'creation-team', canActivate: [AuthGuard], component: PageCreationTeamComponent },
|
||||||
{ path: 'footer', component: FooterComponent},
|
{ path: 'footer', component: FooterComponent},
|
||||||
|
{ path: 'ajout-evenement', canActivate: [AuthGuard], component: PageAjoutEvenementsComponent },
|
||||||
{ path: '**', component: PageNotFoundComponent },
|
{ path: '**', component: PageNotFoundComponent },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ import { CardAvatarComponent } from './components/card-avatar/card-avatar.compon
|
|||||||
import { HumeurComponent } from './components/humeur/humeur.component';
|
import { HumeurComponent } from './components/humeur/humeur.component';
|
||||||
import { DeconnexionComponent } from './components/deconnexion/deconnexion.component';
|
import { DeconnexionComponent } from './components/deconnexion/deconnexion.component';
|
||||||
import { AlertComponent } from './components/alert/alert.component';
|
import { AlertComponent } from './components/alert/alert.component';
|
||||||
|
import { PageAjoutEvenementsComponent } from './pages/page-ajout-evenements/page-ajout-evenements.component';
|
||||||
registerLocaleData(localeFr)
|
registerLocaleData(localeFr)
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@ -84,7 +85,8 @@ registerLocaleData(localeFr)
|
|||||||
CardAvatarComponent,
|
CardAvatarComponent,
|
||||||
DeconnexionComponent,
|
DeconnexionComponent,
|
||||||
HumeurComponent,
|
HumeurComponent,
|
||||||
AlertComponent
|
AlertComponent,
|
||||||
|
PageAjoutEvenementsComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
|
|
||||||
<span style="float: right"
|
<span style="float: right"
|
||||||
><a
|
><a
|
||||||
href="#"
|
routerLink="/ajout-evenement"
|
||||||
class="btn btn-sm btn-primary"
|
class="btn btn-sm btn-primary"
|
||||||
style="margin-right: 5px"
|
style="margin-right: 5px"
|
||||||
>Ajouter un évènement</a
|
>Ajouter un évènement</a
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
<app-header></app-header>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-auto">
|
||||||
|
<app-side-bar class="sidebarMenu"></app-side-bar>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4 offset-md-4 text-center">
|
||||||
|
<h2>Ajouter un évènement à l'agenda</h2>
|
||||||
|
<div class="text-center col-md-6 offset-md-3">
|
||||||
|
<main class="form-signup">
|
||||||
|
<form (ngSubmit)="onSubmit()" [formGroup]="eventForm">
|
||||||
|
<div class="form-floating">
|
||||||
|
<input type="datetime-local"
|
||||||
|
class="form-control"
|
||||||
|
id="floatingInputDebut"
|
||||||
|
placeholder=""
|
||||||
|
name="start"
|
||||||
|
formControlName="startFc">
|
||||||
|
<label for="floatingInputfirstName">Début</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-floating">
|
||||||
|
<input type="datetime-local"
|
||||||
|
class="form-control"
|
||||||
|
id="floatingInputFin"
|
||||||
|
placeholder=""
|
||||||
|
name="end"
|
||||||
|
formControlName="endFc">
|
||||||
|
<label for="floatingInputlastName">Fin</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-floating">
|
||||||
|
<input type="text"
|
||||||
|
class="form-control"
|
||||||
|
id="floatingInputText"
|
||||||
|
placeholder=""
|
||||||
|
name="text"
|
||||||
|
formControlName="textFc">
|
||||||
|
<label for="floatingInputlastName">Libelle</label>
|
||||||
|
</div>
|
||||||
|
<button class="w-100 btn btn-lg btn-primary"
|
||||||
|
type="submit"
|
||||||
|
[disabled]="eventForm.invalid">Validation</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<app-footer></app-footer>
|
@ -0,0 +1,25 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { PageAjoutEvenementsComponent } from './page-ajout-evenements.component';
|
||||||
|
|
||||||
|
describe('PageAjoutEvenementsComponent', () => {
|
||||||
|
let component: PageAjoutEvenementsComponent;
|
||||||
|
let fixture: ComponentFixture<PageAjoutEvenementsComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ PageAjoutEvenementsComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(PageAjoutEvenementsComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,67 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { EvenementService } from 'src/app/services/evenement.service';
|
||||||
|
import { TokenService } from 'src/app/services/token.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-page-ajout-evenements',
|
||||||
|
templateUrl: './page-ajout-evenements.component.html',
|
||||||
|
styleUrls: ['./page-ajout-evenements.component.scss']
|
||||||
|
})
|
||||||
|
export class PageAjoutEvenementsComponent implements OnInit {
|
||||||
|
public eventForm: FormGroup;
|
||||||
|
public userId : any;
|
||||||
|
public teamId : any;
|
||||||
|
public isShow: boolean;
|
||||||
|
public alert:any;
|
||||||
|
|
||||||
|
constructor(private evenementService:EvenementService, private tokenService: TokenService, private router: Router,) {
|
||||||
|
this.eventForm = new FormGroup({});
|
||||||
|
this.isShow = false;
|
||||||
|
this.alert = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.userId = this.tokenService.getCurrentMembreId();
|
||||||
|
this.teamId = this.tokenService.getCurrentTeamId();
|
||||||
|
|
||||||
|
this.eventForm = new FormGroup({
|
||||||
|
startFc : new FormControl(''),
|
||||||
|
endFc : new FormControl(''),
|
||||||
|
textFc : new FormControl('', [ Validators.required])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public onSubmit(): void {
|
||||||
|
const startValue = this.eventForm.value['startFc'];
|
||||||
|
const endValue = this.eventForm.value['endFc'];
|
||||||
|
const textValue = this.eventForm.value['textFc'];
|
||||||
|
|
||||||
|
const event = {
|
||||||
|
start: startValue,
|
||||||
|
end: endValue,
|
||||||
|
text: textValue,
|
||||||
|
id:"",
|
||||||
|
membre: {id:this.userId},
|
||||||
|
team: {id:this.teamId}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.evenementService.addEvenements(event).subscribe({
|
||||||
|
next: result => {
|
||||||
|
this.alert={"type":"success", "content":"L'évènement à été correctement ajouté au calendrier"};
|
||||||
|
this.isShow = true;
|
||||||
|
},
|
||||||
|
error: err => {
|
||||||
|
this.alert={"type":"danger", "content":"Problème lors de l'ajout de l'évenment"};
|
||||||
|
this.isShow = true;
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
console.log('DONE!');
|
||||||
|
this.router.navigate(['agenda']);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user