Merge branch 'develop' into ICU-350-users-crud
This commit is contained in:
8 files changed
+33
-6
No files matched your search
@@ -4,6 +4,16 @@ 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}
|
||||
*/
|
||||
|
||||
@@ -11,6 +11,23 @@ module('Unit | Model | base', function (hooks) {
|
||||
assert.ok(model);
|
||||
});
|
||||
|
||||
test('it has a displayName attribute', function (assert) {
|
||||
assert.expect(3);
|
||||
const store = this.owner.lookup('service:store');
|
||||
store.push({
|
||||
data: {
|
||||
id: '123abc',
|
||||
type: 'project',
|
||||
attributes: {},
|
||||
},
|
||||
});
|
||||
const model = store.peekRecord('project', '123abc');
|
||||
assert.equal(model.name, null);
|
||||
assert.equal(model.displayName, '123abc');
|
||||
model.name = 'Test';
|
||||
assert.equal(model.displayName, 'Test');
|
||||
});
|
||||
|
||||
test('it has canSave and cannotSave attributes', function (assert) {
|
||||
assert.expect(8);
|
||||
const store = this.owner.lookup('service:store');
|
||||
|
||||
@@ -8,6 +8,6 @@ export default class OrgsOrgProjectsProjectController extends Controller {
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
@alias('model.name') breadCrumb;
|
||||
@alias('model.displayName') breadCrumb;
|
||||
|
||||
}
|
||||
@@ -8,6 +8,6 @@ export default class OrgsOrgProjectsProjectHostCatalogsHostCatalogController ext
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
@alias('model.name') breadCrumb;
|
||||
@alias('model.displayName') breadCrumb;
|
||||
|
||||
}
|
||||
@@ -7,6 +7,6 @@ export default class OrgsOrgRolesRoleController extends Controller {
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
@alias('model.name') breadCrumb;
|
||||
@alias('model.displayName') breadCrumb;
|
||||
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
{{title @model.name}}
|
||||
{{title @model.displayName}}
|
||||
|
||||
{{outlet}}
|
||||
@@ -1,3 +1,3 @@
|
||||
{{title @model.name}}
|
||||
{{title @model.displayName}}
|
||||
|
||||
{{outlet}}
|
||||
@@ -1,3 +1,3 @@
|
||||
{{title @model.name}}
|
||||
{{title @model.displayName}}
|
||||
|
||||
{{outlet}}
|
||||
Reference in new issue
Block a user