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>
<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>

View File

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

View File

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

View File

@@ -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>

View File

@@ -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,10 +57,16 @@ 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) {

View File

@@ -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),

View File

@@ -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)">

View File

@@ -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 {