diff --git a/src/BreCalClient/EditTimesControl.xaml b/src/BreCalClient/EditTimesControl.xaml
new file mode 100644
index 0000000..cec997c
--- /dev/null
+++ b/src/BreCalClient/EditTimesControl.xaml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/BreCalClient/EditTimesControl.xaml.cs b/src/BreCalClient/EditTimesControl.xaml.cs
new file mode 100644
index 0000000..4ef8f72
--- /dev/null
+++ b/src/BreCalClient/EditTimesControl.xaml.cs
@@ -0,0 +1,114 @@
+// Copyright (c) 2023 schick Informatik
+// Description: Single dialog to edit times for all participant types
+// (we might use different controls at a later time)
+//
+
+using BreCalClient.misc.Model;
+using System.Windows;
+
+namespace BreCalClient
+{
+ ///
+ /// Interaction logic for EditTimesControl.xaml
+ ///
+ public partial class EditTimesControl : Window
+ {
+
+ #region Construction
+
+ public EditTimesControl()
+ {
+ InitializeComponent();
+ }
+
+ #endregion
+
+ #region Properties
+
+ public Times Times { get; set; } = new();
+
+ internal Extensions.ParticipantType ParticipantType { get; set; } = Extensions.ParticipantType.NONE;
+
+ #endregion
+
+ #region event handler
+
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ this.CopyToControls();
+ // enable controls according to participant type
+ this.datePickerETABerth.IsEnabled = App.Participant.IsFlagSet(Extensions.ParticipantType.AGENCY) ||
+ App.Participant.IsFlagSet(Extensions.ParticipantType.MOORING) ||
+ App.Participant.IsFlagSet(Extensions.ParticipantType.PILOT) ||
+ App.Participant.IsFlagSet(Extensions.ParticipantType.PORT_ADMINISTRATION) ||
+ App.Participant.IsFlagSet(Extensions.ParticipantType.TUG);
+
+
+ this.checkBoxEtaBerthFixed.IsEnabled = this.datePickerETABerth.IsEnabled;
+ this.datePickerETDBerth.IsEnabled = this.datePickerETABerth.IsEnabled;
+ this.checkBoxEtDBerthFixed.IsEnabled = this.datePickerETABerth.IsEnabled;
+
+ this.datePickerLockTime.IsEnabled = App.Participant.IsFlagSet(Extensions.ParticipantType.AGENCY) ||
+ App.Participant.IsFlagSet(Extensions.ParticipantType.MOORING) ||
+ App.Participant.IsFlagSet(Extensions.ParticipantType.PORT_ADMINISTRATION);
+ this.checkBoxLockTimeFixed.IsEnabled = this.datePickerLockTime.IsEnabled;
+
+ this.datePickerZoneEntry.IsEnabled = App.Participant.IsFlagSet(Extensions.ParticipantType.AGENCY) ||
+ App.Participant.IsFlagSet(Extensions.ParticipantType.PILOT);
+ this.checkBoxZoneEntryFixed.IsEnabled = this.datePickerZoneEntry.IsEnabled;
+
+ this.datePickerOperationStart.IsEnabled = App.Participant.IsFlagSet(Extensions.ParticipantType.TERMINAL);
+ this.datePickerOperationEnd.IsEnabled = App.Participant.IsFlagSet(Extensions.ParticipantType.TERMINAL);
+ }
+
+ private void buttonOK_Click(object sender, RoutedEventArgs e)
+ {
+ this.CopyToModel();
+ this.DialogResult = true;
+ this.Close();
+ }
+
+ private void buttonCancel_Click(object sender, RoutedEventArgs e)
+ {
+ this.DialogResult = false;
+ this.Close();
+ }
+
+ #endregion
+
+ #region private methods
+
+ private void CopyToModel()
+ {
+ this.Times.Remarks = this.textBoxRemarks.Text.Trim().Truncate(512);
+ this.Times.EtaBerth = this.datePickerETABerth.Value;
+ this.Times.EtdBerth = this.datePickerETDBerth.Value;
+ this.Times.LockTime = this.datePickerLockTime.Value;
+ this.Times.ZoneEntry = this.datePickerZoneEntry.Value;
+ this.Times.OperationsStart = this.datePickerOperationStart.Value;
+ this.Times.OperationsEnd = this.datePickerOperationEnd.Value;
+ this.Times.EtaBerthFixed = this.checkBoxEtaBerthFixed.IsChecked;
+ this.Times.EtdBerthFixed = this.checkBoxEtDBerthFixed.IsChecked;
+ this.Times.LockTimeFixed = this.checkBoxLockTimeFixed.IsChecked;
+ this.Times.ZoneEntryFixed = this.checkBoxZoneEntryFixed.IsChecked;
+ }
+
+ private void CopyToControls()
+ {
+ this.textBoxRemarks.Text = this.Times.Remarks;
+ this.datePickerETABerth.Value = this.Times.EtaBerth;
+ this.datePickerETDBerth.Value = this.Times.EtdBerth;
+ this.datePickerLockTime.Value = this.Times.LockTime;
+ this.datePickerZoneEntry.Value = this.Times.ZoneEntry;
+ this.datePickerOperationStart.Value = this.Times.OperationsStart;
+ this.datePickerOperationEnd.Value = this.Times.OperationsEnd;
+ this.checkBoxEtaBerthFixed.IsChecked = this.Times.EtaBerthFixed;
+ this.checkBoxEtDBerthFixed.IsChecked = this.Times.EtdBerthFixed;
+ this.checkBoxLockTimeFixed.IsChecked = this.Times.LockTimeFixed;
+ this.checkBoxZoneEntryFixed.IsChecked = this.Times.ZoneEntryFixed;
+ }
+
+ #endregion
+
+ }
+}
diff --git a/src/BreCalClient/Extensions.cs b/src/BreCalClient/Extensions.cs
index 40bf07b..9ec655a 100644
--- a/src/BreCalClient/Extensions.cs
+++ b/src/BreCalClient/Extensions.cs
@@ -66,6 +66,12 @@ namespace BreCalClient
else participant.Type &= (int)~flag;
}
+ public static string Truncate(this string value, int maxLength)
+ {
+ if (string.IsNullOrEmpty(value)) return value;
+ return value.Length <= maxLength ? value : value.Substring(0, maxLength);
+ }
+
#endregion
}
diff --git a/src/BreCalClient/MainWindow.xaml.cs b/src/BreCalClient/MainWindow.xaml.cs
index b553096..c591f41 100644
--- a/src/BreCalClient/MainWindow.xaml.cs
+++ b/src/BreCalClient/MainWindow.xaml.cs
@@ -337,11 +337,41 @@ namespace BreCalClient
}
}
- private void Sc_EditTimesRequested(ShipcallControl obj, Times times)
+ private async void Sc_EditTimesRequested(ShipcallControl obj, Times? times)
{
// show a dialog that lets the user create / update times for the given shipcall
-
-
+ EditTimesControl etc = new();
+ bool wasEdit = false;
+ if (times != null)
+ {
+ etc.Times = times;
+ wasEdit = true;
+ }
+ if(etc.ShowDialog() ?? false)
+ {
+ try
+ {
+ if (wasEdit)
+ {
+ await _api.TimesPutAsync(etc.Times);
+ }
+ else
+ {
+ etc.Times.ParticipantId = App.Participant.Id;
+ if ((obj.ShipcallControlModel != null) && (obj.ShipcallControlModel.Shipcall != null))
+ {
+ etc.Times.ShipcallId = obj.ShipcallControlModel.Shipcall.Id;
+ }
+ await _api.TimesPostAsync(etc.Times);
+ obj.ShipcallControlModel?.Times.Add(etc.Times);
+ }
+ obj.RefreshData();
+ }
+ catch (Exception ex)
+ {
+ ShowErrorDialog(ex.Message, "Error saving times");
+ }
+ }
}
private void ShowErrorDialog(string message, string caption)
diff --git a/src/BreCalClient/Resources/Resources.Designer.cs b/src/BreCalClient/Resources/Resources.Designer.cs
index ca28c6e..3e1de73 100644
--- a/src/BreCalClient/Resources/Resources.Designer.cs
+++ b/src/BreCalClient/Resources/Resources.Designer.cs
@@ -333,6 +333,15 @@ namespace BreCalClient.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Edit times.
+ ///
+ public static string textEditTimes {
+ get {
+ return ResourceManager.GetString("textEditTimes", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Enter keyword.
///
@@ -342,6 +351,24 @@ namespace BreCalClient.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to ETA berth.
+ ///
+ public static string textETABerth {
+ get {
+ return ResourceManager.GetString("textETABerth", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to ETD berth.
+ ///
+ public static string textETDBerth {
+ get {
+ return ResourceManager.GetString("textETDBerth", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Exit.
///
@@ -351,6 +378,15 @@ namespace BreCalClient.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Fixed.
+ ///
+ public static string textFixed {
+ get {
+ return ResourceManager.GetString("textFixed", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to from.
///
@@ -378,6 +414,15 @@ namespace BreCalClient.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Lock time.
+ ///
+ public static string textLockTime {
+ get {
+ return ResourceManager.GetString("textLockTime", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Login.
///
@@ -450,6 +495,24 @@ namespace BreCalClient.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Operations end.
+ ///
+ public static string textOperationsEnd {
+ get {
+ return ResourceManager.GetString("textOperationsEnd", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Operations start.
+ ///
+ public static string textOperationsStart {
+ get {
+ return ResourceManager.GetString("textOperationsStart", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Participants.
///
@@ -513,6 +576,15 @@ namespace BreCalClient.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Remarks.
+ ///
+ public static string textRemarks {
+ get {
+ return ResourceManager.GetString("textRemarks", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Repeat new password.
///
@@ -666,6 +738,15 @@ namespace BreCalClient.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Zone entry.
+ ///
+ public static string textZoneEntryTime {
+ get {
+ return ResourceManager.GetString("textZoneEntryTime", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized resource of type System.Byte[].
///
diff --git a/src/BreCalClient/Resources/Resources.de.resx b/src/BreCalClient/Resources/Resources.de.resx
index 2ab3ce8..6009777 100644
--- a/src/BreCalClient/Resources/Resources.de.resx
+++ b/src/BreCalClient/Resources/Resources.de.resx
@@ -196,6 +196,15 @@
Schiffsanlauf bearbeiten
+
+ Zeiten bearbeiten
+
+
+ ETA Liegeplatz
+
+
+ ETD Liegeplatz
+
Suchbegriff eingeben
@@ -214,6 +223,18 @@
Anmelden
+
+ Fest
+
+
+ Zeit Schleuse
+
+
+ Operation Ende
+
+
+ Operation Start
+
Festmacher in Schleuse
@@ -229,6 +250,9 @@
Ungedreht
+
+ Reviereintritt
+
OK
diff --git a/src/BreCalClient/Resources/Resources.resx b/src/BreCalClient/Resources/Resources.resx
index 6d0a74e..531d465 100644
--- a/src/BreCalClient/Resources/Resources.resx
+++ b/src/BreCalClient/Resources/Resources.resx
@@ -205,12 +205,24 @@
Edit ship call
+
+ Edit times
+
Enter keyword
+
+ ETA berth
+
+
+ ETD berth
+
Exit
+
+ Fixed
+
from
@@ -220,6 +232,9 @@
L/W
+
+ Lock time
+
Login
@@ -244,6 +259,12 @@
Old password
+
+ Operations end
+
+
+ Operations start
+
Participants
@@ -265,6 +286,9 @@
Recommended tugs
+
+ Remarks
+
Repeat new password
@@ -316,6 +340,9 @@
Voyage
+
+ Zone entry
+
trafficlight_green.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
diff --git a/src/BreCalClient/ShipcallControl.xaml.cs b/src/BreCalClient/ShipcallControl.xaml.cs
index 356de8f..decf5e5 100644
--- a/src/BreCalClient/ShipcallControl.xaml.cs
+++ b/src/BreCalClient/ShipcallControl.xaml.cs
@@ -30,7 +30,7 @@ namespace BreCalClient
public event Action? EditRequested;
- public event Action? EditTimesRequested;
+ public event Action? EditTimesRequested;
public event Action? OpenExtraRequested;
@@ -161,11 +161,8 @@ namespace BreCalClient
{
if (App.Participant.IsFlagSet(Extensions.ParticipantType.AGENCY))
{
- Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.AGENCY);
- if (times != null)
- {
- this.EditTimesRequested?.Invoke(this, times);
- }
+ Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.AGENCY);
+ this.EditTimesRequested?.Invoke(this, times);
}
}
@@ -174,10 +171,7 @@ namespace BreCalClient
if (App.Participant.IsFlagSet(Extensions.ParticipantType.MOORING))
{
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.MOORING);
- if(times != null)
- {
- this.EditTimesRequested?.Invoke(this, times);
- }
+ this.EditTimesRequested?.Invoke(this, times);
}
}
@@ -185,11 +179,8 @@ namespace BreCalClient
{
if (App.Participant.IsFlagSet(Extensions.ParticipantType.PORT_ADMINISTRATION))
{
- Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.PORT_ADMINISTRATION);
- if (times != null)
- {
- this.EditTimesRequested?.Invoke(this, times);
- }
+ Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.PORT_ADMINISTRATION);
+ this.EditTimesRequested?.Invoke(this, times);
}
}
@@ -198,10 +189,7 @@ namespace BreCalClient
if (App.Participant.IsFlagSet(Extensions.ParticipantType.PILOT))
{
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.PILOT);
- if (times != null)
- {
- this.EditTimesRequested?.Invoke(this, times);
- }
+ this.EditTimesRequested?.Invoke(this, times);
}
}
@@ -210,10 +198,7 @@ namespace BreCalClient
if (App.Participant.IsFlagSet(Extensions.ParticipantType.TUG))
{
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.TUG);
- if (times != null)
- {
- this.EditTimesRequested?.Invoke(this, times);
- }
+ this.EditTimesRequested?.Invoke(this, times);
}
}
@@ -222,10 +207,7 @@ namespace BreCalClient
if (App.Participant.IsFlagSet(Extensions.ParticipantType.TERMINAL))
{
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.TERMINAL);
- if (times != null)
- {
- this.EditTimesRequested?.Invoke(this, times);
- }
+ this.EditTimesRequested?.Invoke(this, times);
}
}
diff --git a/src/server/BreCal/impl/shipcalls.py b/src/server/BreCal/impl/shipcalls.py
index d59cd83..2a61951 100644
--- a/src/server/BreCal/impl/shipcalls.py
+++ b/src/server/BreCal/impl/shipcalls.py
@@ -59,6 +59,10 @@ def PostShipcalls(schemaModel):
continue
if key == "participants":
continue
+ if key == "created":
+ continue
+ if key == "modified":
+ continue
if isNotFirst:
query += ","
isNotFirst = True
@@ -70,6 +74,10 @@ def PostShipcalls(schemaModel):
continue
if key == "participants":
continue
+ if key == "created":
+ continue
+ if key == "modified":
+ continue
if isNotFirst:
query += ","
isNotFirst = True
@@ -125,6 +133,10 @@ def PutShipcalls(schemaModel):
continue
if key == "participants":
continue
+ if key == "created":
+ continue
+ if key == "modified":
+ continue
if isNotFirst:
query += ", "
isNotFirst = True
diff --git a/src/server/BreCal/impl/times.py b/src/server/BreCal/impl/times.py
index 359d8d0..6aded52 100644
--- a/src/server/BreCal/impl/times.py
+++ b/src/server/BreCal/impl/times.py
@@ -53,6 +53,10 @@ def PostTimes(schemaModel):
for key in schemaModel.keys():
if key == "id":
continue
+ if key == "created":
+ continue
+ if key == "modified":
+ continue
if isNotFirst:
query += ","
isNotFirst = True
@@ -62,6 +66,10 @@ def PostTimes(schemaModel):
for key in schemaModel.keys():
if key == "id":
continue
+ if key == "created":
+ continue
+ if key == "modified":
+ continue
if isNotFirst:
query += ","
isNotFirst = True
@@ -100,6 +108,10 @@ def PutTimes(schemaModel):
for key in schemaModel.keys():
if key == "id":
continue
+ if key == "created":
+ continue
+ if key == "modified":
+ continue
if isNotFirst:
query += ", "
isNotFirst = True
diff --git a/src/server/BreCal/schemas/model.py b/src/server/BreCal/schemas/model.py
index 59140e2..2b096c1 100644
--- a/src/server/BreCal/schemas/model.py
+++ b/src/server/BreCal/schemas/model.py
@@ -130,21 +130,21 @@ class TimesSchema(Schema):
pass
id = fields.Int(Required=False)
- eta_berth = fields.DateTime(Required = False)
- eta_berth_fixed = fields.Bool(Required = False)
- etd_berth = fields.DateTime(Required = False)
- etd_berth_fixed = fields.Bool(Required = False)
- lock_time = fields.DateTime(Required = False)
- lock_time_fixed = fields.Bool(Required = False)
- zone_entry = fields.DateTime(Required = False)
- zone_entry_fixed = fields.Bool(Required = False)
- operations_start = fields.DateTime(Required = False)
- operations_end = fields.DateTime(Required = False)
- remarks = fields.String(Required = False)
+ eta_berth = fields.DateTime(Required = False, allow_none=True)
+ eta_berth_fixed = fields.Bool(Required = False, allow_none=True)
+ etd_berth = fields.DateTime(Required = False, allow_none=True)
+ etd_berth_fixed = fields.Bool(Required = False, allow_none=True)
+ lock_time = fields.DateTime(Required = False, allow_none=True)
+ lock_time_fixed = fields.Bool(Required = False, allow_none=True)
+ zone_entry = fields.DateTime(Required = False, allow_none=True)
+ zone_entry_fixed = fields.Bool(Required = False, allow_none=True)
+ operations_start = fields.DateTime(Required = False, allow_none=True)
+ operations_end = fields.DateTime(Required = False, allow_none=True)
+ remarks = fields.String(Required = False, allow_none=True)
participant_id = fields.Int(Required = True)
shipcall_id = fields.Int(Required = True)
- created = fields.DateTime(Required = False)
- modified = fields.DateTime(Required = False)
+ created = fields.DateTime(Required = False, allow_none=True)
+ modified = fields.DateTime(Required = False, allow_none=True)
# deserialize PUT object target