mirror of https://github.com/status-im/consul.git
Validate all the things, all the time
This commit is contained in:
parent
ee3a32d771
commit
f4218b4bea
|
@ -40,6 +40,7 @@ export default Controller.extend({
|
|||
// normalize back to standard event
|
||||
const target = e.target || { ..._target, ...{ name: e, value: value } };
|
||||
switch (target.name) {
|
||||
case 'Description':
|
||||
case 'Action':
|
||||
set(this.changeset, target.name, target.value);
|
||||
break;
|
||||
|
@ -60,6 +61,7 @@ export default Controller.extend({
|
|||
set(this, target.name, selected);
|
||||
break;
|
||||
}
|
||||
this.changeset.validate();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -50,13 +50,13 @@
|
|||
</div>
|
||||
<label class="type-text{{if item.error.Description ' has-error'}}">
|
||||
<span>Description</span>
|
||||
{{input value=item.Description name='description' placeholder="Description"}}
|
||||
<input type="text" name="Description" value="{{item.Description}}" placeholder="Description" onchange={{action 'change'}} />
|
||||
<em>Choose a Consul Service, write in a future Consul Service, or write any Service URL</em>
|
||||
</label>
|
||||
</fieldset>
|
||||
<div>
|
||||
{{#if create }}
|
||||
<button type="submit" {{ action "create" item}} disabled={{if item.isInvalid 'disabled'}}>Save</button>
|
||||
<button type="submit" {{ action "create" item}} disabled={{if (or item.isPristine item.isInvalid) 'disabled'}}>Save</button>
|
||||
{{ else }}
|
||||
<button type="submit" {{ action "update" item}} disabled={{if item.isInvalid 'disabled'}}>Save</button>
|
||||
{{/if}}
|
||||
|
|
Loading…
Reference in New Issue