github.com/outbrain/consul@v1.4.5/ui-v2/app/controllers/dc/acls/edit.js (about)

     1  import Controller from '@ember/controller';
     2  import { set } from '@ember/object';
     3  import Changeset from 'ember-changeset';
     4  import validations from 'consul-ui/validations/acl';
     5  import lookupValidator from 'ember-changeset-validations';
     6  
     7  export default Controller.extend({
     8    setProperties: function(model) {
     9      this.changeset = new Changeset(model.item, lookupValidator(validations), validations);
    10      this._super({
    11        ...model,
    12        ...{
    13          item: this.changeset,
    14        },
    15      });
    16    },
    17    actions: {
    18      change: function(e) {
    19        const target = e.target || { name: 'Rules', value: e };
    20        switch (target.name) {
    21          case 'Type':
    22            set(this.changeset, target.name, target.value);
    23            break;
    24          case 'Rules':
    25            set(this, 'item.Rules', target.value);
    26            break;
    27        }
    28      },
    29    },
    30  });