This repository has been archived by the owner on Oct 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(settings): add ability to label accounts
- Loading branch information
Showing
21 changed files
with
220 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Component from '@ember/component'; | ||
|
||
import { storageFor } from 'ember-local-storage'; | ||
|
||
export default Component.extend({ | ||
settings: storageFor('settings', 'account'), | ||
|
||
account: null, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
& { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{{#if settings.label}} | ||
<big>{{settings.label}}</big> | ||
<br> | ||
{{account-address value=account.id truncate=true}} | ||
{{else}} | ||
{{account-address value=account.id}} | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Component from '@ember/component'; | ||
import { get } from '@ember/object'; | ||
import { tryInvoke } from '@ember/utils'; | ||
|
||
import { storageFor } from 'ember-local-storage'; | ||
|
||
import { action } from 'ember-decorators/object'; | ||
|
||
import ChangeAccountSettingsValidations from '../../validations/change-account-settings'; | ||
|
||
export default Component.extend({ | ||
ChangeAccountSettingsValidations, | ||
|
||
settings: storageFor('settings', 'account'), | ||
|
||
account: null, | ||
onSave: null, | ||
onCancel: null, | ||
|
||
@action | ||
save(changeset) { | ||
const settings = this.get('settings'); | ||
const label = get(changeset, 'label'); | ||
tryInvoke(settings, 'setProperties', [{ label }]); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{{#with (changeset (hash label=settings.label) ChangeAccountSettingsValidations) as |model|}} | ||
{{#bs-modal onHide=(action (optional onCancel)) as |modal|}} | ||
{{#modal.header}} | ||
<h4 class="modal-title"> | ||
{{t 'accountSettings'}} | ||
</h4> | ||
{{/modal.header}} | ||
{{#modal.body}} | ||
{{#bs-form model=model onSubmit=(action (queue (action 'save' model) (action (optional onSave)))) as |form|}} | ||
<div class="form-group"> | ||
<label>{{t 'account'}}</label> | ||
{{account-address class="form-control-plaintext" value=account.id truncate=true}} | ||
</div> | ||
{{form.element controlType="text" label=(t 'label') property="label"}} | ||
{{/bs-form}} | ||
{{/modal.body}} | ||
{{#modal.footer}} | ||
{{#bs-button onClick=(action modal.close) type="secondary"}} | ||
{{t 'cancel'}} | ||
{{/bs-button}} | ||
{{#bs-button type="primary" buttonType='submit'}} | ||
{{fa-icon 'check'}} | ||
{{t 'save'}} | ||
{{/bs-button}} | ||
{{/modal.footer}} | ||
{{/bs-modal}} | ||
{{/with}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { validatePresence } from 'ember-changeset-validations/validators'; | ||
|
||
export default { | ||
label: validatePresence(true), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
import { service } from 'ember-decorators/service'; | ||
import { action } from 'ember-decorators/object'; | ||
|
||
export default Route.extend({ | ||
@service intl: null, | ||
@service flashMessages: null, | ||
|
||
@action | ||
save() { | ||
const message = this.get('intl').t('accountSettingsSaved'); | ||
this.get('flashMessages').success(message); | ||
return this.transitionTo('wallets.overview'); | ||
}, | ||
|
||
@action | ||
cancel() { | ||
return this.transitionTo('wallets.overview'); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{account-settings account=model onSave=(action (route-action 'save')) onCancel=(action (route-action 'cancel'))}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
tests/integration/components/account-label/component-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
import { setupComponentTest } from 'ember-mocha'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
describe('Integration | Component | account-label', () => { | ||
setupComponentTest('account-label', { | ||
integration: true, | ||
}); | ||
|
||
it('renders', function () { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.on('myAction', function(val) { ... }); | ||
// Template block usage: | ||
// this.render(hbs` | ||
// {{#account-label}} | ||
// template content | ||
// {{/account-label}} | ||
// `); | ||
|
||
this.render(hbs`{{account-label}}`); | ||
expect(this.$()).to.have.length(1); | ||
}); | ||
}); |
38 changes: 38 additions & 0 deletions
38
tests/integration/components/account-settings/component-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { expect } from 'chai'; | ||
import { beforeEach, describe, it } from 'mocha'; | ||
import { setupComponentTest } from 'ember-mocha'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
describe('Integration | Component | account-settings', () => { | ||
setupComponentTest('account-settings', { | ||
integration: true, | ||
}); | ||
|
||
beforeEach(function () { | ||
this.inject.service('intl'); | ||
this.get('intl').setLocale('en-us'); | ||
}); | ||
|
||
it('renders', function () { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.on('myAction', function(val) { ... }); | ||
// Template block usage: | ||
// this.render(hbs` | ||
// {{#account-settings}} | ||
// template content | ||
// {{/account-settings}} | ||
// `); | ||
|
||
const store = this.container.lookup('service:store'); | ||
const account = store.createRecord('account', { | ||
id: '1', | ||
wallet: '1', | ||
balance: '1000000000000000000000000000000', | ||
pending: '0', | ||
}); | ||
|
||
this.set('account', account); | ||
this.render(hbs`{{account-settings account=account}}`); | ||
expect(this.$()).to.have.length(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tests/unit/wallets/overview/accounts/settings/route-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
import { setupTest } from 'ember-mocha'; | ||
|
||
describe('Unit | Route | wallets/overview/accounts/settings', () => { | ||
setupTest('route:wallets/overview/accounts/settings', { | ||
// Specify the other units that are required for this test. | ||
needs: [ | ||
'service:intl', | ||
'service:flashMessages', | ||
], | ||
}); | ||
|
||
it('exists', function () { | ||
const route = this.subject(); | ||
expect(route).to.be.ok; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters