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

@@ -28,7 +28,8 @@ export class ListOfAircraftsComponent implements OnInit {
ngOnInit() {
this.serviceComm.refreshRequest.subscribe(action => {
if (action === AddAction.Gear) {
if (action === AddAction.Aircraft) {
this.dialog.closeAll();
this.getListOfAircrafts();
}
});

View File

@@ -37,7 +37,8 @@ export class ListOfDzsComponent implements OnInit {
ngOnInit() {
this.serviceComm.refreshRequest.subscribe(action => {
if (action === AddAction.Gear) {
if (action === AddAction.Dropzone) {
this.dialog.closeAll();
this.getListOfDropZones();
}
});

View File

@@ -37,6 +37,7 @@ export class ListOfGearsComponent implements OnInit {
ngOnInit() {
this.serviceComm.refreshRequest.subscribe(action => {
if (action === AddAction.Gear) {
this.dialog.closeAll();
this.getListOfGears();
}
});

View File

@@ -28,7 +28,8 @@ export class ListOfJumpTypesComponent implements OnInit {
ngOnInit() {
this.serviceComm.refreshRequest.subscribe(action => {
if (action === AddAction.Gear) {
if (action === AddAction.JumpType) {
this.dialog.closeAll();
this.getListOfJumpTypes();
}
});

View File

@@ -11,3 +11,9 @@ table {
min-width: 200px;
word-wrap: break-word;
}
.smallSpanWithBreakWord {
display: inline-block;
min-width: 50px;
word-wrap: break-word;
}

View File

@@ -7,21 +7,32 @@
<ng-container matColumnDef="jumpDate">
<th mat-header-cell *matHeaderCellDef>Date</th>
<td mat-cell *matCellDef="let element">{{element.jumpDate | date: 'yyyy-MM-dd'}} </td>
<td mat-cell *matCellDef="let element">
<span class="smallSpanWithBreakWord" [innerHTML]="element.jumpDate | date: 'yyyy-MM-dd'"></span>
</td>
</ng-container>
<ng-container matColumnDef="jumpType">
<th mat-header-cell *matHeaderCellDef>Jump Type</th>
<td mat-cell *matCellDef="let element">{{element.jumpType.name}}</td>
<td mat-cell *matCellDef="let element">
<span class="smallSpanWithBreakWord" [innerHTML]="element.jumpType.name"></span>
</td>
</ng-container>
<ng-container matColumnDef="aircraft">
<th mat-header-cell *matHeaderCellDef>Aircraft</th>
<td mat-cell *matCellDef="let element">{{element.aircraft.name}}</td>
<td mat-cell *matCellDef="let element">
<span class="smallSpanWithBreakWord" [innerHTML]="element.aircraft.name"></span>
</td>
</ng-container>
<ng-container matColumnDef="dropZone">
<th mat-header-cell *matHeaderCellDef>Drop Zone</th>
<td mat-cell *matCellDef="let element">{{element.dropZone.name}}</td>
<td mat-cell *matCellDef="let element">
<span class="spanWithBreakWord" [innerHTML]="element.dropZone.name"></span>
</td>
</ng-container>
<ng-container matColumnDef="gear">
<th mat-header-cell *matHeaderCellDef>Gear</th>
<td mat-cell *matCellDef="let element">{{element.gear.name}}</td>

View File

@@ -16,18 +16,18 @@ export class NewAircraftComponent implements OnInit {
private serviceComm: ServiceComm,
private serviceApi: AircraftService
) {
this.addForm = new FormGroup({
aircraftName: new FormControl("", Validators.required)
});
this.addForm = new FormGroup(
{
aircraftName: new FormControl("", Validators.required)
},
{ updateOn: "blur" }
);
}
ngOnInit() {}
onSubmit(formData) {
this.serviceApi.AddAircraft(formData.value.aircraftName);
this.serviceApi.AddAircraft(formData.aircraftName);
this.serviceComm.RefreshData(AddAction.Aircraft);
this.serviceComm.RefreshData(AddAction.Aircraft);
this.addForm.reset();
}
}

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);
}
}

View File

@@ -17,47 +17,48 @@ export class NewGearComponent implements OnInit {
private serviceComm: ServiceComm,
private serviceApi: GearService
) {
this.addForm = new FormGroup({
name: new FormControl("", Validators.required),
manufacturer: new FormControl("", Validators.required),
minSize: new FormControl("", [
Validators.required,
Validators.min(60),
Validators.max(320)
]),
maxSize: new FormControl("", [
Validators.required,
Validators.min(60),
Validators.max(320)
]),
aad: new FormControl("", Validators.required),
mainCanopy: new FormControl("", [
Validators.required,
Validators.min(60),
Validators.max(320)
]),
reserveCanopy: new FormControl("", [
Validators.required,
Validators.min(60),
Validators.max(320)
])
});
this.addForm = new FormGroup(
{
name: new FormControl("", Validators.required),
manufacturer: new FormControl("", Validators.required),
minSize: new FormControl("", [
Validators.required,
Validators.min(60),
Validators.max(320)
]),
maxSize: new FormControl("", [
Validators.required,
Validators.min(60),
Validators.max(320)
]),
aad: new FormControl("", Validators.required),
mainCanopy: new FormControl("", [
Validators.required,
Validators.min(60),
Validators.max(320)
]),
reserveCanopy: new FormControl("", [
Validators.required,
Validators.min(60),
Validators.max(320)
])
},
{ updateOn: "blur" }
);
}
ngOnInit() {}
onSubmit(formData) {
this.serviceApi.AddGear(
formData.value.name,
formData.value.manufacturer,
formData.value.minSize,
formData.value.maxSize,
formData.value.aad,
formData.value.mainCanopy,
formData.value.reserveCanopy
formData.name,
formData.manufacturer,
+formData.minSize,
+formData.maxSize,
formData.aad,
formData.mainCanopy,
formData.reserveCanopy
);
this.serviceComm.RefreshData(AddAction.Gear);
this.addForm.reset();
}
}

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 { JumpTypeService } from "../../services/jump-type.service";
@Component({
selector: "app-new-jump-type",
@@ -11,19 +12,22 @@ import { ServiceComm } from "../../services/service-comm.service";
export class NewJumpTypeComponent implements OnInit {
public addForm: FormGroup;
constructor(private serviceComm: ServiceComm) {
this.addForm = new FormGroup({
jumptypeName: new FormControl("", Validators.required)
});
constructor(
private serviceComm: ServiceComm,
private jumpTypeService: JumpTypeService
) {
this.addForm = new FormGroup(
{
jumptypeName: new FormControl("", Validators.required)
},
{ updateOn: "blur" }
);
}
ngOnInit() {}
onSubmit(formData) {
console.log(formData.status);
console.warn("New data : ", formData);
this.serviceComm.RefreshData(AddAction.Gear);
this.addForm.reset();
this.jumpTypeService.AddJumpType(formData.jumptypeName);
this.serviceComm.RefreshData(AddAction.JumpType);
}
}