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..d39d2d4 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 @@ -241,22 +241,6 @@ function($, _, S, pgAdmin, pgBrowser, alertify) { toJSON: Backbone.Model.prototype.toJSON }); - var formatNode = function(opt) { - if (!opt.id) { - return opt.text; - } - - var optimage = $(opt.element).data('image'); - - if(!optimage){ - return opt.text; - } else { - return $( - '' + opt.text + '' - ); - } - }; - /* NodeAjaxOptionsMultipleControl is for multiple selection of Combobox. * This control is used to select Multiple Parent Tables to be inherited. @@ -264,83 +248,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) { * To populates the column, it calls the server and fetch the columns data * for the selected table. */ - - var NodeAjaxOptionsMultipleControl = Backform.NodeAjaxOptionsMultipleControl = Backform.NodeAjaxOptionsControl.extend({ - template: _.template([ - '', - '
', - ' ', - '
'].join("\n")), - defaults: _.extend( - {}, Backform.NodeAjaxOptionsControl.prototype.defaults, - { - select2: { - allowClear: true, - placeholder: 'Select from the list', - width: 'style', - templateResult: formatNode, - templateSelection: formatNode - } - }), - render: function() { - var field = _.defaults(this.field.toJSON(), this.defaults), - attributes = this.model.toJSON(), - attrArr = field.name.split('.'), - name = attrArr.shift(), - path = attrArr.join('.'), - rawValue = this.keyPathAccessor(attributes[name], path), - data = _.extend(field, { - rawValue: rawValue, - value: this.formatter.fromRaw(rawValue, this.model), - attributes: attributes, - formatter: this.formatter - }), - evalF = function(f, d, m) { - return (_.isFunction(f) ? !!f.apply(d, [m]) : !!f); - }; - - // Evaluate the disabled, visible, and required option - _.extend(data, { - disabled: evalF(data.disabled, data, this.model), - visible: evalF(data.visible, data, this.model), - required: evalF(data.required, data, this.model) - }); - - if (field.node_info.server.version < field.min_version) { - field.version_compatible = false - return this; - } - else { - // Evaluation the options - if (_.isFunction(data.options)) { - try { - data.options = data.options.apply(this) - } catch(e) { - // Do nothing - data.options = [] - this.model.trigger('pgadmin-view:transform:error', self.model, self.field, e); - } - } - - // Clean up first - this.$el.removeClass(Backform.hiddenClassname); - this.$el.html(this.template(data)).addClass(field.name); - - if (!data.visible) { - this.$el.addClass(Backform.hiddenClassname); - } else { - var opts = _.extend( - {}, this.defaults.select2, data.select2, - { - 'data': data.options - }); - this.$el.find("select").select2(opts).val(data.rawValue).trigger("change"); - this.updateInvalid(); - } - } - return this; - }, + var NodeAjaxOptionsMultipleControl = Backform.NodeAjaxOptionsControl.extend({ onChange: function(e) { var model = this.model, $el = $(e.target), @@ -370,7 +278,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); } @@ -632,7 +540,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) { type: 'text', group: 'Definition', url: 'get_foreign_servers', disabled: function(m) { return !m.isNew(); } },{ id: 'inherits', label:'{{ _('Inherits') }}', group: 'Definition', - type: 'array', min_version: 90500, control: 'node-ajax-options-multiple', + type: 'array', min_version: 90500, control: NodeAjaxOptionsMultipleControl, url: 'get_tables', select2: {multiple: true}, 'cache_level': 'database', transform: function(d, self){ 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 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([ '
', '