Import "TranslateModule"
This commit is contained in:
@@ -1,41 +1,46 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { formatDate } from '@angular/common';
|
||||
import { DateAdapter, MAT_DATE_FORMATS, NativeDateAdapter } from "@angular/material/core";
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { formatDate } from "@angular/common";
|
||||
import {
|
||||
DateAdapter,
|
||||
MAT_DATE_FORMATS,
|
||||
NativeDateAdapter,
|
||||
} from "@angular/material/core";
|
||||
import { TranslateModule, TranslateService } from "@ngx-translate/core";
|
||||
|
||||
import { TunnelResp } from "../../models/tunnel";
|
||||
|
||||
import { JumpTypeResp } from "../../models/jumpType";
|
||||
import { TunnelService } from '../../services/tunnel.service';
|
||||
import { ServiceComm } from '../../services/service-comm.service';
|
||||
import { TunnelService } from "../../services/tunnel.service";
|
||||
import { ServiceComm } from "../../services/service-comm.service";
|
||||
import { TunnelFlightService } from "../../services/tunnel-flight.service";
|
||||
import { JumpTypeService } from "../../services/jump-type.service";
|
||||
import { DateService } from "../../services/date.service";
|
||||
import { MatAutocompleteModule } from "@angular/material/autocomplete";
|
||||
|
||||
export const PICK_FORMATS = {
|
||||
parse: { dateInput: 'yy MM dd' },
|
||||
parse: { dateInput: "yy MM dd" },
|
||||
display: {
|
||||
dateInput: 'yyyy-MM-dd',
|
||||
monthYearLabel: 'yyyy MMM',
|
||||
dateA11yLabel: 'yyyy MM dd',
|
||||
monthYearA11yLabel: 'yyyy MMMM',
|
||||
}
|
||||
dateInput: "yyyy-MM-dd",
|
||||
monthYearLabel: "yyyy MMM",
|
||||
dateA11yLabel: "yyyy MM dd",
|
||||
monthYearA11yLabel: "yyyy MMMM",
|
||||
},
|
||||
};
|
||||
class PickDateAdapter extends NativeDateAdapter {
|
||||
format(date: Date, displayFormat: Object): string {
|
||||
override format(date: Date, displayFormat: Object): string {
|
||||
return formatDate(date, displayFormat.toString(), "en");
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-new-tunnel-flight',
|
||||
templateUrl: './new-tunnel-flight.component.html',
|
||||
styleUrls: ['./new-tunnel-flight.component.css'],
|
||||
providers: [
|
||||
{ provide: DateAdapter, useClass: PickDateAdapter },
|
||||
{ provide: MAT_DATE_FORMATS, useValue: PICK_FORMATS }
|
||||
],
|
||||
standalone: false
|
||||
selector: "app-new-tunnel-flight",
|
||||
templateUrl: "./new-tunnel-flight.component.html",
|
||||
styleUrls: ["./new-tunnel-flight.component.css"],
|
||||
providers: [
|
||||
{ provide: DateAdapter, useClass: PickDateAdapter },
|
||||
{ provide: MAT_DATE_FORMATS, useValue: PICK_FORMATS },
|
||||
],
|
||||
imports: [MatAutocompleteModule, TranslateModule],
|
||||
})
|
||||
export class NewTunnelFlightComponent implements OnInit {
|
||||
public flightDate: Date;
|
||||
@@ -51,12 +56,14 @@ export class NewTunnelFlightComponent implements OnInit {
|
||||
public listOfJumpType: Array<JumpTypeResp>;
|
||||
public maxDate: Date;
|
||||
|
||||
constructor(private serviceComm: ServiceComm,
|
||||
private serviceTunnel: TunnelService,
|
||||
private serviceTunnelFlight: TunnelFlightService,
|
||||
private serviceJumpType: JumpTypeService,
|
||||
private translateService: TranslateService,
|
||||
private dateService: DateService) { }
|
||||
constructor(
|
||||
private serviceComm: ServiceComm,
|
||||
private serviceTunnel: TunnelService,
|
||||
private serviceTunnelFlight: TunnelFlightService,
|
||||
private serviceJumpType: JumpTypeService,
|
||||
private translateService: TranslateService,
|
||||
private dateService: DateService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.serviceComm.forceTranslateTitle.subscribe((data) => {
|
||||
@@ -77,45 +84,48 @@ export class NewTunnelFlightComponent implements OnInit {
|
||||
public onFormSubmit() {
|
||||
this.pendingAddRequest = true;
|
||||
|
||||
this.serviceTunnelFlight.addFlight(this.selectedTunnel.id,
|
||||
this.selectedJumpType.id,
|
||||
this.flightDate,
|
||||
this.minutesOfFlight,
|
||||
this.comments)
|
||||
.subscribe(() => {
|
||||
this.comments = undefined;
|
||||
this.serviceTunnelFlight
|
||||
.addFlight(
|
||||
this.selectedTunnel.id,
|
||||
this.selectedJumpType.id,
|
||||
this.flightDate,
|
||||
this.minutesOfFlight,
|
||||
this.comments
|
||||
)
|
||||
.subscribe(() => {
|
||||
this.comments = undefined;
|
||||
|
||||
if (this.resetForm === true) {
|
||||
this.initForm();
|
||||
}
|
||||
this.pendingAddRequest = false;
|
||||
});
|
||||
if (this.resetForm === true) {
|
||||
this.initForm();
|
||||
}
|
||||
this.pendingAddRequest = false;
|
||||
});
|
||||
}
|
||||
|
||||
public isValidatedForm(): boolean {
|
||||
return (this.selectedTunnel !== undefined &&
|
||||
this.selectedTunnel.id !== undefined &&
|
||||
this.minutesOfFlight !== undefined &&
|
||||
typeof this.minutesOfFlight === "number");
|
||||
return (
|
||||
this.selectedTunnel !== undefined &&
|
||||
this.selectedTunnel.id !== undefined &&
|
||||
this.minutesOfFlight !== undefined &&
|
||||
typeof this.minutesOfFlight === "number"
|
||||
);
|
||||
}
|
||||
|
||||
private getListOfTunnels() {
|
||||
this.serviceTunnel.getListOfTunnels()
|
||||
.subscribe((data) => {
|
||||
data.sort((a, b) => a.name.localeCompare(b.name));
|
||||
this.listOfTunnel = data;
|
||||
this.listOfFilteredTunnel = data;
|
||||
this.countDatasLoaded++;
|
||||
});
|
||||
this.serviceTunnel.getListOfTunnels().subscribe((data) => {
|
||||
data.sort((a, b) => a.name.localeCompare(b.name));
|
||||
this.listOfTunnel = data;
|
||||
this.listOfFilteredTunnel = data;
|
||||
this.countDatasLoaded++;
|
||||
});
|
||||
}
|
||||
|
||||
private getListOfJumpTypes() {
|
||||
this.serviceJumpType.getListOfJumpTypesForTunnel()
|
||||
.subscribe((data) => {
|
||||
data.sort((a, b) => a.name.localeCompare(b.name));
|
||||
this.listOfJumpType = data;
|
||||
this.countDatasLoaded++;
|
||||
});
|
||||
this.serviceJumpType.getListOfJumpTypesForTunnel().subscribe((data) => {
|
||||
data.sort((a, b) => a.name.localeCompare(b.name));
|
||||
this.listOfJumpType = data;
|
||||
this.countDatasLoaded++;
|
||||
});
|
||||
}
|
||||
|
||||
public notLoadingToDisplay(): boolean {
|
||||
@@ -123,9 +133,9 @@ export class NewTunnelFlightComponent implements OnInit {
|
||||
}
|
||||
|
||||
private updateTitle() {
|
||||
this.translateService.get("NewTunnelFlight_Title").subscribe(
|
||||
data => { this.serviceComm.updatedComponentTitle(data); }
|
||||
);
|
||||
this.translateService.get("NewTunnelFlight_Title").subscribe((data) => {
|
||||
this.serviceComm.updatedComponentTitle(data);
|
||||
});
|
||||
}
|
||||
|
||||
private initForm() {
|
||||
@@ -139,7 +149,7 @@ export class NewTunnelFlightComponent implements OnInit {
|
||||
|
||||
public resetTunnel() {
|
||||
this.selectedTunnel = undefined;
|
||||
this.onChangeTunnel('');
|
||||
this.onChangeTunnel("");
|
||||
}
|
||||
|
||||
public onChangeTunnel(event: any) {
|
||||
|
||||
Reference in New Issue
Block a user