From 3b3601baebb3ecaa40094269221f6f9aa2ee8360 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Thu, 19 Sep 2024 09:10:15 +0200 Subject: [PATCH] Added agency port dependency when editing shipcalls --- src/BreCalClient/BreCalLists.cs | 11 +++++++++++ src/BreCalClient/EditShipcallControl.xaml.cs | 6 +++--- src/RoleEditor/EditBerthDialog.xaml.cs | 6 ++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/BreCalClient/BreCalLists.cs b/src/BreCalClient/BreCalLists.cs index b888b4d..4bf9b18 100644 --- a/src/BreCalClient/BreCalLists.cs +++ b/src/BreCalClient/BreCalLists.cs @@ -148,6 +148,17 @@ namespace BreCalClient return berths; } + public static List GetParticipants(int port, Extensions.ParticipantType type) + { + List participants = new(); + foreach(Participant participant in _participants) + { + if(participant.IsTypeFlagSet(type) && participant.Ports.Contains(port)) + participants.Add(participant); + } + return participants; + } + #endregion #region Internal initializer methods diff --git a/src/BreCalClient/EditShipcallControl.xaml.cs b/src/BreCalClient/EditShipcallControl.xaml.cs index c52daaa..5a97ed8 100644 --- a/src/BreCalClient/EditShipcallControl.xaml.cs +++ b/src/BreCalClient/EditShipcallControl.xaml.cs @@ -445,9 +445,9 @@ namespace BreCalClient this.comboBoxDepartureBerth.ItemsSource = availableBerths; // Filter agency combobox by port - - // TODO - + List availableAgencies = BreCalLists.GetParticipants(port.Id, ParticipantType.AGENCY); + this.comboBoxAgency.ItemsSource = null; + this.comboBoxAgency.ItemsSource = availableAgencies; } #endregion diff --git a/src/RoleEditor/EditBerthDialog.xaml.cs b/src/RoleEditor/EditBerthDialog.xaml.cs index 3f1b649..6f12bea 100644 --- a/src/RoleEditor/EditBerthDialog.xaml.cs +++ b/src/RoleEditor/EditBerthDialog.xaml.cs @@ -45,6 +45,12 @@ namespace RoleEditor else this.Berth.Authority_Id = null; + this.Berth.Port = this.comboBoxPorts.SelectedItem as Port; + if (this.Berth.Port != null) + this.Berth.Port_Id = this.Berth.Port.Id; + else + this.Berth.Port_Id = null; + this.DialogResult = true; this.Close(); }