diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js index 031c79c3f..7fc53a242 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js @@ -79,14 +79,14 @@ export default class ColumnSchema extends BaseUISchema { if(!_.isUndefined(state.inheritedfrom)) { return true; } - // ie: it's position is less than 1 - if(!_.isUndefined(state.attnum) && state.attnum <= 0) { - return true; + + if(this.isNew(state)) { + return false; } - // if we are in edit mode - return !this.isNew(state); + // ie: it's position is less than 1 + return !(!_.isUndefined(state.attnum) && state.attnum > 0); } - return false; + return true; } editableCheckForTable(state) { @@ -152,7 +152,7 @@ export default class ColumnSchema extends BaseUISchema { return [{ id: 'name', label: gettext('Name'), cell: 'text', - type: 'text', disabled: obj.inSchemaWithColumnCheck, + type: 'text', readonly: obj.inSchemaWithColumnCheck, editable: this.editableCheckForTable, noEmpty: true, minWidth: 115, },{ @@ -226,7 +226,7 @@ export default class ColumnSchema extends BaseUISchema { type: 'text', disabled: this.inCatalog, mode: ['properties'], },{ id: 'cltype', label: gettext('Data type'), - disabled: obj.inSchemaWithColumnCheck, minWidth: 150, + readonly: obj.inSchemaWithColumnCheck, minWidth: 150, group: gettext('Definition'), noEmpty: true, editable: this.editableCheckForTable, options: this.cltypeOptions, optionsLoaded: (options)=>{obj.datatypes = options;}, @@ -345,12 +345,12 @@ export default class ColumnSchema extends BaseUISchema { } },{ id: 'attstattarget', label: gettext('Statistics'), cell: 'text', - type: 'text', disabled: obj.inSchemaWithColumnCheck, mode: ['properties', 'edit'], + type: 'text', readonly: obj.inSchemaWithColumnCheck, mode: ['properties', 'edit'], group: gettext('Definition'), },{ id: 'attstorage', label: gettext('Storage'), group: gettext('Definition'), type: 'select', mode: ['properties', 'edit'], - cell: 'select', disabled: obj.inSchemaWithColumnCheck, + cell: 'select', readonly: obj.inSchemaWithColumnCheck, controlProps: { placeholder: gettext('Select storage'), allowClear: false, }, diff --git a/web/pgadmin/static/js/components/FormComponents.jsx b/web/pgadmin/static/js/components/FormComponents.jsx index 7ea4abd56..2a001bc56 100644 --- a/web/pgadmin/static/js/components/FormComponents.jsx +++ b/web/pgadmin/static/js/components/FormComponents.jsx @@ -511,7 +511,7 @@ export function InputToggle({cid, value, onChange, options, disabled, readonly, { (options||[]).map((option)=>{ const isSelected = option.value === value; - const isDisabled = disabled || (readonly && !isSelected); + const isDisabled = disabled || option.disabled || (readonly && isSelected); return ( diff --git a/web/regression/javascript/schema_ui_files/column.ui.spec.js b/web/regression/javascript/schema_ui_files/column.ui.spec.js index bde3aff27..a6528ab16 100644 --- a/web/regression/javascript/schema_ui_files/column.ui.spec.js +++ b/web/regression/javascript/schema_ui_files/column.ui.spec.js @@ -202,13 +202,13 @@ describe('ColumnSchema', ()=>{ expect(schemaObj.inSchemaWithColumnCheck(state)).toBe(true); schemaObj.nodeInfo = {}; - expect(schemaObj.inSchemaWithColumnCheck(state)).toBe(false); + expect(schemaObj.inSchemaWithColumnCheck(state)).toBe(true); }); it('editableCheckForTable', ()=>{ let state = {}; schemaObj.nodeInfo = {}; - expect(schemaObj.editableCheckForTable(state)).toBe(true); + expect(schemaObj.editableCheckForTable(state)).toBe(false); }); it('depChange', ()=>{