|
|
|
@ -16,26 +16,26 @@ namespace Volo.Abp.FeatureManagement.Blazor.Components |
|
|
|
public partial class FeatureManagementModal |
|
|
|
{ |
|
|
|
[Inject] protected IFeatureAppService FeatureAppService { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
[Inject] protected IUiMessageService UiMessageService { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
[Inject] protected IStringLocalizerFactory HtmlLocalizerFactory { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
[Inject] protected IOptions<AbpLocalizationOptions> LocalizationOptions { get; set; } |
|
|
|
|
|
|
|
protected Modal Modal; |
|
|
|
|
|
|
|
|
|
|
|
protected string ProviderName; |
|
|
|
protected string ProviderKey; |
|
|
|
|
|
|
|
protected string SelectedTabName; |
|
|
|
|
|
|
|
|
|
|
|
protected List<FeatureGroupDto> Groups { get; set; } |
|
|
|
|
|
|
|
protected Dictionary<string, bool> ToggleValues; |
|
|
|
|
|
|
|
protected Dictionary<string, string> SelectionStringValues; |
|
|
|
|
|
|
|
|
|
|
|
public virtual async Task OpenAsync([NotNull]string providerName, string providerKey = null) |
|
|
|
{ |
|
|
|
ProviderName = providerName; |
|
|
|
@ -43,11 +43,11 @@ namespace Volo.Abp.FeatureManagement.Blazor.Components |
|
|
|
|
|
|
|
ToggleValues = new Dictionary<string, bool>(); |
|
|
|
SelectionStringValues = new Dictionary<string, string>(); |
|
|
|
|
|
|
|
|
|
|
|
Groups = (await FeatureAppService.GetAsync(ProviderName, ProviderKey)).Groups; |
|
|
|
|
|
|
|
SelectedTabName = GetNormalizedGroupName(Groups.First().Name); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var featureGroupDto in Groups) |
|
|
|
{ |
|
|
|
foreach (var featureDto in featureGroupDto.Features) |
|
|
|
@ -66,13 +66,13 @@ namespace Volo.Abp.FeatureManagement.Blazor.Components |
|
|
|
|
|
|
|
Modal.Show(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual Task CloseModal() |
|
|
|
{ |
|
|
|
Modal.Hide(); |
|
|
|
return Task.CompletedTask; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual async Task SaveAsync() |
|
|
|
{ |
|
|
|
var features = new UpdateFeaturesDto |
|
|
|
@ -80,21 +80,21 @@ namespace Volo.Abp.FeatureManagement.Blazor.Components |
|
|
|
Features = Groups.SelectMany(g => g.Features).Select(f => new UpdateFeatureDto |
|
|
|
{ |
|
|
|
Name = f.Name, |
|
|
|
Value = f.ValueType is ToggleStringValueType ? ToggleValues[f.Name].ToString() : |
|
|
|
Value = f.ValueType is ToggleStringValueType ? ToggleValues[f.Name].ToString() : |
|
|
|
f.ValueType is SelectionStringValueType ? SelectionStringValues[f.Name] : f.Value |
|
|
|
}).ToList() |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
await FeatureAppService.UpdateAsync(ProviderName, ProviderKey, features); |
|
|
|
|
|
|
|
|
|
|
|
Modal.Hide(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual string GetNormalizedGroupName(string name) |
|
|
|
{ |
|
|
|
return "FeatureGroup_" + name.Replace(".", "_"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual bool IsDisabled(string providerName) |
|
|
|
{ |
|
|
|
return providerName != ProviderName && providerName != DefaultValueFeatureValueProvider.ProviderName; |
|
|
|
@ -102,7 +102,7 @@ namespace Volo.Abp.FeatureManagement.Blazor.Components |
|
|
|
|
|
|
|
protected virtual async Task OnFeatureValueChangedAsync(string value, FeatureDto feature) |
|
|
|
{ |
|
|
|
if (feature.ValueType.Validator.IsValid(value)) |
|
|
|
if (feature?.ValueType?.Validator.IsValid(value) == true) |
|
|
|
{ |
|
|
|
feature.Value = value; |
|
|
|
} |
|
|
|
@ -116,11 +116,11 @@ namespace Volo.Abp.FeatureManagement.Blazor.Components |
|
|
|
{ |
|
|
|
SelectionStringValues[featureName] = value; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual IStringLocalizer CreateStringLocalizer(string resourceName) |
|
|
|
{ |
|
|
|
var resource = LocalizationOptions.Value.Resources.Values.FirstOrDefault(x => x.ResourceName == resourceName); |
|
|
|
return HtmlLocalizerFactory.Create(resource != null ? resource.ResourceType : LocalizationOptions.Value.DefaultResourceType); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|