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