Browse Source
Merge pull request #5895 from abpframework/liangshiwei/abp.js
Define abp.features API in abp.js
pull/5908/head
Halil İbrahim Kalkan
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
33 additions and
4 deletions
-
docs/en/UI/AspNetCore/JavaScript-API/Features.md
-
npm/packs/core/src/abp.js
|
|
|
@ -6,10 +6,24 @@ |
|
|
|
|
|
|
|
## Basic Usage |
|
|
|
|
|
|
|
`abp.features.values` can be used to access to the all feature values. |
|
|
|
|
|
|
|
````js |
|
|
|
var excelExportFeatureValue = abp.features.values["ExportingToExcel"]; |
|
|
|
//Gets a value as string. |
|
|
|
var value = abp.features.get('ExportingToExcel'); |
|
|
|
|
|
|
|
//Check the feature is enabled |
|
|
|
var enabled = abp.features.isEnabled('ExportingToExcel.Enabled'); |
|
|
|
```` |
|
|
|
|
|
|
|
Then you can check the value of the feature to perform your logic. |
|
|
|
## All Values |
|
|
|
|
|
|
|
`abp.features.values` can be used to access to the all feature values. |
|
|
|
|
|
|
|
An example value of this object is shown below: |
|
|
|
|
|
|
|
````js |
|
|
|
{ |
|
|
|
Identity.TwoFactor: "Optional", |
|
|
|
ExportingToExcel.Enabled: "true", |
|
|
|
... |
|
|
|
} |
|
|
|
```` |
|
|
|
@ -750,5 +750,20 @@ var abp = abp || {}; |
|
|
|
return toUtc(date); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
/* FEATURES *************************************************/ |
|
|
|
|
|
|
|
abp.features = abp.features || {}; |
|
|
|
|
|
|
|
abp.features.values = abp.features.values || {}; |
|
|
|
|
|
|
|
abp.features.isEnabled = function(name){ |
|
|
|
var value = abp.features.get(name); |
|
|
|
return value == 'true' || value == 'True'; |
|
|
|
} |
|
|
|
|
|
|
|
abp.features.get = function (name) { |
|
|
|
return abp.features.values[name]; |
|
|
|
}; |
|
|
|
|
|
|
|
})(); |
|
|
|
|