From 44da935a5bb8b58a88e5d060f87b449a2d95420d Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 29 Nov 2024 12:13:10 +0800 Subject: [PATCH] doc(SortableList): update parameter document (#4756) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: bump version 9.0.1 * doc: 增加参数说明文档 * doc: 精简代码 --- .../BootstrapBlazor.Server.csproj | 2 +- .../Components/Samples/Charts/Bar.razor.cs | 18 +++++----- .../Components/Samples/SortableLists.razor | 2 ++ .../Components/Samples/SortableLists.razor.cs | 36 +++++++++++++++++++ src/BootstrapBlazor.Server/Locales/en-US.json | 6 +++- src/BootstrapBlazor.Server/Locales/zh-CN.json | 6 +++- 6 files changed, 57 insertions(+), 13 deletions(-) diff --git a/src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj b/src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj index 06a78ddd95f..82e3ac84980 100644 --- a/src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj +++ b/src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj @@ -57,7 +57,7 @@ - + diff --git a/src/BootstrapBlazor.Server/Components/Samples/Charts/Bar.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/Charts/Bar.razor.cs index 92dde12b847..dd2d0a3f529 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/Charts/Bar.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Samples/Charts/Bar.razor.cs @@ -10,8 +10,6 @@ namespace BootstrapBlazor.Server.Components.Samples.Charts; /// public partial class Bar { - private Random Randomer { get; } = new Random(); - private int _barDatasetCount = 2; private int _barDataCount = 7; @@ -68,7 +66,7 @@ private Task OnInit(bool stacked, bool setTitle = true) ds.Labels = Enumerable.Range(1, _barDataCount).Select(i => i.ToString()); for (var index = 0; index < _barDatasetCount; index++) { - ds.Data.Add(new ChartDataset() { Label = $"Set {index}", Data = Enumerable.Range(1, _barDataCount).Select(i => Randomer.Next(20, 37)).Cast() }); + ds.Data.Add(new ChartDataset() { Label = $"Set {index}", Data = Enumerable.Range(1, _barDataCount).Select(i => Random.Shared.Next(20, 37)).Cast() }); } return Task.FromResult(ds); @@ -99,7 +97,7 @@ private Task OnPlayChart() /// private Task OnReloadChart() { - BarDataCount = Randomer.Next(5, 15); + BarDataCount = Random.Shared.Next(5, 15); BarChart.Reload(); return Task.CompletedTask; } @@ -124,7 +122,7 @@ private Task OnInitTwoYAxes(bool stacked, bool setTitle = true) { Label = $"Y2 Set {index}", IsAxisY2 = index == 0, - Data = Enumerable.Range(1, BarDataCount).Select(i => Randomer.Next(20, 7000)).Cast() + Data = Enumerable.Range(1, BarDataCount).Select(i => Random.Shared.Next(20, 7000)).Cast() }); for (index = 1; index < BarDatasetCount; index++) @@ -133,7 +131,7 @@ private Task OnInitTwoYAxes(bool stacked, bool setTitle = true) { Label = $"Y Set {index}", IsAxisY2 = index == 0, - Data = Enumerable.Range(1, BarDataCount).Select(i => Randomer.Next(20, 37)).Cast() + Data = Enumerable.Range(1, BarDataCount).Select(i => Random.Shared.Next(20, 37)).Cast() }); } return Task.FromResult(ds); @@ -156,7 +154,7 @@ private Task OnInitStack(bool stacked, bool setTitle = true) ds.Data.Add(new ChartDataset() { Label = $"Set {index}", - Data = Enumerable.Range(1, BarDataCount).Select(i => Randomer.Next(20, 37)).Cast() + Data = Enumerable.Range(1, BarDataCount).Select(i => Random.Shared.Next(20, 37)).Cast() }); } return Task.FromResult(ds); @@ -176,7 +174,7 @@ private Task OnInitAspectRatio(bool stacked) ds.Data.Add(new ChartDataset() { Label = $"Set {index}", - Data = Enumerable.Range(1, BarDataCount).Select(i => Randomer.Next(20, 37)).Cast() + Data = Enumerable.Range(1, BarDataCount).Select(i => Random.Shared.Next(20, 37)).Cast() }); } return Task.FromResult(ds); @@ -198,7 +196,7 @@ private Task OnInitShowDataLabel(bool showDataLabel) ds.Data.Add(new ChartDataset() { Label = $"Set {0}", - Data = Enumerable.Range(1, BarDataCount).Select(i => Randomer.Next(20, 37)).Cast() + Data = Enumerable.Range(1, BarDataCount).Select(i => Random.Shared.Next(20, 37)).Cast() }); return Task.FromResult(ds); } @@ -215,7 +213,7 @@ private Task OnInitBarColorSeparately(bool barColorSeparately) ds.Data.Add(new ChartDataset() { Label = $"Set {0}", - Data = Enumerable.Range(1, BarDataCount).Select(i => Randomer.Next(20, 37)).Cast(), + Data = Enumerable.Range(1, BarDataCount).Select(i => Random.Shared.Next(20, 37)).Cast(), BackgroundColor = ["rgb(54, 162, 235, 0.5)", "rgb(75, 192, 192, 0.5)", "rgb(255, 99, 132, 0.5)", "rgb(255, 159, 64, 0.5)", "rgb(255, 205, 86, 0.5)", "rgb(255, 99, 71, 0.5)", "rgb(255, 192, 203, 0.5)"], BorderColor = ["rgb(54, 162, 235)", "rgb(75, 192, 192)", "rgb(255, 99, 132)", "rgb(255, 159, 64)", "rgb(255, 205, 86)", "rgb(255, 99, 71)", "rgb(255, 192, 203)"] }); diff --git a/src/BootstrapBlazor.Server/Components/Samples/SortableLists.razor b/src/BootstrapBlazor.Server/Components/Samples/SortableLists.razor index 4e5b9eeb9cc..cb7c0531aa7 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/SortableLists.razor +++ b/src/BootstrapBlazor.Server/Components/Samples/SortableLists.razor @@ -267,3 +267,5 @@ + + diff --git a/src/BootstrapBlazor.Server/Components/Samples/SortableLists.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/SortableLists.razor.cs index 4b11867b6f3..6dedbd39e24 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/SortableLists.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Samples/SortableLists.razor.cs @@ -299,4 +299,40 @@ private Task OnRemoveItems3(SortableEvent @event) AddItems3.RemoveAt(@event.OldIndex); return Task.CompletedTask; } + + private AttributeItem[] GetAttributes() => + [ + new() + { + Name = nameof(SortableList.Option), + Description = Localizer["AttributeSortableListOption"], + Type = "SortableOption", + ValueList = " — ", + DefaultValue = "false" + }, + new() + { + Name = nameof(SortableList.OnAdd), + Description = Localizer["AttributeOnAdd"], + Type = "Func", + ValueList = " — ", + DefaultValue = " — " + }, + new() + { + Name = nameof(SortableList.OnUpdate), + Description = Localizer["AttributeOnUpdate"], + Type = "Func", + ValueList = " — ", + DefaultValue = " — " + }, + new() + { + Name = nameof(SortableList.OnRemove), + Description = Localizer["AttributeOnRemove"], + Type = "Func", + ValueList = " — ", + DefaultValue = " — " + } + ]; } diff --git a/src/BootstrapBlazor.Server/Locales/en-US.json b/src/BootstrapBlazor.Server/Locales/en-US.json index 964045f12a9..74e6ce9588c 100644 --- a/src/BootstrapBlazor.Server/Locales/en-US.json +++ b/src/BootstrapBlazor.Server/Locales/en-US.json @@ -6803,7 +6803,11 @@ "SortableListSwapTitle": "Swap", "SortableListSwapIntro": "By setting the Swap parameter of SortableListOption, the drag item and the target item are swapped.", "SortableListOnAddTitle": "Multiple SortableList", - "SortableListOnAddIntro": "Get the SortableList to which the dragged item belongs by setting the FromId parameter of the SortableEvent. In this example, the elements in the three areas can be dragged arbitrarily" + "SortableListOnAddIntro": "Get the SortableList to which the dragged item belongs by setting the FromId parameter of the SortableEvent. In this example, the elements in the three areas can be dragged arbitrarily", + "AttributeSortableListOption": "SortableListOption instance", + "AttributeOnAdd": "Callback method when adding elements", + "AttributeOnUpdate": "Callback method when updating elements", + "AttributeOnRemove": "Callback method when deleting elements" }, "BootstrapBlazor.Server.Components.Samples.WinBoxes": { "WinBoxTitle": "WinBox", diff --git a/src/BootstrapBlazor.Server/Locales/zh-CN.json b/src/BootstrapBlazor.Server/Locales/zh-CN.json index d6f7fda0002..eda5d38ee8c 100644 --- a/src/BootstrapBlazor.Server/Locales/zh-CN.json +++ b/src/BootstrapBlazor.Server/Locales/zh-CN.json @@ -6803,7 +6803,11 @@ "SortableListSwapTitle": "交换", "SortableListSwapIntro": "通过设置 SortableListOption 参数 Swap 设置拖拽项与目标项目交换", "SortableListOnAddTitle": "多区域拖动", - "SortableListOnAddIntro": "通过设置 SortableEvent 参数 FromId 获得拖动项所属 SortableList。本示例中三个区域内元素可以任意拖动" + "SortableListOnAddIntro": "通过设置 SortableEvent 参数 FromId 获得拖动项所属 SortableList。本示例中三个区域内元素可以任意拖动", + "AttributeSortableListOption": "SortableListOption 实例", + "AttributeOnAdd": "增加元素时回调方法", + "AttributeOnUpdate": "更新元素时回调方法", + "AttributeOnRemove": "删除元素时回调方法" }, "BootstrapBlazor.Server.Components.Samples.WinBoxes": { "WinBoxTitle": "WinBox 窗口组件",