FormWizard, FormWizardStep - fixed not showing steps in certain conditions, DatePicker - code cleanup, showing selected month and year

pull/13/head
markosteger 2 years ago
parent f9ba559480
commit b67973cb68

@ -1,5 +1,4 @@
using Connected.Utilities; using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components;
namespace Connected.Components; namespace Connected.Components;
public partial class DatePicker public partial class DatePicker
@ -131,17 +130,17 @@ public partial class DatePicker
public string MonthChipClass(int month) public string MonthChipClass(int month)
{ {
if (month.CompareTo(SelectedDate.Month) == 0) if (month.CompareTo(SelectedDate.Month) == 0)
return "bg-info text-white"; return "active";
else else
return "bg-core text-light"; return "";
} }
public string YearChipClass(int year) public string YearChipClass(int year)
{ {
if (year.CompareTo(SelectedDate.Year) == 0) if (year.CompareTo(SelectedDate.Year) == 0)
return "bg-info text-white"; return "active";
else else
return "bg-core text-light"; return "";
} }
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
@ -153,32 +152,6 @@ public partial class DatePicker
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }
private string NavBarClass
{
get
{
return new CssBuilder("text-justify")
.AddClass("text-md-justify")
//.AddClass("bg-warning")
.AddClass("p-2")
.AddClass("text-small")
.AddClass("text-dark")
.Build();
}
}
private string NavBarStyle
{
get
{
return new StyleBuilder("display","flex")
.AddStyle("flex-direction","row")
.AddStyle("flex-wrap","nowrap")
.AddStyle("justify-content","space-between")
.Build();
}
}
private async Task ClosePicker(bool resetDate=true) private async Task ClosePicker(bool resetDate=true)
{ {
if (resetDate) if (resetDate)

@ -207,13 +207,14 @@ public partial class FormWizard
StateHasChanged(); StateHasChanged();
} }
protected override async Task OnParametersSetAsync() /*protected override async Task OnParametersSetAsync()
{ {
if (Steps is not null) if (Steps is null) Steps = new();
Steps.Clear(); Steps.Clear();
InitializeSteps();
await base.OnParametersSetAsync(); await base.OnParametersSetAsync();
} }*/
protected override async Task OnAfterRenderAsync(bool firstRender) protected override async Task OnAfterRenderAsync(bool firstRender)
{ {

@ -9,8 +9,11 @@ public partial class FormWizardStep
[CascadingParameter] [CascadingParameter]
public FormWizard Parent { get; set; } public FormWizard Parent { get; set; }
[Parameter, EditorRequired] /// <summary>
public string Name { get; set; } /// Unique name of the step (used for properly identifying steps)
/// </summary>
[Parameter]
public string? Id { get; set; } = Guid.NewGuid().ToString();
/// <summary> /// <summary>
/// Text shown inside the button /// Text shown inside the button
@ -88,9 +91,16 @@ public partial class FormWizardStep
#region Lifecycle #region Lifecycle
private bool ItemExists()
{
if (Parent.Steps.Where(step => step.Id.Equals(this.Id)).Count() > 0) return true;
return false;
}
protected override async Task OnInitializedAsync() protected override async Task OnParametersSetAsync()
{ {
if (!ItemExists())
Parent.Steps.Add(this); Parent.Steps.Add(this);
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }

Loading…
Cancel
Save