Browse Source
Add `abp.globalFeatures.isEnabled` to `abp.js`
pull/12553/head
maliming
4 years ago
No known key found for this signature in database
GPG Key ID: 96224957E51C89E
4 changed files with
17 additions and
13 deletions
-
docs/en/UI/AspNetCore/JavaScript-API/GlobalFeatures.md
-
framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationGlobalFeatureConfigurationDto.cs
-
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs
-
npm/packs/core/src/abp.js
|
|
|
@ -7,15 +7,18 @@ |
|
|
|
## Usage |
|
|
|
|
|
|
|
````js |
|
|
|
//Gets all enabled global features. |
|
|
|
> abp.globalFeatures.enabledFeatures |
|
|
|
|
|
|
|
[ 'Shopping.Payment', 'Ecommerce.Subscription' ] |
|
|
|
|
|
|
|
> abp.globalFeatures.moduleEnabledFeatures |
|
|
|
|
|
|
|
{ Ecommerce } |
|
|
|
//Check the global feature is enabled |
|
|
|
> abp.globalFeatures.isEnabled('Ecommerce.Subscription') |
|
|
|
|
|
|
|
> abp.globalFeatures.moduleEnabledFeatures.Ecommerce |
|
|
|
true |
|
|
|
|
|
|
|
[ 'Ecommerce.Subscription', 'Ecommerce.Invoice' ] |
|
|
|
> abp.globalFeatures.isEnabled('My.Subscription') |
|
|
|
|
|
|
|
false |
|
|
|
```` |
|
|
|
|
|
|
|
@ -8,11 +8,8 @@ public class ApplicationGlobalFeatureConfigurationDto |
|
|
|
{ |
|
|
|
public HashSet<string> EnabledFeatures { get; set; } |
|
|
|
|
|
|
|
public Dictionary<string, List<string>> ModuleEnabledFeatures { get; set; } |
|
|
|
|
|
|
|
public ApplicationGlobalFeatureConfigurationDto() |
|
|
|
{ |
|
|
|
EnabledFeatures = new HashSet<string>(); |
|
|
|
ModuleEnabledFeatures = new Dictionary<string, List<string>>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -295,15 +295,9 @@ public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApp |
|
|
|
result.EnabledFeatures.AddIfNotContains(enabledFeatureName); |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var module in GlobalFeatureManager.Instance.Modules) |
|
|
|
{ |
|
|
|
result.ModuleEnabledFeatures.AddIfNotContains(new KeyValuePair<string, List<string>>(module.Key, module.Value.GetFeatures().Select(x => x.FeatureName).ToList())); |
|
|
|
} |
|
|
|
|
|
|
|
return Task.FromResult(result); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual async Task<TimingDto> GetTimingConfigAsync() |
|
|
|
{ |
|
|
|
var windowsTimeZoneId = await _settingProvider.GetOrNullAsync(TimingSettingNames.TimeZone); |
|
|
|
|
|
|
|
@ -773,4 +773,14 @@ var abp = abp || {}; |
|
|
|
return abp.features.values[name]; |
|
|
|
}; |
|
|
|
|
|
|
|
/* GLOBAL FEATURES *************************************************/ |
|
|
|
|
|
|
|
abp.globalFeatures = abp.globalFeatures || {}; |
|
|
|
|
|
|
|
abp.globalFeatures.enabledFeatures = abp.globalFeatures.enabledFeatures || {}; |
|
|
|
|
|
|
|
abp.globalFeatures.isEnabled = function(name){ |
|
|
|
return abp.globalFeatures.enabledFeatures.indexOf(name) != -1; |
|
|
|
} |
|
|
|
|
|
|
|
})(); |
|
|
|
|