Skip to content

Commit

Permalink
fixed renderer issues
Browse files Browse the repository at this point in the history
  • Loading branch information
suxrobGM committed Jul 26, 2024
1 parent f8bab3e commit e7ec0b8
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/FormBuilder.DesignerApp/Pages/Designer.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

<RadzenText TextStyle="TextStyle.H3">Designer</RadzenText>

<FormBuilder></FormBuilder>
<FormEditor></FormEditor>
4 changes: 2 additions & 2 deletions src/FormBuilder.DesignerApp/Pages/Renderer.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<RadzenText TextStyle="TextStyle.H3">Renderer</RadzenText>

<RadzenStack Class="vh-100" Orientation="Orientation.Vertical" Gap="1rem">
<FormRenderer ref="@_formRendererRef" @bind-IsLoadingForm="_isLoading" />
<FormRenderer @ref="_formRendererRef" @bind-IsLoadingForm="_isLoading" />

<RadzenText TextStyle="TextStyle.Subtitle1">
Specify either Form ID or JSON design to load into renderer
</RadzenText>

<RadzenTemplateForm TItem="InputModel" Submit="() => LoadFormAsync()">
<RadzenTemplateForm TItem="InputModel" Data="_input" Submit="() => LoadFormAsync()">
<RadzenStack Orientation="Orientation.Vertical">
<RadzenFormField Text="Form ID">
<RadzenTextBox @bind-Value="_input.FormId" Disabled="_isLoading"/>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace FormBuilder.Components;
/// <summary>
/// Component that allows building forms by adding and removing inputs.
/// </summary>
public partial class FormBuilder : ComponentBase
public partial class FormEditor : ComponentBase
{
private FormDefinition _formDefinition = new();
private string _formDesignJson = "{}";
Expand Down
2 changes: 1 addition & 1 deletion src/FormBuilder/Components/FormRenderer.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ else if (!string.IsNullOrEmpty(_errorMessage))
{
<RadzenText Class="text-danger" Text="@_errorMessage" TextStyle="TextStyle.H6" />
}
else
else if (!string.IsNullOrEmpty(_formDefinition.Id))
{
<RadzenTemplateForm TItem="object">
<RadzenFieldset Text="@GetFormTitle()" Style="max-height: 600px; overflow-y: auto">
Expand Down
10 changes: 5 additions & 5 deletions src/FormBuilder/Extensions/EnumExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;

namespace System;

Expand All @@ -8,13 +8,13 @@ namespace System;
public static class EnumExtensions
{
/// <summary>
/// Gets the description of the enum value marked with the DisplayAttribute.
/// Gets the description of the enum value marked with the DescriptionAttribute.
/// </summary>
/// <param name="enumValue">
/// The enum value.
/// </param>
/// <returns>
/// The description of the enum value marked with the DisplayAttribute or the enum name if the attribute is not found.
/// The description of the enum value marked with the DescriptionAttribute or the enum name if the attribute is not found.
/// </returns>
public static string GetDescription(this Enum enumValue)
{
Expand All @@ -26,9 +26,9 @@ public static string GetDescription(this Enum enumValue)
return enumValue.ToString();
}

var displayAttribute = Attribute.GetCustomAttribute(fieldInfo, typeof(DisplayAttribute)) as DisplayAttribute;
var descriptionAttribute = Attribute.GetCustomAttribute(fieldInfo, typeof(DescriptionAttribute)) as DescriptionAttribute;

// Return the description, if it exists; otherwise, return the enum name
return displayAttribute?.Description ?? enumValue.ToString();
return descriptionAttribute?.Description ?? enumValue.ToString();
}
}
10 changes: 5 additions & 5 deletions src/FormBuilder/Models/FieldType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ namespace FormBuilder.Models;
public enum FieldType
{
[Description("Text")]
Text,
Text = 1,

[Description("Numeric (Int)")]
NumericInt,
NumericInt = 2,

[Description("Numeric (Double)")]
NumericDouble,
NumericDouble = 3,

[Description("Date")]
Date,
Date = 4,

[Description("Select (Dropdown)")]
Select,
Select = 5,
}

0 comments on commit e7ec0b8

Please sign in to comment.