!3722 doc(#I68PJP): update display demos

* update display demos
This commit is contained in:
Lambert Lee 2023-01-04 06:00:19 +00:00 committed by Argo
parent 09f564853e
commit 6c4273a758
10 changed files with 261 additions and 152 deletions

View File

@ -0,0 +1,50 @@
@inject IStringLocalizer<DisplayDataType> Localizer
<div class="row g-3">
<div class="col-12 col-sm-6">
Integer
<Display FormatString="000" @bind-Value="@Model.Count" ShowLabel="true" DisplayText="@Localizer["Integer"]" />
</div>
<div class="col-12 col-sm-6">
<Display @bind-Value="@Model.Education" ShowLabel="true" DisplayText="@Localizer["Enum"]" />
</div>
<div class="col-12 col-sm-6">
<Display @bind-Value="@Model.Hobby" ShowLabel="true" DisplayText="@Localizer["Collection"]" />
</div>
<div class="col-12 col-sm-6">
<Display @bind-Value="@ByteArray" ShowLabel="true" DisplayText="@Localizer["Arr"]" />
</div>
<div class="col-12 col-sm-6">
<Display Value="@DateTime.Now" ShowLabel="true" DisplayText="DateTime" />
</div>
<div class="col-12 col-sm-6">
<Display Value="@DateTimeOffset.Now" ShowLabel="true" DisplayText="DateTimeOffset" />
</div>
</div>
@code {
/// <summary>
/// Foo 类为Demo测试用如有需要请自行下载源码查阅
/// Foo class is used for Demo test, please download the source code if necessary
/// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs
/// </summary>
[NotNull]
private Foo? Model { get; set; }
[Inject]
[NotNull]
private IStringLocalizer<Foo>? FooLocalizer { get; set; }
private byte[] ByteArray { get; set; } = { 0x01, 0x12, 0x34, 0x56 };
/// <summary>
/// OnInitialized 方法
/// </summary>
protected override void OnInitialized()
{
base.OnInitialized();
Model = Foo.Generate(FooLocalizer);
Model.Hobby = Foo.GenerateHobbys(FooLocalizer).Take(3).Select(i => i.Text);
}
}

View File

@ -0,0 +1,34 @@
<EditorForm Model="@Model" ItemsPerRow="3" IsDisplay="true">
<FieldItems>
<EditorItem @bind-Field="@Model.Hobby" Items="@Hobbys" />
</FieldItems>
</EditorForm>
@code {
/// <summary>
/// Foo 类为Demo测试用如有需要请自行下载源码查阅
/// Foo class is used for Demo test, please download the source code if necessary
/// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs
/// </summary>
[NotNull]
private Foo? Model { get; set; }
[Inject]
[NotNull]
private IStringLocalizer<Foo>? FooLocalizer { get; set; }
[NotNull]
private IEnumerable<SelectedItem>? Hobbys { get; set; }
/// <summary>
/// OnInitialized 方法
/// </summary>
protected override void OnInitialized()
{
base.OnInitialized();
Model = Foo.Generate(FooLocalizer);
Model.Hobby = Foo.GenerateHobbys(FooLocalizer).Take(3).Select(i => i.Text);
Hobbys = Foo.GenerateHobbys(FooLocalizer);
}
}

View File

@ -0,0 +1,31 @@
@inject IStringLocalizer<DisplayFormatString> Localizer
<div class="row g-3">
<div class="col-12 col-sm-6">@Localizer["FormatStringettingText"] <code class="ms-1">FormatString</code></div>
<div class="col-12 col-sm-6">
<Display Value="DateTime.Now" FormatString="yyyy-MM-dd" />
</div>
<div class="col-12 col-sm-6">@Localizer["FormatStringettingText"] <code class="ms-1">Formatter</code></div>
<div class="col-12 col-sm-6">
<Display Value="DateTime.Now" FormatterAsync="@DateTimeFormatter" />
</div>
</div>
<p class="mt-3">@((MarkupString)Localizer["FormatStringP"].Value)</p>
<div class="row g-3">
<div class="col-12 col-sm-6">@Localizer["FormatStringettingText"] <code class="ms-1">Formatter</code></div>
<div class="col-12 col-sm-6">
<Display Value="@ByteArray" FormatterAsync="@ByteArrayFormatter" />
</div>
</div>
@code {
private byte[] ByteArray { get; set; } = { 0x01, 0x12, 0x34, 0x56 };
private static Task<string> DateTimeFormatter(DateTime source) => Task.FromResult(source.ToString("yyyy-MM-dd"));
private static async Task<string> ByteArrayFormatter(byte[] source)
{
await Task.Delay(10);
return Convert.ToBase64String(source);
}
}

View File

@ -0,0 +1,56 @@
@inject IStringLocalizer<DisplayLabels> Localizer
<div class="row g-3">
<div class="col-12">
<Divider Text="@Localizer["BindWayCustomLabel"]" />
</div>
<div class="col-12">
<p>@((MarkupString)Localizer["BindWayP2"].Value)</p>
</div>
<div class="col-12 col-sm-6">
<Display @bind-Value="@Model.Name" DisplayText="@Localizer["BindWayCustomLabel"]" ShowLabel="true" />
</div>
<div class="col-12">
<Divider Text="@Localizer["BindWayOccupants"]" />
</div>
<div class="col-12">
<p>@((MarkupString)Localizer["BindWayP3"].Value)</p>
</div>
<div class="col-12 col-sm-6">
<Display @bind-Value="@Model.Name" ShowLabel="true" />
</div>
<div class="col-12">
<Divider Text="@Localizer["BindWayNotccupants"]" />
</div>
<div class="col-12">
<p>@((MarkupString)Localizer["BindWayP4"].Value)</p>
</div>
<div class="col-12 col-sm-6">
<Display @bind-Value="@Model.Name" />
</div>
</div>
@code {
/// <summary>
/// Foo 类为Demo测试用如有需要请自行下载源码查阅
/// Foo class is used for Demo test, please download the source code if necessary
/// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs
/// </summary>
[NotNull]
private Foo? Model { get; set; }
[Inject]
[NotNull]
private IStringLocalizer<Foo>? FooLocalizer { get; set; }
/// <summary>
/// OnInitialized 方法
/// </summary>
protected override void OnInitialized()
{
base.OnInitialized();
Model = Foo.Generate(FooLocalizer);
Model.Hobby = Foo.GenerateHobbys(FooLocalizer).Take(3).Select(i => i.Text);
}
}

View File

@ -0,0 +1,12 @@
<Display Value="@IntValue" Lookup="@IntValueSource" />
@code {
private IEnumerable<int> IntValue { get; set; } = new[] { 1, 2, 3 };
private IEnumerable<SelectedItem> IntValueSource { get; set; } = new[]
{
new SelectedItem("1", "Text1"),
new SelectedItem("2", "Text2"),
new SelectedItem("3", "Text3")
};
}

View File

@ -0,0 +1,35 @@
@inject IStringLocalizer<DisplayNormal> Localizer
<div class="row g-3">
<div class="col-auto col-form-label">
<span>@Localizer["BasicUsage"]</span>
</div>
<div class="col-6">
<Display TValue="string" Value="@Model.Name" />
</div>
</div>
@code {
/// <summary>
/// Foo 类为Demo测试用如有需要请自行下载源码查阅
/// Foo class is used for Demo test, please download the source code if necessary
/// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs
/// </summary>
[NotNull]
private Foo? Model { get; set; }
[Inject]
[NotNull]
private IStringLocalizer<Foo>? FooLocalizer { get; set; }
/// <summary>
/// OnInitialized 方法
/// </summary>
protected override void OnInitialized()
{
base.OnInitialized();
Model = Foo.Generate(FooLocalizer);
Model.Hobby = Foo.GenerateHobbys(FooLocalizer).Take(3).Select(i => i.Text);
}
}

View File

@ -3984,37 +3984,45 @@
"SubTitle": "Displays static text data",
"BasicUsageTitle": "Basic usage",
"BasicUsageIntro": "Show only",
"BasicUsage": "Basic usage",
"BindWayTitle": "Bind data in both directions",
"BindWayIntro": "Two-way binding automatically gets the display labels in the resource file",
"BindWayP1": "When the <code>Dispaly</code> components turn on bidirectional binding, the <code>Display/DisplayName</code> label value is automatically obtained based on the <code>Model</code> property value of the binding and appears as a <code>pre-Label</code>, with <code>DisplayText</code> properties you can customize the display of the pre-label, or by turning off the display of the pre-label through the <code>ShowLabel</code> property",
"BindWayCustomLabel": "Custom labels",
"BindWayP2": "Set the <code>DisplayText</code> value to <b>custom label </b>",
"BindWayOccupants": "Occupants",
"BindWayP3": "The value of <code>DisplayText</code> is displayed when <code>ShowLabel</code> is <code>true</code>, regardless of whether the value is set",
"BindWayNotccupants": "Do not occupy seats",
"BindWayP4": "The value of <code>DisplayText</code> is not displayed when the <code>ShowLabel</code> is <code>false</code>",
"DataTypeTitle": "Generic binding",
"DataTypeIntro": "The <code>Display</code> component has built-in processing of <code>enumerated</code> <code>collections</code> <code>array</code>, customize formatting or callback delegate methods if they do not meet the criteria",
"EditorFormTitle": "Used within the form",
"EditorFormIntro": "The <code>Dispaly</code> component is used in form components <code>EditorForm</code>, and is used in detail pages and is not editable",
"FormatStringTitle": "Custom format",
"FormatStringIntro": "When you set the <code>FormatString</code> property value to <code>yyyy-MM-dd</code>, the component displays a time format of the year and day",
"FormatStringettingText": "Set up",
"FormatStringP": "The <code>Dispaly</code> component binding <code>byte[]</code> array, formatted as an example of <code>base64</code> encoded string",
"LookupTitle": "Automatically translated into Text",
"LookupIntro": "Set the <code>Lookup</code> value to <code>IEnumerable&lt;SelectedItem&gt;</code> collection, through which the component will perform translations through the <code>Value</code> display <code>Text</code>",
"LookupP1": "In this example, the component <code>Value='@IntValue'</code> set <code>Lookup='@IntValueSource'</code> component to display the <code>Text</code> corresponding to the value of the</code> <code>Value",
"LookupP1": "In this example, the component <code>Value='@IntValue'</code> set <code>Lookup='@IntValueSource'</code> component to display the <code>Value</code> corresponding to the value of the <code>Text</code> Value",
"ShowLabel": "Whether to display the front label",
"DisplayText": "The front label displays text",
"FormatString": "The numerically formatted string",
"Formatter": "TableHeader instance",
"TypeResolver": "It is used internally when the type resolution callback method tvalue is an array instance",
"TypeResolver": "It is used internally when the type resolution callback method tvalue is an array instance"
},
"BootstrapBlazor.Shared.Demos.Display.DisplayNormal": {
"BasicUsage": "Basic usage"
},
"BootstrapBlazor.Shared.Demos.Display.DisplayLabels": {
"BindWayCustomLabel": "Custom labels",
"BindWayP2": "Set the <code>DisplayText</code> value to <b>custom label </b>",
"BindWayOccupants": "Occupants",
"BindWayP3": "The value of <code>DisplayText</code> is displayed when <code>ShowLabel</code> is <code>true</code>, regardless of whether the value is set",
"BindWayNotccupants": "Do not occupy seats",
"BindWayP4": "The value of <code>DisplayText</code> is not displayed when the <code>ShowLabel</code> is <code>false</code>"
},
"BootstrapBlazor.Shared.Demos.Display.DisplayDataType": {
"Integer": "Integer",
"Enum": "Enumerate",
"Collection": "Collection",
"Arr": "Array"
},
"BootstrapBlazor.Shared.Demos.Display.DisplayFormatString": {
"FormatStringettingText": "Set up",
"FormatStringP": "The <code>Dispaly</code> component binding <code>byte[]</code> array, formatted as an example of <code>base64</code> encoded string"
},
"BootstrapBlazor.Shared.Samples.DropdownWidgets": {
"Title": "DropdownWidget",
"SubTitle": "More for head information summary presentation",

View File

@ -3988,24 +3988,15 @@
"SubTitle": "显示静态文本数据",
"BasicUsageTitle": "基础用法",
"BasicUsageIntro": "仅显示",
"BasicUsage": "基础用法",
"BindWayTitle": "双向绑定数据",
"BindWayIntro": "通过双向绑定可以自动获取资源文件中的显示标签",
"BindWayP1": "<code>Display</code> 组件开启双向绑定时,会根据绑定的 <code>Model</code> 属性值去自动获取 <code>Display/DisplayName</code> 标签值并且显示为前置 <code>Label</code>,通过 <code>DisplayText</code> 属性可以自定义显示前置标签,或者通过 <code>ShowLabel</code> 属性关闭前置标签是否显示",
"BindWayCustomLabel": "自定义标签",
"BindWayP2": "设置 <code>DisplayText</code> 值为 <b>自定义标签</b>",
"BindWayOccupants": "占位",
"BindWayP3": "无论是否设置 <code>DisplayText</code> 值,当 <code>ShowLabel</code> 为 <code>true</code> 时均显示",
"BindWayNotccupants": "不占位",
"BindWayP4": "无论是否设置 <code>DisplayText</code> 值,当 <code>ShowLabel</code> 为 <code>false</code> 时均不显示",
"DataTypeTitle": "泛型绑定",
"DataTypeIntro": "<code>Display</code> 组件内置对 <code>枚举</code> <code>集合</code> <code>数组</code> 进行处理,如不符合条件时,请自定义格式化或者回调委托方法",
"EditorFormTitle": "表单内使用",
"EditorFormIntro": "<code>Display</code> 组件在表单组件 <code>EditorForm</code> 中使用,多用于明细页,不可编辑模式",
"FormatStringTitle": "自定义格式",
"FormatStringIntro": "设置 <code>FormatString</code> 属性值为 <code>yyyy-MM-dd</code> 时,组件显示的时间格式为年月日",
"FormatStringettingText": "设置",
"FormatStringP": "<code>Display</code> 组件绑定 <code>byte[]</code> 数组,格式化成 <code>base64</code> 编码字符串示例",
"LookupTitle": "自动翻译为 Text",
"LookupIntro": "设置 <code>Lookup</code> 值为 <code>IEnumerable&lt;SelectedItem&gt;</code> 集合,组件将通过此数据集,进行通过 <code>Value</code> 显示 <code>Text</code> 翻译工作",
"LookupP1": "本例中组件 <code>Value='@IntValue'</code> 设置 <code>Lookup='@IntValueSource'</code> 组件将 <code>Value</code> 值对应的 <code>Text</code> 显示出来",
@ -4013,12 +4004,29 @@
"DisplayText": "前置标签显示文本",
"FormatString": "数值格式化字符串",
"Formatter": "TableHeader 实例",
"TypeResolver": "类型解析回调方法 TValue 为 Array 实例时内部使用",
"TypeResolver": "类型解析回调方法 TValue 为 Array 实例时内部使用"
},
"BootstrapBlazor.Shared.Demos.Display.DisplayNormal": {
"BasicUsage": "基础用法"
},
"BootstrapBlazor.Shared.Demos.Display.DisplayLabels": {
"BindWayCustomLabel": "自定义标签",
"BindWayP2": "设置 <code>DisplayText</code> 值为 <b>自定义标签</b>",
"BindWayOccupants": "占位",
"BindWayP3": "无论是否设置 <code>DisplayText</code> 值,当 <code>ShowLabel</code> 为 <code>true</code> 时均显示",
"BindWayNotccupants": "不占位",
"BindWayP4": "无论是否设置 <code>DisplayText</code> 值,当 <code>ShowLabel</code> 为 <code>false</code> 时均不显示"
},
"BootstrapBlazor.Shared.Demos.Display.DisplayDataType": {
"Integer": "整型",
"Enum": "枚举",
"Collection": "集合",
"Arr": "数组"
},
"BootstrapBlazor.Shared.Demos.Display.DisplayFormatString": {
"FormatStringettingText": "设置",
"FormatStringP": "<code>Display</code> 组件绑定 <code>byte[]</code> 数组,格式化成 <code>base64</code> 编码字符串示例"
},
"BootstrapBlazor.Shared.Samples.DropdownWidgets": {
"Title": "DropdownWidget 下拉挂件",
"SubTitle": "多用于头部信息汇总展示",

View File

@ -5,108 +5,24 @@
<h4>@Localizer["SubTitle"]</h4>
<DemoBlock Title="@Localizer["BasicUsageTitle"]" Introduction="@Localizer["BasicUsageIntro"]" Name="Normal">
<div class="row g-3">
<div class="col-auto col-form-label">
<span>@Localizer["BasicUsage"]</span>
</div>
<div class="col-6">
<Display TValue="string" Value="@Model.Name" />
</div>
</div>
</DemoBlock>
<DemoBlock Title="@Localizer["BasicUsageTitle"]" Introduction="@Localizer["BasicUsageIntro"]" Name="Normal" Demo="typeof(Demos.Display.DisplayNormal)" />
<DemoBlock Title="@Localizer["BindWayTitle"]" Introduction="@Localizer["BindWayIntro"]" Name="Labels">
<DemoBlock Title="@Localizer["BindWayTitle"]" Introduction="@Localizer["BindWayIntro"]" Name="Labels" Demo="typeof(Demos.Display.DisplayLabels)">
<p>@((MarkupString)Localizer["BindWayP1"].Value)</p>
<div class="row g-3">
<div class="col-12">
<Divider Text="@Localizer["BindWayCustomLabel"]" />
</div>
<div class="col-12">
<p>@((MarkupString)Localizer["BindWayP2"].Value)</p>
</div>
<div class="col-12 col-sm-6">
<Display @bind-Value="@Model.Name" DisplayText="@Localizer["BindWayCustomLabel"]" ShowLabel="true" />
</div>
<div class="col-12">
<Divider Text="@Localizer["BindWayOccupants"]" />
</div>
<div class="col-12">
<p>@((MarkupString)Localizer["BindWayP3"].Value)</p>
</div>
<div class="col-12 col-sm-6">
<Display @bind-Value="@Model.Name" ShowLabel="true" />
</div>
<div class="col-12">
<Divider Text="@Localizer["BindWayNotccupants"]" />
</div>
<div class="col-12">
<p>@((MarkupString)Localizer["BindWayP4"].Value)</p>
</div>
<div class="col-12 col-sm-6">
<Display @bind-Value="@Model.Name" />
</div>
</div>
</DemoBlock>
<DemoBlock Title="@Localizer["DataTypeTitle"]" Introduction="@Localizer["DataTypeIntro"]" Name="DataType">
<div class="row g-3">
<div class="col-12 col-sm-6">Integer
<Display FormatString="000" @bind-Value="@Model.Count" ShowLabel="true" DisplayText="@Localizer["Integer"]" />
</div>
<div class="col-12 col-sm-6">
<Display @bind-Value="@Model.Education" ShowLabel="true" DisplayText="@Localizer["Enum"]" />
</div>
<div class="col-12 col-sm-6">
<Display @bind-Value="@Model.Hobby" ShowLabel="true" DisplayText="@Localizer["Collection"]" />
</div>
<div class="col-12 col-sm-6">
<Display @bind-Value="@ByteArray" ShowLabel="true" DisplayText="@Localizer["Arr"]" />
</div>
<div class="col-12 col-sm-6">
<Display Value="@DateTime.Now" ShowLabel="true" DisplayText="DateTime" />
</div>
<div class="col-12 col-sm-6">
<Display Value="@DateTimeOffset.Now" ShowLabel="true" DisplayText="DateTimeOffset" />
</div>
</div>
</DemoBlock>
<DemoBlock Title="@Localizer["DataTypeTitle"]" Introduction="@Localizer["DataTypeIntro"]" Name="DataType" Demo="typeof(Demos.Display.DisplayDataType)" />
<DemoBlock Title="@Localizer["EditorFormTitle"]" Introduction="@Localizer["EditorFormIntro"]" Name="EditorForm">
<EditorForm Model="@Model" ItemsPerRow="3" IsDisplay="true">
<FieldItems>
<EditorItem @bind-Field="@Model.Hobby" Items="@Hobbys" />
</FieldItems>
</EditorForm>
</DemoBlock>
<DemoBlock Title="@Localizer["EditorFormTitle"]" Introduction="@Localizer["EditorFormIntro"]" Name="EditorForm" Demo="typeof(Demos.Display.DisplayEditorForm)" />
<DemoBlock Title="@Localizer["FormatStringTitle"]" Introduction="@Localizer["FormatStringIntro"]" Name="FormatString">
<div class="row g-3">
<div class="col-12 col-sm-6">@Localizer["FormatStringettingText"] <code class="ms-1">FormatString</code></div>
<div class="col-12 col-sm-6">
<Display Value="DateTime.Now" FormatString="yyyy-MM-dd" />
</div>
<div class="col-12 col-sm-6">@Localizer["FormatStringettingText"] <code class="ms-1">Formatter</code></div>
<div class="col-12 col-sm-6">
<Display Value="DateTime.Now" FormatterAsync="@DateTimeFormatter" />
</div>
</div>
<p class="mt-3">@((MarkupString)Localizer["FormatStringP"].Value)</p>
<div class="row g-3">
<div class="col-12 col-sm-6">@Localizer["FormatStringettingText"] <code class="ms-1">Formatter</code></div>
<div class="col-12 col-sm-6">
<Display Value="@ByteArray" FormatterAsync="@ByteArrayFormatter" />
</div>
</div>
</DemoBlock>
<DemoBlock Title="@Localizer["FormatStringTitle"]" Introduction="@Localizer["FormatStringIntro"]" Name="FormatString" Demo="typeof(Demos.Display.DisplayFormatString)" />
<DemoBlock Title="@Localizer["LookupTitle"]" Introduction="@Localizer["LookupIntro"]" Name="Lookup">
<DemoBlock Title="@Localizer["LookupTitle"]" Introduction="@Localizer["LookupIntro"]" Name="Lookup" Demo="typeof(Demos.Display.DisplayLookup)">
<p>
<div>@((MarkupString)Localizer["LookupP1"].Value)</div>
<div><b>InitValue</b>: 1,2,3</div>
<div><b>IntValueSource</b>: Text1,Text2,Text3</div>
</p>
<Display Value="@IntValue" Lookup="@IntValueSource" />
</DemoBlock>
<AttributeTable Items="@GetAttributes()" />

View File

@ -9,47 +9,6 @@ namespace BootstrapBlazor.Shared.Samples;
/// </summary>
public partial class Displays
{
[NotNull]
private Foo? Model { get; set; }
[Inject]
[NotNull]
private IStringLocalizer<Foo>? FooLocalizer { get; set; }
[NotNull]
private IEnumerable<SelectedItem>? Hobbys { get; set; }
private byte[] ByteArray { get; set; } = new byte[] { 0x01, 0x12, 0x34, 0x56 };
private IEnumerable<int> IntValue { get; set; } = new[] { 1, 2, 3 };
private IEnumerable<SelectedItem> IntValueSource { get; set; } = new[]
{
new SelectedItem("1", "Text1"),
new SelectedItem("2", "Text2"),
new SelectedItem("3", "Text3")
};
private static async Task<string> ByteArrayFormatter(byte[] source)
{
await Task.Delay(10);
return Convert.ToBase64String(source);
}
private static Task<string> DateTimeFormatter(DateTime source) => Task.FromResult(source.ToString("yyyy-MM-dd"));
/// <summary>
/// OnInitialized 方法
/// </summary>
protected override void OnInitialized()
{
base.OnInitialized();
Model = Foo.Generate(FooLocalizer);
Model.Hobby = Foo.GenerateHobbys(FooLocalizer).Take(3).Select(i => i.Text);
Hobbys = Foo.GenerateHobbys(FooLocalizer);
}
private IEnumerable<AttributeItem> GetAttributes() => new[]
{
new AttributeItem() {