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