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 (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to