Skip to content

Commit

Permalink
Check for null selectedIndex before calculating precedence options
Browse files Browse the repository at this point in the history
  • Loading branch information
jmccollum-woolpert committed Aug 24, 2023
1 parent 0205c7b commit 4a0f78e
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -772,17 +772,19 @@ export class PreSolveShipmentModelSettingsComponent implements OnInit, OnDestroy
}

getPrecedenceRuleFirstIndexOptions(selectedIndex: number): Shipment[] {
return [
selectedIndex && this.scenarioShipments$.value[selectedIndex],
...this.scenarioShipments$.value,
];
const options = [...this.scenarioShipments$.value];
if (selectedIndex) {
options.push(this.scenarioShipments$.value[selectedIndex]);
}
return options;
}

getPrecendenceRuleSecondIndexOptions(firstIndex: number, selectedIndex: number): Shipment[] {
return [
selectedIndex && this.scenarioShipments$.value[selectedIndex],
...this.scenarioShipments$.value.filter((_, i) => i !== firstIndex),
];
const options = [...this.scenarioShipments$.value.filter((_, i) => i !== firstIndex)];
if (selectedIndex) {
options.push(this.scenarioShipments$.value[selectedIndex]);
}
return options;
}

getIndexOfShipment(shipment: Shipment): number {
Expand Down

0 comments on commit 4a0f78e

Please sign in to comment.