Switch to single selects rather than inputs
This commit is contained in:
parent
33d823c53d
commit
87d128971c
|
@ -11,19 +11,23 @@ export default Controller.extend({
|
|||
...model,
|
||||
...{
|
||||
item: this.changeset,
|
||||
SourceName: model.items.filterBy('Name', get(model.item, 'SourceName'))[0],
|
||||
DestinationName: model.items.filterBy('Name', get(model.item, 'DestinationName'))[0],
|
||||
},
|
||||
});
|
||||
},
|
||||
actions: {
|
||||
change: function(e) {
|
||||
const target = e.target || { name: 'SourceName', value: e };
|
||||
change: function(e, value, _target) {
|
||||
const target = e.target || { ..._target, ...{ name: e, value: value } };
|
||||
switch (target.name) {
|
||||
case 'Action':
|
||||
set(this.changeset, target.name, target.value);
|
||||
break;
|
||||
case 'SourceName':
|
||||
set(this.changeset, 'SourceName', get(target.value, 'Name'));
|
||||
set(this.item, 'SourceName', get(target.value, 'Name'));
|
||||
case 'DestinationName':
|
||||
set(this.changeset, target.name, get(target.value, 'Name'));
|
||||
set(this.item, target.name, get(target.value, 'Name'));
|
||||
set(this, target.name, target.value);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -7,6 +7,7 @@ import WithIntentionActions from 'consul-ui/mixins/intention/with-actions';
|
|||
export default Route.extend(WithIntentionActions, {
|
||||
templateName: 'dc/intentions/edit',
|
||||
repo: service('intentions'),
|
||||
servicesRepo: service('services'),
|
||||
beforeModel: function() {
|
||||
get(this, 'repo').invalidate();
|
||||
},
|
||||
|
@ -17,6 +18,7 @@ export default Route.extend(WithIntentionActions, {
|
|||
create: true,
|
||||
isLoading: false,
|
||||
item: this.item,
|
||||
items: get(this, 'servicesRepo').findAllByDatacenter(this.modelFor('dc').dc.Name),
|
||||
intents: ['allow', 'deny'],
|
||||
});
|
||||
},
|
||||
|
|
|
@ -2,15 +2,28 @@
|
|||
<fieldset>
|
||||
<label class="type-text{{if item.error.SourceName ' has-error'}}">
|
||||
<span>Source Service</span>
|
||||
{{#power-select selected=item options=items onchange=(action 'change') as |service|}}
|
||||
{{#power-select
|
||||
options=items
|
||||
searchField='Name'
|
||||
selected=SourceName
|
||||
searchPlaceholder='Type service name'
|
||||
onchange=(action 'change' 'SourceName') as |service|
|
||||
}}
|
||||
{{service.Name}}
|
||||
{{/power-select}}
|
||||
{{input value=item.SourceName name='source' autofocus='autofocus'}}
|
||||
<em>Choose a Consul Service, write in a future Consul Service, or write any Service URL</em>
|
||||
</label>
|
||||
<label class="type-text{{if item.error.DestinationName ' has-error'}}">
|
||||
<span>Destination Service</span>
|
||||
{{input value=item.DestinationName name='name'}}
|
||||
{{#power-select
|
||||
options=items
|
||||
searchField='Name'
|
||||
selected=DestinationName
|
||||
searchPlaceholder='Type service name'
|
||||
onchange=(action 'change' 'DestinationName') as |service|
|
||||
}}
|
||||
{{service.Name}}
|
||||
{{/power-select}}
|
||||
<em>Choose a Consul Service, write in a future Consul Service, or write any Service URL</em>
|
||||
</label>
|
||||
<div role="radiogroup" class={{if item.error.Action ' has-error'}}>
|
||||
|
|
Loading…
Reference in New Issue