33 lines
635 B
JavaScript
33 lines
635 B
JavaScript
import Model from '@ember-data/model';
|
|
import { computed } from '@ember/object';
|
|
|
|
export default class BaseModel extends Model {
|
|
// =attributes
|
|
|
|
/**
|
|
* Names are optional on models in our API. Thus we need to fallback on ID
|
|
* for display purposes.
|
|
* @type {string}
|
|
*/
|
|
@computed('name', 'id')
|
|
get displayName() {
|
|
return this.name || this.id;
|
|
}
|
|
|
|
/**
|
|
* @type {boolean}
|
|
*/
|
|
@computed('hasDirtyAttributes', 'isSaving')
|
|
get canSave() {
|
|
return this.hasDirtyAttributes && !this.isSaving;
|
|
}
|
|
|
|
/**
|
|
* @type {boolean}
|
|
*/
|
|
@computed('canSave')
|
|
get cannotSave() {
|
|
return !this.canSave;
|
|
}
|
|
}
|