Possibilité d'éditer un saut (sur 3 infos)
Indication d'un saut est spécial.
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
<p><span>Gear : {{data.gear.name}} ({{data.gear.mainCanopy}})</span></p>
|
||||
<p><mat-checkbox [(ngModel)]="data.withCutaway" labelPosition="before">Cutaway : </mat-checkbox></p>
|
||||
<p><span>Notes : {{data.notes}}</span></p>
|
||||
<form (ngSubmit)="updateJump()">
|
||||
<p><span>Gear : {{jump.gear.name}} ({{jump.gear.mainCanopy}})</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>
|
||||
@@ -1,7 +1,10 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
|
||||
import { AddAction } from '../../models/add-action.enum';
|
||||
import { JumpResp } from '../../models/jump';
|
||||
import { JumpService } from '../../services/jump.service';
|
||||
import { ServiceComm } from '../../services/service-comm.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-jump-infos',
|
||||
@@ -9,10 +12,25 @@ import { JumpResp } from '../../models/jump';
|
||||
styleUrls: ['./jump-infos.component.css']
|
||||
})
|
||||
export class JumpInfosComponent implements OnInit {
|
||||
public editMode: boolean;
|
||||
public jump: JumpResp
|
||||
|
||||
constructor(@Inject(MAT_DIALOG_DATA) public data: JumpResp) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
constructor(@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
private serviceJump: JumpService,
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,9 @@ export class ListOfGearsComponent implements OnInit {
|
||||
public resultsLength = 0;
|
||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||
|
||||
constructor(
|
||||
private serviceApi: GearService,
|
||||
constructor(private serviceApi: GearService,
|
||||
private serviceComm: ServiceComm,
|
||||
public dialog: MatDialog
|
||||
) {}
|
||||
public dialog: MatDialog) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.serviceComm.refreshRequest.subscribe(action => {
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
<ng-container matColumnDef="infos">
|
||||
<th mat-header-cell *matHeaderCellDef></th>
|
||||
<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;"
|
||||
(click)='openDialog(element)'>info</mat-icon>
|
||||
<mat-icon aria-hidden="false" aria-label="Special jump" [style.visibility]="element.isSpecial ? 'visible' : 'hidden'">celebration</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>
|
||||
</ng-container>
|
||||
|
||||
@@ -55,6 +56,8 @@
|
||||
<td mat-cell *matCellDef="let element" style="text-align: left;">
|
||||
<mat-icon aria-hidden="false" aria-label="Delete this jump" style="cursor: pointer;"
|
||||
(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>
|
||||
</ng-container>
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import { JumpResp } from '../../models/jump';
|
||||
import { JumpService } from '../../services/jump.service';
|
||||
import { ServiceComm } from '../../services/service-comm.service';
|
||||
import { JumpInfosComponent } from "../jump-infos/jump-infos.component";
|
||||
import { AddAction } from '../../models/add-action.enum';
|
||||
|
||||
@Component({
|
||||
selector: 'app-list-of-jumps',
|
||||
@@ -34,12 +35,18 @@ export class ListOfJumpsComponent implements OnInit {
|
||||
public dialog: MatDialog) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.serviceComm.refreshRequest.subscribe(action => {
|
||||
if (action === AddAction.Jump) {
|
||||
this.dialog.closeAll();
|
||||
this.getListOfJumps();
|
||||
}
|
||||
});
|
||||
this.serviceComm.UpdatedComponentTitle('List of jumps');
|
||||
this.getListOfJumps();
|
||||
}
|
||||
|
||||
getListOfJumps() {
|
||||
this.listOfJumps = this.serviceApi.getListOfJumps();
|
||||
this.listOfJumps = this.serviceApi.GetListOfJumps();
|
||||
this.listOfJumps.subscribe(data => {
|
||||
setTimeout(() => {
|
||||
data.sort((a, b) => b.jumpDate.getTime() - a.jumpDate.getTime());
|
||||
@@ -50,12 +57,18 @@ export class ListOfJumpsComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
openDialog(item: JumpResp) {
|
||||
this.dialog.open(JumpInfosComponent, {
|
||||
data: item
|
||||
openDialog(item: JumpResp, editMode: boolean) {
|
||||
this.dialog.open(JumpInfosComponent,
|
||||
{ data: { "jump": item, "editMode": editMode},
|
||||
maxHeight: "400px",
|
||||
minWidth: "350px"
|
||||
});
|
||||
}
|
||||
|
||||
toShow(item: JumpResp) {
|
||||
return item.withCutaway === true || item.notes != undefined;
|
||||
}
|
||||
|
||||
delete(item: JumpResp) {
|
||||
let data : Array<JumpResp> = this.dataSourceTable.data;
|
||||
data = data.filter(d => d.id !== item.id);
|
||||
|
||||
@@ -13,10 +13,9 @@ import { AddAction } from "../../models/add-action.enum";
|
||||
export class NewGearComponent implements OnInit {
|
||||
public addForm: FormGroup;
|
||||
|
||||
constructor(
|
||||
private serviceComm: ServiceComm,
|
||||
private serviceApi: GearService
|
||||
) {
|
||||
constructor(private serviceComm: ServiceComm,
|
||||
private serviceApi: GearService)
|
||||
{
|
||||
this.addForm = new FormGroup(
|
||||
{
|
||||
name: new FormControl("", Validators.required),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="content">
|
||||
<div>
|
||||
<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>
|
||||
<form class="formNewJumps" (ngSubmit)="onFormSubmit()" *ngIf="notLoadingToDisplay() else loading">
|
||||
<mat-form-field>
|
||||
@@ -66,6 +66,7 @@
|
||||
</mat-form-field>
|
||||
|
||||
<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>
|
||||
<input matInput [matDatepicker]="beginDateDp" [(ngModel)]="beginDate" name="beginDate" disabled (ngModelChange)="onChangeBeginDate($event)">
|
||||
|
||||
@@ -27,6 +27,7 @@ export class NewJumpComponent implements OnInit {
|
||||
public selectedAircraft: AircraftResp;
|
||||
public selectedJumpType: JumpTypeResp;
|
||||
public withCutaway: boolean;
|
||||
public isSpecial: boolean;
|
||||
public listOfJumpType: Array<JumpTypeResp>;
|
||||
public listOfAircraft: Array<AircraftResp>;
|
||||
public listOfFilteredDropZone: Array<DropZoneResp>;
|
||||
@@ -67,7 +68,8 @@ export class NewJumpComponent implements OnInit {
|
||||
this.exitAltitude,
|
||||
this.deployAltitude,
|
||||
this.countOfJumps,
|
||||
this.comments);
|
||||
this.comments,
|
||||
this.isSpecial === undefined ? false : this.isSpecial);
|
||||
|
||||
setTimeout(() => {
|
||||
if (this.resetForm === true) {
|
||||
@@ -143,6 +145,9 @@ export class NewJumpComponent implements OnInit {
|
||||
|
||||
this.listOfFilteredDropZone = this.listOfDropZone;
|
||||
this.comments = undefined;
|
||||
|
||||
this.withCutaway = false;
|
||||
this.isSpecial = false;
|
||||
}
|
||||
|
||||
public displayFn(data?: JumpTypeResp): string | undefined {
|
||||
|
||||
@@ -17,7 +17,8 @@ export class JumpReq {
|
||||
public deployAltitude: number;
|
||||
public withCutaway: boolean;
|
||||
public notes: string;
|
||||
public jumpDate: string; //Date;
|
||||
public jumpDate: string;
|
||||
public isSpecial: boolean;
|
||||
}
|
||||
|
||||
export class JumpResp {
|
||||
@@ -36,4 +37,5 @@ export class JumpResp {
|
||||
public withCutaway: boolean;
|
||||
public notes: string;
|
||||
public jumpDate: Date;
|
||||
public isSpecial: boolean;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ export class GearService extends BaseService {
|
||||
maxSize: number,
|
||||
aad: string,
|
||||
mainCanopy: string,
|
||||
reserveCanopy: string) {
|
||||
reserveCanopy: string)
|
||||
{
|
||||
const bodyNewGear: GearReq = {
|
||||
id: 0,
|
||||
name: name,
|
||||
|
||||
@@ -17,11 +17,9 @@ export class JumpService extends BaseService {
|
||||
super();
|
||||
}
|
||||
|
||||
public getListOfJumps(): Observable<Array<JumpResp>> {
|
||||
return this.http
|
||||
.get<Array<JumpResp>>(`${this.apiUrl}/Jump`, {
|
||||
headers: this.headers,
|
||||
})
|
||||
public GetListOfJumps(): Observable<Array<JumpResp>> {
|
||||
return this.http.get<Array<JumpResp>>(`${this.apiUrl}/Jump`,
|
||||
{ headers: this.headers })
|
||||
.pipe(
|
||||
map((response) => {
|
||||
const details = response.map((data) => new JumpResp(data));
|
||||
@@ -40,7 +38,8 @@ export class JumpService extends BaseService {
|
||||
defaultExitAltitude: number,
|
||||
defaultDeployAltitude: number,
|
||||
countOfJumps: number,
|
||||
notes: string)
|
||||
notes: string,
|
||||
isSpecial: boolean)
|
||||
{
|
||||
const diffInDays = this.dateService.DiffBetweenDates(beginDate, endDate) + 1;
|
||||
const countOfJumpsPerDay = Math.trunc(countOfJumps / diffInDays);
|
||||
@@ -55,7 +54,8 @@ export class JumpService extends BaseService {
|
||||
defaultExitAltitude,
|
||||
defaultDeployAltitude,
|
||||
countOfJumpsPerDay,
|
||||
notes);
|
||||
notes,
|
||||
isSpecial);
|
||||
|
||||
beginDate = this.dateService.AddDays(beginDate, 1);
|
||||
}
|
||||
@@ -71,7 +71,8 @@ export class JumpService extends BaseService {
|
||||
defaultExitAltitude,
|
||||
defaultDeployAltitude,
|
||||
restfJumps,
|
||||
notes);
|
||||
notes,
|
||||
isSpecial);
|
||||
}
|
||||
|
||||
public DeleteJump(item: JumpResp) {
|
||||
@@ -80,6 +81,23 @@ export class JumpService extends BaseService {
|
||||
.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,
|
||||
selectedAircraft: number,
|
||||
selectedDz: number,
|
||||
@@ -89,7 +107,8 @@ export class JumpService extends BaseService {
|
||||
defaultExitAltitude: number,
|
||||
defaultDeployAltitude: number,
|
||||
countOfJumps: number,
|
||||
notes: string)
|
||||
notes: string,
|
||||
isSpecial: boolean)
|
||||
{
|
||||
for (let i = 0; i < countOfJumps; i++) {
|
||||
const bodyNewjump: JumpReq = {
|
||||
@@ -102,7 +121,8 @@ export class JumpService extends BaseService {
|
||||
gearId: selectedRig,
|
||||
notes: notes,
|
||||
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`,
|
||||
|
||||
Reference in New Issue
Block a user