Merge branch 'master' of http://git2.aycode.com/Adam/TourIAm
This commit is contained in:
commit
438d41e870
|
|
@ -0,0 +1,360 @@
|
|||
@using AyCode.Core.Consts
|
||||
@using System.Linq.Expressions
|
||||
@using System.ComponentModel.DataAnnotations
|
||||
@using AyCode.Services.Loggers
|
||||
@using System.Reflection
|
||||
@using TIAM.Entities.Transfers
|
||||
@using TIAMSharedUI.Shared
|
||||
@using TIAMWebApp.Shared.Application.Utility
|
||||
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||
|
||||
<h2>Edit Form</h2>
|
||||
|
||||
@if (isEditing)
|
||||
{
|
||||
<EditForm Model="@Data"
|
||||
OnValidSubmit="@HandleValidSubmit"
|
||||
OnInvalidSubmit="@HandleInvalidSubmit"
|
||||
Context="EditFormContext">
|
||||
<DataAnnotationsValidator />
|
||||
<div class="card cw-480">
|
||||
<div class="card-header text-center py-3">
|
||||
<h4>Edit Your Details</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@CreateEditFormFields()
|
||||
</div>
|
||||
</div>
|
||||
</EditForm>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="card cw-480">
|
||||
<div class="card-header text-center py-3">
|
||||
<h4>Details</h4>
|
||||
<DxButton Click="StartEditing" RenderStyle="ButtonRenderStyle.Primary">Edit</DxButton>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@CreateCardView()
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
<p class="tm-8 cw-480 mt-2">
|
||||
@FormSubmitResult
|
||||
</p>
|
||||
|
||||
@code {
|
||||
[Parameter] public object? Data { get; set; }
|
||||
[Parameter] public List<string> IgnoreReflection { get; set; }
|
||||
[Parameter] public EventCallback<object> OnSubmit { get; set; }
|
||||
[Parameter] public bool isEditing { get; set; } = false;
|
||||
|
||||
string _formSubmitResult = "";
|
||||
private string _spinnerClass = "";
|
||||
|
||||
string FormSubmitResult = "";
|
||||
private LoggerClient<DynamicEditForm> _logger;
|
||||
string PhoneMask { get; set; } = AcRegExpression.PhoneNumberMask;
|
||||
string EmailMask { get; set; } = AcRegExpression.EmailMask;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_logger = new LoggerClient<DynamicEditForm>(LogWriters.ToArray());
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
// void HandleValidSubmit()
|
||||
// {
|
||||
// FormSubmitResult = "You have been registered successfully.";
|
||||
// isEditing = false; // Stop editing after successful submission
|
||||
// }
|
||||
|
||||
async Task HandleValidSubmit()
|
||||
{
|
||||
//_spinnerClass = "spinner-border spinner-border-sm";
|
||||
//await Task.Delay(500);
|
||||
|
||||
var debugString = "Success: ";
|
||||
|
||||
var myType = Data.GetType();
|
||||
IList<PropertyInfo> props = new List<PropertyInfo>(myType.GetProperties());
|
||||
|
||||
foreach (var prop in props)
|
||||
{
|
||||
var propValue = prop.GetValue(Data, null);
|
||||
|
||||
// Do something with propValue
|
||||
debugString += $"{prop.Name} = {propValue}\n";
|
||||
}
|
||||
|
||||
_formSubmitResult = debugString;
|
||||
_spinnerClass = "";
|
||||
|
||||
await OnSubmit.InvokeAsync(Data);
|
||||
|
||||
isEditing = false;
|
||||
|
||||
}
|
||||
|
||||
void HandleInvalidSubmit()
|
||||
{
|
||||
FormSubmitResult = "Please correct all errors";
|
||||
}
|
||||
|
||||
void StartEditing()
|
||||
{
|
||||
isEditing = true;
|
||||
}
|
||||
|
||||
public RenderFragment CreateCardView() => cardViewBuilder =>
|
||||
{
|
||||
var mytype = Data.GetType();
|
||||
var propertyList = mytype.GetProperties();
|
||||
|
||||
foreach (var property in propertyList)
|
||||
{
|
||||
if (IgnoreReflection.Contains(property.Name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var displayLabel = (DisplayAttribute)property.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault();
|
||||
|
||||
cardViewBuilder.OpenElement(0, "p");
|
||||
cardViewBuilder.AddContent(1, $"{displayLabel?.Name ?? property.Name}: {property.GetValue(Data)}");
|
||||
cardViewBuilder.CloseElement();
|
||||
}
|
||||
};
|
||||
|
||||
public RenderFragment CreateEditFormFields() => formLayoutBuilder =>
|
||||
{
|
||||
_logger.Debug($"Data type: {Data.GetType().FullName}");
|
||||
var mytype = Data.GetType();
|
||||
var propertyList = mytype.GetProperties();
|
||||
_logger.Debug($"Data property list count: {propertyList.Length}");
|
||||
formLayoutBuilder.OpenComponent<DxFormLayout>(0);
|
||||
formLayoutBuilder.AddAttribute(1, "ChildContent", (RenderFragment)((layoutItemBuilder) =>
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var property in propertyList)
|
||||
{
|
||||
if (IgnoreReflection.Contains(property.Name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var attrList = (DataTypeAttribute)property.GetCustomAttributes(typeof(DataTypeAttribute), false).FirstOrDefault();
|
||||
var displayLabel = (DisplayAttribute)property.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault();
|
||||
layoutItemBuilder.OpenComponent<DxFormLayoutItem>(i++);
|
||||
layoutItemBuilder.AddAttribute(i++, "Caption", displayLabel?.Name ?? property.Name);
|
||||
layoutItemBuilder.AddAttribute(i++, "ColSpanMd", 12);
|
||||
var access = Expression.Property(Expression.Constant(Data), property.Name);
|
||||
var lambda = Expression.Lambda(typeof(Func<>).MakeGenericType(property.PropertyType), access);
|
||||
layoutItemBuilder.AddAttribute(i++, "Template", (RenderFragment<Object>)((context) => ((editor) =>
|
||||
{
|
||||
var j = 0;
|
||||
switch (attrList?.DataType)
|
||||
{
|
||||
case DataType.Text:
|
||||
editor.OpenComponent<DxTextBox>(j++);
|
||||
editor.AddAttribute(j++, "Text", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "TextExpression", lambda);
|
||||
editor.AddAttribute(j++, "CssClass", "form-field");
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
case DataType.Password:
|
||||
editor.OpenComponent<DxTextBox>(j++);
|
||||
editor.AddAttribute(j++, "Password", true);
|
||||
editor.AddAttribute(j++, "NullText", "Password");
|
||||
editor.AddAttribute(j++, "Text", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "CssClass", "form-field");
|
||||
editor.AddAttribute(j++, "TextExpression", lambda);
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
case DataType.PhoneNumber:
|
||||
editor.OpenComponent<DxMaskedInput<string>>(j++);
|
||||
editor.AddAttribute(j++, "Value", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "MaskMode", MaskMode.RegEx);
|
||||
editor.AddAttribute(j++, "Mask", PhoneMask);
|
||||
editor.AddAttribute(j++, "BindValueMode", BindValueMode.OnInput);
|
||||
editor.AddAttribute(j++, "NullText", "+11234567890");
|
||||
editor.AddAttribute(j++, "MaskAutoCompleteMode", MaskAutoCompleteMode.None);
|
||||
editor.AddAttribute(j++, "ValueExpression", lambda);
|
||||
editor.AddAttribute(j++, "CssClass", "form-field");
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
case DataType.Date:
|
||||
editor.OpenComponent<DxDateEdit<DateTime>>(j);
|
||||
editor.AddAttribute(j++, "Date", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "DateExpression", lambda);
|
||||
editor.AddAttribute(j++, "CssClass", "form-field");
|
||||
editor.AddAttribute(j++, "DateChanged", EventCallback.Factory.Create<DateTime>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
case DataType.Custom:
|
||||
if (property.PropertyType == typeof(double))
|
||||
{
|
||||
|
||||
editor.OpenComponent<DxMaskedInput<double>>(j);
|
||||
|
||||
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<double>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
}
|
||||
else if (property.PropertyType == typeof(int))
|
||||
{
|
||||
|
||||
editor.OpenComponent<DxMaskedInput<int>>(j);
|
||||
|
||||
editor.AddAttribute(j++, "Value", property.GetValue(Data));
|
||||
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<int>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
}
|
||||
else if (property.PropertyType == typeof(IEnumerable<string>) && property.Name == "Occupation")
|
||||
{
|
||||
|
||||
editor.OpenComponent<DxComboBox<string, string>>(j);
|
||||
editor.AddAttribute(j++, "Data", AdditionalData.Occupations);
|
||||
editor.AddAttribute(j++, "Value", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "ValueExpression", lambda);
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
else if (property.PropertyType == typeof(string) && string.Compare(attrList.CustomDataType, "TransferDestination", true) == 0)
|
||||
{
|
||||
|
||||
editor.OpenComponent<ComboboxItemSelector>(j);
|
||||
editor.AddAttribute(j++, "TextValue", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "CssClass", "form-field");
|
||||
// editor.AddAttribute(j++, "ValExpression", lambda);
|
||||
editor.AddAttribute(j++, "OnSliderChanged", EventCallback.Factory.Create<string>(this, result =>
|
||||
{
|
||||
_logger.Debug($"Slider changed to {result}");
|
||||
property.SetValue(Data, result);
|
||||
_logger.DetailConditional($"bleh: {property.Name} = {property.GetValue(Data)}");
|
||||
|
||||
}));
|
||||
|
||||
editor.CloseComponent();
|
||||
|
||||
}
|
||||
|
||||
else if (property.PropertyType == typeof(string) && string.Compare(attrList.CustomDataType, "FullName", true) == 0)
|
||||
{
|
||||
|
||||
editor.OpenComponent<FullNameEditor>(j);
|
||||
editor.AddAttribute(j++, "NullText", "Please tell us your name.");
|
||||
editor.AddAttribute(j++, "FirstNameChanged", EventCallback.Factory.Create<string>(this, result =>
|
||||
{
|
||||
_logger.DetailConditional($"FirstName changed to {result}");
|
||||
|
||||
//find property with name FirstName
|
||||
var firstNameProperty = propertyList.FirstOrDefault(p => p.Name == "FirstName");
|
||||
firstNameProperty.SetValue(Data, result);
|
||||
//find property with name LastName
|
||||
var lastNameProperty = propertyList.FirstOrDefault(p => p.Name == "LastName");
|
||||
//combine the two values, if they are not null
|
||||
if (firstNameProperty != null && lastNameProperty != null)
|
||||
{
|
||||
var firstName = result;
|
||||
var lastName = (string)lastNameProperty.GetValue(Data);
|
||||
var fullName = $"{firstName} {lastName}";
|
||||
property.SetValue(Data, fullName);
|
||||
}
|
||||
}));
|
||||
|
||||
editor.AddAttribute(j++, "LastNameChanged", EventCallback.Factory.Create<string>(this, result =>
|
||||
{
|
||||
_logger.DetailConditional($"LastName changed to {result}");
|
||||
|
||||
//find property with name FirstName
|
||||
var firstNameProperty = propertyList.FirstOrDefault(p => p.Name == "FirstName");
|
||||
//find property with name LastName
|
||||
var lastNameProperty = propertyList.FirstOrDefault(p => p.Name == "LastName");
|
||||
lastNameProperty.SetValue(Data, result);
|
||||
//combine the two values, if they are not null
|
||||
if (firstNameProperty != null && lastNameProperty != null)
|
||||
{
|
||||
var firstName = (string)firstNameProperty.GetValue(Data);
|
||||
var lastName = result;
|
||||
var fullName = $"{firstName} {lastName}";
|
||||
property.SetValue(Data, fullName);
|
||||
}
|
||||
_logger.DetailConditional($"bleh: {property.Name} = {property.GetValue(Data)}");
|
||||
StateHasChanged(); // Add this line to refresh the UI
|
||||
}));
|
||||
|
||||
editor.CloseComponent();
|
||||
editor.OpenComponent<DxTextBox>(j++);
|
||||
/*editor.AddAttribute(j++, "CssClass", "form-field");*/
|
||||
editor.AddAttribute(j++, "NullText", "Please type in the above fields");
|
||||
editor.AddAttribute(j++, "Enabled", false);
|
||||
editor.AddAttribute(j++, "Text", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "TextExpression", lambda);
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<string>(this, str =>
|
||||
{
|
||||
property.SetValue(Data, str);
|
||||
_logger.DetailConditional($"bleh: {property.Name} = {property.GetValue(Data)}");
|
||||
}));
|
||||
editor.CloseComponent();
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
case DataType.MultilineText:
|
||||
editor.OpenComponent<DxMemo>(j);
|
||||
editor.AddAttribute(j++, "Text", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "TextExpression", lambda);
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
default:
|
||||
editor.OpenComponent<DxTextBox>(j++);
|
||||
editor.AddAttribute(j++, "Text", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "TextExpression", lambda);
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
}
|
||||
})));
|
||||
|
||||
layoutItemBuilder.CloseComponent();
|
||||
layoutItemBuilder.OpenElement(i++, "div");
|
||||
layoutItemBuilder.AddAttribute(i++, "class", "text-danger");
|
||||
layoutItemBuilder.OpenComponent(i++, typeof(ValidationMessage<>).MakeGenericType(property.PropertyType));
|
||||
layoutItemBuilder.AddAttribute(i++, "For", lambda);
|
||||
layoutItemBuilder.CloseComponent();
|
||||
layoutItemBuilder.CloseElement();
|
||||
}
|
||||
layoutItemBuilder.OpenComponent<DxFormLayoutItem>(i++);
|
||||
layoutItemBuilder.AddAttribute(i++, "Template", (RenderFragment<Object>)((context) => ((editor) =>
|
||||
{
|
||||
editor.OpenComponent<DxButton>(i++);
|
||||
editor.AddAttribute(i++, "SubmitFormOnClick", true);
|
||||
editor.AddAttribute(i++, "Text", "Save");
|
||||
editor.CloseComponent();
|
||||
})));
|
||||
|
||||
layoutItemBuilder.CloseComponent();
|
||||
}));
|
||||
formLayoutBuilder.CloseComponent();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -1,10 +1,16 @@
|
|||
@page "/user/createAndManageTransfer"
|
||||
@using TIAMSharedUI.Pages.Components.EditComponents
|
||||
@using TIAMSharedUI.Shared
|
||||
@using AyCode.Services.Loggers
|
||||
@using TIAMWebApp.Shared.Application.Interfaces;
|
||||
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
||||
@using TIAMWebApp.Shared.Application.Utility
|
||||
@layout AdminLayout
|
||||
@inject IPopulationStructureDataProvider DataProvider
|
||||
@inject ISupplierService SupplierService
|
||||
@inject ISessionService SessionService
|
||||
@inject IUserDataService UserDataService
|
||||
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||
|
||||
<PageTitle>Transfer</PageTitle>
|
||||
|
||||
|
||||
|
|
@ -14,14 +20,11 @@
|
|||
|
||||
|
||||
|
||||
<!-- Stats admin-->
|
||||
<hr />
|
||||
|
||||
<div class="row py-3">
|
||||
<div class=" col-12 col-xl-3">
|
||||
|
||||
</div>
|
||||
|
||||
<DynamicEditForm Data="Data" isEditing="true" IgnoreReflection="TransferIgnorList" OnSubmit="SubmitForm"></DynamicEditForm>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
@ -30,15 +33,39 @@
|
|||
|
||||
|
||||
@code {
|
||||
string Id = "2312-32132121-32123";
|
||||
bool isUserLoggedIn;
|
||||
int userType = 0;
|
||||
private LoggerClient<CreateAndManageTransfer> _logger;
|
||||
private TransferWizardModel Data;
|
||||
public List<string> TransferIgnorList = new List<string>
|
||||
{
|
||||
"Id",
|
||||
"UserId",
|
||||
"ProductId",
|
||||
"PaymentId",
|
||||
"FirstName",
|
||||
"LastName",
|
||||
"UserProductMappingId",
|
||||
"UserProductToCarId",
|
||||
"ReferralId",
|
||||
"Price"
|
||||
};
|
||||
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_logger = new LoggerClient<CreateAndManageTransfer>(LogWriters.ToArray());
|
||||
Data = new TransferWizardModel();
|
||||
base.OnInitialized();
|
||||
|
||||
}
|
||||
|
||||
public async Task SubmitForm(object result)
|
||||
{
|
||||
var valami = (TransferWizardModel)result;
|
||||
//valami.ProductId = SessionService.User.UserId; //TODO ProductID!
|
||||
// await WizardProcessor.ProcessWizardAsync<TransferDestinationWizardModel>(result.GetType(), result);
|
||||
|
||||
_logger.Info($"Submitted nested form: {result.GetType().FullName}, {valami.Destination}, {valami.PickupAddress}, {valami.ProductId}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
@page "/chat"
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using TIAM.Entities.Users
|
||||
@using TIAMSharedUI.Pages.Components.EditComponents
|
||||
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
||||
@using TIAMWebApp.Shared.Application.Services
|
||||
@using TIAMSharedUI.Pages.Components
|
||||
@inject SignalRService SignalRService
|
||||
@attribute [Authorize]
|
||||
<h3>Chat</h3>
|
||||
|
|
@ -31,17 +35,36 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<NavLink href="tictactoe">
|
||||
TicTacToe
|
||||
</NavLink>
|
||||
<DynamicEditForm Data="Data" IgnoreReflection="IgnoreList"></DynamicEditForm>
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
<NavLink href="tictactoe">
|
||||
TicTacToe
|
||||
</NavLink>
|
||||
</li>
|
||||
<li>
|
||||
<NavLink href="phonevalidator">
|
||||
phone validator
|
||||
</NavLink>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
<NavLink href="create-payment">
|
||||
Create Payment
|
||||
</NavLink>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
|
||||
<NavLink href="@($"mytransfers/{Guid.Parse("108E5A63-AA9E-47BE-ACFA-00306FFC5215")}")">
|
||||
My trasnfers
|
||||
</NavLink>
|
||||
</li>
|
||||
<li></li>
|
||||
</ul>
|
||||
|
||||
<NavLink href="create-payment">
|
||||
Create Payment
|
||||
</NavLink>
|
||||
|
||||
<NavLink href="@($"mytransfers/{Guid.Parse("108E5A63-AA9E-47BE-ACFA-00306FFC5215")}")">
|
||||
My trasnfers
|
||||
</NavLink>
|
||||
|
||||
@code {
|
||||
private string userName;
|
||||
|
|
@ -49,10 +72,23 @@
|
|||
private List<string> messages = new List<string>();
|
||||
//private string hrefString = "mytransfers/" + "108E5A63-AA9E-47BE-ACFA-00306FFC5215";
|
||||
|
||||
private MessageWizardModel Data;
|
||||
|
||||
public List<string> IgnoreList =
|
||||
[
|
||||
nameof(MessageWizardModel.ReceiverEmailAddress),
|
||||
nameof(MessageWizardModel.ReceiverFullName),
|
||||
nameof(MessageWizardModel.ReceiverId),
|
||||
nameof(MessageWizardModel.SenderEmailAddress),
|
||||
nameof(MessageWizardModel.SenderFullName),
|
||||
nameof(MessageWizardModel.SenderId),
|
||||
nameof(MessageWizardModel.ContextId)
|
||||
];
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
userName = Guid.NewGuid().ToString();
|
||||
|
||||
Data = new MessageWizardModel();
|
||||
SignalRService.OnMessageReceived += (user, message) =>
|
||||
{
|
||||
messages.Add($"{user}: {message}");
|
||||
|
|
@ -10,9 +10,9 @@ using TIAM.Models.Dtos.Users;
|
|||
using TIAMWebApp.Shared.Application.Interfaces;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
|
||||
namespace TIAMSharedUI.Pages
|
||||
namespace TIAMSharedUI.Pages.Utility
|
||||
{
|
||||
public partial class DbTestComponent
|
||||
public partial class DbTestComponent : ComponentBase
|
||||
{
|
||||
[Parameter]
|
||||
public string EmailAddress
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
@page "/phonevalidator"
|
||||
|
||||
@using System.Text.RegularExpressions
|
||||
|
||||
|
||||
<EditForm Model="@phoneNumberModel" OnValidSubmit="HandleValidSubmit">
|
||||
<DataAnnotationsValidator />
|
||||
<ValidationSummary />
|
||||
|
||||
<DxTextBox @bind-Text="phoneNumberModel.PhoneNumber" Placeholder="Enter phone number" />
|
||||
<DxButton Context="BtnContext" SubmitFormOnClick="true" RenderStyle=@ButtonRenderStyle.Primary>Validate</DxButton>
|
||||
</EditForm>
|
||||
|
||||
<p>@result</p>
|
||||
|
||||
@if (validationResult.HasValue)
|
||||
{
|
||||
<DxLabel CssClass="mt-3">
|
||||
@if (validationResult.Value)
|
||||
{
|
||||
<span class="text-success">The phone number is valid.</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="text-danger">The phone number is invalid.</span>
|
||||
}
|
||||
</DxLabel>
|
||||
}
|
||||
|
||||
@code {
|
||||
private PhoneNumberModel phoneNumberModel = new PhoneNumberModel();
|
||||
private bool? validationResult = null;
|
||||
private string result = "";
|
||||
private void HandleValidSubmit()
|
||||
{
|
||||
validationResult = IsValidInternationalPhoneNumber(phoneNumberModel.PhoneNumber);
|
||||
result = $"Validation result for {phoneNumberModel.PhoneNumber}: {validationResult}";
|
||||
}
|
||||
|
||||
private bool IsValidInternationalPhoneNumber(string phoneNumber)
|
||||
{
|
||||
if (string.IsNullOrEmpty(phoneNumber))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// string pattern = @"\+(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)\W*\d\W*\d\W*\d\W*\d\W*\d\W*\d\W*\d\W*\d\W*(\d{1,2})";
|
||||
string pattern = @"^\+(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)\W*\d(\W*\d){1,14}$";
|
||||
Regex regex = new Regex(pattern);
|
||||
|
||||
return regex.IsMatch(phoneNumber);
|
||||
}
|
||||
|
||||
public class PhoneNumberModel
|
||||
{
|
||||
public string PhoneNumber { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
@using System.Linq.Expressions
|
||||
@using AyCode.Core.Loggers
|
||||
@using AyCode.Services.Loggers
|
||||
@using TIAM.Core.Loggers
|
||||
@using TIAM.Entities.Transfers
|
||||
@using TIAM.Services
|
||||
@using TIAMSharedUI.Pages
|
||||
@using TIAMSharedUI.Pages.User.SysAdmins
|
||||
@using TIAMWebApp.Shared.Application.Interfaces
|
||||
@using TIAMWebApp.Shared.Application.Services
|
||||
@using TIAMWebApp.Shared.Application.Utility
|
||||
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||
@inject AdminSignalRClient _adminSignalRClient
|
||||
@inject ITransferDataService TransferDataService
|
||||
|
||||
<label for="cbOverview" class="demo-text cw-480 mb-1">
|
||||
Select a destination
|
||||
</label>
|
||||
<DxComboBox Data="@Data"
|
||||
InputCssClass="@CssClass"
|
||||
@bind-Value="@SelectedDestination"
|
||||
TextFieldName="@nameof(TransferDestination.Name)"
|
||||
CssClass="cw-480"
|
||||
InputId="cbOverview" />
|
||||
|
||||
@* <p class="demo-text cw-480 mt-3">
|
||||
@GetSelectedItemDescription()
|
||||
</p> *@
|
||||
|
||||
@*
|
||||
<DxComboBox Data="@Data"
|
||||
ValueExpression="@valueExpression"
|
||||
TextFieldName="@nameof(TransferDestination.Name)"
|
||||
CssClass="cw-480"
|
||||
InputId="cbOverview"
|
||||
ValueChanged="@((TransferDestination destination) => SetNewDestination(destination))" /> *@
|
||||
|
||||
|
||||
@code {
|
||||
[Parameter] public EventCallback<string> OnSliderChanged { get; set; }
|
||||
|
||||
[Parameter] public string TextValue { get; set; } = "";
|
||||
|
||||
[Parameter] public string CssClass { get; set; } = "";
|
||||
|
||||
public List<TransferDestination> Destinations = new List<TransferDestination>();
|
||||
|
||||
public DxTextBox TextField;
|
||||
|
||||
TransferDestination Result;
|
||||
|
||||
ILogger _logger;
|
||||
|
||||
IEnumerable<TransferDestination> Data { get; set; }
|
||||
|
||||
private TransferDestination _selectedDestination;
|
||||
public TransferDestination SelectedDestination
|
||||
{
|
||||
get => _selectedDestination;
|
||||
set
|
||||
{
|
||||
if (_selectedDestination != value)
|
||||
{
|
||||
_selectedDestination = value;
|
||||
SetNewDestination(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_logger = new LoggerClient<ComboboxItemSelector>(LogWriters.ToArray());
|
||||
|
||||
Data = await _adminSignalRClient.GetAllAsync<List<TransferDestination>>(SignalRTags.GetAllTransferDestinations);
|
||||
_logger.Debug($"List length: {Data.Count().ToString()}");
|
||||
SelectedDestination = Data.FirstOrDefault();
|
||||
}
|
||||
// RenderFragment GetSelectedItemDescription()
|
||||
// {
|
||||
// if (SelectedDestination != null)
|
||||
// {
|
||||
// SetNewDestination(SelectedDestination);
|
||||
// return @<text>
|
||||
// Selected Item: (
|
||||
// @GetFieldDescription(nameof(TransferDestination.Name), SelectedDestination.Name),
|
||||
// @GetFieldDescription(nameof(TransferDestination.AddressString), SelectedDestination.AddressString),
|
||||
// @GetFieldDescription(nameof(TransferDestination.Description), SelectedDestination.Description)
|
||||
// )
|
||||
// </text>;
|
||||
// }
|
||||
// return @<text>Selected Item: <b>null</b></text>;
|
||||
|
||||
// }
|
||||
|
||||
public void SetNewDestination(TransferDestination destination)
|
||||
{
|
||||
OnSliderChanged.InvokeAsync(destination.Name);
|
||||
}
|
||||
|
||||
// RenderFragment GetFieldDescription(string fieldName, object value)
|
||||
// {
|
||||
// return @<text>@fieldName: <b>@value</b></text>;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
|
||||
|
|
@ -69,7 +69,8 @@ namespace TIAMSharedUI.Shared.Components
|
|||
{
|
||||
_logger.Debug($"Navbar refresh called! {DateTime.Now} ");
|
||||
|
||||
OnInitialized();
|
||||
//OnInitialized();
|
||||
InitUser();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
|
|
@ -115,8 +116,13 @@ namespace TIAMSharedUI.Shared.Components
|
|||
|
||||
_logger.Debug($"Navbar OnInit {DateTime.Now} ");
|
||||
|
||||
InitUser();
|
||||
}
|
||||
|
||||
private void InitUser()
|
||||
{
|
||||
if (sessionService.User != null)
|
||||
{
|
||||
{
|
||||
myUser = true;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -227,13 +227,13 @@
|
|||
protected override void OnInitialized()
|
||||
{
|
||||
_logger = new LoggerClient<AdminNavMenu>(LogWriters.ToArray());
|
||||
_logger.Debug($"UserId: {SessionService.User.UserModelDto.Id}");
|
||||
//_logger.Debug($"UserId: {SessionService.User.UserModelDto.Id}"); //errorokat dobott
|
||||
IsDevAdmin = SessionService.IsDevAdmin;
|
||||
_logger.Debug($"UserId: {SessionService.IsDevAdmin}");
|
||||
//_logger.Debug($"UserId: {SessionService.IsDevAdmin}");
|
||||
IsSysAdmin = SessionService.IsSysAdmin;
|
||||
_logger.Debug($"UserId: {SessionService.IsSysAdmin}");
|
||||
//_logger.Debug($"UserId: {SessionService.IsSysAdmin}");
|
||||
IsDriver = SessionService.IsDriver;
|
||||
_logger.Debug($"UserId: {SessionService.IsDriver}");
|
||||
//_logger.Debug($"UserId: {SessionService.IsDriver}");
|
||||
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@
|
|||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="Pages\Utility\DynamicForm.razor" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<SupportedPlatform Include="browser" />
|
||||
|
|
@ -82,4 +86,16 @@
|
|||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<_ContentIncludedByDefault Remove="Pages\Utility\DynamicForm.razor" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="Pages\Utility\DynamicForm.razor" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<UpToDateCheckInput Remove="Pages\Utility\DynamicForm.razor" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ EndProject
|
|||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DD32C7C2-218C-4148-8FD6-1AB3C824A7D5}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
DeployReadme.txt = DeployReadme.txt
|
||||
C:\Users\Fullepi\Desktop\SqlDataCompare_DevRelese_to_Prod.dcmp = C:\Users\Fullepi\Desktop\SqlDataCompare_DevRelese_to_Prod.dcmp
|
||||
SqlSchemaCompare_Dev_to_DevRelease.scmp = SqlSchemaCompare_Dev_to_DevRelease.scmp
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
|
|
|||
Loading…
Reference in New Issue