Fixed error in validation when not all fields are transmitted. Added UI for Notification flags.

This commit is contained in:
Daniel Schick 2024-12-05 18:39:28 +01:00
parent 44f5d07ed7
commit 7d4f202692
10 changed files with 261 additions and 25 deletions

View File

@ -1,7 +1,7 @@
//---------------------- //----------------------
// <auto-generated> // <auto-generated>
// Generated REST API Client Code Generator v1.16.0.0 on 05.12.2024 17:03:25 // Generated REST API Client Code Generator v1.16.0.0 on 05.12.2024 18:21:44
// Using the tool OpenAPI Generator v7.9.0 // Using the tool OpenAPI Generator v7.9.0
// </auto-generated> // </auto-generated>
//---------------------- //----------------------
@ -6909,9 +6909,13 @@ namespace BreCalClient.misc.Model
/// <param name="userName">userName.</param> /// <param name="userName">userName.</param>
/// <param name="userPhone">userPhone.</param> /// <param name="userPhone">userPhone.</param>
/// <param name="userEmail">userEmail.</param> /// <param name="userEmail">userEmail.</param>
/// <param name="notifyEmail">notifyEmail.</param>
/// <param name="notifyWhatsapp">notifyWhatsapp.</param>
/// <param name="notifySignal">notifySignal.</param>
/// <param name="notifyPopup">notifyPopup.</param>
/// <param name="exp">exp.</param> /// <param name="exp">exp.</param>
/// <param name="token">token.</param> /// <param name="token">token.</param>
public LoginResult(int id = default(int), int participantId = default(int), string firstName = default(string), string lastName = default(string), string userName = default(string), string userPhone = default(string), string userEmail = default(string), float exp = default(float), string token = default(string)) public LoginResult(int id = default(int), int participantId = default(int), string firstName = default(string), string lastName = default(string), string userName = default(string), string userPhone = default(string), string userEmail = default(string), bool notifyEmail = default(bool), bool notifyWhatsapp = default(bool), bool notifySignal = default(bool), bool notifyPopup = default(bool), float exp = default(float), string token = default(string))
{ {
this.Id = id; this.Id = id;
this.ParticipantId = participantId; this.ParticipantId = participantId;
@ -6920,6 +6924,10 @@ namespace BreCalClient.misc.Model
this.UserName = userName; this.UserName = userName;
this.UserPhone = userPhone; this.UserPhone = userPhone;
this.UserEmail = userEmail; this.UserEmail = userEmail;
this.NotifyEmail = notifyEmail;
this.NotifyWhatsapp = notifyWhatsapp;
this.NotifySignal = notifySignal;
this.NotifyPopup = notifyPopup;
this.Exp = exp; this.Exp = exp;
this.Token = token; this.Token = token;
} }
@ -6980,6 +6988,38 @@ namespace BreCalClient.misc.Model
[DataMember(Name = "user_email", EmitDefaultValue = true)] [DataMember(Name = "user_email", EmitDefaultValue = true)]
public string UserEmail { get; set; } public string UserEmail { get; set; }
/// <summary> /// <summary>
/// Gets or Sets NotifyEmail
/// </summary>
/*
<example>true</example>
*/
[DataMember(Name = "notify_email", EmitDefaultValue = true)]
public bool NotifyEmail { get; set; }
/// <summary>
/// Gets or Sets NotifyWhatsapp
/// </summary>
/*
<example>false</example>
*/
[DataMember(Name = "notify_whatsapp", EmitDefaultValue = true)]
public bool NotifyWhatsapp { get; set; }
/// <summary>
/// Gets or Sets NotifySignal
/// </summary>
/*
<example>false</example>
*/
[DataMember(Name = "notify_signal", EmitDefaultValue = true)]
public bool NotifySignal { get; set; }
/// <summary>
/// Gets or Sets NotifyPopup
/// </summary>
/*
<example>false</example>
*/
[DataMember(Name = "notify_popup", EmitDefaultValue = true)]
public bool NotifyPopup { get; set; }
/// <summary>
/// Gets or Sets Exp /// Gets or Sets Exp
/// </summary> /// </summary>
/* /*
@ -7010,6 +7050,10 @@ namespace BreCalClient.misc.Model
sb.Append(" UserName: ").Append(UserName).Append("\n"); sb.Append(" UserName: ").Append(UserName).Append("\n");
sb.Append(" UserPhone: ").Append(UserPhone).Append("\n"); sb.Append(" UserPhone: ").Append(UserPhone).Append("\n");
sb.Append(" UserEmail: ").Append(UserEmail).Append("\n"); sb.Append(" UserEmail: ").Append(UserEmail).Append("\n");
sb.Append(" NotifyEmail: ").Append(NotifyEmail).Append("\n");
sb.Append(" NotifyWhatsapp: ").Append(NotifyWhatsapp).Append("\n");
sb.Append(" NotifySignal: ").Append(NotifySignal).Append("\n");
sb.Append(" NotifyPopup: ").Append(NotifyPopup).Append("\n");
sb.Append(" Exp: ").Append(Exp).Append("\n"); sb.Append(" Exp: ").Append(Exp).Append("\n");
sb.Append(" Token: ").Append(Token).Append("\n"); sb.Append(" Token: ").Append(Token).Append("\n");
sb.Append("}\n"); sb.Append("}\n");
@ -8728,7 +8772,11 @@ namespace BreCalClient.misc.Model
/// <param name="lastName">lastName.</param> /// <param name="lastName">lastName.</param>
/// <param name="userPhone">userPhone.</param> /// <param name="userPhone">userPhone.</param>
/// <param name="userEmail">userEmail.</param> /// <param name="userEmail">userEmail.</param>
public UserDetails(int id = default(int), string oldPassword = default(string), string newPassword = default(string), string firstName = default(string), string lastName = default(string), string userPhone = default(string), string userEmail = default(string)) /// <param name="notifyEmail">notifyEmail.</param>
/// <param name="notifyPopup">notifyPopup.</param>
/// <param name="notifyWhatsapp">notifyWhatsapp.</param>
/// <param name="notifySignal">notifySignal.</param>
public UserDetails(int id = default(int), string oldPassword = default(string), string newPassword = default(string), string firstName = default(string), string lastName = default(string), string userPhone = default(string), string userEmail = default(string), bool? notifyEmail = default(bool?), bool? notifyPopup = default(bool?), bool? notifyWhatsapp = default(bool?), bool? notifySignal = default(bool?))
{ {
this.Id = id; this.Id = id;
this.OldPassword = oldPassword; this.OldPassword = oldPassword;
@ -8737,6 +8785,10 @@ namespace BreCalClient.misc.Model
this.LastName = lastName; this.LastName = lastName;
this.UserPhone = userPhone; this.UserPhone = userPhone;
this.UserEmail = userEmail; this.UserEmail = userEmail;
this.NotifyEmail = notifyEmail;
this.NotifyPopup = notifyPopup;
this.NotifyWhatsapp = notifyWhatsapp;
this.NotifySignal = notifySignal;
} }
/// <summary> /// <summary>
/// Gets or Sets Id /// Gets or Sets Id
@ -8795,6 +8847,38 @@ namespace BreCalClient.misc.Model
[DataMember(Name = "user_email", EmitDefaultValue = true)] [DataMember(Name = "user_email", EmitDefaultValue = true)]
public string UserEmail { get; set; } public string UserEmail { get; set; }
/// <summary> /// <summary>
/// Gets or Sets NotifyEmail
/// </summary>
/*
<example>true</example>
*/
[DataMember(Name = "notify_email", EmitDefaultValue = true)]
public bool? NotifyEmail { get; set; }
/// <summary>
/// Gets or Sets NotifyPopup
/// </summary>
/*
<example>false</example>
*/
[DataMember(Name = "notify_popup", EmitDefaultValue = true)]
public bool? NotifyPopup { get; set; }
/// <summary>
/// Gets or Sets NotifyWhatsapp
/// </summary>
/*
<example>false</example>
*/
[DataMember(Name = "notify_whatsapp", EmitDefaultValue = true)]
public bool? NotifyWhatsapp { get; set; }
/// <summary>
/// Gets or Sets NotifySignal
/// </summary>
/*
<example>false</example>
*/
[DataMember(Name = "notify_signal", EmitDefaultValue = true)]
public bool? NotifySignal { get; set; }
/// <summary>
/// Returns the string presentation of the object /// Returns the string presentation of the object
/// </summary> /// </summary>
/// <returns>String presentation of the object</returns> /// <returns>String presentation of the object</returns>
@ -8809,6 +8893,10 @@ namespace BreCalClient.misc.Model
sb.Append(" LastName: ").Append(LastName).Append("\n"); sb.Append(" LastName: ").Append(LastName).Append("\n");
sb.Append(" UserPhone: ").Append(UserPhone).Append("\n"); sb.Append(" UserPhone: ").Append(UserPhone).Append("\n");
sb.Append(" UserEmail: ").Append(UserEmail).Append("\n"); sb.Append(" UserEmail: ").Append(UserEmail).Append("\n");
sb.Append(" NotifyEmail: ").Append(NotifyEmail).Append("\n");
sb.Append(" NotifyPopup: ").Append(NotifyPopup).Append("\n");
sb.Append(" NotifyWhatsapp: ").Append(NotifyWhatsapp).Append("\n");
sb.Append(" NotifySignal: ").Append(NotifySignal).Append("\n");
sb.Append("}\n"); sb.Append("}\n");
return sb.ToString(); return sb.ToString();
} }

View File

@ -1545,15 +1545,15 @@ components:
id: id:
type: integer type: integer
example: 42 example: 42
nullable: false nullable: false
shipcall_id: shipcall_id:
type: integer type: integer
example: 5 example: 5
nullable: false nullable: false
notification_type: notification_type:
$ref: '#/components/schemas/NotificationType' $ref: '#/components/schemas/NotificationType'
message: message:
type: string type: string
example: Entry XY violates rule Z example: Entry XY violates rule Z
created: created:
type: string type: string
@ -1704,6 +1704,18 @@ components:
user_email: user_email:
type: string type: string
example: no@where.com example: no@where.com
notify_email:
type: boolean
example: true
notify_whatsapp:
type: boolean
example: false
notify_signal:
type: boolean
example: false
notify_popup:
type: boolean
example: false
exp: exp:
type: number type: number
format: float format: float
@ -1758,6 +1770,22 @@ components:
type: string type: string
nullable: true nullable: true
example: no@where.com example: no@where.com
notify_email:
type: boolean
nullable: true
example: true
notify_popup:
type: boolean
nullable: true
example: false
notify_whatsapp:
type: boolean
nullable: true
example: false
notify_signal:
type: boolean
nullable: true
example: false
example: example:
id: 42 id: 42
old_password: oldpassword old_password: oldpassword

View File

@ -17,3 +17,11 @@ public bool ShouldSerializeEvaluation()
``` ```
Witziger(!)weise funktioniert es für das Property EvaluationMessage korrekt. Witziger(!)weise funktioniert es für das Property EvaluationMessage korrekt.
### Vacuum Yaml Linter
Example Usage:
```bash
vacuum lint -d .\misc\BreCalApi.yaml --fail-severity warn
```

View File

@ -7,7 +7,7 @@
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:p = "clr-namespace:BreCalClient.Resources" xmlns:p = "clr-namespace:BreCalClient.Resources"
mc:Ignorable="d" Left="{local:SettingBinding W1Left}" Top="{local:SettingBinding W1Top}" mc:Ignorable="d" Left="{local:SettingBinding W1Left}" Top="{local:SettingBinding W1Top}"
Title="Help" Height="374" Width="500" Loaded="Window_Loaded"> Title="Help" Height="496" Width="500" Loaded="Window_Loaded">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="180" /> <ColumnDefinition Width="180" />
@ -25,6 +25,11 @@
<RowDefinition Height="28" /> <RowDefinition Height="28" />
<RowDefinition Height="28" /> <RowDefinition Height="28" />
<RowDefinition Height="28" /> <RowDefinition Height="28" />
<RowDefinition Height="10" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="28" /> <RowDefinition Height="28" />
@ -49,14 +54,24 @@
<TextBox Name="textBoxUserEmail" Grid.Column="1" Grid.Row="4" Margin="2" VerticalContentAlignment="Center" /> <TextBox Name="textBoxUserEmail" Grid.Column="1" Grid.Row="4" Margin="2" VerticalContentAlignment="Center" />
<TextBox Name="textBoxUserPhone" Grid.Column="1" Grid.Row="5" Margin="2" VerticalContentAlignment="Center" /> <TextBox Name="textBoxUserPhone" Grid.Column="1" Grid.Row="5" Margin="2" VerticalContentAlignment="Center" />
<Label FontWeight="DemiBold" Grid.Row="7" Grid.Column="0" Content="{x:Static p:Resources.textChangePassword}" HorizontalContentAlignment="Right"/> <Label FontWeight="DemiBold" Grid.Row="7" Grid.Column="0" Content="{x:Static p:Resources.textNotifications}" HorizontalContentAlignment="Right"/>
<CheckBox HorizontalAlignment="Right" Margin="2" Grid.Column="0" Grid.Row="8" VerticalAlignment="Center" x:Name="checkboxEMailNotify" />
<xctk:WatermarkPasswordBox Watermark="{x:Static p:Resources.textOldPassword}" Grid.Column="1" Grid.Row="7" Margin="2" x:Name="wpBoxOldPassword" TextChanged="wpBoxOldPassword_TextChanged"/> <Label Grid.Row="8" Grid.Column="1" Content="{x:Static p:Resources.textNotifyEmail}" />
<xctk:WatermarkPasswordBox Watermark="{x:Static p:Resources.textNewPassword}" Grid.Column="1" Grid.Row="8" Margin="2" x:Name="wpBoxNewPassword" TextChanged="wpBoxOldPassword_TextChanged"/> <CheckBox HorizontalAlignment="Right" Margin="2" Grid.Column="0" Grid.Row="9" VerticalAlignment="Center" x:Name="checkboxPushNotify" />
<xctk:WatermarkPasswordBox Watermark="{x:Static p:Resources.textRepeatNewPassword}" Grid.Column="1" Grid.Row="9" Margin="2" x:Name="wpBoxNewPasswordRepeat" TextChanged="wpBoxOldPassword_TextChanged"/> <Label Grid.Row="9" Grid.Column="1" Content="{x:Static p:Resources.textNotifyPush}" />
<Button x:Name="buttonChangePassword" Click="buttonChangePassword_Click" Grid.Column="1" Grid.Row="10" Margin="2" Content="{x:Static p:Resources.textChange}" Width="80" HorizontalAlignment="Left" IsEnabled="True" /> <Button x:Name="buttonChangeUserFields" Click="buttonChangeUserFields_Click" Grid.Column="1" Grid.Row="10" Margin="2" Content="{x:Static p:Resources.textChange}" Width="80" HorizontalAlignment="Left" IsEnabled="True" />
<Button x:Name="buttonClose" Click="buttonClose_Click" Content="{x:Static p:Resources.textClose}" Width="80" Margin="2" Grid.Column="1" Grid.Row="12" HorizontalAlignment="Right" /> <Border BorderThickness="0 0 0 2" Grid.Row="11" Grid.Column="0" Grid.ColumnSpan="2" BorderBrush="Gray" />
<Label FontWeight="DemiBold" Grid.Row="12" Grid.Column="0" Content="{x:Static p:Resources.textChangePassword}" HorizontalContentAlignment="Right"/>
<xctk:WatermarkPasswordBox Watermark="{x:Static p:Resources.textOldPassword}" Grid.Column="1" Grid.Row="12" Margin="2" x:Name="wpBoxOldPassword" TextChanged="wpBoxOldPassword_TextChanged"/>
<xctk:WatermarkPasswordBox Watermark="{x:Static p:Resources.textNewPassword}" Grid.Column="1" Grid.Row="13" Margin="2" x:Name="wpBoxNewPassword" TextChanged="wpBoxOldPassword_TextChanged"/>
<xctk:WatermarkPasswordBox Watermark="{x:Static p:Resources.textRepeatNewPassword}" Grid.Column="1" Grid.Row="14" Margin="2" x:Name="wpBoxNewPasswordRepeat" TextChanged="wpBoxOldPassword_TextChanged"/>
<Button x:Name="buttonChangePassword" Click="buttonChangePassword_Click" Grid.Column="1" Grid.Row="15" Margin="2" Content="{x:Static p:Resources.textChangePassword}" Width="120" HorizontalAlignment="Left" IsEnabled="False" />
<Button x:Name="buttonClose" Click="buttonClose_Click" Content="{x:Static p:Resources.textClose}" Width="80" Margin="2" Grid.Column="1" Grid.Row="17" HorizontalAlignment="Right" />
</Grid> </Grid>
</Window> </Window>

View File

@ -34,6 +34,7 @@ namespace BreCalClient
#region events #region events
public event Action<string, string>? ChangePasswordRequested; public event Action<string, string>? ChangePasswordRequested;
public event Action? ChangeUserSettingsRequested;
#endregion #endregion
@ -45,14 +46,20 @@ namespace BreCalClient
} }
private void buttonChangePassword_Click(object sender, RoutedEventArgs e) private void buttonChangePassword_Click(object sender, RoutedEventArgs e)
{
this.ChangePasswordRequested?.Invoke(this.wpBoxOldPassword.Password, this.wpBoxNewPassword.Password);
}
private void buttonChangeUserFields_Click(object sender, RoutedEventArgs e)
{ {
if (this.LoginResult != null) if (this.LoginResult != null)
{ {
this.LoginResult.UserPhone = this.textBoxUserPhone.Text.Trim(); this.LoginResult.UserPhone = this.textBoxUserPhone.Text.Trim();
this.LoginResult.UserEmail = this.textBoxUserEmail.Text.Trim(); this.LoginResult.UserEmail = this.textBoxUserEmail.Text.Trim();
this.LoginResult.NotifyEmail = this.checkboxEMailNotify.IsChecked ?? false;
this.LoginResult.NotifyPopup = this.checkboxPushNotify.IsChecked ?? false;
this.ChangeUserSettingsRequested?.Invoke();
} }
this.ChangePasswordRequested?.Invoke(this.wpBoxOldPassword.Password, this.wpBoxNewPassword.Password);
} }
private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e) private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
@ -77,9 +84,12 @@ namespace BreCalClient
{ {
this.textBoxUserEmail.Text = LoginResult.UserEmail; this.textBoxUserEmail.Text = LoginResult.UserEmail;
this.textBoxUserPhone.Text = LoginResult.UserPhone; this.textBoxUserPhone.Text = LoginResult.UserPhone;
this.checkboxEMailNotify.IsChecked = LoginResult.NotifyEmail;
this.checkboxPushNotify.IsChecked = LoginResult.NotifyPopup;
} }
} }
#endregion #endregion
} }
} }

View File

@ -324,11 +324,7 @@ namespace BreCalClient
{ {
UserDetails ud = new() UserDetails ud = new()
{ {
Id = _loginResult.Id, Id = _loginResult.Id,
FirstName = _loginResult.FirstName,
LastName = _loginResult.LastName,
UserPhone = _loginResult.UserPhone,
UserEmail = _loginResult.UserEmail,
OldPassword = oldPw, OldPassword = oldPw,
NewPassword = newPw NewPassword = newPw
}; };
@ -346,6 +342,36 @@ namespace BreCalClient
} }
} }
}; };
ad.ChangeUserSettingsRequested += async () =>
{
if (_loginResult != null)
{
UserDetails ud = new()
{
Id = _loginResult.Id,
FirstName = _loginResult.FirstName,
LastName = _loginResult.LastName,
UserPhone = _loginResult.UserPhone,
UserEmail = _loginResult.UserEmail,
NotifyEmail = _loginResult.NotifyEmail,
NotifyPopup = _loginResult.NotifyPopup,
NotifySignal = _loginResult.NotifySignal,
NotifyWhatsapp = _loginResult.NotifyWhatsapp
};
try
{
await _userApi.UserUpdateAsync(ud);
MessageBox.Show(BreCalClient.Resources.Resources.textInformationUpdated, BreCalClient.Resources.Resources.textConfirmation, MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
this.Dispatcher.Invoke(new Action(() =>
{
ShowErrorDialog(ex.Message, "Error saving user information");
}));
}
}
};
ad.ShowDialog(); ad.ShowDialog();
} }

View File

@ -776,6 +776,15 @@ namespace BreCalClient.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Information successfully updated.
/// </summary>
public static string textInformationUpdated {
get {
return ResourceManager.GetString("textInformationUpdated", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Interval. /// Looks up a localized string similar to Interval.
/// </summary> /// </summary>
@ -875,6 +884,33 @@ namespace BreCalClient.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Notifications.
/// </summary>
public static string textNotifications {
get {
return ResourceManager.GetString("textNotifications", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Notify by e-mail.
/// </summary>
public static string textNotifyEmail {
get {
return ResourceManager.GetString("textNotifyEmail", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Notify by push notification in app.
/// </summary>
public static string textNotifyPush {
get {
return ResourceManager.GetString("textNotifyPush", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Not rotated. /// Looks up a localized string similar to Not rotated.
/// </summary> /// </summary>

View File

@ -598,4 +598,16 @@
<data name="textHarbour" xml:space="preserve"> <data name="textHarbour" xml:space="preserve">
<value>Hafen</value> <value>Hafen</value>
</data> </data>
<data name="textInformationUpdated" xml:space="preserve">
<value>Einstellungen erfolgreich aktualisiert</value>
</data>
<data name="textNotifications" xml:space="preserve">
<value>Benachrichtigungen</value>
</data>
<data name="textNotifyEmail" xml:space="preserve">
<value>E-Mail Benachrichtigung</value>
</data>
<data name="textNotifyPush" xml:space="preserve">
<value>Banner / Push Benachrichtigung in App</value>
</data>
</root> </root>

View File

@ -601,4 +601,16 @@
<data name="textStartTimeMissing" xml:space="preserve"> <data name="textStartTimeMissing" xml:space="preserve">
<value>If an end time is set, a start time is also required</value> <value>If an end time is set, a start time is also required</value>
</data> </data>
<data name="textInformationUpdated" xml:space="preserve">
<value>Information successfully updated</value>
</data>
<data name="textNotifications" xml:space="preserve">
<value>Notifications</value>
</data>
<data name="textNotifyEmail" xml:space="preserve">
<value>Notify by e-mail</value>
</data>
<data name="textNotifyPush" xml:space="preserve">
<value>Notify by push notification in app</value>
</data>
</root> </root>

View File

@ -494,13 +494,14 @@ class UserSchema(Schema):
@validates("user_phone") @validates("user_phone")
def validate_user_phone(self, value): def validate_user_phone(self, value):
valid_characters = list(map(str,range(0,10)))+["+", " "] if value is not None:
if not all([v in valid_characters for v in value]): valid_characters = list(map(str,range(0,10)))+["+", " "]
raise ValidationError({"user_phone":f"one of the phone number values is not valid."}) if not all([v in valid_characters for v in value]):
raise ValidationError({"user_phone":f"one of the phone number values is not valid."})
@validates("user_email") @validates("user_email")
def validate_user_email(self, value): def validate_user_email(self, value):
if not "@" in value: if value is not None and not "@" in value:
raise ValidationError({"user_email":f"invalid email address"}) raise ValidationError({"user_email":f"invalid email address"})