Skip to content

Commit

Permalink
fix INSERT NEXT WPT input field, throw error if not successful
Browse files Browse the repository at this point in the history
(cherry picked from commit 433b2c1)
  • Loading branch information
flogross89 committed Jul 23, 2024
1 parent 06797f1 commit 9be355b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ interface DestinationWindowProps extends ComponentProps {
fmcService: FmcServiceInterface;
mfd: DisplayInterface & MfdDisplayInterface;
visible: Subject<boolean>;
contentContainerStyle?: string;
}
export class DestinationWindow extends DisplayComponent<DestinationWindowProps> {
// Make sure to collect all subscriptions here, otherwise page navigation doesn't work.
Expand All @@ -23,16 +22,18 @@ export class DestinationWindow extends DisplayComponent<DestinationWindowProps>

private newDest = Subject.create<string>('');

private onModified(newDest: string): void {
const revWpt = this.props.fmcService.master?.revisedWaypointIndex.get();
if (newDest.length === 4 && revWpt) {
this.props.fmcService.master?.flightPlanService.newDest(
revWpt,
newDest,
this.props.fmcService.master.revisedWaypointPlanIndex.get() ?? undefined,
this.props.fmcService.master.revisedWaypointIsAltn.get() ?? undefined,
);
this.props.fmcService.master?.acInterface.updateOansAirports();
private onModified(newDest: string | null): void {
if (newDest) {
const revWpt = this.props.fmcService.master?.revisedWaypointIndex.get();
if (newDest.length === 4 && revWpt) {
this.props.fmcService.master?.flightPlanService.newDest(
revWpt,
newDest,
this.props.fmcService.master.revisedWaypointPlanIndex.get() ?? undefined,
this.props.fmcService.master.revisedWaypointIsAltn.get() ?? undefined,
);
this.props.fmcService.master?.acInterface.updateOansAirports();
}
this.props.visible.set(false);
this.newDest.set('');
this.props.fmcService.master?.resetRevisedWaypoint();
Expand Down Expand Up @@ -72,7 +73,7 @@ export class DestinationWindow extends DisplayComponent<DestinationWindowProps>
render(): VNode {
return (
<div ref={this.topRef} style="position: relative;">
<div class="mfd-dialog mfd-fms-new-dest-box" style={`${this.props.contentContainerStyle ?? ''}`}>
<div class="mfd-dialog mfd-fms-new-dest-box">
<div class="mfd-fms-new-dest-box-inner">
<span class="mfd-label">
NEW DEST FROM{' '}
Expand All @@ -85,7 +86,8 @@ export class DestinationWindow extends DisplayComponent<DestinationWindowProps>
dataEntryFormat={new AirportFormat()}
mandatory={Subject.create(false)}
canBeCleared={Subject.create(true)}
onModified={(val) => this.onModified(val ?? '')}
inactive={Subject.create(false)}
onModified={(val) => this.onModified(val)}
value={this.newDest}
alignText="center"
errorHandler={(e) => this.props.mfd.showFmsErrorMessage(e)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { FmcServiceInterface } from 'instruments/src/MFD/FMC/FmcServiceInterface
import { FlightPlanIndex } from '@fmgc/index';
import { DisplayInterface } from '@fmgc/flightplanning/interface/DisplayInterface';
import { MfdDisplayInterface } from 'instruments/src/MFD/MFD';
import { FmsError } from '@fmgc/FmsError';

export type NextWptInfo = {
ident: string;
Expand Down Expand Up @@ -76,15 +77,21 @@ export class InsertNextWptFromWindow extends DisplayComponent<InsertNextWptFromW
);
}
} else {
const wpt = await WaypointEntryUtils.getOrCreateWaypoint(this.props.fmcService.master, text, true, undefined);
const revWpt = this.props.fmcService.master.revisedWaypointIndex.get();
if (wpt && revWpt) {
await this.props.fmcService.master.flightPlanService.nextWaypoint(
revWpt,
wpt,
this.props.fmcService.master.revisedWaypointPlanIndex.get() ?? undefined,
this.props.fmcService.master.revisedWaypointIsAltn.get() ?? undefined,
);
try {
const wpt = await WaypointEntryUtils.getOrCreateWaypoint(this.props.fmcService.master, text, true, undefined);
const revWpt = this.props.fmcService.master.revisedWaypointIndex.get();
if (wpt && revWpt) {
await this.props.fmcService.master.flightPlanService.nextWaypoint(
revWpt,
wpt,
this.props.fmcService.master.revisedWaypointPlanIndex.get() ?? undefined,
this.props.fmcService.master.revisedWaypointIsAltn.get() ?? undefined,
);
}
} catch (msg: unknown) {
if (msg instanceof FmsError) {
this.props.fmcService.master?.showFmsErrorMessage(msg.type);
}
}
this.props.visible.set(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ export class InputField<T> extends DisplayComponent<InputFieldProps<T>> {
render(): VNode {
return (
<div ref={this.topRef} class="mfd-input-field-root">
<div ref={this.containerRef} class="mfd-input-field-container" style={`${this.props.containerStyle}`}>
<div ref={this.containerRef} class="mfd-input-field-container" style={`${this.props.containerStyle ?? ''}`}>
<span ref={this.leadingUnitRef} class="mfd-label-unit mfd-unit-leading mfd-input-field-unit">
{this.leadingUnit}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ class TopTabElement extends DisplayComponent<TopTabElementProps> {
y2={this.props.height}
style="stroke: lightgrey; stroke-width:2"
/>
!
{this.props.isSelected && (
{!this.props.isSelected && (
<line
x1="0"
y1={this.props.height - 1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@
position: absolute;
top: -18px;
z-index: 5;
border: 1px solid $display-grey;
border: 1px solid $display-grey !important;
}

.mfd-input-field-text-input {
Expand Down

0 comments on commit 9be355b

Please sign in to comment.