Make sure future services are available when editing intentions

This commit is contained in:
John Cowen 2018-06-08 14:55:23 +01:00 committed by Jack Pearkes
parent 5575455053
commit 50507b34a5
1 changed files with 14 additions and 2 deletions

View File

@ -8,12 +8,24 @@ import validations from 'consul-ui/validations/intention';
export default Controller.extend({ export default Controller.extend({
setProperties: function(model) { setProperties: function(model) {
this.changeset = new Changeset(model.item, lookupValidator(validations), validations); this.changeset = new Changeset(model.item, lookupValidator(validations), validations);
const sourceName = get(model.item, 'SourceName');
const destinationName = get(model.item, 'DestinationName');
let source = model.items.findBy('Name', sourceName);
let destination = model.items.findBy('Name', destinationName);
if (!source) {
source = { Name: sourceName };
model.items = [source].concat(model.items);
}
if (!destination) {
destination = { Name: destinationName };
model.items = [destination].concat(model.items);
}
this._super({ this._super({
...model, ...model,
...{ ...{
item: this.changeset, item: this.changeset,
SourceName: model.items.filterBy('Name', get(model.item, 'SourceName'))[0], SourceName: source,
DestinationName: model.items.filterBy('Name', get(model.item, 'DestinationName'))[0], DestinationName: destination,
}, },
}); });
}, },