fix(EditorForm): update ItemsPerRow value is 1 logic (#3952)

* fix: 兼容 ItemsPerRow=1 情况

* chore: bump version 8.7.5

* doc: 更新文档

* doc: 更新注释文档
This commit is contained in:
Argo Zhang 2024-07-30 18:38:05 +08:00 committed by GitHub
parent e2fd0797e7
commit 6b75cf5b73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 15 additions and 17 deletions

View File

@ -21,9 +21,9 @@
<GroupBox Title="@Localizer["GroupBoxTitle"]" style="margin-top: 1.5rem;">
<EditorForm Model="@Model">
<FieldItems>
<EditorItem @bind-Field="@context.Education" Editable="false" />
<EditorItem @bind-Field="@context.Complete" Editable="false" />
<EditorItem @bind-Field="@context.Hobby" Items="@Hobbies" Editable="IgnoreItem"/>
<EditorItem @bind-Field="@context.Education" Readonly="true" />
<EditorItem @bind-Field="@context.Complete" Readonly="true" />
<EditorItem @bind-Field="@context.Hobby" Items="@Hobbies" Readonly="true" />
</FieldItems>
<Buttons>
<Button Icon="fa-solid fa-floppy-disk" Text="@Localizer["SubButtonText"]" />
@ -33,8 +33,10 @@
</DemoBlock>
<DemoBlock Title="@Localizer["ValidateFormTitle"]" Introduction="@Localizer["ValidateFormIntro"]" Name="ValidateForm">
<p>@((MarkupString)Localizer["ValidateFormTips1"].Value)</p>
<p>@((MarkupString)Localizer["ValidateFormTips2"].Value)</p>
<section ignore>
<p>@((MarkupString)Localizer["ValidateFormTips1"].Value)</p>
<p>@((MarkupString)Localizer["ValidateFormTips2"].Value)</p>
</section>
<GroupBox Title="@Localizer["GroupBoxTitle"]" style="margin-top: 1.5rem;">
<ValidateForm Model="@ValidateModel">
<EditorForm TModel="Foo">
@ -63,7 +65,7 @@
</DemoBlock>
<DemoBlock Title="@Localizer["SkipValidateTitle"]" Introduction="@Localizer["SkipValidateIntro"]" Name="SkipValidate">
<GroupBox Title="@Localizer["GroupBoxTitle"]">
<GroupBox Title="@Localizer["GroupBoxTitle"]" style="margin-top: 1.5rem;">
<p>@((MarkupString)Localizer["SkipValidateDescription"].Value)</p>
<ValidateForm Model="Model">
<EditorForm Model="Model" AutoGenerateAllItem="false">

View File

@ -24,8 +24,6 @@ public sealed partial class EditorForms
[NotNull]
private IStringLocalizer<Foo>? FooLocalizer { get; set; }
private bool IgnoreItem { get; set; } = true;
private List<SelectedItem> DummyItems { get; } =
[
new SelectedItem("1", "1"),
@ -55,8 +53,6 @@ public sealed partial class EditorForms
[NotNull]
private Foo? ValidateModel { get; set; }
private void OnClickIgnoreColumn() => IgnoreItem = !IgnoreItem;
private AttributeItem[] GetAttributes() =>
[
new()
@ -149,8 +145,8 @@ public sealed partial class EditorForms
}
];
private IEnumerable<AttributeItem> GetEditorItemAttributes() => new AttributeItem[]
{
private List<AttributeItem> GetEditorItemAttributes() =>
[
new()
{
Name = "Field",
@ -199,5 +195,5 @@ public sealed partial class EditorForms
ValueList = " — ",
DefaultValue = " — "
}
};
];
}

View File

@ -12,7 +12,7 @@ public abstract class AutoGenerateBaseAttribute : Attribute
/// <summary>
/// 获得/设置 当前列是否可编辑 默认为 true 当设置为 false 时自动生成编辑 UI 不生成此列
/// </summary>
[Obsolete("已弃用,是否显示使用 Visible 参数,新建时使用 IsVisibleWhenAdd 编辑时使用 IsVisibleWhenEdit; Discarded, use Visible parameter. IsVisibleWhenAdd should be used when creating a new one, and IsVisibleWhenEdit should be used when editing")]
[Obsolete("已弃用,是否可编辑改用 Readonly 参数,是否可见改用 Ignore 参数; Deprecated If it is editable, use the Readonly parameter. If it is visible, use the Ignore parameter.")]
[ExcludeFromCodeCoverage]
public bool Editable { get; set; } = true;

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<Version>8.7.5-beta03</Version>
<Version>8.7.5</Version>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">

View File

@ -38,7 +38,7 @@ public partial class EditorForm<TModel> : IShowLabel
}
return CssBuilder.Default("col-12")
.AddClass($"col-sm-{cols}", cols > 0) // 指定 Cols
.AddClass($"col-sm-6 col-md-{mdCols}", cols == 0 && item.Items == null && item.Rows == 0) // 指定 ItemsPerRow
.AddClass($"col-sm-6 col-md-{mdCols}", mdCols < 12 && cols == 0 && item.Items == null && item.Rows == 0) // 指定 ItemsPerRow
.Build();
}

View File

@ -153,7 +153,7 @@ public class TableColumn<TItem, TType> : BootstrapComponentBase, ITableColumn
/// </summary>
[Parameter]
[ExcludeFromCodeCoverage]
[Obsolete("已弃用,是否显示使用 Visible 参数,新建时使用 IsVisibleWhenAdd 编辑时使用 IsVisibleWhenEdit 只读使用 Readonly 参数,新建时使用 IsReadonlyWhenAdd 编辑时使用 IsReadonlyWhenEdit 参数; Discarded, use Visible parameter. IsVisibleWhenAdd should be used when creating a new one, and IsVisibleWhenEdit should be used when editing")]
[Obsolete("已弃用,是否可编辑改用 Readonly 参数,是否可见改用 Ignore 参数; Deprecated If it is editable, use the Readonly parameter. If it is visible, use the Ignore parameter.")]
public bool Editable { get; set; } = true;
/// <summary>