diff --git a/docs/en/Settings.md b/docs/en/Settings.md index 32761ff201..567cb02c4c 100644 --- a/docs/en/Settings.md +++ b/docs/en/Settings.md @@ -2,7 +2,7 @@ [Configuration system](Configuration.md) is a good way to configure the application on startup. In addition to the configurations, ABP provides another way to set and get some application settings. -A setting is a name-value pair stored in a dynamic data source, generally in a database. Setting system is extensible and there are pre-built provides for a user, a tenant, global and default. +A setting is a name-value pair stored in a dynamic data source, generally in a database. Setting system is extensible and there are pre-built providers for a user, a tenant, global and default. ## Defining Settings @@ -67,7 +67,7 @@ public class MySettingDefinitionProvider : SettingDefinitionProvider > Using constants for the setting names is a good practice and ABP packages do it. `Abp.Mailing.Smtp.Host` setting name is a constant defined by the `EmailSettingNames` class (in the `Volo.Abp.Emailing` namespace). -## Reading Setting Values +## Reading the Setting Values ### ISettingProvider @@ -108,24 +108,15 @@ public class MyService } ```` -> `ISettingProvider` is a very common service and some base classes (like `IApplicationService`) already property-inject it. You can directly use the `SettingProvider` in such cases. +> `ISettingProvider` is a very common service and some base classes (like `IApplicationService`) already property-inject it. You can directly use the `SettingProvider` property in such cases. ### Reading Setting Values on the Client Side -If a setting is allowed to be visible on the client side, current value of the setting can also be read from the JavaScript code. Examples: +If a setting is allowed to be visible on the client side, current value of the setting can also be read from the client code. See the following documents to understand how to get the setting values in different UI types; -````js -//Gets a value as string. -var language = abp.setting.get('Abp.Localization.DefaultLanguage'); - -//Gets an integer value. -var requiredLength = abp.setting.getInt('Abp.Identity.Password.RequiredLength'); - -//Gets a boolean value. -var requireDigit = abp.setting.getBoolean('Abp.Identity.Password.RequireDigit'); -```` - -In addition, use `abp.setting.values` to get a dictionary of all the setting values. +* [MVC / Razor Pages](UI/AspNetCore/JavaScript-API/Settings.md) +* [Angular](UI/Angular/Settings.md) +* [Blazor](UI/Blazor/Settings.md) ## Setting Value Providers diff --git a/docs/en/UI/Angular/Settings.md b/docs/en/UI/Angular/Settings.md new file mode 100644 index 0000000000..47868f2363 --- /dev/null +++ b/docs/en/UI/Angular/Settings.md @@ -0,0 +1,3 @@ +# Angular UI: Settings + +> This document explains how to get setting values in an Angular application. See the [settings document](../../Settings.md) to learn the setting system. \ No newline at end of file diff --git a/docs/en/UI/AspNetCore/JavaScript-API/Index.md b/docs/en/UI/AspNetCore/JavaScript-API/Index.md index bca62835f7..25251dcdbf 100644 --- a/docs/en/UI/AspNetCore/JavaScript-API/Index.md +++ b/docs/en/UI/AspNetCore/JavaScript-API/Index.md @@ -16,7 +16,7 @@ ABP provides a set of JavaScript APIs for ASP.NET Core MVC / Razor Pages applica * abp.ModalManager * [abp.notify](Notify.md) * abp.security -* abp.setting +* [abp.setting](Settings.md) * abp.ui * abp.utils * abp.ResourceLoader diff --git a/docs/en/UI/AspNetCore/JavaScript-API/Settings.md b/docs/en/UI/AspNetCore/JavaScript-API/Settings.md new file mode 100644 index 0000000000..cf96cecdd0 --- /dev/null +++ b/docs/en/UI/AspNetCore/JavaScript-API/Settings.md @@ -0,0 +1,33 @@ +# ASP.NET Core MVC / Razor Pages UI: JavaScript Setting API + +Localization API allows you to get the values of the settings on the client side. You can read the current value of a setting in the client side only if it is allowed by the setting definition (on the server side). + +> This document only explains the JavaScript API. See the [settings document](../../../Settings.md) to understand the ABP setting system. + +## Basic Usage + +````js +//Gets a value as string. +var language = abp.setting.get('Abp.Localization.DefaultLanguage'); + +//Gets an integer value. +var requiredLength = abp.setting.getInt('Abp.Identity.Password.RequiredLength'); + +//Gets a boolean value. +var requireDigit = abp.setting.getBoolean('Abp.Identity.Password.RequireDigit'); +```` + +## All Values + +`abp.setting.values` can be used to obtain all the setting values as an object where the object properties are setting names and property values are the setting values. + +An example value of this object is shown below: + +````js +{ + Abp.Localization.DefaultLanguage: "en", + Abp.Timing.TimeZone: "UTC", + ... +} +```` + diff --git a/docs/en/UI/Blazor/Settings.md b/docs/en/UI/Blazor/Settings.md new file mode 100644 index 0000000000..276462c411 --- /dev/null +++ b/docs/en/UI/Blazor/Settings.md @@ -0,0 +1,3 @@ +# Blazor UI: Settings + +Blazor applications can reuse the same `ISettingProvider` service that is explained in the [settings document](../../Settings.md). \ No newline at end of file diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index c0c25fd658..2ad29baad1 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -455,6 +455,10 @@ "text": "Localization", "path": "UI/AspNetCore/JavaScript-API/Localization.md" }, + { + "text": "Settings", + "path": "UI/AspNetCore/JavaScript-API/Settings.md" + }, { "text": "AJAX", "path": "UI/AspNetCore/JavaScript-API/Ajax.md" diff --git a/docs/zh-Hans/docs-nav.json b/docs/zh-Hans/docs-nav.json index 5df3376507..3f018ae3a4 100644 --- a/docs/zh-Hans/docs-nav.json +++ b/docs/zh-Hans/docs-nav.json @@ -12,7 +12,7 @@ "path": "Startup-Templates/Console.md" }, { - "text": "空Web应用程序t", + "text": "空Web应用程序", "path": "Getting-Started-AspNetCore-Application.md" } ] diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs index 9436acbbbf..ff5b085df5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs @@ -260,7 +260,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form var label = new TagBuilder("label"); label.Attributes.Add("for", GetIdAttributeValue(inputTag)); - label.InnerHtml.Append(TagHelper.Label); + label.InnerHtml.AppendHtml(TagHelper.Label); if (isCheckbox) { diff --git a/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiMessageService.cs b/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiMessageService.cs index f22ec3b653..3e83166191 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiMessageService.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiMessageService.cs @@ -69,16 +69,16 @@ namespace Volo.Abp.BlazoriseUI return Task.CompletedTask; } - public async Task ConfirmAsync(string message, string title = null, Action options = null) + public Task ConfirmAsync(string message, string title = null, Action options = null) { var uiMessageOptions = CreateDefaultOptions(); options?.Invoke(uiMessageOptions); var callback = new TaskCompletionSource(); - MessageReceived?.Invoke(this, new UiMessageEventArgs(UiMessageType.Confirmation, message, title, uiMessageOptions)); + MessageReceived?.Invoke(this, new UiMessageEventArgs(UiMessageType.Confirmation, message, title, uiMessageOptions, callback)); - return await callback.Task; + return callback.Task; } protected virtual UiMessageOptions CreateDefaultOptions() diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingProvider.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingProvider.cs index 6f5372a4cf..5ef67cbc21 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingProvider.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingProvider.cs @@ -35,7 +35,7 @@ namespace Volo.Abp.Settings //TODO: How to implement setting.IsInherited? var value = await GetOrNullValueFromProvidersAsync(providers, setting); - if (setting.IsEncrypted) + if (value != null && setting.IsEncrypted) { value = SettingEncryptionService.Decrypt(setting, value); } @@ -84,4 +84,4 @@ namespace Volo.Abp.Settings return null; } } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor.cs index 0724ee6c97..c39cb6f880 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor.cs @@ -45,24 +45,16 @@ namespace MyCompanyName.MyProjectName.Blazor.Pages return UiMessageService.ErrorAsync( "This is the Error message", "Error" ); } - Task OnConfirmTestClicked() + async Task OnConfirmTestClicked() { - return UiMessageService.ConfirmAsync( "Are you sure you want to delete the item?", "Confirm", options => + if ( await UiMessageService.ConfirmAsync( "Are you sure you want to delete the item?", "Confirm", options => { options.CancelButtonText = "Do not delete it"; options.ConfirmButtonText = "Yes I'm sure"; - } ) - .ContinueWith( result => - { - if ( result.Result ) - { - Console.WriteLine( "Confirmed" ); - } - else - { - Console.WriteLine( "Cancelled" ); - } - } ); + } ) ) + { + Console.WriteLine( "Confirmed" ); + } } [Inject] IUiMessageService UiMessageService { get; set; }