Possibilité d'éditer un saut (sur 3 infos)

Indication d'un saut est spécial.
This commit is contained in:
Sébastien André
2021-04-21 15:18:40 +02:00
parent 69c49ab011
commit a2ea873ae3
11 changed files with 110 additions and 42 deletions

View File

@@ -1,3 +1,11 @@
<p><span>Gear : {{data.gear.name}} ({{data.gear.mainCanopy}})</span></p> <form (ngSubmit)="updateJump()">
<p><mat-checkbox [(ngModel)]="data.withCutaway" labelPosition="before">Cutaway : </mat-checkbox></p> <p><span>Gear : {{jump.gear.name}} ({{jump.gear.mainCanopy}})</span></p>
<p><span>Notes : {{data.notes}}</span></p> <p><mat-checkbox [(ngModel)]="jump.isSpecial" name="isSpecial" labelPosition="before">Special jump</mat-checkbox></p>
<p><mat-checkbox [(ngModel)]="jump.withCutaway" name="withCutaway" labelPosition="before">Cutaway</mat-checkbox></p>
<mat-form-field>
<textarea matInput placeholder="Comments" name="comments" [(ngModel)]="jump.notes" name="comments" type="text"></textarea>
</mat-form-field>
<br />
<button mat-raised-button color="accent" *ngIf="editMode">Update</button>
</form>

View File

@@ -1,7 +1,10 @@
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { AddAction } from '../../models/add-action.enum';
import { JumpResp } from '../../models/jump'; import { JumpResp } from '../../models/jump';
import { JumpService } from '../../services/jump.service';
import { ServiceComm } from '../../services/service-comm.service';
@Component({ @Component({
selector: 'app-jump-infos', selector: 'app-jump-infos',
@@ -9,10 +12,25 @@ import { JumpResp } from '../../models/jump';
styleUrls: ['./jump-infos.component.css'] styleUrls: ['./jump-infos.component.css']
}) })
export class JumpInfosComponent implements OnInit { export class JumpInfosComponent implements OnInit {
public editMode: boolean;
public jump: JumpResp
constructor(@Inject(MAT_DIALOG_DATA) public data: JumpResp) {} constructor(@Inject(MAT_DIALOG_DATA) public data: any,
private serviceJump: JumpService,
ngOnInit(): void { private serviceComm: ServiceComm) {
this.jump = new JumpResp(data.jump);
this.editMode = data.editMode;
} }
ngOnInit(): void {}
public updateJump() {
this.serviceJump.UpdateJump(this.jump.id,
this.jump.isSpecial,
this.jump.withCutaway,
this.jump.notes)
.subscribe(() => {
this.serviceComm.RefreshData(AddAction.Jump);
});
}
} }

View File

@@ -28,11 +28,9 @@ export class ListOfGearsComponent implements OnInit {
public resultsLength = 0; public resultsLength = 0;
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
constructor( constructor(private serviceApi: GearService,
private serviceApi: GearService, private serviceComm: ServiceComm,
private serviceComm: ServiceComm, public dialog: MatDialog) {}
public dialog: MatDialog
) {}
ngOnInit() { ngOnInit() {
this.serviceComm.refreshRequest.subscribe(action => { this.serviceComm.refreshRequest.subscribe(action => {

View File

@@ -7,8 +7,9 @@
<ng-container matColumnDef="infos"> <ng-container matColumnDef="infos">
<th mat-header-cell *matHeaderCellDef></th> <th mat-header-cell *matHeaderCellDef></th>
<td mat-cell *matCellDef="let element" style="text-align: left;"> <td mat-cell *matCellDef="let element" style="text-align: left;">
<mat-icon aria-hidden="false" aria-label="All informations of the jump" style="cursor: pointer;" <mat-icon aria-hidden="false" aria-label="Special jump" [style.visibility]="element.isSpecial ? 'visible' : 'hidden'">celebration</mat-icon>
(click)='openDialog(element)'>info</mat-icon> <mat-icon aria-hidden="false" aria-label="Additional informations of the jump" style="cursor: pointer;"
(click)='openDialog(element, false)' *ngIf="toShow(element)">info</mat-icon>
</td> </td>
</ng-container> </ng-container>
@@ -55,6 +56,8 @@
<td mat-cell *matCellDef="let element" style="text-align: left;"> <td mat-cell *matCellDef="let element" style="text-align: left;">
<mat-icon aria-hidden="false" aria-label="Delete this jump" style="cursor: pointer;" <mat-icon aria-hidden="false" aria-label="Delete this jump" style="cursor: pointer;"
(click)='delete(element)'>delete</mat-icon> (click)='delete(element)'>delete</mat-icon>
<mat-icon aria-hidden="false" aria-label="Update some informations of the jump" style="cursor: pointer; margin-left: 10px;"
(click)='openDialog(element, true)'>edit</mat-icon>
</td> </td>
</ng-container> </ng-container>

View File

@@ -8,6 +8,7 @@ import { JumpResp } from '../../models/jump';
import { JumpService } from '../../services/jump.service'; import { JumpService } from '../../services/jump.service';
import { ServiceComm } from '../../services/service-comm.service'; import { ServiceComm } from '../../services/service-comm.service';
import { JumpInfosComponent } from "../jump-infos/jump-infos.component"; import { JumpInfosComponent } from "../jump-infos/jump-infos.component";
import { AddAction } from '../../models/add-action.enum';
@Component({ @Component({
selector: 'app-list-of-jumps', selector: 'app-list-of-jumps',
@@ -34,12 +35,18 @@ export class ListOfJumpsComponent implements OnInit {
public dialog: MatDialog) { } public dialog: MatDialog) { }
ngOnInit() { ngOnInit() {
this.serviceComm.refreshRequest.subscribe(action => {
if (action === AddAction.Jump) {
this.dialog.closeAll();
this.getListOfJumps();
}
});
this.serviceComm.UpdatedComponentTitle('List of jumps'); this.serviceComm.UpdatedComponentTitle('List of jumps');
this.getListOfJumps(); this.getListOfJumps();
} }
getListOfJumps() { getListOfJumps() {
this.listOfJumps = this.serviceApi.getListOfJumps(); this.listOfJumps = this.serviceApi.GetListOfJumps();
this.listOfJumps.subscribe(data => { this.listOfJumps.subscribe(data => {
setTimeout(() => { setTimeout(() => {
data.sort((a, b) => b.jumpDate.getTime() - a.jumpDate.getTime()); data.sort((a, b) => b.jumpDate.getTime() - a.jumpDate.getTime());
@@ -50,10 +57,16 @@ export class ListOfJumpsComponent implements OnInit {
}); });
} }
openDialog(item: JumpResp) { openDialog(item: JumpResp, editMode: boolean) {
this.dialog.open(JumpInfosComponent, { this.dialog.open(JumpInfosComponent,
data: item { data: { "jump": item, "editMode": editMode},
}); maxHeight: "400px",
minWidth: "350px"
});
}
toShow(item: JumpResp) {
return item.withCutaway === true || item.notes != undefined;
} }
delete(item: JumpResp) { delete(item: JumpResp) {

View File

@@ -13,10 +13,9 @@ import { AddAction } from "../../models/add-action.enum";
export class NewGearComponent implements OnInit { export class NewGearComponent implements OnInit {
public addForm: FormGroup; public addForm: FormGroup;
constructor( constructor(private serviceComm: ServiceComm,
private serviceComm: ServiceComm, private serviceApi: GearService)
private serviceApi: GearService {
) {
this.addForm = new FormGroup( this.addForm = new FormGroup(
{ {
name: new FormControl("", Validators.required), name: new FormControl("", Validators.required),

View File

@@ -2,7 +2,7 @@
<div class="content"> <div class="content">
<div> <div>
<button mat-raised-button color="accent" [routerLink]="['/jumps']" [routerLinkActive]="['active']" skipLocationChange>View the jumps</button> <button mat-raised-button color="accent" [routerLink]="['/jumps']" [routerLinkActive]="['active']" skipLocationChange>View the jumps</button>
<p><mat-checkbox [(ngModel)]="resetForm" labelPosition="before">Reset form after adding : </mat-checkbox></p> <p><mat-checkbox [(ngModel)]="resetForm" labelPosition="before">Reset form after adding</mat-checkbox></p>
</div> </div>
<form class="formNewJumps" (ngSubmit)="onFormSubmit()" *ngIf="notLoadingToDisplay() else loading"> <form class="formNewJumps" (ngSubmit)="onFormSubmit()" *ngIf="notLoadingToDisplay() else loading">
<mat-form-field> <mat-form-field>
@@ -66,6 +66,7 @@
</mat-form-field> </mat-form-field>
<mat-checkbox [(ngModel)]="withCutaway" name="withCutaway">With a cutaway ?</mat-checkbox> <mat-checkbox [(ngModel)]="withCutaway" name="withCutaway">With a cutaway ?</mat-checkbox>
<mat-checkbox [(ngModel)]="isSpecial" name="isSpecial">Is a special jump ?</mat-checkbox>
<mat-form-field> <mat-form-field>
<input matInput [matDatepicker]="beginDateDp" [(ngModel)]="beginDate" name="beginDate" disabled (ngModelChange)="onChangeBeginDate($event)"> <input matInput [matDatepicker]="beginDateDp" [(ngModel)]="beginDate" name="beginDate" disabled (ngModelChange)="onChangeBeginDate($event)">

View File

@@ -27,6 +27,7 @@ export class NewJumpComponent implements OnInit {
public selectedAircraft: AircraftResp; public selectedAircraft: AircraftResp;
public selectedJumpType: JumpTypeResp; public selectedJumpType: JumpTypeResp;
public withCutaway: boolean; public withCutaway: boolean;
public isSpecial: boolean;
public listOfJumpType: Array<JumpTypeResp>; public listOfJumpType: Array<JumpTypeResp>;
public listOfAircraft: Array<AircraftResp>; public listOfAircraft: Array<AircraftResp>;
public listOfFilteredDropZone: Array<DropZoneResp>; public listOfFilteredDropZone: Array<DropZoneResp>;
@@ -67,7 +68,8 @@ export class NewJumpComponent implements OnInit {
this.exitAltitude, this.exitAltitude,
this.deployAltitude, this.deployAltitude,
this.countOfJumps, this.countOfJumps,
this.comments); this.comments,
this.isSpecial === undefined ? false : this.isSpecial);
setTimeout(() => { setTimeout(() => {
if (this.resetForm === true) { if (this.resetForm === true) {
@@ -143,6 +145,9 @@ export class NewJumpComponent implements OnInit {
this.listOfFilteredDropZone = this.listOfDropZone; this.listOfFilteredDropZone = this.listOfDropZone;
this.comments = undefined; this.comments = undefined;
this.withCutaway = false;
this.isSpecial = false;
} }
public displayFn(data?: JumpTypeResp): string | undefined { public displayFn(data?: JumpTypeResp): string | undefined {

View File

@@ -17,7 +17,8 @@ export class JumpReq {
public deployAltitude: number; public deployAltitude: number;
public withCutaway: boolean; public withCutaway: boolean;
public notes: string; public notes: string;
public jumpDate: string; //Date; public jumpDate: string;
public isSpecial: boolean;
} }
export class JumpResp { export class JumpResp {
@@ -36,4 +37,5 @@ export class JumpResp {
public withCutaway: boolean; public withCutaway: boolean;
public notes: string; public notes: string;
public jumpDate: Date; public jumpDate: Date;
public isSpecial: boolean;
} }

View File

@@ -24,7 +24,8 @@ export class GearService extends BaseService {
maxSize: number, maxSize: number,
aad: string, aad: string,
mainCanopy: string, mainCanopy: string,
reserveCanopy: string) { reserveCanopy: string)
{
const bodyNewGear: GearReq = { const bodyNewGear: GearReq = {
id: 0, id: 0,
name: name, name: name,

View File

@@ -17,17 +17,15 @@ export class JumpService extends BaseService {
super(); super();
} }
public getListOfJumps(): Observable<Array<JumpResp>> { public GetListOfJumps(): Observable<Array<JumpResp>> {
return this.http return this.http.get<Array<JumpResp>>(`${this.apiUrl}/Jump`,
.get<Array<JumpResp>>(`${this.apiUrl}/Jump`, { { headers: this.headers })
headers: this.headers, .pipe(
}) map((response) => {
.pipe( const details = response.map((data) => new JumpResp(data));
map((response) => { return details;
const details = response.map((data) => new JumpResp(data)); })
return details; );
})
);
} }
public AddListOfJump(selectedJumpType: number, public AddListOfJump(selectedJumpType: number,
@@ -40,7 +38,8 @@ export class JumpService extends BaseService {
defaultExitAltitude: number, defaultExitAltitude: number,
defaultDeployAltitude: number, defaultDeployAltitude: number,
countOfJumps: number, countOfJumps: number,
notes: string) notes: string,
isSpecial: boolean)
{ {
const diffInDays = this.dateService.DiffBetweenDates(beginDate, endDate) + 1; const diffInDays = this.dateService.DiffBetweenDates(beginDate, endDate) + 1;
const countOfJumpsPerDay = Math.trunc(countOfJumps / diffInDays); const countOfJumpsPerDay = Math.trunc(countOfJumps / diffInDays);
@@ -55,7 +54,8 @@ export class JumpService extends BaseService {
defaultExitAltitude, defaultExitAltitude,
defaultDeployAltitude, defaultDeployAltitude,
countOfJumpsPerDay, countOfJumpsPerDay,
notes); notes,
isSpecial);
beginDate = this.dateService.AddDays(beginDate, 1); beginDate = this.dateService.AddDays(beginDate, 1);
} }
@@ -71,7 +71,8 @@ export class JumpService extends BaseService {
defaultExitAltitude, defaultExitAltitude,
defaultDeployAltitude, defaultDeployAltitude,
restfJumps, restfJumps,
notes); notes,
isSpecial);
} }
public DeleteJump(item: JumpResp) { public DeleteJump(item: JumpResp) {
@@ -80,6 +81,23 @@ export class JumpService extends BaseService {
.subscribe((data) => console.log(data)); .subscribe((data) => console.log(data));
} }
public UpdateJump(id: number,
isSpecial: boolean,
withCutaway: boolean,
notes: string) {
const jumpData = {
id: id,
isSpecial: isSpecial,
withCutaway: withCutaway,
notes: notes
};
const bodyUpdatedJump = new JumpReq(jumpData);
return this.http.put(`${this.apiUrl}/Jump/${id}`,
bodyUpdatedJump,
{ headers: this.headers, });
}
private AddJumps(selectedJumpType: number, private AddJumps(selectedJumpType: number,
selectedAircraft: number, selectedAircraft: number,
selectedDz: number, selectedDz: number,
@@ -89,7 +107,8 @@ export class JumpService extends BaseService {
defaultExitAltitude: number, defaultExitAltitude: number,
defaultDeployAltitude: number, defaultDeployAltitude: number,
countOfJumps: number, countOfJumps: number,
notes: string) notes: string,
isSpecial: boolean)
{ {
for (let i = 0; i < countOfJumps; i++) { for (let i = 0; i < countOfJumps; i++) {
const bodyNewjump: JumpReq = { const bodyNewjump: JumpReq = {
@@ -102,7 +121,8 @@ export class JumpService extends BaseService {
gearId: selectedRig, gearId: selectedRig,
notes: notes, notes: notes,
id: 0, id: 0,
jumpDate: this.datePipe.transform(jumpDate, "yyyy-MM-dd") jumpDate: this.datePipe.transform(jumpDate, "yyyy-MM-dd"),
isSpecial: isSpecial
}; };
this.http.post(`${this.apiUrl}/Jump`, this.http.post(`${this.apiUrl}/Jump`,