Browse Source

Add `abp.globalFeatures.isEnabled` to `abp.js`

pull/12553/head
maliming 4 years ago
parent
commit
cecc2c1baa
No known key found for this signature in database GPG Key ID: 96224957E51C89E
  1. 11
      docs/en/UI/AspNetCore/JavaScript-API/GlobalFeatures.md
  2. 3
      framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationGlobalFeatureConfigurationDto.cs
  3. 6
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs
  4. 10
      npm/packs/core/src/abp.js

11
docs/en/UI/AspNetCore/JavaScript-API/GlobalFeatures.md

@ -7,15 +7,18 @@
## Usage ## Usage
````js ````js
//Gets all enabled global features.
> abp.globalFeatures.enabledFeatures > abp.globalFeatures.enabledFeatures
[ 'Shopping.Payment', 'Ecommerce.Subscription' ] [ '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
```` ````

3
framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationGlobalFeatureConfigurationDto.cs

@ -8,11 +8,8 @@ public class ApplicationGlobalFeatureConfigurationDto
{ {
public HashSet<string> EnabledFeatures { get; set; } public HashSet<string> EnabledFeatures { get; set; }
public Dictionary<string, List<string>> ModuleEnabledFeatures { get; set; }
public ApplicationGlobalFeatureConfigurationDto() public ApplicationGlobalFeatureConfigurationDto()
{ {
EnabledFeatures = new HashSet<string>(); EnabledFeatures = new HashSet<string>();
ModuleEnabledFeatures = new Dictionary<string, List<string>>();
} }
} }

6
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs

@ -295,15 +295,9 @@ public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApp
result.EnabledFeatures.AddIfNotContains(enabledFeatureName); 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); return Task.FromResult(result);
} }
protected virtual async Task<TimingDto> GetTimingConfigAsync() protected virtual async Task<TimingDto> GetTimingConfigAsync()
{ {
var windowsTimeZoneId = await _settingProvider.GetOrNullAsync(TimingSettingNames.TimeZone); var windowsTimeZoneId = await _settingProvider.GetOrNullAsync(TimingSettingNames.TimeZone);

10
npm/packs/core/src/abp.js

@ -773,4 +773,14 @@ var abp = abp || {};
return abp.features.values[name]; 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;
}
})(); })();

Loading…
Cancel
Save