Quellcode durchsuchen

Recalculate bycicle postion on focus lost of address fields

master
Flo Smilari vor 4 Jahren
Ursprung
Commit
f16ef7464c

+ 15
- 6
Pages/Fundvelo/CaritasServiceFundVeloFoundKeyDataPage.razor Datei anzeigen

@@ -109,13 +109,15 @@
<div class="mat-layout-grid-inner">
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-4-tablet mat-layout-grid-cell-span-12-desktop">
<MatStringField Class="w-100 form-check-label" Label="@getAddressLbl()" Outlined="true" Required="true" Type="text" @bind-Value="@bicycleGeoPosition.Address"
OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync" maxlength="50"></MatStringField>
OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync" maxlength="50"
OnFocusOut="@TransformAdressToDeviceMapLocation"></MatStringField>
</div>
@if (OnlineStatusProvider.Online) {
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-4-tablet mat-layout-grid-cell-span-12-desktop">
<MatStringField Class="w-100 form-check-label" Label="@getZipCityLbl()" Outlined="true" Required="true" type="text" @bind-Value="@bicycleGeoPosition.DisplayCity"
OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatStringField>
OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"
OnFocusOut="@TransformAdressToDeviceMapLocation"></MatStringField>
</div>
} else {
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-4-tablet mat-layout-grid-cell-span-4-desktop">
@@ -259,7 +261,7 @@
await GetBicycleTypes();
await GetBrands();
await GetZipCities();
refreshGUIFromDto();
RefreshGUIFromDto();
OnlineStatusProvider.AddOnlineStatusChangeCallBack(OnOnlineStatusChanged);
StateHasChanged();
}
@@ -327,7 +329,7 @@
private void Next() {
updateDtoFromGUI();
UpdateDtoFromGUI();
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
try {
Validator.ValidateFoundReportKeyData(ReportDataProvider.GetFoundReport());
@@ -383,7 +385,7 @@
}
}
private async void refreshGUIFromDto() {
private async void RefreshGUIFromDto() {
FoundReport report = ReportDataProvider.GetFoundReport();
bicycleGeoPosition.Address = report.GeographicInfo.Address;
bicycleGeoPosition.Zip = report.GeographicInfo.Postcode;
@@ -406,7 +408,7 @@
StateHasChanged();
}
private void updateDtoFromGUI() {
private void UpdateDtoFromGUI() {
FoundReport report = ReportDataProvider.GetFoundReport();
report.GeographicInfo.Address = bicycleGeoPosition.Address;
if (OnlineStatusProvider.Online) {
@@ -433,4 +435,11 @@
report.Bemerkung = remark;
report.AbholadresseIstKontakt = !abholadresseIsNotContact;
}
private async void TransformAdressToDeviceMapLocation() {
bicycleGeoPosition.DisplayCity = bicycleGeoPosition.DisplayCity; // Hack, force a decode of zip and city
await ShowBicycleGeoLocation(true);
StateHasChanged();
}
}

+ 3
- 3
Pages/Fundvelo/CaritasServiceFundVeloFoundKeyDataPage.razor.cs Datei anzeigen

@@ -79,7 +79,7 @@ namespace cwebplusApp.Pages {
protected async Task InitializeBicycleMapPosition() {
CreateBicycleMarkerOptions();
await AddEventsToMap();
await ShowBicycleGeoLocation();
await ShowBicycleGeoLocation(false);
}
protected async Task<string> GetFormattedAddressZipAndTown(ReportDataProvider ReportDataProvider) {
@@ -153,8 +153,8 @@ namespace cwebplusApp.Pages {
return geoPosition;
}
private async Task ShowBicycleGeoLocation() {
if (this.bicycleGeoPosition.Latitude != 0 && this.bicycleGeoPosition.Longitude != 0) {
protected async Task ShowBicycleGeoLocation(bool forceRecalc) {
if (this.bicycleGeoPosition.Latitude != 0 && this.bicycleGeoPosition.Longitude != 0 && !forceRecalc) {
LatLng geoPosition = new(this.bicycleGeoPosition.Latitude, this.bicycleGeoPosition.Longitude);
await this.mapRef.SetZoom(16);
await this.mapRef.SetView(geoPosition);

+ 3
- 0
Shared/Models/Fundvelo/OSM/BicycleGeoPosition.cs Datei anzeigen

@@ -38,6 +38,9 @@ namespace cwebplusApp.Shared.Models {
} else if (tokens.Length == 2) {
Zip = tokens[0];
City = tokens[1];
} else {
Zip = null;
City = null;
}
}
}

Laden…
Abbrechen
Speichern