calendrier : ajout du formulaire d'ajout de evenement
This commit is contained in:
parent
aecd8df7a6
commit
48dedea665
7 changed files with 146 additions and 2 deletions
|
|
@ -66,7 +66,7 @@
|
|||
|
||||
<span style="float: right"
|
||||
><a
|
||||
href="#"
|
||||
routerLink="/ajout-evenement"
|
||||
class="btn btn-sm btn-primary"
|
||||
style="margin-right: 5px"
|
||||
>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…
Add table
Add a link
Reference in a new issue