Allow deleting the entry while creating/adding new label to enumeration type. #8208

This commit is contained in:
Yogesh Mahajan 2024-12-16 14:54:24 +05:30 committed by GitHub
parent 776e092a89
commit a0cd6c6a88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -209,7 +209,7 @@ class EnumerationSchema extends BaseUISchema {
return [ return [
{ {
id: 'label', label: gettext('Label'), id: 'label', label: gettext('Label'),
type: 'text', cell: 'text', minWidth: 640, type: 'text', cell: 'text', minWidth: 620,
editable: (state) => { editable: (state) => {
return _.isUndefined(obj.isNew) ? true : obj.isNew(state); return _.isUndefined(obj.isNew) ? true : obj.isNew(state);
} }
@ -1301,6 +1301,7 @@ export default class TypeSchema extends BaseUISchema {
}, },
{ {
id: 'enum', label: gettext('Enumeration type'), id: 'enum', label: gettext('Enumeration type'),
editable: true,
schema: new EnumerationSchema(), schema: new EnumerationSchema(),
type: 'collection', type: 'collection',
group: gettext('Definition'), mode: ['edit', 'create'], group: gettext('Definition'), mode: ['edit', 'create'],
@ -1308,14 +1309,12 @@ export default class TypeSchema extends BaseUISchema {
return !obj.isInvalidColumnAdded(state); return !obj.isInvalidColumnAdded(state);
}, },
canEdit: false, canEdit: false,
canDeleteRow: function(state) { canDelete: true,
// We will disable it if it's in 'edit' mode canReorder: (state)=>(this.isNew(state)),
return obj.isNew(state); canDeleteRow: (state)=>(_.isUndefined(state.label)),
}, canEditRow: true,
canEditRow: false,
disabled: () => obj.inCatalog(), disabled: () => obj.inCatalog(),
deps: ['typtype'], deps: ['typtype'],
uniqueCol : ['label'],
visible: (state) => isVisible(state, 'e'), visible: (state) => isVisible(state, 'e'),
}, { }, {
type: 'nested-fieldset', type: 'nested-fieldset',