Skip to content

Commit

Permalink
added numeric field property editor component
Browse files Browse the repository at this point in the history
  • Loading branch information
suxrobGM committed Jul 31, 2024
1 parent 238dff6 commit 067730b
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/FormBuilder/Components/NumericFieldPropertyEditor.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@typeparam TValue where TValue : struct

<RadzenFormField Text="Min">
<RadzenNumeric TValue="decimal?" Value="Field.Min" ValueChanged="OnMinChanged"/>
</RadzenFormField>
<RadzenFormField Text="Max">
<RadzenNumeric TValue="decimal?" Value="Field.Max" ValueChanged="OnMaxChanged"/>
</RadzenFormField>
<RadzenFormField Text="Step">
<RadzenNumeric TValue="decimal" />
</RadzenFormField>
<div>
<RadzenCheckBox TValue="bool" Name="ShowUpDownInput" Value="Field.ShowUpDown" ValueChanged="OnShowUpDownChanged"/>
<RadzenLabel Component="ShowUpDownInput" Text="Show Up Down" />
</div>

<RadzenFormField Text="Format">
<RadzenTextBox Value="@Field.Format" ValueChanged="OnFormatChanged"/>
</RadzenFormField>
43 changes: 43 additions & 0 deletions src/FormBuilder/Components/NumericFieldPropertyEditor.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using FormBuilder.Models;
using Microsoft.AspNetCore.Components;

namespace FormBuilder.Components;

public partial class NumericFieldPropertyEditor<TValue> : ComponentBase where TValue : struct
{
[Parameter, EditorRequired]
public NumericField<TValue> Field { get; set; } = default!;

[Parameter]
public EventCallback<NumericField<TValue>> FieldChanged { get; set; }

private void OnMinChanged(decimal? value)
{
Field.Min = value;
FieldChanged.InvokeAsync(Field);
}

private void OnMaxChanged(decimal? value)
{
Field.Max = value;
FieldChanged.InvokeAsync(Field);
}

private void OnStepChanged(string value)
{
Field.Step = value;
FieldChanged.InvokeAsync(Field);
}

private void OnShowUpDownChanged(bool value)
{
Field.ShowUpDown = value;
FieldChanged.InvokeAsync(Field);
}

private void OnFormatChanged(string? value)
{
Field.Format = value;
FieldChanged.InvokeAsync(Field);
}
}

0 comments on commit 067730b

Please sign in to comment.