From d863a7a4398b50e35e66861b69271e6921c90d30 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Mon, 13 Dec 2021 15:18:18 +0800 Subject: [PATCH 1/5] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=20ValidateBa?= =?UTF-8?q?se=20=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Validate/ValidateBase.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/BootstrapBlazor/Components/Validate/ValidateBase.cs b/src/BootstrapBlazor/Components/Validate/ValidateBase.cs index 3777ba37b..3596e40b9 100644 --- a/src/BootstrapBlazor/Components/Validate/ValidateBase.cs +++ b/src/BootstrapBlazor/Components/Validate/ValidateBase.cs @@ -316,17 +316,12 @@ namespace BootstrapBlazor.Components IsShowLabel = showLabel ?? false; - // 内置到验证组件时才使用绑定属性值获取 DisplayName + // 绑定属性值获取 DisplayName if (IsShowLabel && DisplayText == null && FieldIdentifier.HasValue) { DisplayText = FieldIdentifier.Value.GetDisplayName(); } - if (IsShowLabel && string.IsNullOrEmpty(DisplayText)) - { - DisplayText = " "; - } - Required = (IsNeedValidate && !string.IsNullOrEmpty(DisplayText) && (ValidateForm?.ShowRequiredMark ?? false) && IsRequired()) ? "true" : null; } -- Gitee From 461a3b6d4ae1e8f442f744da53cf6bc080eef812 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Mon, 13 Dec 2021 22:16:39 +0800 Subject: [PATCH 2/5] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=20TreeItem?= =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0=20IsActive=20=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor.Shared/Components/TreeDataFoo.cs | 6 ++++-- src/BootstrapBlazor/Components/Tree/Tree.razor.cs | 12 +++++++++++- src/BootstrapBlazor/Components/Tree/TreeItem.cs | 5 +++++ src/BootstrapBlazor/Utils/Utility.cs | 3 ++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/BootstrapBlazor.Shared/Components/TreeDataFoo.cs b/src/BootstrapBlazor.Shared/Components/TreeDataFoo.cs index 00ae70863..48df735f9 100644 --- a/src/BootstrapBlazor.Shared/Components/TreeDataFoo.cs +++ b/src/BootstrapBlazor.Shared/Components/TreeDataFoo.cs @@ -18,6 +18,8 @@ namespace BootstrapBlazor.Shared.Components public string Icon { get; set; } = "fa fa-fa"; + public bool IsActive { get; set; } + /// /// /// @@ -34,7 +36,7 @@ namespace BootstrapBlazor.Shared.Components new TreeDataFoo() { Text = "子菜单二", Code = "1050", ParentCode = "1020" }, new TreeDataFoo() { Text = "子菜单三", Code = "1060", ParentCode = "1020" }, - new TreeDataFoo() { Text = "孙菜单一", Code = "1070", ParentCode = "1050" }, + new TreeDataFoo() { Text = "孙菜单一", Code = "1070", ParentCode = "1050", IsActive = true }, new TreeDataFoo() { Text = "孙菜单二", Code = "1080", ParentCode = "1050" }, new TreeDataFoo() { Text = "孙菜单三", Code = "1090", ParentCode = "1050" }, @@ -55,7 +57,7 @@ namespace BootstrapBlazor.Shared.Components { var subData = foos.Where(i => i.ParentCode == parentCode); - return subData.Select(i => new TreeItem() { Text = i.Text, Items = GetSubItems(i.Code, foos) }).ToList(); + return subData.Select(i => new TreeItem() { Text = i.Text, IsActive = i.IsActive, Items = GetSubItems(i.Code, foos) }).ToList(); } } } diff --git a/src/BootstrapBlazor/Components/Tree/Tree.razor.cs b/src/BootstrapBlazor/Components/Tree/Tree.razor.cs index 510aebd63..e99e2c9f2 100644 --- a/src/BootstrapBlazor/Components/Tree/Tree.razor.cs +++ b/src/BootstrapBlazor/Components/Tree/Tree.razor.cs @@ -1,4 +1,4 @@ -// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. +// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Website: https://www.blazor.zone or https://argozhang.github.io/ @@ -147,6 +147,16 @@ namespace BootstrapBlazor.Components if (_itemsChanged) { Items?.CascadingTree(); + + if (ActiveItem != null) + { + var item = ActiveItem; + while (item.Parent != null) + { + item.Parent.IsExpanded = true; + item = item.Parent; + } + } } } diff --git a/src/BootstrapBlazor/Components/Tree/TreeItem.cs b/src/BootstrapBlazor/Components/Tree/TreeItem.cs index 23985c2b0..55ec080bb 100644 --- a/src/BootstrapBlazor/Components/Tree/TreeItem.cs +++ b/src/BootstrapBlazor/Components/Tree/TreeItem.cs @@ -63,6 +63,11 @@ namespace BootstrapBlazor.Components /// public bool IsExpanded { get; set; } + /// + /// 获得/设置 是否选中当前节点 + /// + public bool IsActive { get; set; } + /// /// 获取/设置 是否有子节点 默认 false /// diff --git a/src/BootstrapBlazor/Utils/Utility.cs b/src/BootstrapBlazor/Utils/Utility.cs index e6073bafa..adc4626ba 100644 --- a/src/BootstrapBlazor/Utils/Utility.cs +++ b/src/BootstrapBlazor/Utils/Utility.cs @@ -530,7 +530,8 @@ namespace BootstrapBlazor.Components /// /// 数据集合 /// 父级节点 - public static void CascadingTree(this List items, TreeItem? parentItem = null) + /// + public static TreeItem? CascadingTree(this List items, TreeItem? parentItem = null) { items.ForEach(i => { -- Gitee From 18d537f4e8170dfdeed31b6922de94a5c6aaaa69 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Mon, 13 Dec 2021 23:00:32 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20ActiveItem=20?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E6=9F=A5=E6=89=BE=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Tree/Tree.razor.cs | 2 +- src/BootstrapBlazor/Utils/Utility.cs | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/BootstrapBlazor/Components/Tree/Tree.razor.cs b/src/BootstrapBlazor/Components/Tree/Tree.razor.cs index e99e2c9f2..b43324ee8 100644 --- a/src/BootstrapBlazor/Components/Tree/Tree.razor.cs +++ b/src/BootstrapBlazor/Components/Tree/Tree.razor.cs @@ -146,7 +146,7 @@ namespace BootstrapBlazor.Components // 通过 Items 构造层次结构 if (_itemsChanged) { - Items?.CascadingTree(); + ActiveItem = Items?.CascadingTree(); if (ActiveItem != null) { diff --git a/src/BootstrapBlazor/Utils/Utility.cs b/src/BootstrapBlazor/Utils/Utility.cs index adc4626ba..4ae501174 100644 --- a/src/BootstrapBlazor/Utils/Utility.cs +++ b/src/BootstrapBlazor/Utils/Utility.cs @@ -530,14 +530,23 @@ namespace BootstrapBlazor.Components /// /// 数据集合 /// 父级节点 - /// public static TreeItem? CascadingTree(this List items, TreeItem? parentItem = null) { + TreeItem? activeItem = null; items.ForEach(i => { i.Parent = parentItem; - i.Items.CascadingTree(i); + if (i.IsActive) + { + activeItem = i; + } + var item = i.Items.CascadingTree(i); + if (item != null) + { + activeItem = item; + } }); + return activeItem; } /// -- Gitee From 5ed3489fa8fc26f269da02a187defef86024ed3b Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Mon, 13 Dec 2021 23:02:24 +0800 Subject: [PATCH 4/5] doc: revert demo --- src/BootstrapBlazor.Shared/Components/TreeDataFoo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor.Shared/Components/TreeDataFoo.cs b/src/BootstrapBlazor.Shared/Components/TreeDataFoo.cs index 48df735f9..ca16130e4 100644 --- a/src/BootstrapBlazor.Shared/Components/TreeDataFoo.cs +++ b/src/BootstrapBlazor.Shared/Components/TreeDataFoo.cs @@ -36,7 +36,7 @@ namespace BootstrapBlazor.Shared.Components new TreeDataFoo() { Text = "子菜单二", Code = "1050", ParentCode = "1020" }, new TreeDataFoo() { Text = "子菜单三", Code = "1060", ParentCode = "1020" }, - new TreeDataFoo() { Text = "孙菜单一", Code = "1070", ParentCode = "1050", IsActive = true }, + new TreeDataFoo() { Text = "孙菜单一", Code = "1070", ParentCode = "1050" }, new TreeDataFoo() { Text = "孙菜单二", Code = "1080", ParentCode = "1050" }, new TreeDataFoo() { Text = "孙菜单三", Code = "1090", ParentCode = "1050" }, -- Gitee From 95cf7019edca4b5b58d4db703f0aed1e485ebe9d Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Tue, 14 Dec 2021 09:55:53 +0800 Subject: [PATCH 5/5] chore: bump verson to 6.1.1-beta04 --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index d76604fa0..ff760908f 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 6.1.1-beta03 + 6.1.1-beta04 -- Gitee