FormWizzard - summaries, EventCallbacks for 'Cancel' and 'Finis' buttons, Id is Guid.NewId() if not set and so for not required parameter anymore
This commit is contained in:
parent
382e5551b3
commit
402e904b10
@ -1,8 +1,7 @@
|
||||
using Connected.Enums;
|
||||
using Connected.Utilities;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
using System.Reflection.Metadata;
|
||||
|
||||
namespace Connected.Components;
|
||||
public partial class FormWizard
|
||||
@ -16,11 +15,26 @@ public partial class FormWizard
|
||||
[Parameter]
|
||||
public RenderFragment? ChildContent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Steps of type FormWizardStep
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public List<FormWizardStep> Steps { get; set; } = new();
|
||||
|
||||
[Parameter, EditorRequired]
|
||||
public string Id { get; set; }
|
||||
/// <summary>
|
||||
/// EventCallback for 'Finish' button click
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public EventCallback OnFinishedClick { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// EventCallback for 'Cancel' button click
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public EventCallback OnCancelClick { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Id { get; set; } = Guid.NewGuid().ToString();
|
||||
|
||||
private string NextBtnText = "Next";
|
||||
private string PreviousBtnText = "Previous";
|
||||
@ -65,7 +79,8 @@ public partial class FormWizard
|
||||
if (ActiveIndex < StepCount - 1)
|
||||
return ActiveIndex + 1;
|
||||
return ActiveIndex;
|
||||
} catch
|
||||
}
|
||||
catch
|
||||
{
|
||||
return ActiveIndex;
|
||||
}
|
||||
@ -80,38 +95,17 @@ public partial class FormWizard
|
||||
}
|
||||
}
|
||||
|
||||
private void NextSlide()
|
||||
private async Task NextSlide()
|
||||
{
|
||||
if (NextBtnText.ToLower().Equals("finish"))
|
||||
{
|
||||
FinishedState = FinishedState.Finished;
|
||||
Steps[ActiveIndex].Completed = true;
|
||||
WizardFinished = true;
|
||||
await OnFinishedClick.InvokeAsync();
|
||||
}
|
||||
if (FinishedState.Equals(FinishedState.Unfinished))
|
||||
{
|
||||
/*if (ActiveIndex < StepCount)
|
||||
{
|
||||
Steps[ActiveIndex].Completed = true;
|
||||
ResetValuesForChild(ActiveIndex);
|
||||
if (ActiveIndex < StepCount)
|
||||
ResetValuesForChild(NextIndex);
|
||||
if (ActiveIndex > 0)
|
||||
ResetValuesForChild(PreviousIndex);
|
||||
|
||||
ActiveIndex = NextIndex;
|
||||
Steps[ActiveIndex].Active = true;
|
||||
Steps[PreviousIndex].IsPrevious = true;
|
||||
if (ActiveIndex != NextIndex)
|
||||
Steps[NextIndex].IsNext = true;
|
||||
else Steps[NextIndex].IsNext = false;
|
||||
|
||||
if (ActiveIndex == NextIndex)
|
||||
NextBtnText = "Finish";
|
||||
else
|
||||
NextBtnText = "Next";
|
||||
StateHasChanged();
|
||||
}*/
|
||||
Steps[ActiveIndex].Completed = true;
|
||||
Steps[ActiveIndex].Active = false;
|
||||
Steps[PreviousIndex].IsPrevious = false;
|
||||
@ -132,7 +126,6 @@ public partial class FormWizard
|
||||
{
|
||||
if (ActiveIndex > 0)
|
||||
{
|
||||
//Steps[ActiveIndex].Completed = true;
|
||||
Steps[ActiveIndex].Active = false;
|
||||
Steps[PreviousIndex].IsPrevious = false;
|
||||
Steps[ActiveIndex].IsNext = false;
|
||||
@ -153,6 +146,11 @@ public partial class FormWizard
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CancelClick()
|
||||
{
|
||||
await OnCancelClick.InvokeAsync();
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
public string Class { get; set; } = string.Empty;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user