Skip to content

Commit

Permalink
fix: clearing fix info fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjozork committed Jan 18, 2025
1 parent dbeb3f6 commit ad33062
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ export class MfdFmsFplnFixInfo extends FmsPage {
<InputField<AnyFix, string, false>
readonlyValue={this.flightPlan.fixInfos[value].map((it) => it?.fix ?? null)}
onModified={async (text) => {
if (!text) {
return null;
if (text === null) {
void this.props.fmcService.master!.flightPlanService.setFixInfoEntry(value, null);
return;
}

const fix = await WaypointEntryUtils.getOrCreateWaypoint(this.props.fmcService.master!, text, true);
Expand Down Expand Up @@ -113,19 +114,19 @@ export class MfdFmsFplnFixInfo extends FmsPage {
(it) => it?.radials?.[0]?.magneticBearing ?? null,
)}
onModified={(radial) => {
if (radial === null) {
return;
}

this.props.fmcService.master?.flightPlanService.editFixInfoEntry(value, (fixInfo) => {
if (!fixInfo.radials) {
fixInfo.radials = [];
}

fixInfo.radials[0] = {
magneticBearing: radial,
trueBearing: A32NX_Util.magneticToTrue(radial, A32NX_Util.getRadialMagVar(fixInfo.fix)),
};
if (radial !== null) {
fixInfo.radials[0] = {
magneticBearing: radial,
trueBearing: A32NX_Util.magneticToTrue(radial, A32NX_Util.getRadialMagVar(fixInfo.fix)),
};
} else {
delete fixInfo.radials[0];
}

return fixInfo;
});
Expand All @@ -147,19 +148,19 @@ export class MfdFmsFplnFixInfo extends FmsPage {
(it) => it?.radials?.[1]?.magneticBearing ?? null,
)}
onModified={(radial) => {
if (radial === null) {
return;
}

this.props.fmcService.master?.flightPlanService.editFixInfoEntry(value, (fixInfo) => {
if (!fixInfo.radials) {
fixInfo.radials = [];
}

fixInfo.radials[1] = {
magneticBearing: radial,
trueBearing: A32NX_Util.magneticToTrue(radial, A32NX_Util.getRadialMagVar(fixInfo.fix)),
};
if (radial !== null) {
fixInfo.radials[1] = {
magneticBearing: radial,
trueBearing: A32NX_Util.magneticToTrue(radial, A32NX_Util.getRadialMagVar(fixInfo.fix)),
};
} else {
delete fixInfo.radials[1];
}

return fixInfo;
});
Expand All @@ -186,16 +187,16 @@ export class MfdFmsFplnFixInfo extends FmsPage {
disabled={this.flightPlan.fixInfos[value].map((it) => it?.fix === undefined)}
readonlyValue={this.flightPlan.fixInfos[value].map((it) => it?.radii?.[0]?.radius ?? null)}
onModified={(radius) => {
if (radius === null) {
return;
}

this.props.fmcService.master?.flightPlanService.editFixInfoEntry(value, (fixInfo) => {
if (!fixInfo.radii) {
fixInfo.radii = [];
}

fixInfo.radii[0] = { radius };
if (radius !== null) {
fixInfo.radii[0] = { radius };
} else {
delete fixInfo.radii[0];
}

return fixInfo;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,10 @@ export class FixFormat implements DataEntryFormat<Fix, string> {
public readonly maxDigits = 7;

async parse(input: string): Promise<string | null> {
if (input.trim().length === 0) {
return null;
}

if (WaypointEntryUtils.isPlaceFormat(input) || WaypointEntryUtils.isRunwayFormat(input)) {
return input;
}
Expand Down

0 comments on commit ad33062

Please sign in to comment.