Add the jump type in the tunnel flight
This commit is contained in:
@@ -6,19 +6,23 @@ import { map } from "rxjs/operators";
|
||||
|
||||
import { TunnelFlightReq, TunnelFlightResp, TunnelFlight, TunnelFlightByMonthResp, TunnelFlightByMonth } from "../models/tunnel-flight";
|
||||
import { DropZoneResp } from '../models/dropzone';
|
||||
import { JumpTypeResp } from '../models/jumpType';
|
||||
|
||||
import { BaseService } from "./base.service";
|
||||
import { DropzoneService } from "./dropzone.service";
|
||||
import { JumpTypeService } from "./jump-type.service";
|
||||
|
||||
@Injectable()
|
||||
export class TunnelFlightService extends BaseService {
|
||||
constructor(private http: HttpClient,
|
||||
private datePipe: DatePipe,
|
||||
private jumpTypeService: JumpTypeService,
|
||||
private dropzoneService: DropzoneService) {
|
||||
super();
|
||||
}
|
||||
|
||||
public addFlight(selectedTunnel: number,
|
||||
selectedJumpType: number,
|
||||
flightDate: Date,
|
||||
nbMinutes: number,
|
||||
comment: string) {
|
||||
@@ -26,6 +30,7 @@ export class TunnelFlightService extends BaseService {
|
||||
const bodyNewFlight: TunnelFlightReq = {
|
||||
id: 0,
|
||||
tunnelId: selectedTunnel,
|
||||
jumpTypeId: selectedJumpType,
|
||||
flightDate: this.datePipe.transform(flightDate, "yyyy-MM-dd"),
|
||||
notes: comment,
|
||||
nbMinutes: nbMinutes
|
||||
@@ -61,10 +66,13 @@ export class TunnelFlightService extends BaseService {
|
||||
private mapWithDataInCache(apiResp: Array<TunnelFlightResp>): Array<TunnelFlight> {
|
||||
let allDropzones: Array<DropZoneResp>;
|
||||
this.dropzoneService.getFromCache().subscribe(data => { allDropzones = data; });
|
||||
let allJumpType: Array<JumpTypeResp>;
|
||||
this.jumpTypeService.getFromCache().subscribe(data => { allJumpType = data; });
|
||||
|
||||
return apiResp.map((data) => {
|
||||
let tmp = new TunnelFlight(data);
|
||||
tmp.tunnel = allDropzones.find(d => d.id == data.tunnelId);
|
||||
tmp.jumpType = allJumpType.find(d => d.id == data.jumpTypeId);
|
||||
|
||||
return tmp;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user