Use defaultValue for making sure Name is at least ''

This commit is contained in:
John Cowen 2018-06-11 17:49:22 +01:00
parent edea43e8a0
commit 26e69d2ad1
2 changed files with 6 additions and 3 deletions

View File

@ -7,7 +7,12 @@ export const SLUG_KEY = 'ID';
export default Model.extend({ export default Model.extend({
[PRIMARY_KEY]: attr('string'), [PRIMARY_KEY]: attr('string'),
[SLUG_KEY]: attr('string'), [SLUG_KEY]: attr('string'),
Name: attr('string'), Name: attr('string', {
// TODO: Why didn't I have to do this for KV's?
// this is to ensure that Name is '' and not null when creating
// maybe its due to the fact that `Key` is the primaryKey in Kv's
defaultValue: '',
}),
Type: attr('string'), Type: attr('string'),
Rules: attr('string'), Rules: attr('string'),
CreateIndex: attr('number'), CreateIndex: attr('number'),

View File

@ -13,8 +13,6 @@ export default Route.extend(WithAclActions, {
}, },
model: function(params) { model: function(params) {
this.item = get(this, 'repo').create(); this.item = get(this, 'repo').create();
// TODO: Why didn't I have to do this for KV's?
set(this.item, 'Name', '');
set(this.item, 'Datacenter', this.modelFor('dc').dc.Name); set(this.item, 'Datacenter', this.modelFor('dc').dc.Name);
return hash({ return hash({
create: true, create: true,