Browse Source

Improved

pull/5361/head
liangshiwei 6 years ago
parent
commit
450f1a105e
  1. 6
      modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/AbpFeatureManagementDomainSharedModule.cs
  2. 6
      modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/FeatureManagementDomainErrorCodes.cs
  3. 14
      modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/FeatureValueInvalidException.cs
  4. 5
      modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/ar.json
  5. 5
      modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/de.json
  6. 3
      modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/en.json
  7. 3
      modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/ru.json
  8. 3
      modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/tr.json
  9. 3
      modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/zh-Hans.json
  10. 3
      modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/zh-Hant.json
  11. 11
      modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManager.cs
  12. 9
      modules/feature-management/src/Volo.Abp.FeatureManagement.Web/Pages/FeatureManagement/FeatureManagementModal.cshtml

6
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/AbpFeatureManagementDomainSharedModule.cs

@ -1,5 +1,6 @@
using Volo.Abp.FeatureManagement.Localization; using Volo.Abp.FeatureManagement.Localization;
using Volo.Abp.Localization; using Volo.Abp.Localization;
using Volo.Abp.Localization.ExceptionHandling;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.Validation; using Volo.Abp.Validation;
using Volo.Abp.Validation.Localization; using Volo.Abp.Validation.Localization;
@ -27,6 +28,11 @@ namespace Volo.Abp.FeatureManagement
typeof(AbpValidationResource) typeof(AbpValidationResource)
).AddVirtualJson("Volo/Abp/FeatureManagement/Localization/Domain"); ).AddVirtualJson("Volo/Abp/FeatureManagement/Localization/Domain");
}); });
Configure<AbpExceptionLocalizationOptions>(options =>
{
options.MapCodeNamespace("Volo.Abp.FeatureManagement", typeof(AbpFeatureManagementResource));
});
} }
} }
} }

6
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/FeatureManagementDomainErrorCodes.cs

@ -1,7 +1,9 @@
namespace Volo.Abp.FeatureManagement using System;
namespace Volo.Abp.FeatureManagement
{ {
public static class FeatureManagementDomainErrorCodes public static class FeatureManagementDomainErrorCodes
{ {
public const string FeatureValueInvalid = "Volo.Abp.FeatureManagement:InvalidFeatureValue";
} }
} }

14
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/FeatureValueInvalidException.cs

@ -0,0 +1,14 @@
using System;
namespace Volo.Abp.FeatureManagement
{
[Serializable]
public class FeatureValueInvalidException : BusinessException
{
public FeatureValueInvalidException(string name) :
base(FeatureManagementDomainErrorCodes.FeatureValueInvalid)
{
WithData("0", name);
}
}
}

5
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/ar.json

@ -2,6 +2,7 @@
"culture": "ar", "culture": "ar",
"texts": { "texts": {
"Features": "المميزات", "Features": "المميزات",
"NoFeatureFoundMessage": "لا توجد أي ميزة متاحة." "NoFeatureFoundMessage": "لا توجد أي ميزة متاحة.",
"Volo.Abp.FeatureManagement:InvalidFeatureValue" : "{0} قيمة الميزة غير صالحة!"
} }
} }

5
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/de.json

@ -2,6 +2,7 @@
"culture": "de", "culture": "de",
"texts": { "texts": {
"Features": "Funktionen", "Features": "Funktionen",
"NoFeatureFoundMessage": "Es ist keine Funktion verfügbar." "NoFeatureFoundMessage": "Es ist keine Funktion verfügbar.",
"Volo.Abp.FeatureManagement:InvalidFeatureValue" : "Der {0} -Feature-Wert ist ungültig!"
} }
} }

3
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/en.json

@ -4,6 +4,7 @@
"Features": "Features", "Features": "Features",
"NoFeatureFoundMessage": "There isn't any available feature.", "NoFeatureFoundMessage": "There isn't any available feature.",
"Permission:FeatureManagement": "Feature management", "Permission:FeatureManagement": "Feature management",
"Permission:FeatureManagement.ManageHostFeatures": "Manage Host features" "Permission:FeatureManagement.ManageHostFeatures": "Manage Host features",
"Volo.Abp.FeatureManagement:InvalidFeatureValue" : "{0} feature value is not valid!"
} }
} }

3
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/ru.json

@ -2,6 +2,7 @@
"culture": "ru", "culture": "ru",
"texts": { "texts": {
"Features": "Функциональные возможности", "Features": "Функциональные возможности",
"NoFeatureFoundMessage": "Нет доступных функциональных возможностей." "NoFeatureFoundMessage": "Нет доступных функциональных возможностей.",
"Volo.Abp.FeatureManagement:InvalidFeatureValue" : "Недопустимое значение функции {0}!"
} }
} }

3
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/tr.json

@ -4,6 +4,7 @@
"Features": "Özellikler", "Features": "Özellikler",
"NoFeatureFoundMessage": "Hiç özellik yok.", "NoFeatureFoundMessage": "Hiç özellik yok.",
"Permission:FeatureManagement": "Özellik yönetimi", "Permission:FeatureManagement": "Özellik yönetimi",
"Permission:FeatureManagement.ManageHostFeatures": "Host özelliklerini düzenle" "Permission:FeatureManagement.ManageHostFeatures": "Host özelliklerini düzenle",
"Volo.Abp.FeatureManagement:InvalidFeatureValue" : "{0} özellik değeri geçerli değil!"
} }
} }

3
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/zh-Hans.json

@ -4,6 +4,7 @@
"Features": "功能", "Features": "功能",
"NoFeatureFoundMessage": "没有可用的功能.", "NoFeatureFoundMessage": "没有可用的功能.",
"Permission:FeatureManagement": "特性管理", "Permission:FeatureManagement": "特性管理",
"Permission:FeatureManagement.ManageHostFeatures": "管理Host特性" "Permission:FeatureManagement.ManageHostFeatures": "管理Host特性",
"Volo.Abp.FeatureManagement:InvalidFeatureValue" : "{0}功能的值无效!"
} }
} }

3
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain.Shared/Volo/Abp/FeatureManagement/Localization/Domain/zh-Hant.json

@ -4,6 +4,7 @@
"Features": "功能", "Features": "功能",
"NoFeatureFoundMessage": "沒有可用的功能.", "NoFeatureFoundMessage": "沒有可用的功能.",
"Permission:FeatureManagement": "功能管理", "Permission:FeatureManagement": "功能管理",
"Permission:FeatureManagement.ManageHostFeatures": "管理Host功能" "Permission:FeatureManagement.ManageHostFeatures": "管理Host功能",
"Volo.Abp.FeatureManagement:InvalidFeatureValue" : "{0}功能的值無效!"
} }
} }

11
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManager.cs

@ -3,10 +3,10 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Features; using Volo.Abp.Features;
using Volo.Abp.Validation;
namespace Volo.Abp.FeatureManagement namespace Volo.Abp.FeatureManagement
{ {
@ -15,15 +15,18 @@ namespace Volo.Abp.FeatureManagement
protected IFeatureDefinitionManager FeatureDefinitionManager { get; } protected IFeatureDefinitionManager FeatureDefinitionManager { get; }
protected List<IFeatureManagementProvider> Providers => _lazyProviders.Value; protected List<IFeatureManagementProvider> Providers => _lazyProviders.Value;
protected FeatureManagementOptions Options { get; } protected FeatureManagementOptions Options { get; }
protected IStringLocalizerFactory StringLocalizerFactory { get; }
private readonly Lazy<List<IFeatureManagementProvider>> _lazyProviders; private readonly Lazy<List<IFeatureManagementProvider>> _lazyProviders;
public FeatureManager( public FeatureManager(
IOptions<FeatureManagementOptions> options, IOptions<FeatureManagementOptions> options,
IServiceProvider serviceProvider, IServiceProvider serviceProvider,
IFeatureDefinitionManager featureDefinitionManager) IFeatureDefinitionManager featureDefinitionManager,
IStringLocalizerFactory stringLocalizerFactory)
{ {
FeatureDefinitionManager = featureDefinitionManager; FeatureDefinitionManager = featureDefinitionManager;
StringLocalizerFactory = stringLocalizerFactory;
Options = options.Value; Options = options.Value;
//TODO: Instead, use IHybridServiceScopeFactory and create a scope..? //TODO: Instead, use IHybridServiceScopeFactory and create a scope..?
@ -131,9 +134,9 @@ namespace Volo.Abp.FeatureManagement
var feature = FeatureDefinitionManager.Get(name); var feature = FeatureDefinitionManager.Get(name);
if (feature.ValueType.Validator != null && !feature.ValueType.Validator.IsValid(value)) if (!feature.ValueType.Validator.IsValid(value))
{ {
throw new BusinessException($"{feature.Name} value is invalid"); throw new FeatureValueInvalidException(feature.DisplayName.Localize(StringLocalizerFactory));
} }
var providers = Enumerable var providers = Enumerable

9
modules/feature-management/src/Volo.Abp.FeatureManagement.Web/Pages/FeatureManagement/FeatureManagementModal.cshtml

@ -51,9 +51,16 @@
@if (feature.ValueType is FreeTextStringValueType) @if (feature.ValueType is FreeTextStringValueType)
{ {
var type = "text";
if(feature.ValueType.Validator is NumericValueValidator)
{
type = "number";
}
<abp-input asp-for="@featureGroups[i].Features[j].Value" <abp-input asp-for="@featureGroups[i].Features[j].Value"
label="@feature.DisplayName" label="@feature.DisplayName"
disabled="@disabled" disabled="@disabled"
type="@type"
group-data-feature-name="@feature.Name" group-data-feature-name="@feature.Name"
group-data-parent-name="@(feature.ParentName ?? "")" group-data-parent-name="@(feature.ParentName ?? "")"
group-style="margin-left: @(feature.Depth * 25)px"/> group-style="margin-left: @(feature.Depth * 25)px"/>
@ -80,7 +87,7 @@
</div> </div>
} }
<input value="@feature.Name" name="FeatureGroups[@i].Features[@j].Name" hidden=""/> <input value="@feature.Name" name="FeatureGroups[@i].Features[@j].Name" hidden=""/>
</div> </div>
} }
</div> </div>

Loading…
Cancel
Save