Skip to content

Commit 8c22a16

Browse files
Lambert LeeArgoZhang
authored andcommitted
!3740 doc(#I69EM1): update editform demos
* update localize * update editform demos
1 parent afb4318 commit 8c22a16

10 files changed

Lines changed: 447 additions & 223 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
@inject IStringLocalizer<EditFormAlignment> Localizer
2+
3+
<ValidateForm Model="@Model">
4+
<EditorForm TModel="Foo" ItemsPerRow="2" RowType="RowType.Inline" LabelAlign="Alignment.Right">
5+
<FieldItems>
6+
<EditorItem @bind-Field="@context.Hobby" Items="@Hobbys" />
7+
</FieldItems>
8+
<Buttons>
9+
<div class="text-end">
10+
<Button ButtonType="ButtonType.Submit" Icon="fa-solid fa-floppy-disk" Text="@Localizer["SubButtonText"]" />
11+
</div>
12+
</Buttons>
13+
</EditorForm>
14+
</ValidateForm>
15+
16+
@code {
17+
/// <summary>
18+
/// Foo 类为Demo测试用,如有需要请自行下载源码查阅
19+
/// Foo class is used for Demo test, please download the source code if necessary
20+
/// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs
21+
/// </summary>
22+
[NotNull]
23+
private Foo? Model { get; set; }
24+
25+
[NotNull]
26+
private IEnumerable<SelectedItem>? Hobbys { get; set; }
27+
28+
[Inject]
29+
[NotNull]
30+
private IStringLocalizer<Foo>? FooLocalizer { get; set; }
31+
32+
/// <summary>
33+
/// OnInitialized
34+
/// </summary>
35+
protected override void OnInitialized()
36+
{
37+
base.OnInitialized();
38+
39+
Hobbys = Foo.GenerateHobbys(FooLocalizer);
40+
Model = new Foo()
41+
{
42+
Name = Localizer["TestName"],
43+
Count = 1,
44+
Address = Localizer["TestAddr"],
45+
DateTime = new DateTime(1997, 12, 05),
46+
Education = EnumEducation.Middle
47+
};
48+
}
49+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
@inject IStringLocalizer<EditFormAutoGenerate> Localizer
2+
3+
<GroupBox Title="@Localizer["GroupBoxTile"]">
4+
<p>@((MarkupString)Localizer["AutoGenerateDescription"].Value)</p>
5+
<EditorForm Model="@Model" AutoGenerateAllItem="false">
6+
<FieldItems>
7+
<EditorItem @bind-Field="@context.Name" />
8+
<EditorItem @bind-Field="@context.Count" />
9+
</FieldItems>
10+
</EditorForm>
11+
</GroupBox>
12+
13+
@code {
14+
/// <summary>
15+
/// Foo 类为Demo测试用,如有需要请自行下载源码查阅
16+
/// Foo class is used for Demo test, please download the source code if necessary
17+
/// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs
18+
/// </summary>
19+
[NotNull]
20+
private Foo? Model { get; set; }
21+
22+
/// <summary>
23+
/// OnInitialized
24+
/// </summary>
25+
protected override void OnInitialized()
26+
{
27+
base.OnInitialized();
28+
29+
Model = new Foo()
30+
{
31+
Name = Localizer["TestName"],
32+
Count = 1,
33+
Address = Localizer["TestAddr"],
34+
DateTime = new DateTime(1997, 12, 05),
35+
Education = EnumEducation.Middle
36+
};
37+
}
38+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
@inject IStringLocalizer<EditFormItemsPerRow> Localizer
2+
3+
<GroupBox Title="@Localizer["GroupBoxTile"]" style="margin-top: 1.5rem;">
4+
<ValidateForm Model="@Model">
5+
<EditorForm TModel="Foo" ItemsPerRow="3">
6+
<FieldItems>
7+
<EditorItem @bind-Field="@context.Hobby" Items="@Hobbys" />
8+
</FieldItems>
9+
<Buttons>
10+
<Button ButtonType="ButtonType.Submit" Icon="fa-solid fa-floppy-disk" Text="@Localizer["SubButtonText"]" />
11+
</Buttons>
12+
</EditorForm>
13+
</ValidateForm>
14+
</GroupBox>
15+
16+
@code {
17+
/// <summary>
18+
/// Foo 类为Demo测试用,如有需要请自行下载源码查阅
19+
/// Foo class is used for Demo test, please download the source code if necessary
20+
/// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs
21+
/// </summary>
22+
[NotNull]
23+
private Foo? Model { get; set; }
24+
25+
[NotNull]
26+
private IEnumerable<SelectedItem>? Hobbys { get; set; }
27+
28+
[Inject]
29+
[NotNull]
30+
private IStringLocalizer<Foo>? FooLocalizer { get; set; }
31+
32+
/// <summary>
33+
/// OnInitialized
34+
/// </summary>
35+
protected override void OnInitialized()
36+
{
37+
base.OnInitialized();
38+
39+
Hobbys = Foo.GenerateHobbys(FooLocalizer);
40+
Model = new Foo()
41+
{
42+
Name = Localizer["TestName"],
43+
Count = 1,
44+
Address = Localizer["TestAddr"],
45+
DateTime = new DateTime(1997, 12, 05),
46+
Education = EnumEducation.Middle
47+
};
48+
}
49+
}
50+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
@inject IStringLocalizer<EditFormNormal> Localizer
2+
3+
<GroupBox Title="@Localizer["GroupBoxTile"]" style="margin-top: 1.5rem;">
4+
<EditorForm Model="@Model">
5+
<FieldItems>
6+
<EditorItem @bind-Field="@context.Education" Editable="false" />
7+
<EditorItem @bind-Field="@context.Complete" Editable="false" />
8+
<EditorItem @bind-Field="@context.Hobby" Items="@Hobbys" />
9+
</FieldItems>
10+
<Buttons>
11+
<Button Icon="fa-solid fa-floppy-disk" Text="@Localizer["SubButtonText"]" />
12+
</Buttons>
13+
</EditorForm>
14+
</GroupBox>
15+
16+
@code {
17+
/// <summary>
18+
/// Foo 类为Demo测试用,如有需要请自行下载源码查阅
19+
/// Foo class is used for Demo test, please download the source code if necessary
20+
/// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs
21+
/// </summary>
22+
[NotNull]
23+
private Foo? Model { get; set; }
24+
25+
[NotNull]
26+
private IEnumerable<SelectedItem>? Hobbys { get; set; }
27+
28+
[Inject]
29+
[NotNull]
30+
private IStringLocalizer<Foo>? FooLocalizer { get; set; }
31+
32+
/// <summary>
33+
/// OnInitialized
34+
/// </summary>
35+
protected override void OnInitialized()
36+
{
37+
base.OnInitialized();
38+
39+
Hobbys = Foo.GenerateHobbys(FooLocalizer);
40+
Model = new Foo()
41+
{
42+
Name = Localizer["TestName"],
43+
Count = 1,
44+
Address = Localizer["TestAddr"],
45+
DateTime = new DateTime(1997, 12, 05),
46+
Education = EnumEducation.Middle
47+
};
48+
}
49+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
@inject IStringLocalizer<EditFormSkipValidate> Localizer
2+
3+
<GroupBox Title="@Localizer["GroupBoxTile"]">
4+
<p>@((MarkupString)Localizer["SkipValidateDescription"].Value)</p>
5+
<ValidateForm Model="Model">
6+
<EditorForm Model="Model" AutoGenerateAllItem="false">
7+
<FieldItems>
8+
<EditorItem @bind-Field="@context.Name" />
9+
<EditorItem @bind-Field="@context.Address" />
10+
<EditorItem @bind-Field="@context.Count">
11+
<EditTemplate Context="value">
12+
<div class="col-12 col-sm-6">
13+
<Select SkipValidate="true" @bind-Value="@value.Count" Items="@DummyItems" ShowSearch="true" />
14+
</div>
15+
<div class="col-12 col-sm-6">
16+
<BootstrapInput Value="@value.Count" Readonly="true" />
17+
</div>
18+
</EditTemplate>
19+
</EditorItem>
20+
<EditorItem @bind-Field="@context.Hobby" Items="@Hobbys" />
21+
</FieldItems>
22+
<Buttons>
23+
<Button ButtonType="ButtonType.Submit" Icon="fa-solid fa-floppy-disk" Text="@Localizer["SubButtonText"]" />
24+
</Buttons>
25+
</EditorForm>
26+
</ValidateForm>
27+
</GroupBox>
28+
29+
@code {
30+
/// <summary>
31+
/// Foo 类为Demo测试用,如有需要请自行下载源码查阅
32+
/// Foo class is used for Demo test, please download the source code if necessary
33+
/// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs
34+
/// </summary>
35+
[NotNull]
36+
private Foo? Model { get; set; }
37+
38+
[NotNull]
39+
private IEnumerable<SelectedItem>? Hobbys { get; set; }
40+
41+
[Inject]
42+
[NotNull]
43+
private IStringLocalizer<Foo>? FooLocalizer { get; set; }
44+
45+
private List<SelectedItem> DummyItems { get; } = new List<SelectedItem>()
46+
{
47+
new SelectedItem("1", "1"),
48+
new SelectedItem("2", "2"),
49+
new SelectedItem("3", "3"),
50+
new SelectedItem("4", "4"),
51+
new SelectedItem("5", "5")
52+
};
53+
54+
/// <summary>
55+
/// OnInitialized 方法
56+
/// </summary>
57+
protected override void OnInitialized()
58+
{
59+
base.OnInitialized();
60+
61+
Hobbys = Foo.GenerateHobbys(FooLocalizer);
62+
Model = new Foo()
63+
{
64+
Name = Localizer["TestName"],
65+
Count = 1,
66+
Address = Localizer["TestAddr"],
67+
DateTime = new DateTime(1997, 12, 05),
68+
Education = EnumEducation.Middle
69+
};
70+
}
71+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
@inject IStringLocalizer<EditFormValidateForm> Localizer
2+
3+
<GroupBox Title="@Localizer["GroupBoxTitle"]" style="margin-top: 1.5rem;">
4+
<ValidateForm Model="@ValidateModel">
5+
<EditorForm TModel="Foo">
6+
<FieldItems>
7+
<EditorItem @bind-Field="@context.DateTime" Readonly="true" />
8+
<EditorItem @bind-Field="@context.Hobby" Items="@Hobbys" />
9+
</FieldItems>
10+
<Buttons>
11+
<Button ButtonType="ButtonType.Submit" Icon="fa-solid fa-floppy-disk" Text='@Localizer["SubButtonText"]' />
12+
</Buttons>
13+
</EditorForm>
14+
</ValidateForm>
15+
</GroupBox>
16+
17+
@code {
18+
/// <summary>
19+
/// Foo 类为Demo测试用,如有需要请自行下载源码查阅
20+
/// Foo class is used for Demo test, please download the source code if necessary
21+
/// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs
22+
/// </summary>
23+
[NotNull]
24+
private Foo? ValidateModel { get; set; }
25+
26+
[NotNull]
27+
private IEnumerable<SelectedItem>? Hobbys { get; set; }
28+
29+
[Inject]
30+
[NotNull]
31+
private IStringLocalizer<Foo>? FooLocalizer { get; set; }
32+
33+
/// <summary>
34+
/// OnInitialized
35+
/// </summary>
36+
protected override void OnInitialized()
37+
{
38+
base.OnInitialized();
39+
40+
Hobbys = Foo.GenerateHobbys(FooLocalizer);
41+
42+
ValidateModel = new Foo()
43+
{
44+
Name = Localizer["TestName"],
45+
Count = 1,
46+
DateTime = new DateTime(1997, 12, 05),
47+
Education = EnumEducation.Middle
48+
};
49+
}
50+
}

0 commit comments

Comments
 (0)