Only offer to create a future service if the name doesn't already exist

This commit is contained in:
John Cowen 2018-06-11 15:53:12 +01:00 committed by Jack Pearkes
parent f914a760fc
commit 1c4b1ee798
2 changed files with 5 additions and 0 deletions

View File

@ -33,6 +33,9 @@ export default Controller.extend({
createNewLabel: function(term) {
return `Use a future Consul Service called '${term}'`;
},
isUnique: function(term) {
return !get(this, 'items').findBy('Name', term);
},
change: function(e, value, _target) {
// normalize back to standard event
const target = e.target || { ..._target, ...{ name: e, value: value } };

View File

@ -8,6 +8,7 @@
selected=SourceName
searchPlaceholder='Type service name'
buildSuggestion=(action 'createNewLabel')
showCreateWhen=(action "isUnique")
oncreate=(action 'change' 'SourceName')
onchange=(action 'change' 'SourceName') as |service search|
}}
@ -27,6 +28,7 @@
selected=DestinationName
searchPlaceholder='Type service name'
buildSuggestion=(action 'createNewLabel')
showCreateWhen=(action "isUnique")
oncreate=(action 'change' 'DestinationName')
onchange=(action 'change' 'DestinationName') as |service|
}}