feat: Display password account's loginname in list

This commit is contained in:
Susmitha Girumala committed 2020-09-17 14:39:15 -04:00
1 parent bbb4426533
commit 905ee87858
4 files changed
+39 -3

No files matched your search

+18 -1
View File
@@ -1,13 +1,26 @@
import GeneratedAccountModel from '../generated/models/account';
import { fragment } from 'ember-data-model-fragments/attributes';
import { computed } from '@ember/object';
export default class AccountModel extends GeneratedAccountModel {
// =attributes
/**
* Attributes of this resource, if any, represented as a JSON fragment.
* @type {FragmentAccountAttributesModel}
*/
@fragment('fragment-account-attributes', { defaultValue: {} }) attributes;
/**
* Convenience for getting login_name attribute.
* @type {string}
*/
@computed('attributes.login_name')
get username() {
return this.attributes.login_name;
}
// =methods
/**
@@ -41,7 +54,11 @@ export default class AccountModel extends GeneratedAccountModel {
* @param {object} options.adapterOptions
* @return {Promise}
*/
changePassword(currentPassword, newPassword, options = { adapterOptions: {} }) {
changePassword(
currentPassword,
newPassword,
options = { adapterOptions: {} }
) {
const defaultAdapterOptions = {
method: 'change-password',
currentPassword,
+5 -2
View File
@@ -22,8 +22,11 @@ export default class AccountSerializer extends ApplicationSerializer {
}
if (snapshot?.adapterOptions?.method === 'change-password') {
const { currentPassword, newPassword } = snapshot?.adapterOptions;
serialized =
this.serializeForChangePassword(snapshot, currentPassword, newPassword);
serialized = this.serializeForChangePassword(
snapshot,
currentPassword,
newPassword
);
}
return serialized;
}
@@ -9,4 +9,16 @@ module('Unit | Model | account', function (hooks) {
let model = store.createRecord('account', {});
assert.ok(model);
});
test('it has an username attribute', function (assert) {
assert.expect(2);
const store = this.owner.lookup('service:store');
let model = store.createRecord('account', {
name: 'name',
type: 'password',
});
assert.equal(model.username, null);
model.attributes.login_name = 'username';
assert.equal(model.username, 'username');
});
});
@@ -4,6 +4,7 @@
<table.header as |header|>
<header.row as |row|>
<row.headerCell>{{t 'form.label.name'}}</row.headerCell>
<row.headerCell>{{t 'form.label.identification'}}</row.headerCell>
<row.headerCell>{{t 'form.label.id'}}</row.headerCell>
</header.row>
</table.header>
@@ -19,6 +20,9 @@
</LinkTo>
<p>{{account.description}}</p>
</row.headerCell>
<row.cell>
{{account.username}}
</row.cell>
<row.cell>
<code>{{account.id}}</code>
</row.cell>