Ensure that name can't be empty in edit mode for Primary Key and Index. #6204

This commit is contained in:
Akshay Joshi committed 2023-05-18 15:46:56 +05:30
1 parent 6949b41fb9
commit 4baae7512b
3 files changed
+16

No files matched your search

@@ -256,6 +256,13 @@ export default class PrimaryKeySchema extends BaseUISchema {
}
validate(state, setError) {
if (!this.isNew(state) && isEmptyString(state.name)) {
setError('name', gettext('Name cannot be empty in edit mode.'));
return true;
} else {
setError('name', null);
}
if(isEmptyString(state.index)
&& (_.isUndefined(state.columns) || _.isNull(state.columns) || state.columns.length < 1)) {
setError('columns', gettext('Please specify columns for %s.', gettext('Primary key')));
@@ -452,6 +452,14 @@ export default class IndexSchema extends BaseUISchema {
validate(state, setError) {
let msg;
if (!this.isNew(state) && isEmptyString(state.name)) {
msg = gettext('Name cannot be empty in edit mode.');
setError('name', msg);
return true;
} else {
setError('name', null);
}
// Checks if columns is empty
let cols = state.columns;
if(_.isArray(cols) && cols.length == 0){