Prevent attempts to create server groups with no name. Fixes #2012

This commit is contained in:
Surinder Kumar 2017-01-08 03:43:59 +00:00 committed by Dave Page
parent ae809c4506
commit e3c8cb2706

View File

@ -40,11 +40,21 @@ function($, _, pgAdmin, Backbone) {
} }
], ],
validate: function(attrs, options) { validate: function(attrs, options) {
var err = {},
errmsg = null;
this.errorModel.clear();
if (!this.isNew() && 'id' in this.changed) { if (!this.isNew() && 'id' in this.changed) {
return '{{ _('The ID cannot be changed.') }}'; errmsg = '{{ _('The ID cannot be changed.') }}';
this.errorModel.set('id', errmsg);
return errmsg;
} }
if (String(this.name).replace(/^\s+|\s+$/g, '') == '') { if (_.isUndefined(this.get('name')) ||
return '{{ _('Name cannot be empty.') }}'; _.isNull(this.get('name')) ||
String(this.get('name')).replace(/^\s+|\s+$/g, '') == '') {
errmsg = '{{ _('Name cannot be empty.') }}';
this.errorModel.set('name', errmsg);
return errmsg;
} }
return null; return null;
} }