Skip to content

Commit

Permalink
field group types
Browse files Browse the repository at this point in the history
  • Loading branch information
Modest-as committed Nov 26, 2021
1 parent d3e7391 commit 2caa02b
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Crude/Core/FieldFragments/BooleanFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ internal class BooleanFragment : FieldFragment
{
internal BooleanFragment(CrudeProperty property) : base(property) { }

public override string FragmentType => "checkbox";

public override RenderFragment Render(RenderContext context) => builder =>
{
var seq = 0;
Expand Down
2 changes: 2 additions & 0 deletions Crude/Core/FieldFragments/CrudeDropdownFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace Crude.Core.FieldFragments
{
internal class CrudeDropdownFragment : FieldFragment
{
public override string FragmentType => "select";

internal CrudeDropdownFragment(CrudeProperty property) : base(property) { }

public override RenderFragment Render(RenderContext context) => builder =>
Expand Down
2 changes: 2 additions & 0 deletions Crude/Core/FieldFragments/DateFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace Crude.Core.FieldFragments
{
internal class DateFragment<T> : FieldFragment
{
public override string FragmentType => "date";

internal DateFragment(CrudeProperty property) : base(property) { }

public override RenderFragment Render(RenderContext context) => builder =>
Expand Down
2 changes: 2 additions & 0 deletions Crude/Core/FieldFragments/EmptyFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ namespace Crude.Core.FieldFragments
{
internal class NotRenderedFragment : FieldFragment
{
public override string FragmentType => "empty";

internal NotRenderedFragment(CrudeProperty property) : base(property) { }

public override RenderFragment Render(RenderContext context) => builder =>
Expand Down
2 changes: 2 additions & 0 deletions Crude/Core/FieldFragments/EnumFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace Crude.Core.FieldFragments
{
internal class EnumFragment : FieldFragment
{
public override string FragmentType => "select";

internal EnumFragment(CrudeProperty property) : base(property) { }

public override RenderFragment Render(RenderContext context) => builder =>
Expand Down
2 changes: 2 additions & 0 deletions Crude/Core/FieldFragments/FieldFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ internal abstract class FieldFragment : IFragment

protected Type? ValidationObjectType { get; set; }

public abstract string FragmentType { get; }

protected FieldFragment(CrudeProperty property)
{
Property = property;
Expand Down
2 changes: 2 additions & 0 deletions Crude/Core/FieldFragments/NumberFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace Crude.Core.FieldFragments
{
internal class NumberFragment<T> : FieldFragment
{
public override string FragmentType => "number";

internal NumberFragment(CrudeProperty property) : base(property) { }

public override RenderFragment Render(RenderContext context) => builder =>
Expand Down
2 changes: 2 additions & 0 deletions Crude/Core/FieldFragments/StringFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace Crude.Core.FieldFragments
{
internal class StringFragment : FieldFragment
{
public override string FragmentType => "string";

internal StringFragment(CrudeProperty property) : base(property) { }

public override RenderFragment Render(RenderContext context) => builder =>
Expand Down
5 changes: 5 additions & 0 deletions Crude/Core/LayoutFragments/FieldGroupFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public RenderFragment Render(RenderContext context) => builder =>

builder.OpenElement(seq++, "crude-field-fragment");

if (!string.IsNullOrWhiteSpace(fragment.FragmentType))
{
builder.AddAttribute(seq++, "class", $"cft-{fragment.FragmentType}");
}

builder.OpenElement(seq++, "label");
builder.AddAttribute(seq++, "for", fragment.Identifier);
builder.AddContent(seq++, _property.Name.ToString(context.Formatter));
Expand Down

0 comments on commit 2caa02b

Please sign in to comment.