From 27040a22a7d463442c98bce5954aafc5241e14d8 Mon Sep 17 00:00:00 2001 From: Ashesh Vashi Date: Tue, 12 Jan 2016 12:06:50 +0530 Subject: [PATCH] Make the select2 control disabled (when required). --- web/pgadmin/browser/static/js/node.ui.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/web/pgadmin/browser/static/js/node.ui.js b/web/pgadmin/browser/static/js/node.ui.js index 0e89acd59..7b43a5296 100644 --- a/web/pgadmin/browser/static/js/node.ui.js +++ b/web/pgadmin/browser/static/js/node.ui.js @@ -140,7 +140,20 @@ 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 '