Subject: PATCH: Select2 control fix [ pgAdmin4 ]

From: Murtuza Zabuawala <[email-masked]>
Date: Mon, 11 Jan 2016 17:48:01 +0530

Hi,

Please find minor patch to fix issue in select2 control.

Issue: We were not able to apply 'disabled' property from schema model 
on select2 control.

Regards,
Murtuza
diff --git a/web/pgadmin/browser/static/js/node.ui.js b/web/pgadmin/browser/static/js/node.ui.js
index 76839c6..b5fa3e2 100644
--- a/web/pgadmin/browser/static/js/node.ui.js
+++ b/web/pgadmin/browser/static/js/node.ui.js
@@ -139,7 +139,21 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) {
       Backform.SelectControl.prototype.render.apply(this, arguments);
 
       var d = this.field.toJSON(),
-          select2_opts = _.defaults({}, d.select2, this.defaults.select2);
+          select2_opts = _.defaults({}, d.select2, this.defaults.select2),
+          evalF = function(f, d, m) {
+            return (_.isFunction(f) ? !!f.apply(d, [m]) : !!f);
+          };
+
+      /*
+       * If select2 options do not have any disabled property on this field
+       * and schema has disabled property then we need to apply it
+       */
+
+      if(!_.has(select2_opts, 'disabled') && (d && d.disabled)) {
+        _.extend(select2_opts, {
+          disabled: evalF(d.disabled, d, this.model)
+        });
+      }
 
       /*
        * Add empty option as Select2 requires any empty '<option><option>' for

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

---

From: Ashesh Vashi <[email-masked]>
Date: Mon, 11 Jan 2016 21:36:29 +0530

Hi Murtuza,

I am not able to apply the patch.
Can you please rebase the patch?

(Also -  please set the proper line endings in your git repository.)

--

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 Mon, Jan 11, 2016 at 5:48 PM, Murtuza Zabuawala <
[email-masked]> wrote:

> Issue: We were not able to apply 'disabled' property from schema model on
> select2 control.
>
>
> Regards,
> Murtuza
>
>
> --

---

From: Murtuza Zabuawala <[email-masked]>
Date: Tue, 12 Jan 2016 10:33:38 +0530

Hi Ashesh,

I am not sure what's wrong here as I'm able to apply the given patch 
with latest pull.

murtuza@debian ~/PROJECT/pgadmin4 $ git pull
Already up-to-date.
murtuza@debian ~/PROJECT/pgadmin4 $ patch -p1 < 
Fix_select2_disabled_property.patch
patching file web/pgadmin/browser/static/js/node.ui.js
murtuza@debian ~/PROJECT/pgadmin4 $ git diff
diff --git a/web/pgadmin/browser/static/js/node.ui.js 
b/web/pgadmin/browser/static/js/node.ui.js
index 76839c6..b5fa3e2 100644

And here are my git settings,

murtuza@debian ~/PROJECT/pgadmin4 $ git config -l
core.editor=vim
core.autocrlf=input
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=http://git.postgresql.org/git/pgadmin4.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

Regards,
Murtuza

On Monday 11 January 2016 09:36 PM, Ashesh Vashi wrote:
> /http://www.linkedin.com/in/asheshvashi/
>
>
> On Mon, Jan 11, 2016 at 5:48 PM, Murtuza Zabuawala 
> <[email-masked] 
> <mailto:[email-masked]>> wrote:
>
>     Hi,
>
>     Issue: We were not able to apply 'disabled' property from schema
>     model on select2 control.
>
>
>     Regards,
>     Murtuza
>
>
>     --
>     Sent via pgadmin-hackers mailing list
>     ([email-masked]
>     <mailto:[email-masked]>)

 
       /*

---

From: Murtuza Zabuawala <[email-masked]>
Date: Tue, 12 Jan 2016 10:56:49 +0530

Hi Ashesh,

Can you please try applying given updated patch, I have manually 
converted file line ending to Unix format.

Regards,
Murtuza

On Tuesday 12 January 2016 10:33 AM, Murtuza Zabuawala wrote:
>> <[email-masked]> wrote:
>>
>>     Hi,
>>
>>     ([email-masked])

 
       /*

---

From: Ashesh Vashi <[email-masked]>
Date: Tue, 12 Jan 2016 14:30:56 +0530

Hi Murtuza,

I have applied the patch manually, and committed.

--

Thanks & Regards,

Ashesh Vashi

On Tue, Jan 12, 2016 at 10:56 AM, Murtuza Zabuawala <
[email-masked]> wrote:

> Hi Ashesh,
>
> Can you please try applying given updated patch, I have manually converted
> file line ending to Unix format.
>
>
> Regards,
> Murtuza
>
>
> I am not sure what's wrong here as I'm able to apply the given patch with
> latest pull.
>
> <[email-masked]>[email-masked]>
> wrote:
>
>> Hi,
>>
>> Sent via pgadmin-hackers mailing list ( <[email-masked]>
>> [email-masked])