Skip to content

Commit

Permalink
Update edit window error messages on property change.
Browse files Browse the repository at this point in the history
Closes #164.
  • Loading branch information
pvginkel committed Dec 10, 2023
1 parent aeabd37 commit 8142955
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 32 deletions.
6 changes: 3 additions & 3 deletions src/Tql.App/ConfigurationUI/PackageSourceEditWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
<Label
Content="{x:Static app:Labels.PackageSourceEditWindow_URLLabel}" />
<TextBox
Text="{Binding Url}"
Text="{Binding Url, UpdateSourceTrigger=PropertyChanged}"
Grid.Column="1"
Margin="3" />

<Label
Content="{x:Static app:Labels.PackageSourceEditWindow_UserNameLabel}"
Grid.Row="1" />
<TextBox
Text="{Binding UserName}"
Text="{Binding UserName, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="1"
Grid.Column="1"
Margin="3" />
Expand All @@ -52,7 +52,7 @@
Content="{x:Static app:Labels.PackageSourceEditWindow_PasswordLabel}"
Grid.Row="2" />
<PasswordBox
utilities:PasswordBoxHelper.BoundPassword="{Binding Password, Mode=TwoWay}"
utilities:PasswordBoxHelper.BoundPassword="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="2"
Grid.Column="1"
Margin="3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@

<Label Content="{x:Static app:Labels.ConnectionEditWindow_NameLabel}" />
<TextBox
Text="{Binding Name}"
Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}"
Grid.Column="1"
Margin="3" />

<Label
Content="{x:Static app:Labels.ConnectionEditWindow_TenantIDLabel}"
Grid.Row="1" />
<TextBox
Text="{Binding TenantId}"
Text="{Binding TenantId, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="1"
Grid.Column="1"
Margin="3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public ConnectionDto(Guid id)
AddProperty(
nameof(Url),
p => ValidateNotEmpty(p) ?? ValidateUrl(p),
p => CoerceUrlEndsInSlash(CoerceEmptyStringToNull(p))
CoerceEmptyStringToNull
);
AddProperty(nameof(PATToken), ValidateNotEmpty, CoerceEmptyStringToNull);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@

<Label Content="{x:Static app:Labels.ConnectionEditWindow_NameLabel}" />
<TextBox
Text="{Binding Name}"
Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}"
Grid.Column="1"
Margin="3" />

<Label
Content="{x:Static app:Labels.ConnectionEditWindow_URLLabel}"
Grid.Row="1" />
<TextBox
Text="{Binding Url}"
Text="{Binding Url, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="1"
Grid.Column="1"
Margin="3" />
Expand All @@ -58,7 +58,7 @@
Content="{x:Static app:Labels.ConnectionEditWindow_PATTokenLabel}"
Grid.Row="3" />
<PasswordBox
utilities:PasswordBoxHelper.BoundPassword="{Binding PATToken, Mode=TwoWay}"
utilities:PasswordBoxHelper.BoundPassword="{Binding PATToken, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="3"
Grid.Column="1"
Margin="3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public ConnectionEditWindow(IUI ui)

private void _acceptButton_Click(object sender, RoutedEventArgs e)
{
var dto = (ConnectionDto)DataContext;
if (!dto.Url!.EndsWith("/"))
dto.Url += "/";

DialogResult = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public ConnectionDto(Guid id)
AddProperty(
nameof(Url),
p => ValidateNotEmpty(p) ?? ValidateUrl(p),
p => CoerceUrlEndsInSlash(CoerceEmptyStringToNull(p))
CoerceEmptyStringToNull
);
AddProperty(nameof(UserName), ValidateNotEmpty, CoerceEmptyStringToNull);
AddProperty(nameof(Password), ValidateNotEmpty, CoerceEmptyStringToNull);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@

<Label Content="{x:Static app:Labels.ConnectionEditWindow_NameLabel}" />
<TextBox
Text="{Binding Name}"
Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}"
Grid.Column="1"
Margin="3" />

<Label
Content="{x:Static app:Labels.ConnectionEditWindow_URLLabel}"
Grid.Row="1" />
<TextBox
Text="{Binding Url}"
Text="{Binding Url, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="1"
Grid.Column="1"
Margin="3" />
Expand All @@ -59,7 +59,7 @@
Content="{x:Static app:Labels.ConnectionEditWindow_UserNameLabel}"
Grid.Row="3" />
<TextBox
Text="{Binding UserName}"
Text="{Binding UserName, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="3"
Grid.Column="1"
Margin="3" />
Expand All @@ -68,7 +68,7 @@
Content="{x:Static app:Labels.ConnectionEditWindow_PasswordLabel}"
Grid.Row="4" />
<PasswordBox
utilities:PasswordBoxHelper.BoundPassword="{Binding Password, Mode=TwoWay}"
utilities:PasswordBoxHelper.BoundPassword="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="4"
Grid.Column="1"
Margin="3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public ConnectionEditWindow(IUI ui)

private void _acceptButton_Click(object sender, RoutedEventArgs e)
{
var dto = (ConnectionDto)DataContext;
if (!dto.Url!.EndsWith("/"))
dto.Url += "/";

DialogResult = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<Label Content="{x:Static app:Labels.ConnectionEditWindow_NameLabel}" />
<TextBox
Text="{Binding Name}"
Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}"
Grid.Column="1"
Margin="3" />

Expand Down
2 changes: 1 addition & 1 deletion src/Tql.Plugins.Jira/ConfigurationUI/ConfigurationDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public ConnectionDto(Guid id)
AddProperty(
nameof(Url),
p => ValidateNotEmpty(p) ?? ValidateUrl(p),
p => CoerceUrlEndsInSlash(CoerceEmptyStringToNull(p))
CoerceEmptyStringToNull
);
AddProperty(nameof(UserName), ValidateNotEmpty, CoerceEmptyStringToNull);
AddProperty(nameof(Password), ValidateNotEmpty, CoerceEmptyStringToNull);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@

<Label Content="{x:Static app:Labels.ConnectionEditWindow_NameLabel}" />
<TextBox
Text="{Binding Name}"
Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}"
Grid.Column="1"
Margin="3" />

<Label
Content="{x:Static app:Labels.ConnectionEditWindow_URLLabel}"
Grid.Row="1" />
<TextBox
Text="{Binding Url}"
Text="{Binding Url, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="1"
Grid.Column="1"
Margin="3" />
Expand All @@ -59,7 +59,7 @@
Content="{x:Static app:Labels.ConnectionEditWindow_UserNameLabel}"
Grid.Row="3" />
<TextBox
Text="{Binding UserName}"
Text="{Binding UserName, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="3"
Grid.Column="1"
Margin="3" />
Expand All @@ -68,7 +68,7 @@
Content="{x:Static app:Labels.ConnectionEditWindow_PasswordLabel}"
Grid.Row="4" />
<PasswordBox
utilities:PasswordBoxHelper.BoundPassword="{Binding Password, Mode=TwoWay}"
utilities:PasswordBoxHelper.BoundPassword="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="4"
Grid.Column="1"
Margin="3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public ConnectionEditWindow(IUI ui)

private void _acceptButton_Click(object sender, RoutedEventArgs e)
{
var dto = (ConnectionDto)DataContext;
if (!dto.Url!.EndsWith("/"))
dto.Url += "/";

DialogResult = true;
}

Expand Down
12 changes: 0 additions & 12 deletions src/Tql.Utilities/DtoBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,6 @@ protected void AddProperty(
protected object? CoerceEmptyStringToNull(object? value) =>
string.Empty.Equals(value) ? null : value;

/// <summary>
/// Utility method to ensure that URLs end in a slash.
/// </summary>
/// <param name="value">Value to coerce.</param>
/// <returns>Coerced value.</returns>
protected object? CoerceUrlEndsInSlash(object? value)
{
if (value is string stringValue && !stringValue.IsEmpty() && !stringValue.EndsWith('/'))
return stringValue + "/";
return value;
}

/// <summary>
/// Gets the value of a property.
/// </summary>
Expand Down

0 comments on commit 8142955

Please sign in to comment.