Fix sur les ajouts d'infos

This commit is contained in:
Sébastien André
2020-04-03 13:46:03 +02:00
parent 6810db7de4
commit dfc04ce981
16 changed files with 206 additions and 110 deletions

View File

@@ -17,6 +17,12 @@
<textarea matInput formControlName="address"></textarea>
</mat-form-field>
</p>
<p>
<mat-form-field>
<mat-label>Web site</mat-label>
<input matInput type="text" formControlName="website" />
</mat-form-field>
</p>
<p>
<mat-form-field>
<mat-label>Mail of contact</mat-label>

View File

@@ -2,6 +2,7 @@ import { Component, OnInit } from "@angular/core";
import { FormControl, FormGroup, Validators } from "@angular/forms";
import { AddAction } from "../../models/add-action.enum";
import { ServiceComm } from "../../services/service-comm.service";
import { DropzoneService } from "../../services/dropzone.service";
@Component({
selector: "app-new-drop-zone",
@@ -11,27 +12,53 @@ import { ServiceComm } from "../../services/service-comm.service";
export class NewDropZoneComponent implements OnInit {
public addForm: FormGroup;
constructor(private serviceComm: ServiceComm) {
this.addForm = new FormGroup({
dzName: new FormControl("", Validators.required),
gps: new FormControl("x.x,y.y", [
Validators.required,
Validators.pattern("d+.d+,d+.d+")
]),
address: new FormControl("", Validators.required),
contactMail: new FormControl("", [Validators.required, Validators.email]),
isDz: new FormControl(true),
isTunnel: new FormControl(false)
});
constructor(
private serviceComm: ServiceComm,
private dropzoneService: DropzoneService
) {
this.addForm = new FormGroup(
{
dzName: new FormControl("", Validators.required),
gps: new FormControl("x.x,y.y", [
Validators.required,
Validators.pattern("d+.d+,d+.d+")
]),
address: new FormControl("", Validators.required),
website: new FormControl("", Validators.required),
contactMail: new FormControl("", [
Validators.required,
Validators.email
]),
isDz: new FormControl(true),
isTunnel: new FormControl(false)
},
{ updateOn: "blur" }
);
}
ngOnInit() {}
onSubmit(formData) {
console.log(formData.status);
console.warn("New data : ", formData);
const splitGps: Array<string> = formData.gps.split(",");
let dzType: Array<string> = new Array<string>();
this.serviceComm.RefreshData(AddAction.Gear);
this.addForm.reset();
if (formData.isDz === true) {
dzType.push("dz");
}
if (formData.isTunnel === true) {
dzType.push("tunnel");
}
this.dropzoneService.AddDropZone(
splitGps[0],
splitGps[1],
formData.dzName,
formData.address,
formData.website,
formData.contactMail,
dzType,
false
);
this.serviceComm.RefreshData(AddAction.Dropzone);
}
}