Kaynağa Gözat

Zips & Cities from server

master
Flo Smilari 4 yıl önce
ebeveyn
işleme
d04ab42742

+ 70
- 17
Pages/Fundvelo/CaritasServiceFundVeloFoundKeyDataPage.razor Dosyayı Görüntüle

@@ -106,19 +106,36 @@
<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"></MatStringField>
</div>
<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="@I18n["PlaceOfDiscovery"]" Outlined="true" Required="true" type="text" @bind-Value="@bicycleGeoPosition.DisplayCity"
OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatStringField>
OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></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>
</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">
<div class="outlined">
<MatAutocompleteList TItem="ZipCity" FullWidth="true" Label="@getZipCityLbl()" Required="true" Items="@ZipCities" OnTextChanged="setZipCityValue" @bind-Value="SelectedZipCity" CustomStringSelector="@(i => i?.Zip_City)"
ShowClearButton="true" NumberOfElementsInPopup="6" @onkeydown="InputCursorHandler.OnKeyDownHandlerAsync">
<ItemTemplate>
<div>
<span>@context?.Zip_City</span>
</div>
</ItemTemplate>
</MatAutocompleteList>
</div>
</div>
}
<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">
<MatTextField Class="w-100 form-check-label italic" Label="@I18n["Latitude"]" Outlined="true" ReadOnly="true" @bind-Value="@bicycleGeoPosition.Latitude"
OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatTextField>
OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatTextField>
</div>
<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">
<MatTextField Class="w-100 form-check-label italic" Label="@I18n["Longitude"]" Outlined="true" ReadOnly="true" @bind-Value="@bicycleGeoPosition.Longitude"
OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatTextField>
OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatTextField>
</div>
</div>
</div>
@@ -127,7 +144,7 @@
<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-4-desktop">
<MatSelectValue Class="required" FullWidth="true" Outlined="true" Label="@I18n["Color"]" @bind-Value="selectedColor" Items="@Colors" ValueSelector="@(i=>i)"
@onkeydown="InputCursorHandler.OnKeyDownHandlerAsync">
@onkeydown="InputCursorHandler.OnKeyDownHandlerAsync">
<ItemTemplate>
<div>
<span class="btn-sm" style="background-color:@context.Code;
@@ -142,7 +159,7 @@
<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">
<div class="outlined">
<MatAutocompleteList TItem="Brand" FullWidth="true" Label="@I18n["Brand"]" Required="true" Items="@Brands" OnTextChanged="setBrandValue" @bind-Value="SelectedBrand" CustomStringSelector="@(i => i?.Bezeichnung)"
ShowClearButton="true" NumberOfElementsInPopup="6" @onkeydown="InputCursorHandler.OnKeyDownHandlerAsync">
ShowClearButton="true" NumberOfElementsInPopup="6" @onkeydown="InputCursorHandler.OnKeyDownHandlerAsync">
<ItemTemplate>
<div>
<span>@context?.Bezeichnung</span>
@@ -153,7 +170,7 @@
</div>
<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">
<MatSelectValue Class="required" FullWidth="true" Outlined="true" Label="@I18n["Type"]" @bind-Value="selectedBcType" Items="@BicycleTypes" ValueSelector="@(i=>i)"
@onkeydown="InputCursorHandler.OnKeyDownHandlerAsync">
@onkeydown="InputCursorHandler.OnKeyDownHandlerAsync">
<ItemTemplate>
<div>
<span>@context?.Bezeichnung</span>
@@ -164,19 +181,19 @@
<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">
<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="@I18n["FrameNumber"]" Outlined="true" type="text" @bind-Value="frameNumber"
OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatStringField>
OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatStringField>
</div>
</div>
<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">
<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="@I18n["Remark"]" Outlined="true" type="text" @bind-Value="remark"
OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatStringField>
OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatStringField>
</div>
</div>
<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">
<div>
<MatCheckbox @bind-Value="@abholadresseIsNotContact" Label="@I18n["AlternatePickupContact"]"
@onkeydown="InputCursorHandler.OnKeyDownHandlerAsync"></MatCheckbox>
@onkeydown="InputCursorHandler.OnKeyDownHandlerAsync"></MatCheckbox>
</div>
</div>
</div>
@@ -213,6 +230,18 @@
brandStringValue = value;
selectedBrand = null;
}
private string zipCityStringValue;
private ZipCity selectedZipCity;
private ZipCity SelectedZipCity {
get { return selectedZipCity; }
set { selectedZipCity = (value != null) ? value : new ZipCity(zipCityStringValue); }
}
private void setZipCityValue(string value) {
zipCityStringValue = value;
selectedZipCity = null;
}
private string frameNumber;
private string remark;
private bool abholadresseIsNotContact;
@@ -226,6 +255,7 @@
await GetColors();
await GetBicycleTypes();
await GetBrands();
await GetZipCities();
refreshGUIFromDto();
OnlineStatusProvider.AddOnlineStatusChangeCallBack(OnOnlineStatusChanged);
StateHasChanged();
@@ -272,6 +302,10 @@
await MasterDataService.GetBrands();
}
private async Task GetZipCities() {
await MasterDataService.GetZipCities();
}
private ColorItem[] Colors {
get => MasterDataService.Colors;
}
@@ -284,6 +318,11 @@
get => MasterDataService.Brands;
}
private ZipCity[] ZipCities {
get => MasterDataService.ZipCities;
}
private void Next() {
updateDtoFromGUI();
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
@@ -305,7 +344,11 @@
private string getAddressLbl() {
return I18n.GetString("Address") + " (" + I18n.GetString("PlaceOfDiscovery") + ")";
return I18n.GetString("Street") + " (" + I18n.GetString("PlaceOfDiscovery") + ")";
}
private string getZipCityLbl() {
return String.Format("{0} {1} ({2})", I18n.GetString("Zip"), I18n.GetString("City"), I18n.GetString("PlaceOfDiscovery"));
}
private async Task OnGatheringPicture(InputFileChangeEventArgs e) {
@@ -344,7 +387,12 @@
bicycleGeoPosition.City = report.GeographicInfo.Town;
bicycleGeoPosition.Latitude = report.GeographicInfo.Latitude;
bicycleGeoPosition.Longitude = report.GeographicInfo.Longitude;
bicycleGeoPosition.DisplayCity = await GetFormattedAddressZipAndTown(ReportDataProvider);
if (OnlineStatusProvider.Online) {
bicycleGeoPosition.DisplayCity = await GetFormattedAddressZipAndTown(ReportDataProvider);
} else {
setZipCityValue(report.GeographicInfo.Postcode + " " + report.GeographicInfo.Town);
SelectedZipCity = new ZipCity(zipCityStringValue);
}
imgUrl = report.FotoString;
selectedColor = Array.Find(Colors, color => color.Id == report.FarbeId);
selectedBrand = String.IsNullOrEmpty(report.NeueMarke) ? Array.Find(Brands, brand => brand.Id == report.MarkeId) : new Brand(-999, report.NeueMarke);
@@ -358,8 +406,13 @@
private void updateDtoFromGUI() {
FoundReport report = ReportDataProvider.GetFoundReport();
report.GeographicInfo.Address = bicycleGeoPosition.Address;
report.GeographicInfo.Postcode = bicycleGeoPosition.Zip;
report.GeographicInfo.Town = bicycleGeoPosition.City;
if (OnlineStatusProvider.Online) {
report.GeographicInfo.Postcode = bicycleGeoPosition.Zip;
report.GeographicInfo.Town = bicycleGeoPosition.City;
} else {
report.GeographicInfo.Postcode = SelectedZipCity.Zip;
report.GeographicInfo.Town = SelectedZipCity.City;
}
report.GeographicInfo.Latitude = bicycleGeoPosition.Latitude;
report.GeographicInfo.Longitude = bicycleGeoPosition.Longitude;
report.FotoString = imgUrl;

+ 10
- 10
Pages/Fundvelo/CaritasServiceFundVeloFoundKeyDataPage.razor.cs Dosyayı Görüntüle

@@ -162,22 +162,22 @@ namespace cwebplusApp.Pages {
!String.IsNullOrEmpty(this.bicycleGeoPosition.Zip) &&
!String.IsNullOrEmpty(this.bicycleGeoPosition.City)) {
LatLng geoPosition = await NominatimService.GetCoordinatesForAddress(bicycleGeoPosition.Address + ", " + bicycleGeoPosition.Zip + " " + bicycleGeoPosition.City);
this.bicycleGeoPosition.Latitude = geoPosition.Lat;
this.bicycleGeoPosition.Longitude = geoPosition.Lng;
await this.mapRef.SetZoom(16);
await this.mapRef.SetView(geoPosition);
MouseEvent mouseEvent = new MouseEvent();
mouseEvent.LatLng = geoPosition;
await AddBicycleMarkerOnClickPosition(mouseEvent);
if (geoPosition != null) {
this.bicycleGeoPosition.Latitude = geoPosition.Lat;
this.bicycleGeoPosition.Longitude = geoPosition.Lng;
await this.mapRef.SetZoom(16);
await this.mapRef.SetView(geoPosition);
MouseEvent mouseEvent = new MouseEvent();
mouseEvent.LatLng = geoPosition;
await AddBicycleMarkerOnClickPosition(mouseEvent);
}
}
}
private static string GetFormattedAddressZipAndTown(NominatimReverseAddress addressDto) {
string country_code = addressDto.address.country_code;
string zip = SplitAndGetFirstPostcode(addressDto.address.postcode);
string town = addressDto.address.city ?? addressDto.address.town ?? addressDto.address.village;
return (!String.IsNullOrEmpty(country_code) ? country_code.ToUpper() + "-" + zip + " " + town : zip + " " + town).TrimEnd();
return (zip + " " + town).TrimEnd();
}
private static string SplitAndGetFirstPostcode(string postcode) {

+ 1
- 1
Properties/launchSettings.json Dosyayı Görüntüle

@@ -24,7 +24,7 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"nativeDebugging": false,
"nativeDebugging": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"jsWebView2Debugging": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"

+ 2
- 2
Shared/Models/Fundvelo/Report.cs Dosyayı Görüntüle

@@ -4,9 +4,9 @@
public string Anrede { get; set; } // required
public string Vorname { get; set; } // required
public string Nachname { get; set; } // required
public string Mobile { get; set; }
public string Mobil { get; set; }
public string Telefon { get; set; }
public string Email { get; set; }
public string Mail { get; set; }
public int? TypId { get; set; } // required
public int? MarkeId { get; set; } // required
public int? FarbeId { get; set; } // required

+ 3
- 0
Shared/ResourceFiles/Resources.de.resx Dosyayı Görüntüle

@@ -528,6 +528,9 @@ Die KulturLegi wirkt dem entgegen indem sie Kultur-, Bildungs- und Sportangebote
<data name="Specifications" xml:space="preserve">
<value>Angaben</value>
</data>
<data name="Street" xml:space="preserve">
<value>Strasse</value>
</data>
<data name="Success.DeleteReport.Msg" xml:space="preserve">
<value>Die Meldung mit der ID {0:d} wurde erfolgreich gelöscht!</value>
</data>

+ 3
- 0
Shared/ResourceFiles/Resources.fr.resx Dosyayı Görüntüle

@@ -528,6 +528,9 @@ La KulturLegi s'attaque à ce problème en rendant les activités culturelles,
<data name="Specifications" xml:space="preserve">
<value>Description détaillée</value>
</data>
<data name="Street" xml:space="preserve">
<value>Rue</value>
</data>
<data name="Success.DeleteReport.Msg" xml:space="preserve">
<value>Le rapport avec l'ID {0:d} a été supprimé avec succès!</value>
</data>

+ 3
- 0
Shared/ResourceFiles/Resources.it.resx Dosyayı Görüntüle

@@ -528,6 +528,9 @@ La KulturLegi si oppone a questo rendendo le attività culturali, educative e sp
<data name="Specifications" xml:space="preserve">
<value>Descrizione dettagliata</value>
</data>
<data name="Street" xml:space="preserve">
<value>Via</value>
</data>
<data name="Success.DeleteReport.Msg" xml:space="preserve">
<value>Il rapporto con l'ID {0:d} è stato cancellato con successo!</value>
</data>

+ 3
- 0
Shared/ResourceFiles/Resources.resx Dosyayı Görüntüle

@@ -528,6 +528,9 @@ The KulturLegi counteracts this by making cultural, educational and sporting act
<data name="Specifications" xml:space="preserve">
<value>Specifications</value>
</data>
<data name="Street" xml:space="preserve">
<value>Street</value>
</data>
<data name="Success.DeleteReport.Msg" xml:space="preserve">
<value>The Report with ID {0:d} was successfully deleted!</value>
</data>

+ 1
- 1
Shared/Services/Fundvelo/BicycleRestService.cs Dosyayı Görüntüle

@@ -107,7 +107,7 @@ namespace cwebplusApp.Shared.Services {
if (httpResult.StatusCode == System.Net.HttpStatusCode.OK) {
string[] zipCitiesStr = JsonConvert.DeserializeObject<string[]>(await httpResult.Content.ReadAsStringAsync());
List<ZipCity> zipCities = new ();
List<ZipCity> zipCities = new();
for (int i = 0; i < zipCitiesStr.Length; i++) {
zipCities.Add(new ZipCity(zipCitiesStr[i]));
}

+ 41
- 0
Shared/Services/Fundvelo/MasterDataService.cs Dosyayı Görüntüle

@@ -24,6 +24,7 @@ namespace cwebplusApp.Shared.Services {
private bool initializedBcTypes;
private bool initializedBrands;
private bool initializedSearchServices;
private bool initializedZipCities;
private ColorItem[] colors;
private BicycleType[] bicycleTypes;
private Brand[] brands;
@@ -42,6 +43,10 @@ namespace cwebplusApp.Shared.Services {
get => this.brands;
}
public ZipCity[] ZipCities {
get => this.zipCities;
}
public SearchService[] SearchServices {
get => this.searchServices;
}
@@ -147,6 +152,15 @@ namespace cwebplusApp.Shared.Services {
return SearchServices;
}
public async Task<ZipCity[]> GetZipCities() {
ZipCity[] _zipCities = await GetZipCitiesFromStorage();
if (_zipCities != null && _zipCities.Length > 0) {
this.zipCities = _zipCities;
}
this.zipCities = SortZipCities(new List<ZipCity>(this.zipCities)).ToArray();
return ZipCities;
}
// This method is called from BlazorRegisterStorageEvent when the storage changed
[JSInvokable]
public void OnStorageUpdated(string key) {
@@ -251,6 +265,27 @@ namespace cwebplusApp.Shared.Services {
return result;
}
private async ValueTask<ZipCity[]> GetZipCitiesFromStorage() {
// Register the Storage event handler. This handler calls OnStorageUpdated when the storage changed.
// This way, you can reload the settings when another instance of the application (tab / window) save the settings
if (!this.initializedZipCities) {
// Create a reference to the current object, so the JS function can call the public method "OnStorageUpdated"
var reference = DotNetObjectReference.Create(this);
await jsRuntime.InvokeVoidAsync("BlazorRegisterStorageEvent", reference);
this.initializedZipCities = true;
}
// Read the JSON string that contains the data from the local storage
ZipCity[] result;
var str = await jsRuntime.InvokeAsync<string>("BlazorGetLocalStorage", KeyNameZipCities);
if (String.IsNullOrEmpty(str)) {
result = Array.Empty<ZipCity>();
} else {
result = JsonConvert.DeserializeObject<ZipCity[]>(str) ?? Array.Empty<ZipCity>();
}
return result;
}
private async Task SaveColorsToStorage(ColorItem[] colors) {
var json = JsonConvert.SerializeObject(colors);
@@ -296,5 +331,11 @@ namespace cwebplusApp.Shared.Services {
searchServices.Sort(delegate (SearchService ss1, SearchService ss2) { return ss1.Id == 0 ? -1 : ss2.Id == 0 ? 1 : ss1.Bezeichnung.CompareTo(ss2.Bezeichnung); });
return searchServices;
}
private static List<ZipCity> SortZipCities(List<ZipCity> zipCities) {
int v = int.Parse("22");
zipCities.Sort(delegate (ZipCity zc1, ZipCity zc2) { return int.Parse(zc1.Zip).CompareTo(int.Parse(zc2.Zip)); });
return zipCities;
}
}
}

+ 1
- 3
Shared/Services/PermissionsProvider.cs Dosyayı Görüntüle

@@ -1,6 +1,4 @@
using Microsoft.JSInterop;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace cwebplusApp.Shared.Services {
@@ -26,7 +24,7 @@ namespace cwebplusApp.Shared.Services {
}
private async Task<bool> GeoLocationAllowed() {
string result = "";
string result = "";
var dotNetObjRef = DotNetObjectReference.Create(this);
result = await JSRuntime.InvokeAsync<string>("IsGeoLocationAllowed", dotNetObjRef);
this.IsGeoLocationAllowed = result.Equals("granted") || result.Equals("prompt");

+ 5
- 5
Shared/Services/UserDataProvider.cs Dosyayı Görüntüle

@@ -59,8 +59,8 @@ namespace cwebplusApp.Shared.Services {
userData.Firstname = report.Vorname;
userData.Lastname = report.Nachname;
userData.Phone = report.Telefon;
userData.Mobile = report.Mobile;
userData.Email = report.Email;
userData.Mobile = report.Mobil;
userData.Email = report.Mail;
}
public static void MapReport(Report report, UserData userData) {
@@ -68,8 +68,8 @@ namespace cwebplusApp.Shared.Services {
report.Vorname = userData.Firstname;
report.Nachname = userData.Lastname;
report.Telefon = userData.Phone;
report.Mobile = userData.Mobile;
report.Email = userData.Email;
report.Mobil = userData.Mobile;
report.Mail = userData.Email;
}
public static void MapReport(Report report, char Salutation, string Firstname, string Lastname, string Phone) {
@@ -87,7 +87,7 @@ namespace cwebplusApp.Shared.Services {
report.PersonOrt = userData.City;
report.PersonPLZ = userData.Zip;
report.PersonStrasse = userData.Address;
report.Mobile = userData.Phone;
report.Mobil = userData.Phone;
report.Mail = userData.Email;
}

+ 2
- 1
wwwroot/css/app.css Dosyayı Görüntüle

@@ -190,11 +190,12 @@ div.outlined input.mat-text-field-input {
}
div.outlined .mdc-text-field.mdc-text-field--fullwidth .mdc-floating-label.mdc-floating-label--float-above {
transform: translateY(-172%) translateX(-8%) scale(0.75);
transform: translateY(-172%) translateX(-2%) scale(0.75);
background-color: white;
z-index: 2;
min-width: 60px;
text-align: center;
padding: 0px 8px;
}
.mat-autocomplete-list-popup {

Loading…
İptal
Kaydet