From 2da705ec224f8926eedc6ee6090ac708ac196cc1 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Mon, 20 Jan 2020 11:42:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=8F=9C=E5=8D=95=E7=BB=B4=E6=8A=A4?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=94=AF=E6=8C=81=20int=20=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E7=9A=84=20Order?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bootstrap.Admin/Components/IRules.cs | 15 ++++++++++ .../{LgbInputTextBase.cs => LgbInputBase.cs} | 22 +++----------- .../Components/LgbInputText.cs | 12 ++++++++ .../Components/QueryInputTextBase.cs | 12 -------- .../Components/ValidateInputBase.cs | 30 +++++++++---------- .../Components/ValidatorComponentBase.cs | 12 ++++---- .../Bootstrap.Admin/Pages/Admin/Menus.razor | 10 +++---- .../Pages/Components/MenusBase.cs | 22 ++++++++++++-- .../{LgbInputText.razor => LgbInput.razor} | 3 +- 9 files changed, 79 insertions(+), 59 deletions(-) create mode 100644 src/admin/Bootstrap.Admin/Components/IRules.cs rename src/admin/Bootstrap.Admin/Components/{LgbInputTextBase.cs => LgbInputBase.cs} (64%) create mode 100644 src/admin/Bootstrap.Admin/Components/LgbInputText.cs delete mode 100644 src/admin/Bootstrap.Admin/Components/QueryInputTextBase.cs rename src/admin/Bootstrap.Admin/Shared/{LgbInputText.razor => LgbInput.razor} (92%) diff --git a/src/admin/Bootstrap.Admin/Components/IRules.cs b/src/admin/Bootstrap.Admin/Components/IRules.cs new file mode 100644 index 00000000..3a1e672d --- /dev/null +++ b/src/admin/Bootstrap.Admin/Components/IRules.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace Bootstrap.Admin.Components +{ + /// + /// IRules 接口 + /// + public interface IRules + { + /// + /// 获得 Rules 集合 + /// + ICollection Rules { get; } + } +} diff --git a/src/admin/Bootstrap.Admin/Components/LgbInputTextBase.cs b/src/admin/Bootstrap.Admin/Components/LgbInputBase.cs similarity index 64% rename from src/admin/Bootstrap.Admin/Components/LgbInputTextBase.cs rename to src/admin/Bootstrap.Admin/Components/LgbInputBase.cs index da9796cf..f706352e 100644 --- a/src/admin/Bootstrap.Admin/Components/LgbInputTextBase.cs +++ b/src/admin/Bootstrap.Admin/Components/LgbInputBase.cs @@ -7,36 +7,22 @@ namespace Bootstrap.Admin.Components /// /// LgbInputText 组件 /// - public class LgbInputTextBase : ValidateInputBase + public class LgbInputBase : ValidateInputBase { /// - /// + /// 获得/设置 控件样式 默认为 col-sm-6 /// [Parameter] public string ColumnClass { get; set; } = "col-sm-6"; /// - /// + /// 获得/设置 控件 type 属性 默认为 text /// [Parameter] public string InputType { get; set; } = "text"; /// - /// - /// - /// - /// - /// - /// - protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) - { - result = value; - validationErrorMessage = ""; - return true; - } - - /// - /// + /// 获取 最大长度属性 /// protected int? MaxLength { diff --git a/src/admin/Bootstrap.Admin/Components/LgbInputText.cs b/src/admin/Bootstrap.Admin/Components/LgbInputText.cs new file mode 100644 index 00000000..1e9890a0 --- /dev/null +++ b/src/admin/Bootstrap.Admin/Components/LgbInputText.cs @@ -0,0 +1,12 @@ +using Bootstrap.Admin.Shared; + +namespace Bootstrap.Admin.Components +{ + /// + /// LgbInputText 组件 + /// + public class LgbInputText : LgbInput + { + + } +} diff --git a/src/admin/Bootstrap.Admin/Components/QueryInputTextBase.cs b/src/admin/Bootstrap.Admin/Components/QueryInputTextBase.cs deleted file mode 100644 index 527e5c05..00000000 --- a/src/admin/Bootstrap.Admin/Components/QueryInputTextBase.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Microsoft.AspNetCore.Components; - -namespace Bootstrap.Admin.Components -{ - /// - /// - /// - public class QueryInputTextBase : LgbInputTextBase - { - - } -} diff --git a/src/admin/Bootstrap.Admin/Components/ValidateInputBase.cs b/src/admin/Bootstrap.Admin/Components/ValidateInputBase.cs index f38b61eb..b956506d 100644 --- a/src/admin/Bootstrap.Admin/Components/ValidateInputBase.cs +++ b/src/admin/Bootstrap.Admin/Components/ValidateInputBase.cs @@ -11,24 +11,24 @@ using System.Linq; namespace Bootstrap.Admin.Components { /// - /// + /// 内置验证组件基类 /// - public abstract class ValidateInputBase : InputBase, IValidateComponent + public abstract class ValidateInputBase : InputBase, IValidateComponent, IRules { /// - /// + /// 获得 IJSRuntime 实例 /// [Inject] protected IJSRuntime? JSRuntime { get; set; } /// - /// + /// 获得 LgbEditFormBase 实例 /// [CascadingParameter] public LgbEditFormBase? EditForm { get; set; } /// - /// + /// 获得 当前组件 Id /// public string Id { @@ -36,13 +36,13 @@ namespace Bootstrap.Admin.Components } /// - /// + /// 获得 子组件 RenderFragment 实例 /// [Parameter] public RenderFragment? ChildContent { get; set; } /// - /// + /// 获得 PlaceHolder 属性 /// protected string? PlaceHolder { @@ -59,22 +59,22 @@ namespace Bootstrap.Admin.Components } /// - /// + /// 获得/设置 错误描述信息 /// protected string ErrorMessage { get; set; } = ""; /// - /// + /// 获得/设置 数据合规样式 /// protected string ValidCss { get; set; } = ""; /// - /// + /// 获得/设置 显示名称 默认为 - /// protected string DisplayName { get; set; } = "-"; /// - /// + /// OnInitialized 方法 /// protected override void OnInitialized() { @@ -83,7 +83,7 @@ namespace Bootstrap.Admin.Components } /// - /// + /// OnAfterRender 方法 /// /// protected override void OnAfterRender(bool firstRender) @@ -96,13 +96,13 @@ namespace Bootstrap.Admin.Components } /// - /// + /// 获得 数据验证方法集合 /// public ICollection Rules { get; } = new HashSet(); private string _tooltipMethod = ""; /// - /// + /// 属性验证方法 /// /// /// @@ -142,7 +142,7 @@ namespace Bootstrap.Admin.Components } /// - /// + /// 将 字符串 Value 属性转化为 泛型 Value 方法 /// /// /// diff --git a/src/admin/Bootstrap.Admin/Components/ValidatorComponentBase.cs b/src/admin/Bootstrap.Admin/Components/ValidatorComponentBase.cs index a1528270..f4eace28 100644 --- a/src/admin/Bootstrap.Admin/Components/ValidatorComponentBase.cs +++ b/src/admin/Bootstrap.Admin/Components/ValidatorComponentBase.cs @@ -6,21 +6,21 @@ using System.ComponentModel.DataAnnotations; namespace Bootstrap.Admin.Components { /// - /// + /// 验证组件基类 /// public abstract class ValidatorComponentBase : ComponentBase { /// - /// + /// 获得/设置 错误描述信息 /// [Parameter] public string ErrorMessage { get; set; } = ""; /// - /// + /// 获得/设置 IRules 实例 /// [CascadingParameter] - public LgbInputTextBase? Input { get; set; } + public IRules? Input { get; set; } /// /// 初始化方法 @@ -30,7 +30,7 @@ namespace Bootstrap.Admin.Components if (Input == null) { throw new InvalidOperationException($"{nameof(ValidatorComponentBase)} requires a cascading " + - $"parameter of type {nameof(LgbInputTextBase)}. For example, you can use {nameof(ValidatorComponentBase)} " + + $"parameter of type {nameof(IRules)}. For example, you can use {nameof(ValidatorComponentBase)} " + $"inside an LgbInputText."); } @@ -38,7 +38,7 @@ namespace Bootstrap.Admin.Components } /// - /// + /// 验证方法 /// /// /// diff --git a/src/admin/Bootstrap.Admin/Pages/Admin/Menus.razor b/src/admin/Bootstrap.Admin/Pages/Admin/Menus.razor index 338d63e7..a3100691 100644 --- a/src/admin/Bootstrap.Admin/Pages/Admin/Menus.razor +++ b/src/admin/Bootstrap.Admin/Pages/Admin/Menus.razor @@ -40,17 +40,17 @@ - - - - + + + + - + diff --git a/src/admin/Bootstrap.Admin/Pages/Components/MenusBase.cs b/src/admin/Bootstrap.Admin/Pages/Components/MenusBase.cs index f5b834ef..56701589 100644 --- a/src/admin/Bootstrap.Admin/Pages/Components/MenusBase.cs +++ b/src/admin/Bootstrap.Admin/Pages/Components/MenusBase.cs @@ -24,7 +24,7 @@ namespace Bootstrap.Pages.Admin.Components /// 获得/设置 菜单类别 /// protected List QueryCategory { get; set; } = new List(new SelectedItem[] { - new SelectedItem() { Text = "全部", Value = "-1", Active = true }, + new SelectedItem() { Text = "全部", Value = "", Active = true }, new SelectedItem() { Text = "系统菜单", Value = "0" }, new SelectedItem() { Text = "外部菜单", Value = "1" } }); @@ -43,7 +43,7 @@ namespace Bootstrap.Pages.Admin.Components /// 获得/设置 所属应用 /// protected List QueryApp { get; set; } = new List(new SelectedItem[] { - new SelectedItem() { Text = "全部", Value = "-1", Active = true } + new SelectedItem() { Text = "全部", Value = "", Active = true } }); @@ -103,6 +103,8 @@ namespace Bootstrap.Pages.Admin.Components /// protected override void OnParametersSet() { + QueryModel.Category = ""; + QueryModel.IsResource = -1; QueryApp.AddRange(DictHelper.RetrieveApps().Select(app => new SelectedItem() { Text = app.Value, Value = app.Key })); DefineApp.AddRange(DictHelper.RetrieveApps().Select(app => new SelectedItem() { Text = app.Value, Value = app.Key })); } @@ -125,6 +127,22 @@ namespace Bootstrap.Pages.Admin.Components return new QueryData() { Items = items, TotalCount = totalCount, PageIndex = pageIndex, PageItems = pageItems }; } + /// + /// 新建方法 + /// + protected override BootstrapMenu Add() + { + return new BootstrapMenu() + { + Order = 10, + Icon = "fa fa-fa", + Target = "_self", + Category = "0", + IsResource = 0, + Application = DefineApp.First().Value + }; + } + /// /// 保存方法 /// diff --git a/src/admin/Bootstrap.Admin/Shared/LgbInputText.razor b/src/admin/Bootstrap.Admin/Shared/LgbInput.razor similarity index 92% rename from src/admin/Bootstrap.Admin/Shared/LgbInputText.razor rename to src/admin/Bootstrap.Admin/Shared/LgbInput.razor index 61d08f6c..f9845852 100644 --- a/src/admin/Bootstrap.Admin/Shared/LgbInputText.razor +++ b/src/admin/Bootstrap.Admin/Shared/LgbInput.razor @@ -1,4 +1,5 @@ -@inherits LgbInputTextBase +@typeparam TItem +@inherits LgbInputBase