PWA Fundvelo der Caritas.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

CaritasServiceFundVeloAlternatePickupContactPage.razor 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. @page "/fundvelo/alternate_pickup"
  2. @using cwebplusApp.Shared.Models;
  3. @using cwebplusApp.Shared.Services;
  4. @inject NavigationManager NavigationManager
  5. @inject UserDataProvider UserDataProvider
  6. @inject IStringLocalizer<Resources> I18n
  7. @inject PageHistoryManager PageHistoryManager
  8. @inject ReportDataProvider ReportDataProvider
  9. @inject Toaster Toaster
  10. @inject InputCursorHandler InputCursorHandler
  11. @inject MasterDataService MasterDataService
  12. <div class="row px-3 h-100">
  13. @*<div class="row no-gutters align-items-start justify-content-center w-100">
  14. <MatHeadline4 Style="font-family:Ubuntu;padding-top:1em">@I18n["PickupContact"]</MatHeadline4>
  15. </div>*@
  16. <div class="row no-gutters align-items-center justify-content-center w-100" style="padding-top:1em">
  17. <h2>@I18n["PickupContact"]</h2>
  18. </div>
  19. <div class="row no-gutters align-items-start w-100">
  20. <div class="row no-gutters w-100">
  21. <div class="col-12">
  22. <MatSelect Class="w-100 required" Label="@I18n["Salutation"]" Outlined="true" @bind-Value="pucSalutation" Required="true" Style="margin-bottom: 0.5rem"
  23. @onkeydown="InputCursorHandler.OnKeyDownHandlerAsync">
  24. <MatOptionString Value="M">@I18n["Male"]</MatOptionString>
  25. <MatOptionString Value="F">@I18n["Female"]</MatOptionString>
  26. </MatSelect>
  27. </div>
  28. </div>
  29. <div class="row no-gutters w-100">
  30. <div class="col-6" style="padding-right:0.5em">
  31. <MatStringField Class="w-100" Label="@I18n["Firstname"]" Outlined="true" type="text" @bind-Value="pucFirstname" Required="true"
  32. OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatStringField>
  33. </div>
  34. <div class="col-6" style="padding-left:0.5em">
  35. <MatStringField Class="w-100" Label="@I18n["Lastname"]" Outlined="true" type="text" @bind-Value="pucLastname" Required="true"
  36. OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatStringField>
  37. </div>
  38. </div>
  39. <div class="row no-gutters align-items-center w-100">
  40. <div class="col-12">
  41. <MatStringField Class="w-100" Label="@I18n["Address"]" Outlined="true" type="text" @bind-Value="pucAddress" Required="true"
  42. OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatStringField>
  43. </div>
  44. </div>
  45. <div class="row no-gutters align-items-center w-100">
  46. <div class="col-12">
  47. <div class="outlined">
  48. <MatAutocompleteList TItem="ZipCity" FullWidth="true" Label="@getZipCityLbl()" Required="true" Items="@ZipCities" OnTextChanged="setZipCityValue" @bind-Value="SelectedZipCity" CustomStringSelector="@(i => i?.Zip_City)"
  49. ShowClearButton="true" NumberOfElementsInPopup="6" @onkeydown="InputCursorHandler.OnKeyDownHandlerAsync">
  50. <ItemTemplate>
  51. <div>
  52. <span>@context?.Zip_City</span>
  53. </div>
  54. </ItemTemplate>
  55. </MatAutocompleteList>
  56. </div>
  57. </div>
  58. </div>
  59. @*<div class="row no-gutters align-items-center w-100">
  60. <div class="col-4" style="padding-right:0.5em">
  61. <MatStringField Class="w-100" Label="@I18n["Zip"]" Outlined="true" type="text" @bind-Value="pucZip" Required="true"
  62. OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatStringField>
  63. </div>
  64. <div class="col-8" style="padding-left:0.5em">
  65. <MatStringField Class="w-100" Label="@I18n["City"]" Outlined="true" type="text" @bind-Value="pucCity" Required="true"
  66. OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatStringField>
  67. </div>
  68. </div>*@
  69. <div class="row no-gutters align-items-center w-100">
  70. <div class="col-12">
  71. <MatStringField Class="w-100" Label="@I18n["Mobile"]" Outlined="true" type="text" @bind-Value="pucMobile"
  72. OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatStringField>
  73. </div>
  74. </div>
  75. <div class="row no-gutters align-items-center w-100">
  76. <div class="col-12">
  77. <MatStringField Class="w-100" Label="@I18n["Phone"]" Outlined="true" type="text" @bind-Value="pucPhone"
  78. OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatStringField>
  79. </div>
  80. </div>
  81. <div class="row no-gutters align-items-center w-100">
  82. <div class="col-12">
  83. <MatStringField Class="w-100" Label="@I18n["Mail"]" Outlined="true" type="text" @bind-Value="pucEmail"
  84. OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync"></MatStringField>
  85. </div>
  86. </div>
  87. </div>
  88. <div class="row no-gutters align-items-end justify-content-center w-100" style="padding-bottom:2em">
  89. <div class="col" style="padding-right:0.5em">
  90. <MatButton Class="w-100" Outlined="true" @onclick="Cancel">@I18n["Cancel"]</MatButton>
  91. </div>
  92. <div class="col" style="padding-left:0.5em">
  93. <MatButton Class="w-100" Raised="true" @onclick="Next">@I18n["Continue"]</MatButton>
  94. </div>
  95. </div>
  96. </div>
  97. @code {
  98. private string pucSalutation;
  99. private string pucFirstname;
  100. private string pucLastname;
  101. private string pucAddress;
  102. //private string pucZip;
  103. //private string pucCity;
  104. private string pucMobile;
  105. private string pucPhone;
  106. private string pucEmail;
  107. private string pucZipCityStringValue;
  108. private ZipCity selectedZipCity;
  109. private ZipCity SelectedZipCity {
  110. get { return selectedZipCity; }
  111. set { selectedZipCity = (value != null) ? value : new ZipCity(pucZipCityStringValue); }
  112. }
  113. private void setZipCityValue(string value) {
  114. pucZipCityStringValue = value;
  115. selectedZipCity = null;
  116. }
  117. private ZipCity[] ZipCities {
  118. get => MasterDataService.ZipCities;
  119. }
  120. protected override void OnInitialized() {
  121. base.OnInitialized();
  122. PageHistoryManager.OnBeforeNavigateBack = new EventCallback(this, (Action)OnBeforeNavigateBack);
  123. refreshGUIFromDto();
  124. StateHasChanged();
  125. }
  126. private void OnBeforeNavigateBack() {
  127. updateDtoFromGUI();
  128. }
  129. private void Next() {
  130. updateDtoFromGUI();
  131. PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
  132. try {
  133. Validator.ValidateAlternatePickContact(ReportDataProvider.GetFoundReport());
  134. NavigationManager.NavigateTo("fundvelo/account/Found");
  135. } catch (ArgumentException) {
  136. Toaster.ShowWarning(I18n.GetString("Warning.MandatoryFields.Title"), I18n.GetString("Warning.MandatoryFields.Msg"));
  137. }
  138. }
  139. private void Cancel() {
  140. NavigationManager.NavigateTo("caritas_services");
  141. }
  142. private string getZipCityLbl() {
  143. return String.Format("{0} {1} ({2})", I18n.GetString("Zip"), I18n.GetString("City"), I18n.GetString("PlaceOfDiscovery"));
  144. }
  145. private void refreshGUIFromDto() {
  146. FoundReport report = ReportDataProvider.GetFoundReport();
  147. pucSalutation = report.AbholAnrede;
  148. pucFirstname = report.AbholVorname;
  149. pucLastname = report.AbholNachname;
  150. pucAddress = report.AbholStrasse;
  151. //pucZip = report.AbholPLZ;
  152. //pucCity = report.AbholOrt;
  153. setZipCityValue(getZipCityFromReport(report));
  154. SelectedZipCity = Array.Find(ZipCities, zipCity => (zipCity.Zip.Equals(report.AbholPLZ) && zipCity.City.Equals(report.AbholOrt)));
  155. pucMobile = report.AbholMobil;
  156. pucPhone = report.AbholTelefon;
  157. pucEmail = report.AbholMail;
  158. }
  159. private void updateDtoFromGUI() {
  160. FoundReport report = ReportDataProvider.GetFoundReport();
  161. report.AbholAnrede = pucSalutation;
  162. report.AbholVorname = pucFirstname;
  163. report.AbholNachname = pucLastname;
  164. report.AbholStrasse = pucAddress;
  165. //report.AbholPLZ = pucZip;
  166. //report.AbholOrt = pucCity;
  167. report.AbholPLZ = SelectedZipCity.Zip;
  168. report.AbholOrt = SelectedZipCity.City;
  169. report.AbholMobil = pucMobile;
  170. report.AbholTelefon = pucPhone;
  171. report.AbholMail = pucEmail;
  172. }
  173. private String getZipCityFromReport(FoundReport report) {
  174. return report.AbholPLZ + (!String.IsNullOrEmpty(report.AbholOrt)? " " + report.AbholOrt: "");
  175. }
  176. }