diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.ui.js index e1d64ac1a..aaf53dbf4 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.ui.js @@ -22,7 +22,7 @@ export default class CheckConstraintSchema extends BaseUISchema { if(_.isUndefined(this.nodeInfo)) { return true; } - return _.isUndefined(this.nodeInfo['table']); + return _.isUndefined(this.nodeInfo['check_constraint']); } isReadonly(state) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.ui.js index 5f64e58cd..e405c0ac9 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.ui.js @@ -213,7 +213,7 @@ export default class ExclusionConstraintSchema extends BaseUISchema { if(_.isUndefined(this.nodeInfo)) { return true; } - return _.isUndefined(this.nodeInfo['table']); + return _.isUndefined(this.nodeInfo['exclusion_constraint']); } initialise(data) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.ui.js index 5c10d077d..979b70706 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.ui.js @@ -149,7 +149,7 @@ export default class ForeignKeySchema extends BaseUISchema { if(_.isUndefined(nodeInfo)) { return true; } - return _.isUndefined(nodeInfo['table']); + return _.isUndefined(nodeInfo['foreign_key']); } changeColumnOptions(columns) { @@ -222,12 +222,14 @@ export default class ForeignKeySchema extends BaseUISchema { id: 'convalidated', label: gettext('Validated?'), type: 'switch', group: gettext('Definition'), readonly: (state)=>{ - // If we are in table edit mode then - if(obj.inTable && obj.top && !obj.top.isNew()) { - return !(_.isUndefined(state.oid) || !state.convalidated); - } - if(!obj.isNew(state) && obj.origData.convalidated) { - return true; + if(!obj.isNew(state)) { + let origData = {}; + if(obj.inTable && obj.top) { + origData = _.find(obj.top.origData['foreign_key'], (r)=>r.cid == state.cid); + } else { + origData = obj.origData; + } + return origData.convalidated; } return false; }, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.ui.js index 8eb67b2cb..52e2ca5a4 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.ui.js @@ -31,7 +31,7 @@ export default class PrimaryKeySchema extends BaseUISchema { if(_.isUndefined(this.nodeInfo)) { return true; } - return _.isUndefined(this.nodeInfo['table']); + return _.isUndefined(this.nodeInfo['primary_key']); } changeColumnOptions(columns) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.ui.js index 7b91a0b5e..0bdc30719 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.ui.js @@ -32,7 +32,7 @@ export default class UniqueConstraintSchema extends BaseUISchema { if(_.isUndefined(this.nodeInfo)) { return true; } - return _.isUndefined(this.nodeInfo['table']); + return _.isUndefined(this.nodeInfo['unique_constraint']); } changeColumnOptions(columns) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js index 68d1eed93..3344be5d8 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js @@ -650,7 +650,12 @@ export default class TableSchema extends BaseUISchema { obj.changeColumnOptions(finalCols); return { columns: finalCols, - primary_key: [] + primary_key: [], + foreign_key: [], + exclude_constraint: [], + unique_constraint: [], + partition_keys: [], + partitions: [], }; }); }; diff --git a/web/regression/javascript/schema_ui_files/foreign_key.ui.spec.js b/web/regression/javascript/schema_ui_files/foreign_key.ui.spec.js index 7f0928b2b..0bd8c0f94 100644 --- a/web/regression/javascript/schema_ui_files/foreign_key.ui.spec.js +++ b/web/regression/javascript/schema_ui_files/foreign_key.ui.spec.js @@ -171,7 +171,7 @@ describe('ForeignKeySchema', ()=>{ let state = {columns: [{local_column: 'id'}]}; let actionObj = {oldState:{name: 'fkname'}}; - schemaObj.nodeInfo = {table: {}}; + schemaObj.nodeInfo = {foreign_key: {}}; state.autoindex = true; state.name = 'fkname'; expect(getFieldDepChange(schemaObj, 'autoindex')(state, null, null, actionObj)).toEqual({ @@ -197,7 +197,7 @@ describe('ForeignKeySchema', ()=>{ expect(getFieldDepChange(schemaObj, 'autoindex')(state, null, null, actionObj)).toEqual({}); state.oid = null; - schemaObj.nodeInfo = {}; + schemaObj.nodeInfo = {table: {}}; schemaObj.top = schemaObj; expect(getFieldDepChange(schemaObj, 'autoindex')(state, null, null, actionObj)).toEqual({ autoindex: false, diff --git a/web/regression/javascript/schema_ui_files/table.ui.spec.js b/web/regression/javascript/schema_ui_files/table.ui.spec.js index c686e8d86..0ddf9accd 100644 --- a/web/regression/javascript/schema_ui_files/table.ui.spec.js +++ b/web/regression/javascript/schema_ui_files/table.ui.spec.js @@ -172,6 +172,11 @@ describe('TableSchema', ()=>{ expect(depChange()).toEqual({ columns: oftypeColumns, primary_key: [], + foreign_key: [], + exclude_constraint: [], + unique_constraint: [], + partition_keys: [], + partitions: [], }); expect(schemaObj.changeColumnOptions).toHaveBeenCalledWith(oftypeColumns); done(); @@ -208,6 +213,11 @@ describe('TableSchema', ()=>{ expect(depChange()).toEqual({ columns: oftypeColumns, primary_key: [], + foreign_key: [], + exclude_constraint: [], + unique_constraint: [], + partition_keys: [], + partitions: [], }); expect(schemaObj.changeColumnOptions).toHaveBeenCalledWith(oftypeColumns); done();