public inbox for [email protected]  
help / color / mirror / Atom feed
From: Harshal Dhumal <[email protected]>
To: Ashesh Vashi <[email protected]>
Cc: Dave Page <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: patch for issue RM1260 [pgAdmin4]
Date: Wed, 27 Jul 2016 15:54:14 +0530
Message-ID: <CAFiP3vxfUTNYr=t8Z8j=jjVB0tzOcoCxgG-9B4e_XHvoZfu68Q@mail.gmail.com> (raw)
In-Reply-To: <CAFiP3vx1vasV3LO1k8x8-YGToDuMhrmj+hs-SLqHGCsgotcY4Q@mail.gmail.com>
References: <CAFiP3vzHR2j6y-8FP5fQFpJD3XNbyOVb=rbRzBwtKzPnv4nJhQ@mail.gmail.com>
	<CAFiP3vw7wCLMnj1NyoSh8pUVedYxLX_su9xM9zO5iRo+wgZr3w@mail.gmail.com>
	<CAFiP3vwQesWW+HXfTi+MgTbYEi1zBQC+fdNZNe32wzr5RfrHHw@mail.gmail.com>
	<CAG7mmoxAcFK3K-Oj-0nMcFkuq_dVQA0OeVa4cSCqU7tVX3pHjw@mail.gmail.com>
	<CAFiP3vyCapVsJf0dmJeFxjUwC6muh3pmZ+QaVp7eywzU2jg2uQ@mail.gmail.com>
	<CA+OCxoweOqqW45t48D9XZDcQVU80rBmHt0x4ZYbXsqao4h4eOg@mail.gmail.com>
	<CAG7mmozviFw1eEJz04icjDSbpQwz98PjvcsSxHYV+UeLutawiA@mail.gmail.com>
	<CAFiP3vx1vasV3LO1k8x8-YGToDuMhrmj+hs-SLqHGCsgotcY4Q@mail.gmail.com>
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

and patch file

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Wed, Jul 27, 2016 at 3:49 PM, Harshal Dhumal <
[email protected]> wrote:

> Hi,
>
> PFA updated patch for RM1260.
>
> In addition to RM1260 issue I have added following changes in this patch.
> 1] datamodel.js: Added option check against undefined.
> 2] foreign key: fixed first empty option issue.
>
> --
> *Harshal Dhumal*
> *Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Thu, Jul 7, 2016 at 5:08 PM, Ashesh Vashi <
> [email protected]> wrote:
>
>> Sure - I will do.
>>
>> --
>>
>> Thanks & Regards,
>>
>> Ashesh Vashi
>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>> <http://www.enterprisedb.com;
>>
>>
>> *http://www.linkedin.com/in/asheshvashi*
>> <http://www.linkedin.com/in/asheshvashi;
>>
>> On Thu, Jul 7, 2016 at 2:33 PM, Dave Page <[email protected]> wrote:
>>
>>> Ashesh, can you review/commit please?
>>>
>>> Thanks.
>>>
>>> On Thu, Jul 7, 2016 at 7:50 AM, Harshal Dhumal <
>>> [email protected]> wrote:
>>>
>>>> Hi,
>>>>
>>>> By mistake I deleted a line which was not supposed to be deleted, and
>>>> that line of code was initialization of select2.
>>>>
>>>> --
>>>> *Harshal Dhumal*
>>>> *Software Engineer*
>>>>
>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>> On Thu, Jul 7, 2016 at 12:13 PM, Ashesh Vashi <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi Harshal,
>>>>>
>>>>> Can you please explain - what was missing in the last patch?
>>>>>
>>>>> --
>>>>>
>>>>> Thanks & Regards,
>>>>>
>>>>> Ashesh Vashi
>>>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>>>> <http://www.enterprisedb.com;
>>>>>
>>>>>
>>>>> *http://www.linkedin.com/in/asheshvashi*
>>>>> <http://www.linkedin.com/in/asheshvashi;
>>>>>
>>>>> On Thu, Jul 7, 2016 at 12:12 PM, Harshal Dhumal <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> PFA updated patch for issue RM1260
>>>>>>
>>>>>> --
>>>>>> *Harshal Dhumal*
>>>>>> *Software Engineer*
>>>>>>
>>>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>>>> The Enterprise PostgreSQL Company
>>>>>>
>>>>>> On Thu, Jul 7, 2016 at 12:04 PM, Harshal Dhumal <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>> Please ignore this patch as this has some minor issue. I'll sent
>>>>>>> updated one.
>>>>>>>
>>>>>>> --
>>>>>>> *Harshal Dhumal*
>>>>>>> *Software Engineer*
>>>>>>>
>>>>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>>>>> The Enterprise PostgreSQL Company
>>>>>>>
>>>>>>> On Wed, Jul 6, 2016 at 5:30 PM, Harshal Dhumal <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> PFA patch for issue RM1260.
>>>>>>>>
>>>>>>>> Changes: Issue wasn't related to foreign table but was due the
>>>>>>>> Select2 control. Now I have improved select2 control to handle null value
>>>>>>>> in multi-select mode. Initial it was returning "null" instead it should
>>>>>>>> return [] (empty array).
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> *Harshal Dhumal*
>>>>>>>> *Software Engineer*
>>>>>>>>
>>>>>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>>>>>> The Enterprise PostgreSQL Company
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Sent via pgadmin-hackers mailing list ([email protected]
>>>>>> )
>>>>>> To make changes to your subscription:
>>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> Dave Page
>>> Blog: http://pgsnake.blogspot.com
>>> Twitter: @pgsnake
>>>
>>> EnterpriseDB UK: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>
>>
>


-- 
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] RM1260_V3.patch (7.1K, 3-RM1260_V3.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/js/foreign_tables.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/js/foreign_tables.js
index a4b5a27..3af6c61 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/js/foreign_tables.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/js/foreign_tables.js
@@ -266,12 +266,6 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
   */
 
   var NodeAjaxOptionsMultipleControl = Backform.NodeAjaxOptionsMultipleControl = Backform.NodeAjaxOptionsControl.extend({
-    template: _.template([
-      '<label class="<%=Backform.controlLabelClassName%>"><%=label%></label>',
-      '<div class="<%=Backform.controlsClassName%> <%=extraClasses.join(\' \')%>">',
-      '  <select class="pgadmin-node-select form-control" name="<%=name%>" style="width:100%;" value=<%-value%> <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> >',
-      '  </select>',
-      '</div>'].join("\n")),
     defaults: _.extend(
       {}, Backform.NodeAjaxOptionsControl.prototype.defaults,
       {
@@ -335,7 +329,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
           {
             'data': data.options
           });
-        this.$el.find("select").select2(opts).val(data.rawValue).trigger("change");
+        this.$el.find("select").select2(opts);
         this.updateInvalid();
         }
       }
@@ -370,7 +364,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
 
       // Remove Columns if inherit option is deselected from the combobox
       if(_.size(value) < _.size(inherits)) {
-        var dif =  _.difference(inherits, JSON.parse(value));
+        var dif =  _.difference(inherits, value);
         var rmv_columns = columns.where({inheritedid: parseInt(dif[0])});
         columns.remove(rmv_columns);
       }
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_tables.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_tables.sql
index 83445a2..1bb501e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_tables.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_tables.sql
@@ -9,7 +9,7 @@ WHERE
 
 {% else %}
 SELECT
-    c.oid AS id, quote_ident(n.nspname) || '.' || quote_ident(c.relname) as text
+    c.oid AS value, quote_ident(n.nspname) || '.' || quote_ident(c.relname) as label
 FROM
     pg_class c, pg_namespace n
 WHERE
@@ -19,4 +19,4 @@ WHERE
 {% endif %}
 ORDER BY
     n.nspname, c.relname;
-{% endif %}
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js
index 3ffa6ef..d7c947f 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js
@@ -21,6 +21,7 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
       headerSelectControlTemplate =  _.template([
                               '<div class="<%=Backform.controlsClassName%> <%=extraClasses.join(\' \')%>">',
                               '  <select class="pgadmin-node-select form-control" name="<%=name%>" style="width:100%;" value="<%-value%>" <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> >',
+                              '    <%=select2.first_empty ? " <option></option>" : ""%>',
                               '    <% for (var i=0; i < options.length; i++) { %>',
                               '    <% var option = options[i]; %>',
                               '    <option <% if (option.image) { %> data-image=<%= option.image %> <% } %> value=<%= formatter.fromRaw(option.value) %> <%=option.value === rawValue ? "selected=\'selected\'" : "" %>><%-option.label%></option>',
@@ -134,8 +135,9 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
           }),
           select2: {
             allowClear: false, width: 'style',
-            placeholder: 'Select column'
-          }, first_empty: !_.isUndefined(self.model.get('oid')),
+            placeholder: '{{ _('Select column') }}',
+            first_empty: !_.isUndefined(self.model.get('oid'))
+          },
           version_compatible: self.field.get('version_compatible'),
           disabled: function(m) {
             return !_.isUndefined(self.model.get('oid'));
@@ -234,10 +236,11 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
               Backform.Select2Control.prototype.render.apply(this, arguments);
               return this;
             }
-          }), url: 'get_columns', first_empty: true,
+          }), url: 'get_columns',
           select2: {
+            allowClear: false,
             width: "style",
-            placeholder: 'Select column',
+            placeholder: '{{ _('Select column') }}',
             templateResult: formatNode,
             templateSelection: formatNode
           },
diff --git a/web/pgadmin/browser/static/js/datamodel.js b/web/pgadmin/browser/static/js/datamodel.js
index 8cb7034..7b379ce 100644
--- a/web/pgadmin/browser/static/js/datamodel.js
+++ b/web/pgadmin/browser/static/js/datamodel.js
@@ -124,7 +124,7 @@ function(_, pgAdmin, $, Backbone) {
         var self = this;
         self._previous_key_values = {};
 
-        if ('on_server' in options && options.on_server) {
+        if (!_.isUndefined(options) && 'on_server' in options && options.on_server) {
           self.on_server = true;
         }
 
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 2530db9..e27ea2d 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -1804,7 +1804,11 @@
       if (_.isArray(formattedData)) {
         return _.map(formattedData, decodeURIComponent);
       } else {
-        return decodeURIComponent(formattedData);
+        if(!_.isNull(formattedData) && !_.isUndefined(formattedData)) {
+          return decodeURIComponent(formattedData);
+        } else {
+          return null;
+        }
       }
     }
   });
@@ -1915,9 +1919,15 @@
       return this;
     },
     getValueFromDOM: function() {
-      return Backform.SelectControl.prototype.getValueFromDOM.apply(
-        this, arguments
-      );
+      var val = Backform.SelectControl.prototype.getValueFromDOM.apply(
+                  this, arguments
+                ),
+        select2Opts = _.extend({}, this.field.get("select2") || this.defaults.select2);
+
+      if (select2Opts.multiple && val == null) {
+        return [];
+      }
+      return val;
     }
   });
 


view thread (13+ messages)  latest in thread

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], [email protected], [email protected]
  Subject: Re: patch for issue RM1260 [pgAdmin4]
  In-Reply-To: <CAFiP3vxfUTNYr=t8Z8j=jjVB0tzOcoCxgG-9B4e_XHvoZfu68Q@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