[pve-devel] [PATCH manager 3/4] optimize resourcestore field collection
Dominik Csapak
d.csapak at proxmox.com
Wed May 3 17:04:28 CEST 2017
instead of doing weird if/elsif checks with nonsensical logic
we simply check the 3 properties we want (namely convert,calculate and
defaultValue) and add them to our field definition.
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
www/manager6/data/ResourceStore.js | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/www/manager6/data/ResourceStore.js b/www/manager6/data/ResourceStore.js
index 93caa6c8..fc40d861 100644
--- a/www/manager6/data/ResourceStore.js
+++ b/www/manager6/data/ResourceStore.js
@@ -247,20 +247,21 @@ Ext.define('PVE.data.ResourceStore', {
var fields = [];
var fieldNames = [];
Ext.Object.each(field_defaults, function(key, value) {
- if (!Ext.isDefined(value.convert) && !Ext.isDefined(value.calculate)) {
- var field = {name: key, type: value.type};
- if (Ext.isDefined(value.defaultValue)) {
- field.defaultValue = value.defaultValue;
- }
- fields.push(field);
- fieldNames.push(key);
- } else if (key === 'text' || key === 'running') {
- fields.push({name: key, type: value.type, convert: value.convert});
- fieldNames.push(key);
- } else {
- value.name = key;
- fields.push(value);
+ var field = {name: key, type: value.type};
+ if (Ext.isDefined(value.convert)) {
+ field.convert = value.convert;
+ }
+
+ if (Ext.isDefined(value.calculate)) {
+ field.calculate = value.calculate;
}
+
+ if (Ext.isDefined(value.defaultValue)) {
+ field.defaultValue = value.defaultValue;
+ }
+
+ fields.push(field);
+ fieldNames.push(key);
});
Ext.define('PVEResources', {
--
2.11.0
More information about the pve-devel
mailing list