diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/js/column.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/js/column.js index a2a0413..6312567 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/js/column.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/js/column.js @@ -12,6 +12,32 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) { columns: ['name', 'atttypid', 'description'] }); }; + // Deps checkbox for primary key field + var BooleanDepCell = Backgrid.BooleanCell.extend({ + initialize: function() { + Backgrid.BooleanCell.prototype.initialize.apply(this, arguments); + Backgrid.Extension.DependentCell.prototype.initialize.apply(this, arguments); + }, + dependentChanged: function () { + var model = this.model, + column = this.column, + editable = this.column.get("editable"), + input = this.$el.find('input[type=checkbox]').first(); + + is_editable = _.isFunction(editable) ? !!editable.apply(column, [model]) : !!editable; + if (is_editable) { + this.$el.addClass("editable"); + input.prop('disabled', false); + } else { + this.$el.removeClass("editable"); + input.prop('disabled', true); + } + + this.delegateEvents(); + return this; + }, + remove: Backgrid.Extension.DependentCell.prototype.remove + }); // This Node model will be used for variable control for column var VariablesModel = Backform.VariablesModel = pgBrowser.Node.Model.extend({ @@ -143,7 +169,7 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) { // Need to show this field only when creating new table // [in SubNode control] id: 'is_primary_key', label: '{{ _('Is primary key?') }}', - cell: Backgrid.Extension.SwitchDepCell, type: 'switch', deps:['name'], + cell: BooleanDepCell, type: 'switch', deps:['name'], options: { onText: 'Yes', offText: 'No', onColor: 'success', offColor: 'primary', size: 'small'},