Fix sur les ajouts d'infos
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user