github.hscsec.cn/hashicorp/consul@v1.4.5/ui-v2/app/mixins/creating-route.js (about)

     1  import Mixin from '@ember/object/mixin';
     2  import { get } from '@ember/object';
     3  
     4  /**
     5   * Used for create-type Routes
     6   *
     7   * 'repo' is standardized across the app
     8   * 'item' is standardized across the app
     9   *  they could be replaced with `getRepo` and `getItem`
    10   */
    11  export default Mixin.create({
    12    beforeModel: function() {
    13      get(this, 'repo').invalidate();
    14    },
    15    deactivate: function() {
    16      // TODO: This is dependent on ember-changeset
    17      // Change changeset to support ember-data props
    18      const item = get(this.controller, 'item.data');
    19      // TODO: Look and see if rollbackAttributes is good here
    20      if (get(item, 'isNew')) {
    21        item.destroyRecord();
    22      }
    23    },
    24  });