Fixed an issue where unable to change the column properties from edit dialog. Fixes #6766

This commit is contained in:
Aditya Toshniwal 2021-09-22 18:23:40 +05:30 committed by Akshay Joshi
parent a8c8ea69e3
commit a1aa080956
3 changed files with 13 additions and 13 deletions

View File

@ -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,
},

View File

@ -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 (
<ToggleButton key={option.label} value={option.value} component={isSelected ? PrimaryButton : DefaultButton}
disabled={isDisabled} aria-label={option.label}>

View File

@ -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', ()=>{