2018-05-22 15:03:45 +00:00
|
|
|
import Controller from '@ember/controller';
|
2018-05-24 08:52:07 +00:00
|
|
|
import { get, set } from '@ember/object';
|
2018-05-22 15:03:45 +00:00
|
|
|
// import Changeset from 'ember-changeset';
|
|
|
|
// import validations from 'consul-ui/validations/acl';
|
|
|
|
// import lookupValidator from 'ember-changeset-validations';
|
|
|
|
|
|
|
|
export default Controller.extend({
|
|
|
|
setProperties: function(model) {
|
|
|
|
this.changeset = model.item; //new Changeset(model.item, lookupValidator(validations), validations);
|
|
|
|
this._super({
|
|
|
|
...model,
|
|
|
|
...{
|
|
|
|
item: this.changeset,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
actions: {
|
|
|
|
change: function(e) {
|
2018-05-24 08:52:07 +00:00
|
|
|
const target = e.target || { name: 'SourceName', value: e };
|
2018-05-22 15:03:45 +00:00
|
|
|
switch (target.name) {
|
|
|
|
case 'Action':
|
|
|
|
set(this.changeset, target.name, target.value);
|
|
|
|
break;
|
2018-05-24 08:52:07 +00:00
|
|
|
case 'SourceName':
|
|
|
|
set(this.changeset, 'SourceName', get(target.value, 'Name'));
|
|
|
|
set(this.item, 'SourceName', get(target.value, 'Name'));
|
|
|
|
break;
|
2018-05-22 15:03:45 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|