refactor(app): extract dialog component logic to code-behind
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Duempelkas.App.Components.Dialogs;
|
||||
|
||||
public partial class EditNameDialog
|
||||
{
|
||||
#region Parameters
|
||||
|
||||
[Parameter]
|
||||
public string CurrentName { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public string DialogTitle { get; set; } = "Kontoname bearbeiten";
|
||||
|
||||
[Parameter]
|
||||
public string NameLabel { get; set; } = "Kontoname";
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<string> OnSave { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback OnCancel { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
private string name = string.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Lifecycle
|
||||
|
||||
protected override void OnParametersSet() => name = CurrentName;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Actions
|
||||
|
||||
private async Task Save()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
await OnSave.InvokeAsync(name.Trim());
|
||||
}
|
||||
}
|
||||
|
||||
private async Task Cancel() => await OnCancel.InvokeAsync();
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user