Helpers: Add Normalizer to normalize street names in addresses

This commit is contained in:
2026-09-29 19:04:12 +02:00
parent d8126e254d
commit fda337c3cb
9 changed files with 3193 additions and 8 deletions
+9 -1
View File
@@ -434,7 +434,7 @@ namespace Elwig.Windows {
UpdateButtons();
}
protected void TextBox_TextChanged(object sender, RoutedEventArgs? evt) {
protected void TextBox_TextChanged(object sender, TextChangedEventArgs? evt) {
var input = (Control)sender;
var tb = input as TextBox;
if (SenderIsRequired(input) && tb?.Text.Length == 0) {
@@ -603,5 +603,13 @@ namespace Elwig.Windows {
protected void AreaComTypeDetailsButton_Click(object sender, RoutedEventArgs? evt) {
App.FocusBaseDataAreaComType();
}
protected void AddressInput_TextChanged(object sender, TextChangedEventArgs? evt) {
if ((IsCreating || IsEditing) && sender is TextBox b) {
InputTextChanged(b, (i, r) => Validator.CheckAddress(i, r));
} else {
TextBox_TextChanged(sender, evt);
}
}
}
}
+1 -1
View File
@@ -90,7 +90,7 @@
<Label Content="Adresse:"
VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="0" Margin="10,160,0,10"/>
<TextBox x:Name="ClientAddressInput"
TextChanged="TextBox_TextChanged"
TextChanged="AddressInput_TextChanged"
VerticalAlignment="Top" HorizontalAlignment="Stretch" Grid.Column="1" Margin="0,160,10,10"/>
<Label Content="PLZ/Ort:"
+4 -2
View File
@@ -371,7 +371,7 @@
<Label Content="Adresse:" Margin="10,130,0,0"/>
<TextBox x:Name="AddressInput" Text="{Binding Address, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Margin="0,130,10,0" Grid.Column="1" Grid.ColumnSpan="3"
TextChanged="TextBox_TextChanged"/>
TextChanged="AddressInput_TextChanged"/>
<Label Content="PLZ/Ort:" Margin="10,160,0,0" Grid.Column="0"/>
<TextBox x:Name="PlzInput" Margin="0,160,0,0" Text="{Binding PlzString, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
@@ -379,6 +379,7 @@
TextChanged="PlzInput_TextChanged" LostFocus="PlzInput_LostFocus" Tag="PLZ"/>
<ComboBox x:Name="OrtInput" SelectedItem="{Binding Ort, Mode=TwoWay}" ItemsSource="{Binding OrtSource, Mode=TwoWay}"
ItemTemplate="{StaticResource PostalDestTemplate}" TextSearch.TextPath="Ort.Name"
SelectionChanged="OrtInput_SelectionChanged"
Margin="47,160,10,0" Grid.Column="1" Grid.ColumnSpan="3"/>
</Grid>
</GroupBox>
@@ -603,7 +604,7 @@
<Label Content="Adresse:" Margin="10,40,0,0" Grid.Column="0"/>
<TextBox x:Name="BillingAddressInput" Text="{Binding BillingAddress, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Margin="0,40,10,0" Grid.Column="1"
TextChanged="TextBox_TextChanged"/>
TextChanged="AddressInput_TextChanged"/>
<Label Content="PLZ/Ort:" Margin="10,70,0,0" Grid.Column="0"/>
<TextBox x:Name="BillingPlzInput" Text="{Binding BillingPlzString, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
@@ -611,6 +612,7 @@
TextChanged="PlzInput_TextChanged" LostFocus="PlzInput_LostFocus" Tag="PLZ"/>
<ComboBox x:Name="BillingOrtInput" SelectedItem="{Binding BillingOrt, Mode=TwoWay}" ItemsSource="{Binding BillingOrtSource, Mode=TwoWay}"
ItemTemplate="{StaticResource PostalDestTemplate}" TextSearch.TextPath="Ort.Name"
SelectionChanged="OrtInput_SelectionChanged"
Margin="47,70,10,0" Grid.Column="1"/>
</Grid>
</GroupBox>
+18
View File
@@ -1008,5 +1008,23 @@ namespace Elwig.Windows {
ValidateRequiredInputs();
UpdateButtons();
}
new protected void AddressInput_TextChanged(object sender, TextChangedEventArgs? evt) {
if ((IsCreating || IsEditing) && sender is TextBox b) {
InputTextChanged(b, (i, r) => Validator.CheckAddress(i, r, b == BillingAddressInput ? ViewModel.BillingOrt?.Ort.Name : ViewModel.Ort?.Ort.Name));
} else {
TextBox_TextChanged(sender, evt);
}
}
private void OrtInput_SelectionChanged(object sender, SelectionChangedEventArgs? evt) {
if (!IsCreating && !IsEditing)
return;
if (sender == BillingOrtInput) {
InputTextChanged(BillingAddressInput, (i, r) => Validator.CheckAddress(i, r, ViewModel.BillingOrt?.Ort.Name));
} else {
InputTextChanged(AddressInput, (i, r) => Validator.CheckAddress(i, r, ViewModel.Ort?.Ort.Name));
}
}
}
}