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.Enums;
|
||||||
using Connected.Utilities;
|
using Connected.Utilities;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.Reflection.Metadata;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Connected.Components;
|
namespace Connected.Components;
|
||||||
public partial class FormWizard
|
public partial class FormWizard
|
||||||
@ -16,11 +15,26 @@ public partial class FormWizard
|
|||||||
[Parameter]
|
[Parameter]
|
||||||
public RenderFragment? ChildContent { get; set; }
|
public RenderFragment? ChildContent { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Steps of type FormWizardStep
|
||||||
|
/// </summary>
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public List<FormWizardStep> Steps { get; set; } = new();
|
public List<FormWizardStep> Steps { get; set; } = new();
|
||||||
|
|
||||||
[Parameter, EditorRequired]
|
/// <summary>
|
||||||
public string Id { get; set; }
|
/// 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 NextBtnText = "Next";
|
||||||
private string PreviousBtnText = "Previous";
|
private string PreviousBtnText = "Previous";
|
||||||
@ -50,7 +64,7 @@ public partial class FormWizard
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (ActiveIndex>0)
|
if (ActiveIndex > 0)
|
||||||
return ActiveIndex - 1;
|
return ActiveIndex - 1;
|
||||||
return ActiveIndex;
|
return ActiveIndex;
|
||||||
}
|
}
|
||||||
@ -62,10 +76,11 @@ public partial class FormWizard
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (ActiveIndex < StepCount-1)
|
if (ActiveIndex < StepCount - 1)
|
||||||
return ActiveIndex + 1;
|
return ActiveIndex + 1;
|
||||||
return ActiveIndex;
|
return ActiveIndex;
|
||||||
} catch
|
}
|
||||||
|
catch
|
||||||
{
|
{
|
||||||
return ActiveIndex;
|
return ActiveIndex;
|
||||||
}
|
}
|
||||||
@ -80,38 +95,17 @@ public partial class FormWizard
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NextSlide()
|
private async Task NextSlide()
|
||||||
{
|
{
|
||||||
if (NextBtnText.ToLower().Equals("finish"))
|
if (NextBtnText.ToLower().Equals("finish"))
|
||||||
{
|
{
|
||||||
FinishedState = FinishedState.Finished;
|
FinishedState = FinishedState.Finished;
|
||||||
Steps[ActiveIndex].Completed = true;
|
Steps[ActiveIndex].Completed = true;
|
||||||
WizardFinished = true;
|
WizardFinished = true;
|
||||||
|
await OnFinishedClick.InvokeAsync();
|
||||||
}
|
}
|
||||||
if (FinishedState.Equals(FinishedState.Unfinished))
|
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].Completed = true;
|
||||||
Steps[ActiveIndex].Active = false;
|
Steps[ActiveIndex].Active = false;
|
||||||
Steps[PreviousIndex].IsPrevious = false;
|
Steps[PreviousIndex].IsPrevious = false;
|
||||||
@ -132,7 +126,6 @@ public partial class FormWizard
|
|||||||
{
|
{
|
||||||
if (ActiveIndex > 0)
|
if (ActiveIndex > 0)
|
||||||
{
|
{
|
||||||
//Steps[ActiveIndex].Completed = true;
|
|
||||||
Steps[ActiveIndex].Active = false;
|
Steps[ActiveIndex].Active = false;
|
||||||
Steps[PreviousIndex].IsPrevious = false;
|
Steps[PreviousIndex].IsPrevious = false;
|
||||||
Steps[ActiveIndex].IsNext = false;
|
Steps[ActiveIndex].IsNext = false;
|
||||||
@ -146,13 +139,18 @@ public partial class FormWizard
|
|||||||
else
|
else
|
||||||
NextBtnText = "Next";
|
NextBtnText = "Next";
|
||||||
}
|
}
|
||||||
if (ActiveIndex==0)
|
if (ActiveIndex == 0)
|
||||||
{
|
{
|
||||||
ResetAllChildren();
|
ResetAllChildren();
|
||||||
Steps[ActiveIndex].Active = true;
|
Steps[ActiveIndex].Active = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task CancelClick()
|
||||||
|
{
|
||||||
|
await OnCancelClick.InvokeAsync();
|
||||||
|
}
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string Class { get; set; } = string.Empty;
|
public string Class { get; set; } = string.Empty;
|
||||||
|
|
||||||
@ -201,10 +199,10 @@ public partial class FormWizard
|
|||||||
ResetAllChildren();
|
ResetAllChildren();
|
||||||
Steps[ActiveIndex].Active = true;
|
Steps[ActiveIndex].Active = true;
|
||||||
|
|
||||||
if (ActiveIndex!=0)
|
if (ActiveIndex != 0)
|
||||||
{
|
{
|
||||||
Steps[ActiveIndex].IsNext = true;
|
Steps[ActiveIndex].IsNext = true;
|
||||||
Steps[PreviousIndex].IsPrevious= true;
|
Steps[PreviousIndex].IsPrevious = true;
|
||||||
}
|
}
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
@ -212,7 +210,7 @@ public partial class FormWizard
|
|||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
if (Steps is not null)
|
if (Steps is not null)
|
||||||
Steps.Clear();
|
Steps.Clear();
|
||||||
|
|
||||||
await base.OnParametersSetAsync();
|
await base.OnParametersSetAsync();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user