From b035872db619c406a9192370744f04f611002237 Mon Sep 17 00:00:00 2001 From: Argo Date: Sun, 15 Jan 2023 08:32:06 +0000 Subject: [PATCH] =?UTF-8?q?!3764=20feat(#I6ALST):=20add=20CollapsedGroupCa?= =?UTF-8?q?llback=20parameter=20on=20ListView=20*=20chore:=20bump=20versio?= =?UTF-8?q?n=207.2.4-beta01=20*=20doc:=20=E5=A2=9E=E5=8A=A0=20CollapsedGro?= =?UTF-8?q?upCallback=20=E5=8F=82=E6=95=B0=E8=AF=B4=E6=98=8E=E6=96=87?= =?UTF-8?q?=E6=A1=A3=20*=20refactor:=20=E9=87=8D=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E6=96=B9=E6=B3=95=20*=20doc:=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E8=B5=84=E6=BA=90=E6=96=87=E4=BB=B6=20*=20doc:=20?= =?UTF-8?q?=E7=B2=BE=E7=AE=80=E7=A4=BA=E4=BE=8B=20*=20refactor:=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4=E5=B1=95=E5=BC=80=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E5=88=86=E7=BB=84=E9=A1=B9=E7=9B=AE=E9=80=BB?= =?UTF-8?q?=E8=BE=91=20*=20doc:=20=E6=9B=B4=E6=96=B0=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E6=96=87=E6=A1=A3=20*=20feat:=20=E5=A2=9E=E5=8A=A0=20Collapsed?= =?UTF-8?q?GroupCallbackFirstRender=20=E5=9B=9E=E8=B0=83=20*=20doc:=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=B3=A8=E9=87=8A=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor.Shared/Locales/en.json | 3 ++- src/BootstrapBlazor.Shared/Locales/zh.json | 3 ++- .../Samples/ListViews.razor | 2 +- .../Samples/ListViews.razor.cs | 9 ++++++++ src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- .../Components/Collapse/CollapseItem.cs | 2 +- .../Components/ListView/ListView.razor | 23 +++++++++++-------- .../Components/ListView/ListView.razor.cs | 8 +++++++ 8 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/BootstrapBlazor.Shared/Locales/en.json b/src/BootstrapBlazor.Shared/Locales/en.json index 305726ba2..887818417 100644 --- a/src/BootstrapBlazor.Shared/Locales/en.json +++ b/src/BootstrapBlazor.Shared/Locales/en.json @@ -4253,7 +4253,8 @@ "IsAccordion": "Group accordion", "OnQueryAsync": "Asynchronous query callback method", "OnListViewItemClick": "The ListView element calls back when it clicks on the delegate", - "QueryAsync": "Manually query data methods" + "QueryAsync": "Manually query data methods", + "CollapsedGroupCallback": "Callback for set the IsCollapsed parameter of Collapse component" }, "BootstrapBlazor.Shared.Samples.Locators": { "Title": "Get the IP geographic location", diff --git a/src/BootstrapBlazor.Shared/Locales/zh.json b/src/BootstrapBlazor.Shared/Locales/zh.json index 7ec1dcbb7..64cb968bb 100644 --- a/src/BootstrapBlazor.Shared/Locales/zh.json +++ b/src/BootstrapBlazor.Shared/Locales/zh.json @@ -4260,7 +4260,8 @@ "IsAccordion": "分组数据手风琴效果", "OnQueryAsync": "异步查询回调方法", "OnListViewItemClick": "ListView元素点击时回调委托", - "QueryAsync": "手工查询数据方法" + "QueryAsync": "手工查询数据方法", + "CollapsedGroupCallback": "组件分组项是否收缩回调委托方法" }, "BootstrapBlazor.Shared.Samples.Locators": { "Title": "获取 IP 地理位置", diff --git a/src/BootstrapBlazor.Shared/Samples/ListViews.razor b/src/BootstrapBlazor.Shared/Samples/ListViews.razor index ec21e81bb..c499ed7a8 100644 --- a/src/BootstrapBlazor.Shared/Samples/ListViews.razor +++ b/src/BootstrapBlazor.Shared/Samples/ListViews.razor @@ -69,7 +69,7 @@
- +
@Localizer["ProductListText"]
diff --git a/src/BootstrapBlazor.Shared/Samples/ListViews.razor.cs b/src/BootstrapBlazor.Shared/Samples/ListViews.razor.cs index 335748a65..3752aa767 100644 --- a/src/BootstrapBlazor.Shared/Samples/ListViews.razor.cs +++ b/src/BootstrapBlazor.Shared/Samples/ListViews.razor.cs @@ -46,6 +46,8 @@ public sealed partial class ListViews return Task.CompletedTask; } + private static bool CollapsedGroupCallback(object? groupKey) => groupKey?.ToString() != "Group1"; + private IEnumerable GetAttributes() => new AttributeItem[] { new AttributeItem(){ @@ -110,6 +112,13 @@ public sealed partial class ListViews Type = "Func", ValueList = " — ", DefaultValue = " — " + }, + new AttributeItem() { + Name = nameof(ListView.CollapsedGroupCallback), + Description = Localizer["CollapsedGroupCallback"], + Type = "Func", + ValueList = " — ", + DefaultValue = " — " } }; diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index a79bfe48a..9c2fb0c5c 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 7.2.3 + 7.2.4-beta01 diff --git a/src/BootstrapBlazor/Components/Collapse/CollapseItem.cs b/src/BootstrapBlazor/Components/Collapse/CollapseItem.cs index 984b4aaad..15705ba28 100644 --- a/src/BootstrapBlazor/Components/Collapse/CollapseItem.cs +++ b/src/BootstrapBlazor/Components/Collapse/CollapseItem.cs @@ -16,7 +16,7 @@ public class CollapseItem : BootstrapComponentBase, IDisposable public string? Text { get; set; } /// - /// 获得/设置 当前状态是否激活 + /// 获得/设置 当前状态是否激活 默认 true /// [Parameter] public bool IsCollapsed { get; set; } = true; diff --git a/src/BootstrapBlazor/Components/ListView/ListView.razor b/src/BootstrapBlazor/Components/ListView/ListView.razor index 3eb48cddb..d3a95117a 100644 --- a/src/BootstrapBlazor/Components/ListView/ListView.razor +++ b/src/BootstrapBlazor/Components/ListView/ListView.razor @@ -25,16 +25,19 @@ { - @foreach (var key in Rows.GroupBy(GroupName).OrderBy(k => k.Key)) - { - - @foreach (var item in key) - { -
- @BodyTemplate.Invoke(item) -
- } -
+ @{ + var index = 0; + foreach (var key in Rows.GroupBy(GroupName).OrderBy(k => k.Key)) + { + + @foreach (var item in key) + { +
+ @BodyTemplate.Invoke(item) +
+ } +
+ } }
diff --git a/src/BootstrapBlazor/Components/ListView/ListView.razor.cs b/src/BootstrapBlazor/Components/ListView/ListView.razor.cs index af736dd1f..a7a8d3c6a 100644 --- a/src/BootstrapBlazor/Components/ListView/ListView.razor.cs +++ b/src/BootstrapBlazor/Components/ListView/ListView.razor.cs @@ -75,6 +75,12 @@ public partial class ListView : BootstrapComponentBase [Parameter] public Func? OnCollapseChanged { get; set; } + /// + /// 获得/设置 首次渲染是否收缩回调委托 + /// + [Parameter] + public Func? CollapsedGroupCallback { get; set; } + /// /// 异步查询回调方法 /// @@ -125,6 +131,8 @@ public partial class ListView : BootstrapComponentBase } } + private bool IsCollapsed(int index, object? groupKey) => CollapsedGroupCallback?.Invoke(groupKey) ?? index > 0; + /// /// 点击页码调用此方法 ///