| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367 |
- @page "/fundvelo/keydata/Missing"
-
- @inherits CaritasServiceFundVeloKeyDataPageBase
-
- @using cwebplusApp.Shared.Models;
- @using cwebplusApp.Shared.Services;
- @using System.Globalization;
- @using Microsoft.AspNetCore.Components.Forms;
- @using System.IO;
-
- @inject NavigationManager NavigationManager
- @inject IStringLocalizer<Resources> I18n
- @inject PageHistoryManager PageHistoryManager
- @inject MasterDataService MasterDataService
- @inject Toaster Toaster
- @inject IJSRuntime JS
- @inject ReportDataProvider ReportDataProvider
- @inject InputCursorHandler InputCursorHandler;
-
- <div class="row px-3 h-100">
- <div class="row no-gutters align-items-center justify-content-center w-100" style="padding-top:1em">
- <h2>@I18n["MissingBike"]</h2>
- </div>
- <div class="row no-gutters align-items-center justify-content-center w-100">
- <div class="mat-layout-grid w-100">
- <div class="mat-layout-grid-inner">
- <div class="mat-layout-grid-cell mat-layout-grid-cell-span-1 justify-content-center" style="text-align: center">
- <div>
- <InputFile class="inputFile" id="camera" type="file" name="camera" accept="image/*" capture="environment" OnChange="@OnGatheringPicture" />
- <MatRipple class="inputfile-mat-ripple" Color="@MatRippleColor.Default">
- <label for="camera">
- <svg xmlns="http://www.w3.org/2000/svg" width="48px" height="48px" viewBox="0 0 24 24" fill="#000000">
- <path d="M0 0h21v21H0V0z" fill="none" />
- <path d="M20 6h-4.05l-1.83-2H9.88L8.05 6H4v12h16V6zm-8 11c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z" opacity=".3" />
- <path d="M4 20h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2zM4 6h4.05l1.83-2h4.24l1.83 2H20v12H4V6zm8 1c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zm0 8c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z" />
- </svg>
- </label>
- </MatRipple>
- </div>
- <div style="margin-top:1rem">
- <InputFile class="inputFile" id="file" type="file" name="file" accept="image/x-png,image/jpeg,image/gif" OnChange="@OnGatheringPicture" />
- <MatRipple class="inputfile-mat-ripple" Color="@MatRippleColor.Default">
- <label for="file">
- <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" width="48px" height="48px" viewBox="0 0 24 24" fill="#000000">
- <g><rect fill="none" height="24" width="24" /></g>
- <g>
- <g>
- <path d="M13,4H6v16h12V9h-5V4z M16,15h-3v4h-2v-4H8l4.01-4L16,15z" opacity=".3" />
- <path d="M14,2H6C4.9,2,4.01,2.9,4.01,4L4,20c0,1.1,0.89,2,1.99,2H18c1.1,0,2-0.9,2-2V8L14,2z M18,20H6V4h7v5h5V20z" />
- <polygon points="8,15 11,15 11,19 13,19 13,15 16,15 12.01,11" />
- </g>
- </g>
- </svg>
- </label>
- </MatRipple>
- </div>
- </div>
- <div class="mat-layout-grid-cell mat-layout-grid-cell-span-3">
- <div>
- <MatCard Id="bikePic" Class="fv-mat-card">
- <MatCardContent>
- <MatCardMedia Square="true" Class="" ImageUrl="@imgUrl">
- @if (loading) {
- <MatProgressCircle Indeterminate="true" Size="MatProgressCircleSize.Medium" />
- }
- </MatCardMedia>
- </MatCardContent>
- </MatCard>
- </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-8-desktop">
- <div class="mat-layout-grid-inner">
- <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-8-tablet mat-layout-grid-cell-span-12-desktop">
- <div class="mat-layout-grid-inner">
- <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-8-tablet mat-layout-grid-cell-span-6-desktop">
- <div class="mat-layout-grid-inner">
- <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-8-tablet mat-layout-grid-cell-span-12-desktop">
- <MatSelectValue Class="required" FullWidth="true" Outlined="true" Label="@I18n["Color"]" @bind-Value="selectedColor" Items="@Colors" ValueSelector="@(i=>i)"
- @onkeydown="InputCursorHandler.OnKeyDownHandlerAsync">
- <ItemTemplate>
- <div>
- <span class="btn-sm" style="background-color:@context.Code;
- display:initial;
- border:1px solid black;
- box-shadow:0.2em 0.2em 0.3em 0.025em #3f4244" />
- <span class="btn">@context?.Bezeichnung</span>
- </div>
- </ItemTemplate>
- </MatSelectValue>
- </div>
- <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-8-tablet mat-layout-grid-cell-span-12-desktop">
- <div class="outlined">
- <MatAutocompleteList TItem="Brand" FullWidth="true" Label="@I18n["Brand"]" Items="@Brands" OnTextChanged="setBrandValue" @bind-Value="SelectedBrand" CustomStringSelector="@(i => i?.Bezeichnung)" Required="true"
- @onkeydown="InputCursorHandler.OnKeyDownHandlerAsync">
- <ItemTemplate>
- <div>
- <span>@context?.Bezeichnung</span>
- </div>
- </ItemTemplate>
- </MatAutocompleteList>
- </div>
- </div>
- <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-8-tablet mat-layout-grid-cell-span-12-desktop">
- <MatSelectValue Class="required" FullWidth="true" Outlined="true" Label="@I18n["Type"]" @bind-Value="selectedBcType" Items="@BicycleTypes" ValueSelector="@(i=>i)"
- @onkeydown="InputCursorHandler.OnKeyDownHandlerAsync">
- <ItemTemplate>
- <div>
- <span>@context?.Bezeichnung</span>
- </div>
- </ItemTemplate>
- </MatSelectValue>
- </div>
- <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-8-tablet mat-layout-grid-cell-span-12-desktop">
- <MatStringField Class="w-100" Label="@I18n["FrameNumber"]" Outlined="true" type="text" @bind-Value="frameNumber"
- OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync" maxlength="20"></MatStringField>
- </div>
- </div>
- </div>
- <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-8-tablet mat-layout-grid-cell-span-6-desktop">
- <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">
- <MatNumericUpDownField Class="w-100" Label="@I18n["Age"]" Outlined="true" @bind-Value="@age"
- OnKeyDown="@InputCursorHandler.OnConstrainedFieldKeyDownHandlerAsync" pattern="^([0-9]*)$"></MatNumericUpDownField>
- </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">
- <MatNumericUpDownField Class="w-100" Label="@I18n["Price"]" Outlined="true" @bind-Value="@price"
- OnKeyDown="@InputCursorHandler.OnConstrainedFieldKeyDownHandlerAsync" pattern="^([0-9]{0,5})$"></MatNumericUpDownField>
- </div>
- <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-8-tablet mat-layout-grid-cell-span-12-desktop">
- <MatDatePicker Class="w-100" Label="@I18n["LastLocation.Date"]" Outlined="true" EnableTime="true" Enable24hours="true" EnableWeekNumbers="true" AllowInput="true"
- Maximum="@DateTime.Now" @bind-Value="lastLocationDateTime" @onkeydown="InputCursorHandler.OnKeyDownHandlerAsync">
- </MatDatePicker>
- </div>
- <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-8-tablet mat-layout-grid-cell-span-12-desktop">
- <MatStringField Class="w-100" Label="@I18n["LastLocation.Street"]" Outlined="true" type="text" @bind-Value="lastLocationStreet"
- OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync" maxlength="50"></MatStringField>
- </div>
- <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-8-tablet mat-layout-grid-cell-span-12-desktop">
- <div class="outlined">
- <MatAutocompleteList TItem="ZipCity" FullWidth="true" Label="@I18n["LastLocation.ZipCity"]" 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-8-tablet mat-layout-grid-cell-span-12-desktop">
- <MatSelectValue FullWidth="true" Outlined="true" Label="@I18n["SearchService"]" @bind-Value="selectedSearchService" Items="@SearchServices" ValueSelector="@(i=>i)"
- @onkeydown="InputCursorHandler.OnKeyDownHandlerAsync">
- <ItemTemplate>
- <div>
- <span>@context?.Bezeichnung</span>
- </div>
- </ItemTemplate>
- </MatSelectValue>
- </div>
-
- <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-8-tablet mat-layout-grid-cell-span-12-desktop">
- <MatStringField Class="w-100" Label="@I18n["SearchServiceNbr"]" Outlined="true" type="text" @bind-Value="searchServiceNbr"
- OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync" maxlength="20"></MatStringField>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-8-tablet mat-layout-grid-cell-span-12-desktop">
- <MatStringField Class="w-100" Label="@I18n["Remark"]" Outlined="true" type="text" @bind-Value="remark"
- OnKeyDown="@InputCursorHandler.OnKeyDownHandlerAsync" maxlength="1000" rows="2" TextArea="true"></MatStringField>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <div class="row no-gutters align-items-end justify-content-center w-100" style="padding-bottom:2em;padding-top:2em">
- <div class="col" style="padding-right:0.5em">
- <MatButton Class="w-100" Outlined="true" @onclick="Cancel">@I18n["Cancel"]</MatButton>
- </div>
- <div class="col" style="padding-left:0.5em">
- <MatButton Class="w-100" Raised="true" @onclick="Next">@I18n["Continue"]</MatButton>
- </div>
- </div>
- </div>
-
-
- @code {
- [Parameter]
- public string FromRoute { get; set; }
-
- private static long MAX_FILE_SIZE = 3145728; //3MB
-
- private string imgUrl = string.Empty;
- private Boolean loading = false;
- private ColorItem selectedColor;
- private BicycleType selectedBcType;
- private SearchService selectedSearchService;
- private string brandStringValue;
- private Brand selectedBrand;
- private Brand SelectedBrand {
- get { return selectedBrand; }
- set { selectedBrand = (value != null) ? value : new Brand(-999, brandStringValue); }
- }
- private string frameNumber;
- private string remark;
- private string searchServiceNbr;
- private uint age;
- private uint price;
- private DateTime? lastLocationDateTime;
- private string lastLocationStreet;
- private string lastLocationZipCity;
- private ZipCity selectedZipCity;
-
- private ZipCity SelectedZipCity {
- get { return selectedZipCity; }
- set { selectedZipCity = (value != null) ? value : new ZipCity(lastLocationZipCity); }
- }
-
- private void setZipCityValue(string value) {
- lastLocationZipCity = value;
- selectedZipCity = null;
- }
-
- private void setBrandValue(string value) {
- brandStringValue = value;
- selectedBrand = null;
- }
-
- protected async override void OnInitialized() {
- base.OnInitialized();
- await GetColors();
- await GetBicycleTypes();
- await GetBrands();
- await GetSearchServices();
- refreshGUIFromDto();
- StateHasChanged();
- }
-
- private Brand getBrand(Brand brand) {
- return brand != null ? brand : new Brand(-999, "Test");
- }
-
- private async Task GetColors() {
- await MasterDataService.GetColors();
- }
-
- private async Task GetBicycleTypes() {
- await MasterDataService.GetBicycleTypes();
- }
-
- private async Task GetBrands() {
- await MasterDataService.GetBrands();
- }
-
- private async Task GetSearchServices() {
- await MasterDataService.GetSearchServices();
- }
-
- private ColorItem[] Colors {
- get => MasterDataService.Colors;
- }
-
- private BicycleType[] BicycleTypes {
- get => MasterDataService.BicycleTypes;
- }
-
- private Brand[] Brands {
- get => MasterDataService.Brands;
- }
-
- private SearchService[] SearchServices {
- get => MasterDataService.SearchServices;
- }
-
- private ZipCity[] ZipCities {
- get => MasterDataService.ZipCities;
- }
-
- private void Next() {
- updateDtoFromGUI();
- PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
- try {
- Validator.ValidateMissingReportKeyData(ReportDataProvider.GetMissingReport());
- NavigationManager.NavigateTo("fundvelo/account/Missing");
- } catch (ArgumentException) {
- Toaster.ShowWarning(I18n.GetString("Warning.MandatoryFields.Title"), I18n.GetString("Warning.MandatoryFields.Msg"));
- }
- }
-
- private void Cancel() {
- NavigationManager.NavigateTo("caritas_services");
- }
-
- private async Task OnGatheringPicture(InputFileChangeEventArgs e) {
- IBrowserFile imgFile = e.File;
- var buffer = new byte[imgFile.Size];
- imgUrl = string.Empty;
- loading = true;
- StateHasChanged();
- try {
- using (var stream = imgFile.OpenReadStream(MAX_FILE_SIZE)) {
- await stream.ReadAsync(buffer);
- imgUrl = $"data:{imgFile.ContentType};base64,{Convert.ToBase64String(buffer)}";
- await stream.DisposeAsync();
- }
- } catch (IOException ex) {
- Console.WriteLine("Ex.Message is: {0}.", ex.Message);
- if (ex.Message.Contains("exceeds the maximum of")) {
- Toaster.ShowError(I18n.GetString("Error.PhotoOrPictureToBig.Title"), I18n.GetString("Error.PhotoOrPictureToBig.Msg", MAX_FILE_SIZE / (1024 * 1024)));
- } else {
- Toaster.ShowError(I18n.GetString("Error.IOException.Title"), I18n.GetString("Error.IOException.Msg"));
- }
- } catch (JSException ex) {
- Console.WriteLine("Ex.Message is: {0}.", ex.Message);
- } finally {
- Array.Clear(buffer, 0, buffer.Length);
- buffer = null;
- loading = false;
- StateHasChanged();
- }
- }
-
- private void refreshGUIFromDto() {
- MissingReport report = ReportDataProvider.GetMissingReport();
- 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);
- selectedBcType = Array.Find(BicycleTypes, bcType => bcType.Id == report.TypId);
- frameNumber = report.RahmenNummer;
- age = report.Alter;
- price = report.Preis;
- lastLocationDateTime = report.StandortDatum;
- lastLocationStreet = report.StandortStrasse;
- SelectedZipCity = new ZipCity(report.StandortPlz, report.StandortOrt);
- selectedSearchService = Array.Find(SearchServices, searchService => searchService.Id == report.SuchDienstId);
- searchServiceNbr = report.SuchDienstNr;
- remark = report.Bemerkung;
- }
-
- private void updateDtoFromGUI() {
- MissingReport report = ReportDataProvider.GetMissingReport();
- report.FotoString = imgUrl;
- report.FarbeId = selectedColor != null ? selectedColor.Id : null;
- report.TypId = selectedBcType != null ? selectedBcType.Id : null;
- if (SelectedBrand != null) {
- if (SelectedBrand.Id == -999) {
- report.NeueMarke = SelectedBrand.Bezeichnung;
- } else {
- report.MarkeId = SelectedBrand.Id;
- }
- }
- report.RahmenNummer = frameNumber;
- report.Bemerkung = remark;
- report.Alter = age;
- report.Preis = price;
- report.SuchDienstId = selectedSearchService != null ? selectedSearchService.Id : null;
- report.SuchDienstNr = searchServiceNbr;
- report.StandortDatum = lastLocationDateTime;
- report.StandortStrasse = lastLocationStreet;
- report.StandortPlz = SelectedZipCity.Zip;
- report.StandortOrt = SelectedZipCity.City;
- }
-
- }
|