diff --git a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js index 0a99fa372..b63f6f6f6 100644 --- a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js +++ b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js @@ -102,7 +102,7 @@ // override only once. if (opts && opts.column && opts.column instanceof Backbone.Model && - opts.column.has('orig_options')) { + opts.column.get('options_cached')) { override_opts = false; } Backgrid.Extension.NodeListByNameCell.prototype.initialize.apply( @@ -112,8 +112,7 @@ // Let's override the options if (override_opts) { var opts = self.column.get('options'); - self.column.set('options', self.omit_selected_roles); - self.column.set('orig_options', opts); + self.column.set('options', self.omit_selected_roles.bind(self, opts)); } var rerender = function (m) { @@ -135,17 +134,16 @@ this.listenTo(self.model.collection, "remove", rerender, this); }, // Remove all the selected roles (though- not mine). - omit_selected_roles: function() { - var self = this, - opts = self.column.get('orig_options'), - res = opts.apply(this), + omit_selected_roles: function(opts, cell) { + var res = opts(cell), selected = {}, - cid = self.model.cid, - curr_user = self.model.top.node_info.server.user.name; + model = cell.model, + cid = model.cid, + curr_user = model.top.node_info.server.user.name; var idx = 0; - this.model.collection.each(function(m) { + model.collection.each(function(m) { var grantee = m.get('grantee'); if (m.cid != cid && !_.isUndefined(grantee) && @@ -158,8 +156,6 @@ return !(o.value in selected); }); - this.model.collection.available_roles = {}; - return res; } }), diff --git a/web/pgadmin/browser/static/js/node.ui.js b/web/pgadmin/browser/static/js/node.ui.js index 4d69e1f01..7ee0ef8bf 100644 --- a/web/pgadmin/browser/static/js/node.ui.js +++ b/web/pgadmin/browser/static/js/node.ui.js @@ -153,8 +153,7 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) { * 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) + _.extend(select2_opts, {disabled: evalF(d.disabled, d, this.model) }); } @@ -178,9 +177,11 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) { if(!optimage){ return opt.text; } else { - return $( - '' + opt.text + '' - ); + return $('').append( + $('', {class: "wcTabIcon " + optimage}) + ).append( + $('').text(opt.text) + ); } }; @@ -383,7 +384,7 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) { // We will transform the data later, when rendering. // It will allow us to generate different data based on the // dependencies. - column.set('options', transform.bind(self, data)); + column.set('options', transform.bind(column, data)); } else { column.set('options', data); } @@ -401,7 +402,7 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) { editable = Backgrid.callByNeed(col.editable, column, model), optionValues = _.clone(this.optionValues || _.isFunction(this.column.get('options')) ? - this.column.get('options').apply(this) : + (this.column.get('options'))(this) : this.column.get('options')), select2_opts = _.defaults({}, col.select2, this.defaults.select2), evalF = function(f, col, m) { @@ -443,13 +444,12 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) { (_.indexOf(selectedValues, optionValue) > -1) })); } + // Initialize select2 control. this.$select.select2( - _.defaults( - {'disabled': !editable}, - col.select2, - this.defaults.select2 - )); + _.defaults( + {'disabled': !editable}, col.select2, this.defaults.select2 + )); /* * If select2 options do not have any disabled property on this cell @@ -460,7 +460,6 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) { disabled: evalF(col.disabled, col, this.model) }); } - this.$el.find("select").select2(select2_opts); this.delegateEvents(); @@ -474,8 +473,8 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) { defaults: _.extend({}, NodeAjaxOptionsCell.prototype.defaults, { url: 'nodes', filter: undefined, - transform: function(rows) { - var self = this, + transform: function(rows, control) { + var self = control || this, node = self.column.get('schema_node'), res = [], filter = self.column.get('filter') || function() { return true; }; @@ -518,8 +517,8 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) { defaults: _.extend({}, NodeAjaxOptionsCell.prototype.defaults, { url: 'nodes', filter: undefined, - transform: function(rows) { - var self = this, + transform: function(rows, control) { + var self = control || this, node = self.column.get('schema_node'), res = [], filter = self.column.get('filter') || function() { return true; }; diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js index b85a2cb58..8eaed6dda 100644 --- a/web/pgadmin/static/js/backform.pgadmin.js +++ b/web/pgadmin/static/js/backform.pgadmin.js @@ -339,11 +339,11 @@ // Evaluation the options if (_.isFunction(data.options)) { try { - data.options = data.options.apply(this) + data.options = data.options(this) } catch(e) { // Do nothing data.options = [] - this.model.trigger('pgadmin-view:transform:error', m, self.field, e); + this.model.trigger('pgadmin-view:transform:error', this.model, this.field, e); } } @@ -1732,12 +1732,19 @@ render: function() { Backform.SelectControl.prototype.render.apply(this, arguments); - var col = _.defaults(this.field.toJSON(), this.defaults) + var opts = this.field.toJSON(); + var select2Opts = _.defaults( + {}, opts.select2, (this.defaults && this.defaults.select2) || {} + ); + /* * Add empty option as Select2 requires any empty '')).select2(col.select2); + var $select = this.$el.find("select"); + $select.prepend($('')); + $select.select2(select2Opts); + return this; } });