Merge branch 'bugfix/extend_clientside_validation' into develop
This commit is contained in:
commit
402c9807c9
@ -207,12 +207,14 @@ namespace BreCalClient
|
||||
isEnabled &= this.datePickerETD.Value.HasValue;
|
||||
if(this.datePickerETD.Value.HasValue)
|
||||
isEnabled &= (this.datePickerETD.Value.Value > DateTime.Now);
|
||||
isEnabled &= !this.datePickerETD.Value.IsTooFar();
|
||||
break;
|
||||
case ShipcallType.Arrival:
|
||||
isEnabled &= this.comboBoxArrivalBerth.SelectedItem != null;
|
||||
isEnabled &= this.datePickerETA.Value.HasValue;
|
||||
if(this.datePickerETA.Value.HasValue)
|
||||
isEnabled &= (this.datePickerETA.Value.Value > DateTime.Now);
|
||||
isEnabled &= !this.datePickerETA.Value.IsTooFar();
|
||||
break;
|
||||
case ShipcallType.Shifting:
|
||||
isEnabled &= ((this.comboBoxDepartureBerth.SelectedItem != null) && (this.comboBoxArrivalBerth.SelectedItem != null));
|
||||
@ -222,6 +224,10 @@ namespace BreCalClient
|
||||
isEnabled &= (this.datePickerETD.Value.Value > DateTime.Now);
|
||||
if (this.datePickerETA.Value.HasValue)
|
||||
isEnabled &= (this.datePickerETA.Value.Value > DateTime.Now);
|
||||
if (this.datePickerETA.Value.HasValue && this.datePickerETD.Value.HasValue)
|
||||
isEnabled &= (this.datePickerETA.Value.Value > this.datePickerETD.Value.Value);
|
||||
isEnabled &= !this.datePickerETD.Value.IsTooFar();
|
||||
isEnabled &= !this.datePickerETA.Value.IsTooFar();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,6 +133,18 @@ namespace BreCalClient
|
||||
return false;
|
||||
}
|
||||
|
||||
if((this.datePickerTidalWindowFrom.Value.HasValue && !this.datePickerTidalWindowTo.Value.HasValue) || (!this.datePickerTidalWindowFrom.Value.HasValue && this.datePickerTidalWindowTo.Value.HasValue))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textTidalBothValues;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.datePickerETA.Value.IsTooFar() || this.datePickerETA_End.Value.IsTooFar() || this.datePickerTidalWindowFrom.Value.IsTooFar() || this.datePickerTidalWindowTo.Value.IsTooFar())
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textTooFarInTheFuture;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -143,6 +143,18 @@ namespace BreCalClient
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((this.datePickerTidalWindowFrom.Value.HasValue && !this.datePickerTidalWindowTo.Value.HasValue) || (!this.datePickerTidalWindowFrom.Value.HasValue && this.datePickerTidalWindowTo.Value.HasValue))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textTidalBothValues;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.datePickerETD.Value.IsTooFar() || this.datePickerETD_End.Value.IsTooFar() || this.datePickerTidalWindowFrom.Value.IsTooFar() || this.datePickerTidalWindowTo.Value.IsTooFar())
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textTooFarInTheFuture;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -151,6 +151,19 @@ namespace BreCalClient
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((this.datePickerTidalWindowFrom.Value.HasValue && !this.datePickerTidalWindowTo.Value.HasValue) || (!this.datePickerTidalWindowFrom.Value.HasValue && this.datePickerTidalWindowTo.Value.HasValue))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textTidalBothValues;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.datePickerETA.Value.IsTooFar() || this.datePickerETA_End.Value.IsTooFar() || this.datePickerTidalWindowFrom.Value.IsTooFar() || this.datePickerTidalWindowTo.Value.IsTooFar() ||
|
||||
this.datePickerETD.Value.IsTooFar() || this.datePickerETD_End.Value.IsTooFar())
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textTooFarInTheFuture;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
|
||||
using BreCalClient.misc.Model;
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Xceed.Wpf.Toolkit;
|
||||
@ -125,7 +126,14 @@ namespace BreCalClient
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textZoneEntryInThePast;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.datePickerATA.Value.IsTooFar() || this.datePickerATD.Value.IsTooFar() || this.datePickerETABerth.Value.IsTooFar() || this.datePickerETABerth_End.Value.IsTooFar() ||
|
||||
this.datePickerETDBerth.Value.IsTooFar() || this.datePickerETDBerth_End.Value.IsTooFar() || this.datePickerLockTime.Value.IsTooFar() || this.datePickerZoneEntry.Value.IsTooFar())
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textTooFarInTheFuture;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -236,6 +244,7 @@ namespace BreCalClient
|
||||
if (this.Times.ParticipantId != App.Participant.Id)
|
||||
{
|
||||
this.buttonFixedOrder.IsEnabled = false;
|
||||
this.buttonOK.IsEnabled = false;
|
||||
return; // if this is not "my" entry, there is no editing!
|
||||
}
|
||||
|
||||
|
||||
@ -144,6 +144,12 @@ namespace BreCalClient
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.datePickerOperationEnd.Value.IsTooFar() || this.datePickerOperationEnd_End.Value.IsTooFar() || this.datePickerOperationStart.Value.IsTooFar() || this.datePickerOperationStart_End.Value.IsTooFar())
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textTooFarInTheFuture;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -208,7 +214,11 @@ namespace BreCalClient
|
||||
|
||||
private void EnableControls()
|
||||
{
|
||||
if (this.Times.ParticipantId != App.Participant.Id) return;
|
||||
if (this.Times.ParticipantId != App.Participant.Id)
|
||||
{
|
||||
this.buttonOK.IsEnabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.datePickerOperationStart.IsEnabled = ShipcallModel.Shipcall?.Type == ShipcallType.Arrival;
|
||||
this.datePickerOperationStart_End.IsEnabled = ShipcallModel.Shipcall?.Type == ShipcallType.Arrival;
|
||||
|
||||
@ -3,10 +3,8 @@
|
||||
//
|
||||
|
||||
using BreCalClient.misc.Model;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace BreCalClient
|
||||
{
|
||||
@ -60,6 +58,17 @@ namespace BreCalClient
|
||||
|
||||
#region public helper
|
||||
|
||||
public static bool IsTooFar(this DateTime datetime)
|
||||
{
|
||||
return datetime > DateTime.Now.AddYears(1);
|
||||
}
|
||||
|
||||
public static bool IsTooFar(this DateTime? datetime)
|
||||
{
|
||||
if (datetime == null) return false;
|
||||
return datetime > DateTime.Now.AddYears(1);
|
||||
}
|
||||
|
||||
public static bool IsTypeFlagSet(this Participant participant, ParticipantType flag)
|
||||
{
|
||||
return (participant.Type & (uint)flag) != 0;
|
||||
|
||||
18
src/BreCalClient/Resources/Resources.Designer.cs
generated
18
src/BreCalClient/Resources/Resources.Designer.cs
generated
@ -1208,6 +1208,15 @@ namespace BreCalClient.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to For a tidal window both values must be set.
|
||||
/// </summary>
|
||||
public static string textTidalBothValues {
|
||||
get {
|
||||
return ResourceManager.GetString("textTidalBothValues", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Tidal window.
|
||||
/// </summary>
|
||||
@ -1244,6 +1253,15 @@ namespace BreCalClient.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to A time value is too far in the future.
|
||||
/// </summary>
|
||||
public static string textTooFarInTheFuture {
|
||||
get {
|
||||
return ResourceManager.GetString("textTooFarInTheFuture", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Set as a fixed order.
|
||||
/// </summary>
|
||||
|
||||
@ -541,4 +541,10 @@
|
||||
<data name="textZoneEntryInThePast" xml:space="preserve">
|
||||
<value>Zeit Reviereintritt liegt in der Vergangenheit</value>
|
||||
</data>
|
||||
<data name="textTidalBothValues" xml:space="preserve">
|
||||
<value>Für das Tidenfenster müssen beide Zeiten angegeben werden</value>
|
||||
</data>
|
||||
<data name="textTooFarInTheFuture" xml:space="preserve">
|
||||
<value>Eine Zeiteingabe ist zu weit in der Zukunft</value>
|
||||
</data>
|
||||
</root>
|
||||
@ -487,6 +487,9 @@
|
||||
<data name="textTerminal" xml:space="preserve">
|
||||
<value>Terminal</value>
|
||||
</data>
|
||||
<data name="textTidalBothValues" xml:space="preserve">
|
||||
<value>For a tidal window both values must be set</value>
|
||||
</data>
|
||||
<data name="textTidalWindow" xml:space="preserve">
|
||||
<value>Tidal window</value>
|
||||
</data>
|
||||
@ -499,6 +502,9 @@
|
||||
<data name="textTo" xml:space="preserve">
|
||||
<value>to</value>
|
||||
</data>
|
||||
<data name="textTooFarInTheFuture" xml:space="preserve">
|
||||
<value>A time value is too far in the future</value>
|
||||
</data>
|
||||
<data name="textTooltipSetFixedOrder" xml:space="preserve">
|
||||
<value>Set as a fixed order</value>
|
||||
</data>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user