From 264cad683f00dbb7bbdd880ca259c9226a2fd282 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Sat, 22 Jan 2022 16:45:21 +0800 Subject: [PATCH 1/6] =?UTF-8?q?doc:=20=E5=A2=9E=E5=8A=A0=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Locales/en.json | 1 + src/BootstrapBlazor/Locales/pt.json | 1 + src/BootstrapBlazor/Locales/zh.json | 1 + 3 files changed, 3 insertions(+) diff --git a/src/BootstrapBlazor/Locales/en.json b/src/BootstrapBlazor/Locales/en.json index 1cc90d486..e73f9eb71 100644 --- a/src/BootstrapBlazor/Locales/en.json +++ b/src/BootstrapBlazor/Locales/en.json @@ -230,6 +230,7 @@ "AddButtonToastContent": "Add data failed. Please provider OnAddAsync method", "EditButtonToastTitle": "Add Data", "EditButtonToastNotSelectContent": "Save data failed. Please provider OnSaveAsync method", + "EditButtonToastReadonlyContent": "The selected data cannot be edited", "EditButtonToastMoreSelectContent": "Only one row can be EDIT", "EditButtonToastNoSaveMethodContent": "Can not EDIT data. Please provider OnSaveAsync method", "SaveButtonToastTitle": "Save Data", diff --git a/src/BootstrapBlazor/Locales/pt.json b/src/BootstrapBlazor/Locales/pt.json index 52aa59490..f1762c6f5 100644 --- a/src/BootstrapBlazor/Locales/pt.json +++ b/src/BootstrapBlazor/Locales/pt.json @@ -230,6 +230,7 @@ "AddButtonToastContent": "Falha ao Adicionar. Atribua o método OnAddAsync", "EditButtonToastTitle": "Adicionar Registro", "EditButtonToastNotSelectContent": "Falha ao Salvar. Atribua o método OnSaveAsync", + "EditButtonToastReadonlyContent": "Os dados seleccionados não podem ser editados", "EditButtonToastMoreSelectContent": "Somente uma linha pode ser alterada", "EditButtonToastNoSaveMethodContent": "Falha ao Editar. Atribua o método OnSaveAsync", "SaveButtonToastTitle": "Salvar Registro", diff --git a/src/BootstrapBlazor/Locales/zh.json b/src/BootstrapBlazor/Locales/zh.json index 0bb9ea3ea..693e5c88e 100644 --- a/src/BootstrapBlazor/Locales/zh.json +++ b/src/BootstrapBlazor/Locales/zh.json @@ -230,6 +230,7 @@ "AddButtonToastContent": "未提供新建数据方法,无法新建数据", "EditButtonToastTitle": "编辑数据", "EditButtonToastNotSelectContent": "请选择要编辑的数据", + "EditButtonToastReadonlyContent": "选项不可编辑", "EditButtonToastMoreSelectContent": "只能选择一项要编辑的数据", "EditButtonToastNoSaveMethodContent": "未提供保存数据方法,无法编辑数据", "SaveButtonToastTitle": "保存数据", -- Gitee From 50a4f19a3c8dc5bf96ef0f90fa1b2c2e1760406f Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Sat, 22 Jan 2022 16:45:55 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E9=A1=B9=E6=97=A0=E6=B3=95=E7=BC=96=E8=BE=91=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Table/Table.razor.Localization.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.Localization.cs b/src/BootstrapBlazor/Components/Table/Table.razor.Localization.cs index d9d6a2373..457fa2b61 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.Localization.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.Localization.cs @@ -189,6 +189,13 @@ public partial class Table [NotNull] public string? EditButtonToastNotSelectContent { get; set; } + /// + /// 编辑按钮 Toast 选择项设置不可编辑时提示 Content 文字 + /// + [Parameter] + [NotNull] + public string? EditButtonToastReadonlyContent { get; set; } + /// /// 编辑按钮 Toast 多项选择时提示 Content 文字 /// -- Gitee From 1ecbb1a17134d951b4b7f5ef7d3a87cffbd7e4ce Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Sat, 22 Jan 2022 16:49:14 +0800 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E9=A1=B9=E6=97=A0=E6=B3=95=E5=88=A0=E9=99=A4=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Table/Table.razor.Toolbar.cs | 63 +++++++++++-------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs b/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs index b0994808f..9434ebcc4 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs @@ -325,49 +325,58 @@ public partial class Table { if (SelectedRows.Count == 1) { - await ToggleLoading(true); - await InternalOnEditAsync(); - EditModalTitleString = EditModalTitle; - - // 显示编辑框 - if (EditMode == EditMode.Popup) + // 检查是否选中了不可编辑行(行内无编辑按钮) + if (ShowEditButtonCallback != null && !ShowEditButtonCallback(SelectedRows[0])) { - await ShowEditDialog(ItemChangedType.Update); + // 提示不可编辑 + await ShowToastAsync(ToastCategory.Information, EditButtonToastReadonlyContent); } - else if (EditMode == EditMode.EditForm) + else { - ShowEditForm = true; - ShowAddForm = false; - await UpdateAsync(); + await ToggleLoading(true); + await InternalOnEditAsync(); + EditModalTitleString = EditModalTitle; - } - else if (EditMode == EditMode.InCell) - { - AddInCell = false; - EditInCell = true; - await UpdateAsync(); + // 显示编辑框 + if (EditMode == EditMode.Popup) + { + await ShowEditDialog(ItemChangedType.Update); + } + else if (EditMode == EditMode.EditForm) + { + ShowEditForm = true; + ShowAddForm = false; + await UpdateAsync(); + } + else if (EditMode == EditMode.InCell) + { + AddInCell = false; + EditInCell = true; + await UpdateAsync(); + + } + await ToggleLoading(false); } - await ToggleLoading(false); } else { - var option = new ToastOption - { - Category = ToastCategory.Information, - Title = EditButtonToastTitle, - Content = SelectedRows.Count == 0 ? EditButtonToastNotSelectContent : EditButtonToastMoreSelectContent - }; - await Toast.Show(option); + var content = SelectedRows.Count == 0 ? EditButtonToastNotSelectContent : EditButtonToastMoreSelectContent; + await ShowToastAsync(ToastCategory.Information, content); } } else + { + await ShowToastAsync(ToastCategory.Error, EditButtonToastNoSaveMethodContent); + } + + async Task ShowToastAsync(ToastCategory category, string content) { var option = new ToastOption { - Category = ToastCategory.Error, + Category = category, Title = EditButtonToastTitle, - Content = EditButtonToastNoSaveMethodContent + Content = content }; await Toast.Show(option); } -- Gitee From 76f714903dd17c438e28e9d5abb37d9686557428 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Sat, 22 Jan 2022 17:03:51 +0800 Subject: [PATCH 4/6] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A2=9E=E5=8A=A0=E6=97=A0=E6=B3=95=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Locales/en.json | 1 + src/BootstrapBlazor/Locales/pt.json | 1 + src/BootstrapBlazor/Locales/zh.json | 1 + 3 files changed, 3 insertions(+) diff --git a/src/BootstrapBlazor/Locales/en.json b/src/BootstrapBlazor/Locales/en.json index e73f9eb71..0fa4b14ff 100644 --- a/src/BootstrapBlazor/Locales/en.json +++ b/src/BootstrapBlazor/Locales/en.json @@ -241,6 +241,7 @@ "DeleteButtonToastTitle": "Delete Data", "DeleteButtonToastContent": "Please select DELETE rows, auto close after {0}s", "DeleteButtonToastResultContent": "Delete data {0}, auto close after {1}s", + "DeleteButtonToastCanNotDeleteContent": "There is undeletable data in the selected data, auto close after {0}s", "DataServiceInvalidOperationText": "Cannot provide a value for property 'DataService' on type 'BootstrapBlazor.Components.Table`1[[{0}]]'. There is no registered service of type 'BootstrapBlazor.Components.IDataService`1[{0}]'.", "NotSetOnTreeExpandErrorMessage": "not set OnTreeExpand parameter", "UnsetText": "Asc", diff --git a/src/BootstrapBlazor/Locales/pt.json b/src/BootstrapBlazor/Locales/pt.json index f1762c6f5..8ea862d09 100644 --- a/src/BootstrapBlazor/Locales/pt.json +++ b/src/BootstrapBlazor/Locales/pt.json @@ -241,6 +241,7 @@ "DeleteButtonToastTitle": "Apagar Registro", "DeleteButtonToastContent": "Selecione o registro a excluir, fechando em {0}s", "DeleteButtonToastResultContent": "Registro excluido {0}, fechando em {1}s", + "DeleteButtonToastCanNotDeleteContent": "Não foi possível editar o X, fechando em {0}s", "DataServiceInvalidOperationText": "Não foi possível fornecer um valor para 'DataService' do tipo 'BootstrapBlazor.Components.Table`1[[{0}]]'. Não existe serviço registrado do tipo 'BootstrapBlazor.Components.IDataService`1[{0}]'.", "NotSetOnTreeExpandErrorMessage": "parâmetro OnTreeExpand não atribuído", "UnsetText": "Asc", diff --git a/src/BootstrapBlazor/Locales/zh.json b/src/BootstrapBlazor/Locales/zh.json index 693e5c88e..7164e2db1 100644 --- a/src/BootstrapBlazor/Locales/zh.json +++ b/src/BootstrapBlazor/Locales/zh.json @@ -241,6 +241,7 @@ "DeleteButtonToastTitle": "删除数据", "DeleteButtonToastContent": "请选择要删除的数据, {0} 秒后自动关闭", "DeleteButtonToastResultContent": "删除数据{0}, {1} 秒后自动关闭", + "DeleteButtonToastCanNotDeleteContent": "选中数据中有不可删除数据, {0} 秒后自动关闭", "DataServiceInvalidOperationText": "未注册 'BootstrapBlazor.Components.IDataService`1[{0}]' 服务", "NotSetOnTreeExpandErrorMessage": "未设置 OnTreeExpand 回调委托方法", "UnsetText": "点击升序", -- Gitee From c88855922025302bad17973fa4c1fb013cb2adff Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Sat, 22 Jan 2022 17:04:11 +0800 Subject: [PATCH 5/6] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=8C=89=E9=92=AE=E6=8F=90=E7=A4=BA=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Table/Table.razor.Toolbar.cs | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs b/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs index 9434ebcc4..cd6654822 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs @@ -563,20 +563,32 @@ public partial class Table { var ret = false; if (SelectedRows.Count == 0) + { + await ShowToastAsync(DeleteButtonToastContent); + } + else + { + if (ShowDeleteButtonCallback != null && SelectedRows.Any(i => !ShowDeleteButtonCallback(i))) + { + await ShowToastAsync(DeleteButtonToastCanNotDeleteContent); + } + else + { + ret = true; + } + } + return ret; + + async Task ShowToastAsync(string content) { var option = new ToastOption { Category = ToastCategory.Information, Title = DeleteButtonToastTitle }; - option.Content = string.Format(DeleteButtonToastContent, Math.Ceiling(option.Delay / 1000.0)); + option.Content = string.Format(content, Math.Ceiling(option.Delay / 1000.0)); await Toast.Show(option); } - else - { - ret = true; - } - return ret; } /// @@ -741,11 +753,11 @@ public partial class Table /// 是否显示行内编辑按钮 /// /// - protected bool GetShowEditButton(TItem item) => ShowEditButtonCallback == null ? ShowToolbar && ShowDefaultButtons && ShowEditButton : ShowEditButtonCallback(item); + protected bool GetShowEditButton(TItem item) => ShowToolbar && ShowDefaultButtons && (ShowEditButtonCallback == null ? ShowEditButton : ShowEditButtonCallback(item)); /// /// 是否显示行内删除按钮 /// /// - protected bool GetShowDeleteButton(TItem item) => ShowDeleteButtonCallback == null ? ShowToolbar && ShowDefaultButtons && ShowDeleteButton : ShowDeleteButtonCallback(item); + protected bool GetShowDeleteButton(TItem item) => ShowToolbar && ShowDefaultButtons && (ShowDeleteButtonCallback == null ? ShowDeleteButton : ShowDeleteButtonCallback(item)); } -- Gitee From ae7f87f159c3ec188f67340ca0097e3e6fbf4062 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Sat, 22 Jan 2022 17:42:25 +0800 Subject: [PATCH 6/6] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E4=BF=A1=E6=81=AF=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Table/Table.razor.Localization.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.Localization.cs b/src/BootstrapBlazor/Components/Table/Table.razor.Localization.cs index 457fa2b61..748596f44 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.Localization.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.Localization.cs @@ -252,6 +252,13 @@ public partial class Table [NotNull] public string? DeleteButtonToastTitle { get; set; } + /// + /// 删除按钮选项中有无法删除项时 Toast 提示文字 + /// + [Parameter] + [NotNull] + public string? DeleteButtonToastCanNotDeleteContent { get; set; } + /// /// 删除按钮 Toast 提示 Content 文字 /// @@ -303,6 +310,7 @@ public partial class Table EditButtonToastNotSelectContent ??= Localizer[nameof(EditButtonToastNotSelectContent)]; EditButtonToastMoreSelectContent ??= Localizer[nameof(EditButtonToastMoreSelectContent)]; EditButtonToastNoSaveMethodContent ??= Localizer[nameof(EditButtonToastNoSaveMethodContent)]; + EditButtonToastReadonlyContent ??= Localizer[nameof(EditButtonToastReadonlyContent)]; SaveButtonToastTitle ??= Localizer[nameof(SaveButtonToastTitle)]; SaveButtonToastContent ??= Localizer[nameof(SaveButtonToastContent)]; SaveButtonToastResultContent ??= Localizer[nameof(SaveButtonToastResultContent)]; @@ -311,6 +319,7 @@ public partial class Table DeleteButtonToastTitle ??= Localizer[nameof(DeleteButtonToastTitle)]; DeleteButtonToastContent ??= Localizer[nameof(DeleteButtonToastContent)]; DeleteButtonToastResultContent ??= Localizer[nameof(DeleteButtonToastResultContent)]; + DeleteButtonToastCanNotDeleteContent ??= Localizer[nameof(DeleteButtonToastCanNotDeleteContent)]; DataServiceInvalidOperationText ??= Localizer[nameof(DataServiceInvalidOperationText), typeof(TItem).FullName!]; NotSetOnTreeExpandErrorMessage = Localizer[nameof(NotSetOnTreeExpandErrorMessage)]; UnsetText ??= Localizer[nameof(UnsetText)]; -- Gitee