-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added numeric field property editor component
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/FormBuilder/Components/NumericFieldPropertyEditor.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
43
src/FormBuilder/Components/NumericFieldPropertyEditor.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |