public inbox for [email protected]  
help / color / mirror / Atom feed
From: Harshal Dhumal <[email protected]>
To: [email protected]
Subject: variable.js number formatting and sesschanged atrrib fix [pgadmin4]
Date: Wed, 13 Jan 2016 12:45:35 +0530
Message-ID: <CAFiP3vwMiSq8ZW-QK-Q61zkSAQd7e9kqJjWjNAK9ACg1mZBVFA@mail.gmail.com> (raw)
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

Hi,

Please find attached patch for number formating issue in variable.js and
session changed duplicate values issue.


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com;


-- 
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] variable_js_number_formatting_and_sesschanged_atrrib_fix_13_Jan.patch (2.6K, 3-variable_js_number_formatting_and_sesschanged_atrrib_fix_13_Jan.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/variable.js b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
index 660b65d..5c49955 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/variable.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
@@ -151,7 +151,7 @@
 
           var formatter = self.formatter;
 
-          formatter.decimals = self.decimals;
+          formatter.decimals = 0;
           formatter.decimalSeparator = self.decimalSeparator;
           formatter.orderSeparator = self.orderSeparator;
 
@@ -297,7 +297,6 @@
       self.listenTo(self.headerData, "select2", self.headerDataChanged);
       self.listenTo(self.collection, "remove", self.onRemoveVariable);
     },
-
     /*
      * Get the variable data for this node.
      */
@@ -455,6 +454,30 @@
           });
       }
 
+      // Change format of each of the data
+      // Because - data coming from the server is in string format
+      self.collection.each(function(model){
+        var name = model.get("name");
+
+        if (name in self.availVariables) {
+          switch(self.availVariables[name].vartype) {
+            case 'real':
+              var v = parseFloat(model.get('value'));
+              model.set('value', (isNaN(v) ? undefined : v), {silent: true});
+
+              break;
+            case 'integer':
+              var v = parseInt(model.get('value'));
+              model.set('value', (isNaN(v) ? undefined : v), {silent: true});
+
+              break;
+            default:
+              break;
+          }
+        }
+      });
+      self.collection.startNewSession();
+
       // Initialize a new Grid instance
       var grid = self.grid = new Backgrid.Grid({
         columns: gridSchema.columns,
diff --git a/web/pgadmin/browser/templates/browser/js/node.js b/web/pgadmin/browser/templates/browser/js/node.js
index fe999bb..622e9e1 100644
--- a/web/pgadmin/browser/templates/browser/js/node.js
+++ b/web/pgadmin/browser/templates/browser/js/node.js
@@ -1289,7 +1289,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
         }
         idx = _.indexOf(self.sessAttrs['changed'], obj);
         if (!'sessChanged' in obj) {
-          if (idx > 0) {
+          if (idx >= 0) {
             return true;
           }
           self.sessAttrs['changed'].push(obj);
@@ -1301,7 +1301,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
 
           return true;
         }
-        if (idx > 0) {
+        if (idx >= 0) {
 
           (self || self.handler).trigger(
               'pgadmin-session:changed',


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: variable.js number formatting and sesschanged atrrib fix [pgadmin4]
  In-Reply-To: <CAFiP3vwMiSq8ZW-QK-Q61zkSAQd7e9kqJjWjNAK9ACg1mZBVFA@mail.gmail.com>

* 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