[pve-devel] applied: [PATCH manager 1/2] remove unnecessary trigraph

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Oct 31 17:00:59 CET 2016


On 10/31/2016 04:38 PM, Dietmar Maurer wrote:
> applied, but I would like to have some clenups - see below:
>
>>   	if (values.group === '') {
>>   	    if (!me.create) {
>> -		values['delete'] = values['delete'] ? ',group' : 'group';
>> +		values['delete'] = 'group';
>>   	    }
>>   	    delete values.group;
>>   	}
> Seems we have code to create "values['delete']" at several places. Maybe
> it is possible to write/use a small wrapper?

Yes that should be possible, something like:

---
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 463a546..552fdcb 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1253,6 +1253,20 @@ Ext.define('PVE.Utils', { utilities: {
         menu.showAt(event.getXY());
      }},

+    delete_if_default: function(values, fieldname, default_val, create) {
+       if (values[fieldname] === default_val) {
+           if (!create) {
+               if (values['delete']) {
+                   values['delete'] += ',' + fieldname;
+               } else {
+                   values['delete'] = fieldname;
+               }
+           }
+
+           delete values.group;
+       }
+    },
+
      singleton: true,
      constructor: function() {
         var me = this;

--

works for me. If ok I can add it and replace all the values['delete'] 
code parts with this.






More information about the pve-devel mailing list