67 lines
1.7 KiB
C#
67 lines
1.7 KiB
C#
using DevExpress.Blazor;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace TIAMSharedUI.Pages.Components
|
|
{
|
|
public partial class FullNameEditor : ComponentBase
|
|
{
|
|
|
|
[Parameter]
|
|
public string FirstName { get; set; }
|
|
|
|
[Parameter]
|
|
public string LastName { get; set; }
|
|
|
|
public string FullName { get; set; }
|
|
|
|
[Parameter]
|
|
public string NullText { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<string> FirstNameChanged { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<string> LastNameChanged { get; set; }
|
|
|
|
public int InputDelay { get; set; } = 500;
|
|
public DxTextBox firstNameTextField;
|
|
public DxTextBox lastNameTextField;
|
|
|
|
void OnFirstNameChanged(string newValue)
|
|
{
|
|
if (!string.IsNullOrEmpty(newValue))
|
|
{
|
|
FirstName = newValue;
|
|
FullName = $"{newValue} {LastName}";
|
|
}
|
|
else
|
|
{
|
|
FirstName = null;
|
|
firstNameTextField.Text = "Invalid data";
|
|
}
|
|
FirstNameChanged.InvokeAsync(newValue);
|
|
}
|
|
void OnLastNameChanged(string newValue)
|
|
{
|
|
if (!string.IsNullOrEmpty(newValue))
|
|
{
|
|
LastName = newValue;
|
|
FullName = $"{FirstName} {newValue}";
|
|
}
|
|
else
|
|
{
|
|
LastName = null;
|
|
lastNameTextField.Text = "Invalid data";
|
|
}
|
|
LastNameChanged.InvokeAsync(newValue);
|
|
}
|
|
|
|
|
|
}
|
|
}
|