public inbox for [email protected]  
help / color / mirror / Atom feed
From: Murtuza Zabuawala <[email protected]>
To: [email protected]
Subject: Re: PATCH: Minor patch to fix issue in Integer Control [ pgAdmin4 ]
Date: Thu, 7 Jan 2016 11:02:22 +0530
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

+++ Updated patch file.

Hi,

I have added fix for server drop issue & added min & max value for 
'port' when we add db server in pgAdmin4.
I have also added flags to make sure we enter correct value in model 
when we use Integer Control.


Thanks,
Murtuza Zabuawala



On Thursday 07 January 2016 10:38 AM, Murtuza Zabuawala wrote:
> Hi,
>
> Please find minor patch to fix Backform Integer-Control.
>
> _Issue:__
> _    After validation of input value, value was not getting updated in 
> model, hence it was taking default value from schema.
>
>
> Regards,
> Murtuza Zabuawala



-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [text/x-patch] IntgerControl_Backform.patch (3.5K, 3-IntgerControl_Backform.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js b/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
index 667e1ad..bd932d6 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
+++ b/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
@@ -7,6 +7,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
       parent_type: 'server-group',
       type: 'server',
       label: '{{ _('Server') }}',
+      canDrop: true,
       Init: function() {
 
         /* Avoid multiple registration of same menus */
@@ -26,11 +27,6 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
           category: 'create', priority: 3, label: '{{ _('Server...') }}',
           data: {action: 'create'}, icon: 'wcTabIcon icon-server'
         },{
-          name: 'drop_server', node: 'server', module: this,
-          applies: ['object', 'context'], callback: 'delete_obj',
-          category: 'drop', priority: 3, label: '{{ _('Drop Server...') }}',
-          icon: 'fa fa-trash', enable: 'is_not_connected'
-        },{
           name: 'connect_server', node: 'server', module: this,
           applies: ['object', 'context'], callback: 'connect_server',
           category: 'connect', priority: 4, label: '{{ _('Connect Server...') }}',
@@ -166,7 +162,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
           mode: ['properties', 'edit', 'create'], disabled: 'isConnected'
         },{
           id: 'port', label:'{{ _('Port') }}', type: 'int', group: "Connection",
-          mode: ['properties', 'edit', 'create'], disabled: 'isConnected'
+          mode: ['properties', 'edit', 'create'], disabled: 'isConnected', min: 1024, max: 65534
         },{
           id: 'db', label:'{{ _('Maintenance Database') }}', type: 'text', group: "Connection",
           mode: ['properties', 'edit', 'create'], disabled: 'isConnected'
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 708b7fb..3ce8061 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -1034,6 +1034,9 @@
           value = this.getValueFromDOM(),
           min_value = field.min,
           max_value = field.max,
+          valid_int = false,
+          valid_min = false,
+          valid_max = false,
           intPattern = new RegExp("^-?[0-9]*$"),
           isMatched = intPattern.test(value);
 
@@ -1046,6 +1049,9 @@
               field.label
               ).value()
             );
+      } else {
+        //We have valid int hence set the falg to true
+        valid_int = true;
       }
 
       // Below will check if entered value is in-between min & max range
@@ -1058,6 +1064,9 @@
               min_value
               ).value()
             );
+      } else {
+        //We have valid value when compare to min hence set the falg to true
+        valid_min = true;
       }
 
       if (!_.isUndefined(max_value) && value > max_value) {
@@ -1069,6 +1078,16 @@
               max_value
               ).value()
             );
+      } else {
+        //We have valid value when compare to max hence set the falg to true
+        valid_max = true;
+      }
+
+      //After validation we need to set that value into model (only if all falgs are true)
+      if (valid_int && valid_min && valid_max) {
+      this.stopListening(this.model, "change:" + name, this.render);
+      this.model.set(name, value);
+      this.listenTo(this.model, "change:" + name, this.render);
       }
     }
   });


view thread (2+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: PATCH: Minor patch to fix issue in Integer Control [ pgAdmin4 ]
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox