Hi,

Please find attached patch for RM2421

Issue fixed: 1. Integer/numeric Validation is not working properly.
2. Wrong CPU rate unit
-- 
*Harshal Dhumal*
*Sr. Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/js/resource_groups.js b/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/js/resource_groups.js
index 3cc822e..596a4ee 100644
--- a/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/js/resource_groups.js
+++ b/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/js/resource_groups.js
@@ -72,7 +72,7 @@ define(
           id: 'name', label: '{{ _('Name') }}', cell: 'string',
           type: 'text',
         },{
-          id: 'cpu_rate_limit', label:'{{ _('CPU rate limit (%%)') }}', cell: 'string',
+          id: 'cpu_rate_limit', label:'{{ _('CPU rate limit (%)') }}', cell: 'string',
           type: 'numeric', min:0, max:16777216
         },{
           id: 'dirty_rate_limit', label:'{{ _('Dirty rate limit (KB)') }}', cell: 'string',
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 553676e..a822da8 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -1528,7 +1528,18 @@
           max_value = field.max,
           isValid = true,
           intPattern = new RegExp("^-?[0-9]*$"),
-          isMatched = intPattern.test(value);
+          isMatched = intPattern.test(value),
+          trigger_invalid_event = function(msg) {
+            if (this.model.collection || this.model.handler) {
+              (this.model.collection || this.model.handler).trigger(
+                 'pgadmin-session:model:invalid', msg, this.model
+                );
+            } else {
+              (this.model).trigger(
+                 'pgadmin-session:invalid', msg, this.model
+                );
+            }
+          }.bind(this);
 
       // Below logic will validate input
       if (!isMatched) {
@@ -1573,25 +1584,23 @@
         this.model.errorModel.unset(name);
         this.model.set(name, value);
         this.listenTo(this.model, "change:" + name, this.render);
-        if (this.model.collection || this.model.handler) {
-          (this.model.collection || this.model.handler).trigger(
-             'pgadmin-session:model:valid', this.model, (this.model.collection || this.model.handler)
-            );
+        // Check if other fields of same model are valid before
+        // triggering 'session:valid' event
+        if(_.size(this.model.errorModel.attributes) == 0) {
+          if (this.model.collection || this.model.handler) {
+            (this.model.collection || this.model.handler).trigger(
+               'pgadmin-session:model:valid', this.model, (this.model.collection || this.model.handler)
+              );
+          } else {
+            (this.model).trigger(
+               'pgadmin-session:valid', this.model.sessChanged(), this.model
+              );
+          }
         } else {
-          (this.model).trigger(
-             'pgadmin-session:valid', this.model.sessChanged(), this.model
-            );
+          trigger_invalid_event(_.values(this.model.errorModel.attributes)[0]);
         }
       } else {
-        if (this.model.collection || this.model.handler) {
-          (this.model.collection || this.model.handler).trigger(
-             'pgadmin-session:model:invalid', this.model.errorModel.get(name), this.model
-            );
-        } else {
-          (this.model).trigger(
-             'pgadmin-session:invalid', this.model.errorModel.get(name), this.model
-            );
-        }
+        trigger_invalid_event(this.model.errorModel.get(name));
       }
     }
   });
@@ -1631,7 +1640,18 @@
           max_value = field.max,
           isValid = true,
           intPattern = new RegExp("^-?[0-9]+(\.?[0-9]*)?$"),
-          isMatched = intPattern.test(value);
+          isMatched = intPattern.test(value),
+          trigger_invalid_event = function(msg) {
+            if (this.model.collection || this.model.handler) {
+              (this.model.collection || this.model.handler).trigger(
+                 'pgadmin-session:model:invalid', msg, this.model
+                );
+            } else {
+              (this.model).trigger(
+                 'pgadmin-session:invalid', msg, this.model
+                );
+            }
+          }.bind(this);
 
       // Below logic will validate input
       if (!isMatched) {
@@ -1676,25 +1696,23 @@
         this.model.errorModel.unset(name);
         this.model.set(name, value);
         this.listenTo(this.model, "change:" + name, this.render);
-        if (this.model.collection || this.model.handler) {
-          (this.model.collection || this.model.handler).trigger(
-             'pgadmin-session:model:valid', this.model, (this.model.collection || this.model.handler)
-            );
+        // Check if other fields of same model are valid before
+        // triggering 'session:valid' event
+        if(_.size(this.model.errorModel.attributes) == 0) {
+          if (this.model.collection || this.model.handler) {
+            (this.model.collection || this.model.handler).trigger(
+               'pgadmin-session:model:valid', this.model, (this.model.collection || this.model.handler)
+              );
+          } else {
+            (this.model).trigger(
+               'pgadmin-session:valid', this.model.sessChanged(), this.model
+              );
+          }
         } else {
-          (this.model).trigger(
-             'pgadmin-session:valid', this.model.sessChanged(), this.model
-            );
+          trigger_invalid_event(_.values(this.model.errorModel.attributes)[0]);
         }
       } else {
-        if (this.model.collection || this.model.handler) {
-          (this.model.collection || this.model.handler).trigger(
-             'pgadmin-session:model:invalid', this.model.errorModel.get(name), this.model
-            );
-        } else {
-          (this.model).trigger(
-             'pgadmin-session:invalid', this.model.errorModel.get(name), this.model
-            );
-        }
+        trigger_invalid_event(this.model.errorModel.get(name));
       }
     }
   });
-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to