From 7578ac80107e83cf6be0a036c6ceca52c58fe295 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 6 Jan 2024 19:26:23 +0100 Subject: [PATCH] bleg --- TIAMMobileApp/MauiProgram.cs | 4 + TIAMMobileApp/wwwroot/index.html | 2 +- TIAMResources/TIAM.Resources.csproj | 10 + TIAMResources/TIAMResources.Designer.cs | 288 +++++++++++++++++ TIAMResources/TIAMResources.hu.resx | 96 ++++++ TIAMResources/TIAMResources.resx | 96 ++++++ .../TransferDestinationWizard.Designer.cs | 81 +++++ .../TransferDestinationWizard.hu.resx | 126 ++++++++ TIAMResources/TransferDestinationWizard.resx | 126 ++++++++ .../Pages/Components/InputWizard.razor | 10 +- .../Pages/Components/InputWizard.razor.cs | 168 ++++++++-- TIAMSharedUI/Pages/TestPage.razor | 97 +++++- TIAMSharedUI/Pages/User/Admin.razor | 2 +- .../Pages/User/MyServiceProviders.razor | 201 +++++++++--- TIAMSharedUI/Pages/User/MyTransfers.razor | 294 ++++++++++++++++++ TIAMSharedUI/Shared/Users/AdminNavMenu.razor | 5 + TIAMSharedUI/wwwroot/css/TourIAm.css | 12 + TIAMWebApp/Client/Program.cs | 3 +- TIAMWebApp/Client/wwwroot/index.html | 2 +- TIAMWebApp/Shared/Models/CarModel.cs | 38 +++ .../ServiceProviderWizardModel.cs | 32 ++ .../TransferDestinationWizardModel.cs | 3 + .../UI/WizardModels/TransferWizardModel.cs | 110 +++++++ TIAMWebApp/Shared/Models/DriverModel.cs | 33 ++ .../Services/ServiceProviderDataService.cs} | 8 +- .../TIAMWebApp.Shared.Application.csproj | 2 +- TIAMWebApp/Shared/Utility/ResourceKeys.cs | 39 +++ .../Shared/Utility/TIAMRegularExpressions.cs | 2 +- 28 files changed, 1803 insertions(+), 87 deletions(-) create mode 100644 TIAMResources/TransferDestinationWizard.Designer.cs create mode 100644 TIAMResources/TransferDestinationWizard.hu.resx create mode 100644 TIAMResources/TransferDestinationWizard.resx create mode 100644 TIAMSharedUI/Pages/User/MyTransfers.razor create mode 100644 TIAMWebApp/Shared/Models/CarModel.cs create mode 100644 TIAMWebApp/Shared/Models/ClientSide/UI/WizardModels/ServiceProviderWizardModel.cs create mode 100644 TIAMWebApp/Shared/Models/ClientSide/UI/WizardModels/TransferWizardModel.cs create mode 100644 TIAMWebApp/Shared/Models/DriverModel.cs rename TIAMWebApp/{Client/Services/ServiceProviderDataServiceWeb.cs => Shared/Services/ServiceProviderDataService.cs} (90%) diff --git a/TIAMMobileApp/MauiProgram.cs b/TIAMMobileApp/MauiProgram.cs index e1a9dfb6..55f2f251 100644 --- a/TIAMMobileApp/MauiProgram.cs +++ b/TIAMMobileApp/MauiProgram.cs @@ -4,6 +4,8 @@ using TIAMWebApp.Shared.Application.Interfaces; using DevExpress.Blazor; using System.Resources; using AyCode.Interfaces.StorageHandlers; +using TIAMWebApp.Shared.Application.Utility; +using TIAMWebApp.Shared.Application.Services; namespace TIAMMobileApp { @@ -43,12 +45,14 @@ namespace TIAMMobileApp builder.Services.AddScoped(); builder.Services.AddScoped(); + builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddSingleton(); + builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddSingleton(x => new ResourceManager("TIAMWebApp.Shared.Application.Resources", typeof(Main).Assembly)); return builder.Build(); diff --git a/TIAMMobileApp/wwwroot/index.html b/TIAMMobileApp/wwwroot/index.html index f3cd113e..7a9cda67 100644 --- a/TIAMMobileApp/wwwroot/index.html +++ b/TIAMMobileApp/wwwroot/index.html @@ -13,7 +13,7 @@ - + diff --git a/TIAMResources/TIAM.Resources.csproj b/TIAMResources/TIAM.Resources.csproj index cd8b2454..1558dc55 100644 --- a/TIAMResources/TIAM.Resources.csproj +++ b/TIAMResources/TIAM.Resources.csproj @@ -12,6 +12,11 @@ True TIAMResources.resx + + True + True + TransferDestinationWizard.resx + @@ -23,6 +28,11 @@ TIAMResources.Designer.cs Always + + PublicResXFileCodeGenerator + TransferDestinationWizard.Designer.cs + Always + diff --git a/TIAMResources/TIAMResources.Designer.cs b/TIAMResources/TIAMResources.Designer.cs index d43e6571..f96c908c 100644 --- a/TIAMResources/TIAMResources.Designer.cs +++ b/TIAMResources/TIAMResources.Designer.cs @@ -60,6 +60,105 @@ namespace TIAM.Resources { } } + /// + /// Looks up a localized string similar to Cancel. + /// + public static string ButtonCancel { + get { + return ResourceManager.GetString("ButtonCancel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Delete. + /// + public static string ButtonDelete { + get { + return ResourceManager.GetString("ButtonDelete", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Edit. + /// + public static string ButtonEdit { + get { + return ResourceManager.GetString("ButtonEdit", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Finish. + /// + public static string ButtonFinish { + get { + return ResourceManager.GetString("ButtonFinish", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Next. + /// + public static string ButtonNext { + get { + return ResourceManager.GetString("ButtonNext", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Previous. + /// + public static string ButtonPrevious { + get { + return ResourceManager.GetString("ButtonPrevious", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Save. + /// + public static string ButtonSave { + get { + return ResourceManager.GetString("ButtonSave", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Confirm Email. + /// + public static string ConfirmEmail { + get { + return ResourceManager.GetString("ConfirmEmail", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Confirm Password. + /// + public static string ConfirmPassword { + get { + return ResourceManager.GetString("ConfirmPassword", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Confirm password reset. + /// + public static string ConfirmPasswordReset { + get { + return ResourceManager.GetString("ConfirmPasswordReset", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Destination. + /// + public static string Destination { + get { + return ResourceManager.GetString("Destination", resourceCulture); + } + } + /// /// Looks up a localized string similar to Address. /// @@ -78,6 +177,24 @@ namespace TIAM.Resources { } } + /// + /// Looks up a localized string similar to Destination latitude. + /// + public static string DestinationLatitude { + get { + return ResourceManager.GetString("DestinationLatitude", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Destination longitude. + /// + public static string DestinationLongitude { + get { + return ResourceManager.GetString("DestinationLongitude", resourceCulture); + } + } + /// /// Looks up a localized string similar to Name of destination. /// @@ -87,6 +204,159 @@ namespace TIAM.Resources { } } + /// + /// Looks up a localized string similar to Driver. + /// + public static string Driver { + get { + return ResourceManager.GetString("Driver", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Email. + /// + public static string EmailAddress { + get { + return ResourceManager.GetString("EmailAddress", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Forgot password?. + /// + public static string ForgotPassword { + get { + return ResourceManager.GetString("ForgotPassword", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Full name. + /// + public static string FullName { + get { + return ResourceManager.GetString("FullName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Login. + /// + public static string Login { + get { + return ResourceManager.GetString("Login", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Passengers. + /// + public static string NumberOfPassengers { + get { + return ResourceManager.GetString("NumberOfPassengers", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Password. + /// + public static string Password { + get { + return ResourceManager.GetString("Password", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Phone number. + /// + public static string PhoneNumber { + get { + return ResourceManager.GetString("PhoneNumber", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Pick up address. + /// + public static string PickupAddress { + get { + return ResourceManager.GetString("PickupAddress", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Pick up time. + /// + public static string PickupTime { + get { + return ResourceManager.GetString("PickupTime", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Price. + /// + public static string Price { + get { + return ResourceManager.GetString("Price", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Register. + /// + public static string Register { + get { + return ResourceManager.GetString("Register", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Remember me!. + /// + public static string RememberMe { + get { + return ResourceManager.GetString("RememberMe", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Reset password. + /// + public static string ResetPassword { + get { + return ResourceManager.GetString("ResetPassword", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Service provider name. + /// + public static string ServiceProviderName { + get { + return ResourceManager.GetString("ServiceProviderName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Owner of the Service provider. + /// + public static string ServiceProviderOwnerId { + get { + return ResourceManager.GetString("ServiceProviderOwnerId", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to New Service provider. + /// + public static string ServiceProviderTitle { + get { + return ResourceManager.GetString("ServiceProviderTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to This works!. /// @@ -96,6 +366,24 @@ namespace TIAM.Resources { } } + /// + /// Looks up a localized string similar to New destination. + /// + public static string TransferDestinationTitle { + get { + return ResourceManager.GetString("TransferDestinationTitle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to New Transfer. + /// + public static string TransferTitle { + get { + return ResourceManager.GetString("TransferTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Wizard. /// diff --git a/TIAMResources/TIAMResources.hu.resx b/TIAMResources/TIAMResources.hu.resx index 6d78fa23..0ecda8d9 100644 --- a/TIAMResources/TIAMResources.hu.resx +++ b/TIAMResources/TIAMResources.hu.resx @@ -117,18 +117,114 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Mégse + + + Törlés + + + Szerkesztés + + + Befejezés + + + Tovább + + + Vissza + + + Mentés + + + E-mail cím megerősítése + + + Jelszó ismét + + + Jelszó módosítás megerősítése + + + Uticél + Cím Több információ az uticélról + + Uticél szélességi fok + + + Uticél hosszúsági fok + Uticél neve + + Sofőr + + + E-mail + + + Elfelejtett jelszó + + + Teljes név + + + Belépés + + + Utasok száma + + + Jelszó + + + Telefonszám + + + Indulási cím + + + Indulási idő + + + Ár + + + Regisztráció + + + Emlékezz rám! + + + Jelszó módosítás + + + Szolgáltató neve + + + Szolgáltató tulajdonosa + + + Új szolgáltató + Müxik! + + Új uticél + + + Új transzfer + Varázsló diff --git a/TIAMResources/TIAMResources.resx b/TIAMResources/TIAMResources.resx index 7d018fec..dc9d9124 100644 --- a/TIAMResources/TIAMResources.resx +++ b/TIAMResources/TIAMResources.resx @@ -117,18 +117,114 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Cancel + + + Delete + + + Edit + + + Finish + + + Next + + + Previous + + + Save + + + Confirm Email + + + Confirm Password + + + Confirm password reset + + + Destination + Address Details about the destination + + Destination latitude + + + Destination longitude + Name of destination + + Driver + + + Email + + + Forgot password? + + + Full name + + + Login + + + Passengers + + + Password + + + Phone number + + + Pick up address + + + Pick up time + + + Price + + + Register + + + Remember me! + + + Reset password + + + Service provider name + + + Owner of the Service provider + + + New Service provider + This works! + + New destination + + + New Transfer + Wizard diff --git a/TIAMResources/TransferDestinationWizard.Designer.cs b/TIAMResources/TransferDestinationWizard.Designer.cs new file mode 100644 index 00000000..14e6d2ee --- /dev/null +++ b/TIAMResources/TransferDestinationWizard.Designer.cs @@ -0,0 +1,81 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace TIAM.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class TransferDestinationWizard { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal TransferDestinationWizard() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TIAM.Resources.TransferDestinationWizard", typeof(TransferDestinationWizard).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Fill in the details!. + /// + public static string Subtitle { + get { + return ResourceManager.GetString("Subtitle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to New TransferDestination. + /// + public static string Title { + get { + return ResourceManager.GetString("Title", resourceCulture); + } + } + } +} diff --git a/TIAMResources/TransferDestinationWizard.hu.resx b/TIAMResources/TransferDestinationWizard.hu.resx new file mode 100644 index 00000000..a1e3b62b --- /dev/null +++ b/TIAMResources/TransferDestinationWizard.hu.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Töltsd ki a részleteket! + + + Új transzfer desztináció + + \ No newline at end of file diff --git a/TIAMResources/TransferDestinationWizard.resx b/TIAMResources/TransferDestinationWizard.resx new file mode 100644 index 00000000..40288e8e --- /dev/null +++ b/TIAMResources/TransferDestinationWizard.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Fill in the details! + + + New TransferDestination + + \ No newline at end of file diff --git a/TIAMSharedUI/Pages/Components/InputWizard.razor b/TIAMSharedUI/Pages/Components/InputWizard.razor index bddd642d..474e2ce7 100644 --- a/TIAMSharedUI/Pages/Components/InputWizard.razor +++ b/TIAMSharedUI/Pages/Components/InputWizard.razor @@ -4,26 +4,26 @@
-
+
-
+

@localizer.GetString(TitleResourceString)

- Sibtitle here + @localizer.GetString(SubtitleResourceString)

-
+
@CreateEditFormFields()
-

+

@localizer.GetString("DestinationName")

@_formSubmitResult

diff --git a/TIAMSharedUI/Pages/Components/InputWizard.razor.cs b/TIAMSharedUI/Pages/Components/InputWizard.razor.cs index a298bf51..cb007381 100644 --- a/TIAMSharedUI/Pages/Components/InputWizard.razor.cs +++ b/TIAMSharedUI/Pages/Components/InputWizard.razor.cs @@ -12,6 +12,9 @@ using DevExpress.Pdf.Native.BouncyCastle.Asn1.X509.Qualified; using Microsoft.Extensions.Localization; using TIAM.Resources; using TIAMWebApp.Shared.Application.Interfaces; +using System.Reflection; +using TIAMWebApp.Shared.Application.Models; +using DevExpress.XtraPrinting; namespace TIAMSharedUI.Pages.Components @@ -22,10 +25,7 @@ namespace TIAMSharedUI.Pages.Components public required LogToBrowserConsole LogToBrowserConsole { get; set; } [Inject] - IStringLocalizer localizer { get; set; } - - [Inject] - public IWizardProcessor WizardProcessor { get; set; } + IStringLocalizer localizer { get; set; } public Dictionary FormSteps { get; set; } = new Dictionary(); public int CurrentStep { get; set; } = 0; @@ -34,6 +34,7 @@ namespace TIAMSharedUI.Pages.Components [Parameter] public string TitleResourceString { get; set; } = "Wizard"; + public string SubtitleResourceString { get; set; } = "Let's fill in this form"; [Parameter] public object Data { get; set; } = new object(); @@ -41,6 +42,9 @@ namespace TIAMSharedUI.Pages.Components [Parameter] public EventCallback OnSubmit { get; set; } + [Parameter] + public string SubmitButtonText { get; set; } = "Submit"; + string _formSubmitResult = ""; @@ -50,8 +54,21 @@ namespace TIAMSharedUI.Pages.Components { _spinnerClass = "spinner-border spinner-border-sm"; await Task.Delay(500); - await WizardProcessor.ProcessWizardAsync(Data.GetType(), Data); - _formSubmitResult = "You have been registred successully."; + + string debugString = "Success: "; + + Type myType = Data.GetType(); + IList props = new List(myType.GetProperties()); + + foreach (PropertyInfo prop in props) + { + object propValue = prop.GetValue(Data, null); + + // Do something with propValue + debugString += $"{prop.Name} = {propValue}\n"; + } + + _formSubmitResult = debugString; _spinnerClass = ""; await OnSubmit.InvokeAsync(Data); @@ -90,12 +107,13 @@ namespace TIAMSharedUI.Pages.Components int j = 0; foreach (var property in propertyList) { - + bool isActive = j == CurrentStep; //if (property.Name == "Id" || property.Name == "Latitude" || property.Name == "Longitude" || property.Name == "Created" || property.Name == "Modified") //if (property.Name == "Id" || property.Name == "Created" || property.Name == "Modified") - //{ - // continue; - //} + if (property.Name == "Id" || property.Name == "Price" || property.Name == "Created" || property.Name == "Modified") + { + continue; + } Guid _stepID = Guid.Empty; @@ -109,28 +127,39 @@ namespace TIAMSharedUI.Pages.Components _stepID = FormSteps[j]; } + //the following line creates an expression that accesses the property value by name var access = Expression.Property(Expression.Constant(Data), property.Name); + //the following line creates a lambda expression that returns the value of the property var lambda = Expression.Lambda(typeof(Func<>).MakeGenericType(property.PropertyType), access); LogToBrowserConsole.LogToBC(lambda.ToString()); layoutItemBuilder.OpenElement(i++, "div");//open div layoutItemBuilder.AddAttribute(i++, "id", _stepID.ToString()); - layoutItemBuilder.AddAttribute(i++, "class", "disply-flex align-items-center"); + layoutItemBuilder.AddAttribute(i++, "class", "disply-flex align-items-center "); layoutItemBuilder.AddAttribute(i++, "style", "width: 100%;"); if (j != CurrentStep) + { layoutItemBuilder.AddAttribute(i++, "hidden", "true"); + } + else + { + //this input should be focused, so we set a flag + LogToBrowserConsole.LogToBC($"Setting focus to {property.Name}"); + + } DataTypeAttribute attrList = (DataTypeAttribute)property.GetCustomAttributes(typeof(DataTypeAttribute), false).First(); DisplayAttribute displayLabel = (DisplayAttribute)property.GetCustomAttributes(typeof(DisplayAttribute), false).First(); layoutItemBuilder.OpenComponent(i++); //open dxformlayoutitem - layoutItemBuilder.AddAttribute(i++, "Caption", displayLabel.Name); + layoutItemBuilder.AddAttribute(i++, "Caption", localizer.GetString(displayLabel.Name)); layoutItemBuilder.AddAttribute(i++, "ColSpanMd", 12); - //layoutItemBuilder.AddAttribute(i++, "CssClass", "form-field"); + layoutItemBuilder.AddAttribute(i++, "CaptionPosition", CaptionPosition.Vertical); + //layoutItemBuilder.AddAttribute(i++, "CssClass", "flex-direction: column;"); layoutItemBuilder.AddAttribute(i++, "Template", (RenderFragment)((context) => ((editor) => { - var j = 0; + j = 0; switch (attrList.DataType) { @@ -141,8 +170,14 @@ namespace TIAMSharedUI.Pages.Components editor.AddAttribute(j++, "Text", property.GetValue(Data)); editor.AddAttribute(j++, "TextExpression", lambda); editor.AddAttribute(j++, "CssClass", "form-field"); + + if(isActive) + { + editor.AddAttribute(j++, "Id", "ActiveInput"); + } editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create(this, str => { property.SetValue(Data, str); })); editor.CloseComponent(); + break; } case DataType.Password: @@ -162,6 +197,30 @@ namespace TIAMSharedUI.Pages.Components editor.OpenComponent>(j++); editor.AddAttribute(j++, "Value", property.GetValue(Data)); editor.AddAttribute(j++, "Mask", TIAMRegularExpressions.PhoneNumberMask); + editor.AddAttribute(j++, "MaskMode", MaskMode.RegEx); + editor.AddAttribute(j++, "BindValueMode", BindValueMode.OnInput); + editor.AddAttribute(j++, "ValueExpression", lambda); + editor.AddAttribute(j++, "NullText", "+11234567890"); + editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create(this, str => SetPhoneNumber(property, Data, str))); + //editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create(this, str => { property.SetValue(Data, str); })); + editor.AddAttribute(i++, "Template", (RenderFragment)((context) => ((editor2) => + { + editor2.OpenComponent(j++); + editor2.AddAttribute(j++, "PlaceholdersVisible", false); + editor2.CloseComponent(); + }))); + editor.CloseComponent(); + break; + } + case DataType.EmailAddress: + { + editor.OpenComponent>(j++); + editor.AddAttribute(j++, "Value", property.GetValue(Data)); + editor.AddAttribute(j++, "Mask", TIAMRegularExpressions.EmailMask); + editor.AddAttribute(j++, "MaskMode", MaskMode.RegEx); + editor.AddAttribute(j++, "BindValueMode", BindValueMode.OnInput); + //MaskAutoCompleteMode="@((MaskAutoCompleteMode)AutoCompleteMode)" + editor.AddAttribute(j++, "MaskAutoCompleteMode", MaskAutoCompleteMode.Strong); editor.AddAttribute(j++, "ValueExpression", lambda); editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create(this, str => { property.SetValue(Data, str); })); editor.CloseComponent(); @@ -187,6 +246,7 @@ namespace TIAMSharedUI.Pages.Components editor.AddAttribute(j++, "Value", property.GetValue(Data)); editor.AddAttribute(j++, "Mask", "n6"); + editor.AddAttribute(j++, "BindValueMode", BindValueMode.OnInput); editor.AddAttribute(j++, "ValueExpression", lambda); editor.AddAttribute(j++, "CssClass", "form-field"); editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create(this, str => { property.SetValue(Data, str); })); @@ -199,15 +259,15 @@ namespace TIAMSharedUI.Pages.Components editor.OpenComponent>(j); editor.AddAttribute(j++, "Value", property.GetValue(Data)); - - editor.AddAttribute(j++, "Mask", "n0"); + editor.AddAttribute(j++, "BindValueMode", BindValueMode.OnInput); + editor.AddAttribute(j++, "Mask", NumericMask.WholeNumber); editor.AddAttribute(j++, "ValueExpression", lambda); editor.AddAttribute(j++, "CssClass", "form-field"); editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create(this, str => { property.SetValue(Data, str); })); editor.CloseComponent(); break; } - else if (property.PropertyType == typeof(string) && property.Name == "Occupation") + else if (property.PropertyType == typeof(IEnumerable) && property.Name == "Occupation") { editor.OpenComponent>(j); @@ -218,9 +278,38 @@ namespace TIAMSharedUI.Pages.Components editor.CloseComponent(); break; } + else if (property.PropertyType == typeof(DriverModel) && property.Name == "Driver") + { + //load possible drivers for this serviceprovider + + //DriverModel driver = (DriverModel)property.GetValue(Data); + IEnumerable drivers = new DriverModel[] { + new DriverModel(Guid.NewGuid(), Guid.NewGuid(), "John Doe"), + new DriverModel(Guid.NewGuid(), Guid.NewGuid(), "Jane Doe"), + new DriverModel(Guid.NewGuid(), Guid.NewGuid(), "James Doe") + }; + + var defaultDriver = drivers.FirstOrDefault(); + + //editor.OpenElement(j++, "p"); + //editor.AddContent(j++, localizer.GetString("Driver")); + //editor.CloseElement(); + editor.OpenComponent>(j); + editor.AddAttribute(j++, "Data", drivers); + editor.AddAttribute(j++, "TextFieldName", nameof (defaultDriver.Name)); + editor.AddAttribute(j++, "Value", drivers.FirstOrDefault()); + //editor.AddAttribute(j++, "Text", defaultDriver); + editor.AddAttribute(j++, "CssClass", "form-field"); + //editor.AddAttribute(j++, "TextExpression", lambda); + editor.AddAttribute(j++, "ValueExpression", lambda); + editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create(this, str => { property.SetValue(Data, str); })); + editor.CloseComponent(); + break; + } else if (property.PropertyType == typeof(TransferDestination)) { - + editor.OpenComponent(j); + editor.CloseComponent(); } break; @@ -249,7 +338,7 @@ namespace TIAMSharedUI.Pages.Components layoutItemBuilder.AddAttribute(i++, "Click", EventCallback.Factory.Create(this, OnNext)); layoutItemBuilder.AddAttribute(i++, "SubmitFormOnClick", false); layoutItemBuilder.AddAttribute(i++, "CssClass", "btn btn-primary mt-3"); - layoutItemBuilder.AddAttribute(i++, "Text", "Next"); + layoutItemBuilder.AddAttribute(i++, "Text", localizer.GetString(ResourceKeys.ButtonNext)); layoutItemBuilder.CloseComponent(); } if (j > 0) @@ -258,7 +347,7 @@ namespace TIAMSharedUI.Pages.Components layoutItemBuilder.AddAttribute(i++, "Click", EventCallback.Factory.Create(this, OnPrevious)); layoutItemBuilder.AddAttribute(i++, "SubmitFormOnClick", false); layoutItemBuilder.AddAttribute(i++, "CssClass", "btn btn-secondary mt-3"); - layoutItemBuilder.AddAttribute(i++, "Text", "Previous"); + layoutItemBuilder.AddAttribute(i++, "Text", localizer.GetString(ResourceKeys.ButtonPrevious)); layoutItemBuilder.CloseComponent(); } layoutItemBuilder.CloseElement(); //close div @@ -277,12 +366,33 @@ namespace TIAMSharedUI.Pages.Components } layoutItemBuilder.OpenComponent(i++); + layoutItemBuilder.AddAttribute(i++, "ColSpanMd", 12); + layoutItemBuilder.AddAttribute(i++, "CssClass", "full-width"); layoutItemBuilder.AddAttribute(i++, "Template", (RenderFragment)((context) => ((editor) => { LogToBrowserConsole.LogToBC($"Submit button {CurrentStep}, {propertyList.Length}"); - editor.OpenComponent(i++); + + editor.OpenElement(i++, "button"); + editor.AddAttribute(i++, "type", "submit"); + editor.AddAttribute(i++, "class", "btn btn-primary mt-3"); + if (CurrentStep < propertyList.Length - 1) + { + editor.AddAttribute(i++, "disabled", "true"); + + } + //editor.AddAttribute(i++, "disabled", "true"); + + editor.OpenElement(i++, "span"); + editor.AddAttribute(i++, "class", _spinnerClass); + + editor.CloseElement(); + editor.AddContent(i++, localizer.GetString(SubmitButtonText)); + editor.CloseElement(); + + /*editor.OpenComponent(i++); editor.AddAttribute(i++, "SubmitFormOnClick", true); - editor.AddAttribute(i++, "Text", "Submit"); + editor.AddAttribute(i++, "Text", SubmitButtonText); + editor.AddAttribute(i++, "IconClass", _spinnerClass); editor.AddAttribute(i++, "CssClass", "btn btn-primary mt-3"); if (CurrentStep == propertyList.Length-1) { @@ -291,11 +401,8 @@ namespace TIAMSharedUI.Pages.Components else { editor.AddAttribute(i++, "Visible", false); - } - editor.OpenElement(i++, "span"); - editor.AddAttribute(i++, "class", _spinnerClass); - editor.CloseElement(); - editor.CloseComponent(); + } + editor.CloseComponent();*/ }))); layoutItemBuilder.CloseComponent(); @@ -303,7 +410,10 @@ namespace TIAMSharedUI.Pages.Components formLayoutBuilder.CloseComponent(); }; - - + private void SetPhoneNumber(PropertyInfo property, object Data, string str) + { + LogToBrowserConsole.LogToBC($"SetPhoneNumber called with {str}"); + property.SetValue(Data, str); + } } } diff --git a/TIAMSharedUI/Pages/TestPage.razor b/TIAMSharedUI/Pages/TestPage.razor index 2000b03b..82780097 100644 --- a/TIAMSharedUI/Pages/TestPage.razor +++ b/TIAMSharedUI/Pages/TestPage.razor @@ -1,22 +1,115 @@ @page "/dbtest" @using TIAMSharedUI.Pages.Components +@using TIAMWebApp.Shared.Application.Interfaces @using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels @using TIAMWebApp.Shared.Application.Utility @inject LogToBrowserConsole logToBrowserConsole +@inject IWizardProcessor WizardProcessor

TestPage


+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + -
@code { public TransferDestinationWizardModel myModel = new TransferDestinationWizardModel(); - public void SubmitForm(object Result) + public TransferWizardModel myModel2 = new TransferWizardModel(); + + bool EulaAccepted { get; set; } + bool EulaVisible { get; set; } + bool MessageBoxVisible { get; set; } + bool SkipEulaCheck { get; set; } + void TryAgainClick() { + MessageBoxVisible = false; + } + void CancelEulaClick() + { + myModel = new TransferDestinationWizardModel(); + SkipEulaCheck = true; + MessageBoxVisible = false; + EulaVisible = false; + } + void EulaPopupClosed() + { + EulaAccepted = false; + SkipEulaCheck = false; + } + void EulaPopupClosing(PopupClosingEventArgs args) + { + if (SkipEulaCheck) + return; + args.Cancel = !EulaAccepted; + MessageBoxVisible = !EulaAccepted; + } + + //----------------------------------------------------------------------------------- + + + public async Task SubmitForm(object Result) + { + //await WizardProcessor.ProcessWizardAsync(Result.GetType(), Result); logToBrowserConsole.LogToBC($"Submitted nested form: {Result.GetType().FullName}"); } } + + + + diff --git a/TIAMSharedUI/Pages/User/Admin.razor b/TIAMSharedUI/Pages/User/Admin.razor index a5928003..8ccc2f6e 100644 --- a/TIAMSharedUI/Pages/User/Admin.razor +++ b/TIAMSharedUI/Pages/User/Admin.razor @@ -15,7 +15,7 @@ -
+
diff --git a/TIAMSharedUI/Pages/User/MyServiceProviders.razor b/TIAMSharedUI/Pages/User/MyServiceProviders.razor index 42b9b799..1a97658e 100644 --- a/TIAMSharedUI/Pages/User/MyServiceProviders.razor +++ b/TIAMSharedUI/Pages/User/MyServiceProviders.razor @@ -1,69 +1,190 @@ @page "/user/properties" +@using TIAM.Entities.ServiceProviders +@using TIAM.Resources +@using TIAMSharedUI.Pages.Components @using TIAMSharedUI.Shared +@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels +@using TIAMWebApp.Shared.Application.Utility @layout AdminLayout +@inject LogToBrowserConsole logToBrowserConsole +@inject IStringLocalizer localizer

Properties

-

You have no properties yet...

-
-
-
-
+
+
+
+
+
+
+ Service providers list - - - - - @context.Value - +
+
+ +
+
+
- - - - - - +
+
+ + @* + + + + + + + *@ + + + + + + + @context.Value + + + + + + + + +
+ +
+

Some conclusion

+
+
-
-

Some conclusion

-
+ +
+
+
@code { + IGrid Grid { get; set; } object? OrderData { get; set; } + public ServiceProviderWizardModel myModel = new ServiceProviderWizardModel(); + + bool EulaAccepted { get; set; } + bool EulaVisible { get; set; } + + + void CancelCreateClick() + { + + + EulaVisible = false; + } + void EulaPopupClosed() + { + EulaAccepted = false; + + } + void EulaPopupClosing(PopupClosingEventArgs args) + { + myModel = new ServiceProviderWizardModel(); + } + + //----------------------------------------------------------------------------------- + + + public async Task SubmitForm(object Result) + { + //await WizardProcessor.ProcessWizardAsync(Result.GetType(), Result); + logToBrowserConsole.LogToBC($"Submitted nested form: {Result.GetType().FullName}"); + } + + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + await Grid.StartEditRowAsync(0); + } + + void Grid_CustomizeEditModel(GridCustomizeEditModelEventArgs e) + { + if (e.IsNew) + { + var newEmployee = (TiamServiceProvider)e.EditModel; + newEmployee.Name = "John"; + newEmployee.OwnerId = Guid.NewGuid(); + } + } + + async Task Grid_EditModelSaving(GridEditModelSavingEventArgs e) + { + if (e.IsNew) + //add new orderData to orderData array + logToBrowserConsole.LogToBC("New orderData added"); + //await NwindDataService.InsertEmployeeAsync((EditableEmployee)e.EditModel); + else + logToBrowserConsole.LogToBC("orderData updated"); + //modify orderData where orderData.Name == e.EditModel.Name + + //await NwindDataService.UpdateEmployeeAsync((EditableEmployee)e.DataItem, (EditableEmployee)e.EditModel); + + await UpdateDataAsync(); + } + async Task Grid_DataItemDeleting(GridDataItemDeletingEventArgs e) + { + //await NwindDataService.RemoveEmployeeAsync((EditableEmployee)e.DataItem); + //remove orderData from orderData array + logToBrowserConsole.LogToBC("orderData deleted"); + //await UpdateDataAsync(); + } + async Task UpdateDataAsync() + { + //DataSource = await NwindDataService.GetEmployeesEditableAsync(); + //refresh grid + logToBrowserConsole.LogToBC("orderData grid refreshed"); + } + protected override void OnInitialized() { base.OnInitialized(); - OrderData = new object[] + OrderData = new TiamServiceProvider[] { - new { - Date = DateTime.Now.AddDays(3), - Income = "$5", - TransactionId = "POX987532582", - Status = "Finished" - }, - new { - Date = DateTime.Today.AddDays(-2), - Income = "$5", - TransactionId = "POX645646382", - Status = "Finished" - }, - new - { - Date = DateTime.Today.AddDays(-6), - Income = "$8", - TransactionId = "POX645766311", - Status = "Finished" - }, + new TiamServiceProvider(Guid.NewGuid(), "BAT", Guid.NewGuid()), + new TiamServiceProvider(Guid.NewGuid(), "TIAM", Guid.NewGuid()), + new TiamServiceProvider(Guid.NewGuid(), "TestHotel", Guid.NewGuid()) + }; diff --git a/TIAMSharedUI/Pages/User/MyTransfers.razor b/TIAMSharedUI/Pages/User/MyTransfers.razor new file mode 100644 index 00000000..7c68b51b --- /dev/null +++ b/TIAMSharedUI/Pages/User/MyTransfers.razor @@ -0,0 +1,294 @@ +@page "/user/transfers" +@using TIAM.Entities.ServiceProviders +@using TIAM.Resources +@using TIAMSharedUI.Pages.Components +@using TIAMSharedUI.Shared +@using TIAMWebApp.Shared.Application.Models +@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels +@using TIAMWebApp.Shared.Application.Utility +@layout AdminLayout +@inject LogToBrowserConsole logToBrowserConsole +@inject IStringLocalizer localizer +Transfers +

Properties

+ +
+
+
+
+
+
+
+ Service providers list + +
+
+ +
+
+
+ +
+
+
+ +
+ + + + + + + + @{ + var keyField = context.Value; + @context.Value + } + + + + + + + + + + @{ + var keyField = context.Value; + string buttonText = "Contact"; + + } + + + + + @{ + DriverModel keyField = (DriverModel)context.Value; + string driverText = keyField.Name; +

@driverText

+ } +
+
+ +
+ + + @{ + var transfer = (TransferWizardModel)EditFormContext.EditModel; + } + + + @EditFormContext.GetEditor("Destination") + + + @EditFormContext.GetEditor("PickupAddress") + + + @EditFormContext.GetEditor("TripDate") + + + @EditFormContext.GetEditor("NumberOfPassengers") + + + @EditFormContext.GetEditor("FullName") + + + @EditFormContext.GetEditor("PhoneNumber") + + + @EditFormContext.GetEditor("EmailAddress") + + + + + + + + + +
+ + +
+ +
+

Some conclusion

+
+
+ +
+ +
+ +
+
+ +
+
+ + +@code { + + IGrid Grid { get; set; } + //object? TransferData { get; set; } + + public TransferWizardModel myModel = new TransferWizardModel(); + + bool EulaAccepted { get; set; } + bool EulaVisible { get; set; } + + //IEnumerable drivers { get; set; } + + IEnumerable drivers { get; set; } = new DriverModel[] { + new DriverModel(Guid.NewGuid(), Guid.NewGuid(), "John Doe"), + new DriverModel(Guid.NewGuid(), Guid.NewGuid(), "Jane Doe"), + new DriverModel(Guid.NewGuid(), Guid.NewGuid(), "James Doe") + }; + + object? TransferData = new TransferWizardModel[] + { + new TransferWizardModel(Guid.NewGuid(), "1087, Budapest, Százados út 30/a", "Nyugati Pályaudvar", DateTime.UtcNow.AddDays(3), 3, "John Malkovich", "+13021234567", "john.malkovich@stars.com", new DriverModel(Guid.NewGuid(), Guid.NewGuid(), "John Doe")), + new TransferWizardModel(Guid.NewGuid(), "1027, Budapest, Batthyányi tér 3", "Budapest, Koós Károly sétány 21", DateTime.UtcNow.AddDays(6), 3, "John Malkovich", "+13021234567", "john.malkovich@stars.com", new DriverModel(Guid.NewGuid(), Guid.NewGuid(), "Jane Doe")), + new TransferWizardModel(Guid.NewGuid(), "1087, Budapest, Százados út 30/a", "Nyugati Pályaudvar", DateTime.UtcNow.AddDays(2), 3, "John Malkovich", "+13021234567", "john.malkovich@stars.com", new DriverModel(Guid.NewGuid(), Guid.NewGuid(), "James Doe")), + new TransferWizardModel(Guid.NewGuid(), "1087, Budapest, Százados út 30/a", "Nyugati Pályaudvar", DateTime.UtcNow.AddDays(4).AddHours(-6), 3, "John Malkovich", "+13021234567", "john.malkovich@stars.com", new DriverModel(Guid.NewGuid(), Guid.NewGuid(), "James Doe")), + new TransferWizardModel(Guid.NewGuid(), "1087, Budapest, Százados út 30/a", "Nyugati Pályaudvar", DateTime.UtcNow.AddDays(7), 3, "John Malkovich", "+13021234567", "john.malkovich@stars.com", new DriverModel(Guid.NewGuid(), Guid.NewGuid(), "Joan Doe")), + new TransferWizardModel(Guid.NewGuid(), "1087, Budapest, Százados út 30/a", "Nyugati Pályaudvar", DateTime.UtcNow.AddDays(1), 3, "John Malkovich", "+13021234567", "john.malkovich@stars.com", new DriverModel(Guid.NewGuid(), Guid.NewGuid(), "James Doe")), + new TransferWizardModel(Guid.NewGuid(), "1087, Budapest, Százados út 30/a", "Nyugati Pályaudvar", DateTime.UtcNow.AddDays(6).AddHours(3), 3, "John Malkovich", "+13021234567", "john.malkovich@stars.com", new DriverModel(Guid.NewGuid(), Guid.NewGuid(), "John Doe")) + + }; + + void SendMail(object emailAddress) + { + logToBrowserConsole.LogToBC($"Sending mail to {emailAddress}"); + } + + void CancelCreateClick() + { + + + EulaVisible = false; + } + void EulaPopupClosed() + { + EulaAccepted = false; + + } + void EulaPopupClosing(PopupClosingEventArgs args) + { + myModel = new TransferWizardModel(); + } + + //----------------------------------------------------------------------------------- + + + public async Task SubmitForm(object Result) + { + //await WizardProcessor.ProcessWizardAsync(Result.GetType(), Result); + logToBrowserConsole.LogToBC($"Submitted nested form: {Result.GetType().FullName}"); + } + + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + //if (firstRender) + // await Grid.StartEditRowAsync(0); + } + + void Grid_CustomizeEditModel(GridCustomizeEditModelEventArgs e) + { + if (e.IsNew) + { + var newEmployee = (TransferWizardModel)e.EditModel; + newEmployee.Id = Guid.NewGuid(); + newEmployee.Destination = "ghjgkg hkgh ghjkghgkjgh"; + newEmployee.PickupAddress = "ghjgkg hkgh ghjkghgkjgh"; + newEmployee.TripDate = DateTime.UtcNow.AddDays(3); + newEmployee.NumberOfPassengers = 1; + newEmployee.FullName = "ghjgkg hkgh ghjkghgkjgh"; + newEmployee.PhoneNumber = "+13021234567"; + newEmployee.EmailAddress = "ghjgkg hkgh ghjkghgkjgh"; + newEmployee.Driver = drivers.FirstOrDefault(); + } + } + + async Task Grid_EditModelSaving(GridEditModelSavingEventArgs e) + { + if (e.IsNew) + //add new orderData to orderData array + logToBrowserConsole.LogToBC("New orderData added"); + //await NwindDataService.InsertEmployeeAsync((EditableEmployee)e.EditModel); + else + logToBrowserConsole.LogToBC("orderData updated"); + //modify transferData where transferData.Id == e.EditModel.Id + //get transfer from TransferData by Id + + foreach (var transferToModify in (TransferWizardModel[])TransferData) + { + myModel = (TransferWizardModel)e.EditModel; + + if (transferToModify.Id == myModel.Id) + { + transferToModify.Driver = myModel.Driver; + } + } + + + + //await NwindDataService.UpdateEmployeeAsync((EditableEmployee)e.DataItem, (EditableEmployee)e.EditModel); + + await UpdateDataAsync(); + } + async Task Grid_DataItemDeleting(GridDataItemDeletingEventArgs e) + { + //await NwindDataService.RemoveEmployeeAsync((EditableEmployee)e.DataItem); + //remove orderData from orderData array + logToBrowserConsole.LogToBC("orderData deleted"); + //await UpdateDataAsync(); + } + async Task UpdateDataAsync() + { + //DataSource = await NwindDataService.GetEmployeesEditableAsync(); + //refresh grid + logToBrowserConsole.LogToBC("orderData grid refreshed"); + } + + protected override void OnInitialized() + { + base.OnInitialized(); + + + + + } + + void ColumnChooserButton_Click() + { + Grid.ShowColumnChooser(); + } + +} diff --git a/TIAMSharedUI/Shared/Users/AdminNavMenu.razor b/TIAMSharedUI/Shared/Users/AdminNavMenu.razor index 3245ce3c..b02451b8 100644 --- a/TIAMSharedUI/Shared/Users/AdminNavMenu.razor +++ b/TIAMSharedUI/Shared/Users/AdminNavMenu.razor @@ -34,6 +34,11 @@ Properties
+