|
|
|
@ -1,10 +1,11 @@
|
|
|
|
|
using Connected.Enums;
|
|
|
|
|
using Connected.Classes.FormWizard;
|
|
|
|
|
using Connected.Enums;
|
|
|
|
|
using Connected.Utilities;
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
using System.Reflection.Metadata;
|
|
|
|
|
|
|
|
|
|
namespace Connected.Components;
|
|
|
|
|
public partial class FormWizard
|
|
|
|
|
public partial class FormWizard: Base
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -21,6 +22,18 @@ public partial class FormWizard
|
|
|
|
|
[Parameter]
|
|
|
|
|
public List<FormWizardStep> Steps { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Steps of type FormWizardStep
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Parameter]
|
|
|
|
|
public string LoadingText { get; set; } = "Loading wizard...";
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Steps of type FormWizardStep
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Parameter]
|
|
|
|
|
public bool DisableNavigationOnFinish { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// EventCallback for 'Finish' button click
|
|
|
|
|
/// </summary>
|
|
|
|
@ -33,16 +46,20 @@ public partial class FormWizard
|
|
|
|
|
[Parameter]
|
|
|
|
|
public EventCallback OnCancelClick { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Text shown inside the button
|
|
|
|
|
/// Options: any string variable
|
|
|
|
|
/// Default: string.Empty
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Parameter]
|
|
|
|
|
public string Id { get; set; } = Guid.NewGuid().ToString();
|
|
|
|
|
public FormWizardOptions Options { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
private string NextBtnText = "Next";
|
|
|
|
|
private string PreviousBtnText = "Previous";
|
|
|
|
|
|
|
|
|
|
private bool WizardFinished { get; set; } = false;
|
|
|
|
|
private bool NavigationDisabled { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
private FinishedState FinishedState { get; set; } = FinishedState.Unfinished;
|
|
|
|
|
|
|
|
|
|
private string NextBtnText { get; set; } = "Next";
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public int ActiveIndex
|
|
|
|
|
{
|
|
|
|
@ -101,7 +118,7 @@ public partial class FormWizard
|
|
|
|
|
{
|
|
|
|
|
FinishedState = FinishedState.Finished;
|
|
|
|
|
Steps[ActiveIndex].Completed = true;
|
|
|
|
|
WizardFinished = true;
|
|
|
|
|
if (DisableNavigationOnFinish) NavigationDisabled = true;
|
|
|
|
|
await OnFinishedClick.InvokeAsync();
|
|
|
|
|
}
|
|
|
|
|
if (FinishedState.Equals(FinishedState.Unfinished))
|
|
|
|
@ -116,9 +133,9 @@ public partial class FormWizard
|
|
|
|
|
Steps[PreviousIndex].IsPrevious = true;
|
|
|
|
|
|
|
|
|
|
if (ActiveIndex == NextIndex)
|
|
|
|
|
NextBtnText = "Finish";
|
|
|
|
|
NextBtnText = Options.FinishButtonText;
|
|
|
|
|
else
|
|
|
|
|
NextBtnText = "Next";
|
|
|
|
|
NextBtnText = Options.NextButtonText;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -135,9 +152,9 @@ public partial class FormWizard
|
|
|
|
|
Steps[PreviousIndex].IsPrevious = true;
|
|
|
|
|
|
|
|
|
|
if (ActiveIndex == NextIndex)
|
|
|
|
|
NextBtnText = "Finish";
|
|
|
|
|
NextBtnText = Options.FinishButtonText;
|
|
|
|
|
else
|
|
|
|
|
NextBtnText = "Next";
|
|
|
|
|
NextBtnText = Options.NextButtonText;
|
|
|
|
|
}
|
|
|
|
|
if (ActiveIndex == 0)
|
|
|
|
|
{
|
|
|
|
@ -148,6 +165,9 @@ public partial class FormWizard
|
|
|
|
|
|
|
|
|
|
private async Task CancelClick()
|
|
|
|
|
{
|
|
|
|
|
ResetAllChildren(true);
|
|
|
|
|
ActiveIndex = 0;
|
|
|
|
|
Steps[0].Active = true;
|
|
|
|
|
await OnCancelClick.InvokeAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -184,13 +204,14 @@ public partial class FormWizard
|
|
|
|
|
Steps[ChildIndex].IsPrevious = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ResetAllChildren()
|
|
|
|
|
private void ResetAllChildren(bool reset_finished = false)
|
|
|
|
|
{
|
|
|
|
|
foreach (var step in Steps)
|
|
|
|
|
{
|
|
|
|
|
step.Active = false;
|
|
|
|
|
step.IsNext = false;
|
|
|
|
|
step.IsPrevious = false;
|
|
|
|
|
if (reset_finished) step.Completed = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -216,11 +237,23 @@ public partial class FormWizard
|
|
|
|
|
await base.OnParametersSetAsync();
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
private bool loaded = false;
|
|
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
|
|
|
|
loaded = true;
|
|
|
|
|
await Task.Run(StateHasChanged);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
|
|
|
{
|
|
|
|
|
if (firstRender)
|
|
|
|
|
{
|
|
|
|
|
InitializeSteps();
|
|
|
|
|
if (ActiveIndex == NextIndex)
|
|
|
|
|
NextBtnText = Options.FinishButtonText;
|
|
|
|
|
else
|
|
|
|
|
NextBtnText = Options.NextButtonText;
|
|
|
|
|
}
|
|
|
|
|
await base.OnAfterRenderAsync(firstRender);
|
|
|
|
|
}
|
|
|
|
|