Skip to content
This repository has been archived by the owner on Nov 30, 2020. It is now read-only.

Commit

Permalink
#48 separate alert group for warning of missing memo enables us to cl…
Browse files Browse the repository at this point in the history
…ear out warning if destination is changed and on the other hand keep the warning if it is not changed (if user navigates back to sendSetup screen from confirm screen)
  • Loading branch information
lenondupe committed Dec 21, 2017
1 parent 71ede16 commit 176c6a9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
25 changes: 16 additions & 9 deletions controllers/send-widget.controller.es6
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,17 @@ export default class SendWidgetController {
});
Alerts.registerGroup(this.amountAlertGroup);

this.memoAlertGroup = new AlertGroup();
this.memoAlertGroup.registerUpdateListener(alerts => {
this.memoAlerts = alerts;
this.memoErrorAlertGroup = new AlertGroup();
this.memoErrorAlertGroup.registerUpdateListener(alerts => {
this.memoErrorAlerts = alerts;
});
Alerts.registerGroup(this.memoAlertGroup);
Alerts.registerGroup(this.memoErrorAlertGroup);

this.memoWarningAlertGroup = new AlertGroup();
this.memoWarningAlertGroup.registerUpdateListener(alerts => {
this.memoWarningAlerts = alerts;
});
Alerts.registerGroup(this.memoWarningAlertGroup);

this.useLedger = this.session.data && this.session.data['useLedger'];
this.bip32Path = this.session.data && this.session.data['bip32Path'];
Expand All @@ -78,6 +84,7 @@ export default class SendWidgetController {
loadDestination($event) {
this.loadingDestination = true;
this.addressAlertGroup.clear();
this.memoWarningAlertGroup.clear();

let resetState = () => {
this.destination = null;
Expand Down Expand Up @@ -133,7 +140,7 @@ export default class SendWidgetController {
text: 'The payment destination (' + knownAccounts[this.destination].name +') requires you to specify a memo to identify your account.',
type: Alert.TYPES.WARNING
});
this.memoAlertGroup.show(alert);
this.memoWarningAlertGroup.show(alert);
}

this.loadingDestination = false;
Expand Down Expand Up @@ -171,7 +178,7 @@ export default class SendWidgetController {
if ($event) {
$event.preventDefault();
}
this.memoAlertGroup.clear();
this.memoErrorAlertGroup.clear();
this.memo = false;
this.memoType = null;
this.memoValue = null;
Expand All @@ -194,7 +201,7 @@ export default class SendWidgetController {

this.addressAlertGroup.clear();
this.amountAlertGroup.clear();
this.memoAlertGroup.clear();
this.memoErrorAlertGroup.clear();

if (!Account.isValidAccountId(this.destination)) {
let alert = new Alert({
Expand Down Expand Up @@ -242,11 +249,11 @@ export default class SendWidgetController {
text: memoError,
type: Alert.TYPES.ERROR
});
this.memoAlertGroup.show(alert);
this.memoErrorAlertGroup.show(alert);
}
}

if (this.addressAlerts.length || this.amountAlerts.length || this.memoAlerts.length) {
if (this.addressAlerts.length || this.amountAlerts.length || this.memoErrorAlerts.length) {
this.sending = false;
return;
}
Expand Down
11 changes: 8 additions & 3 deletions templates/send-widget.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <h2 class="sendPane__title">Send lumens</h2>
<input ng-model="widget.memoValue"
ng-disabled="widget.memoBlocked"
class="sendSetup__memo__memoSetup__input"
ng-class="{'s-inputAlert--alert': widget.memoAlerts.length > 0, 'is-disabled': widget.memoBlocked}"
ng-class="{'s-inputAlert--alert': widget.memoErrorAlerts.length > 0, 'is-disabled': widget.memoBlocked}"
placeholder="{{widget.memoPlaceholder}}" type="text" />
</div>
</div>
Expand All @@ -75,8 +75,13 @@ <h2 class="sendPane__title">Send lumens</h2>
<strong>Note</strong>: The specified federation address requires this transaction's memo to be a certain value.
</span>
</div>
<div class="s-alert s-alert--alert sendSetup__error" ng-if="widget.memoAlerts.length > 0">
<span ng-repeat="alert in widget.memoAlerts">
<div class="s-alert s-alert--alert sendSetup__error" ng-if="widget.memoErrorAlerts.length > 0">
<span ng-repeat="alert in widget.memoErrorAlerts">
{{alert.title}} {{alert.text}}
</span>
</div>
<div class="s-alert s-alert--warning sendSetup__error" ng-if="widget.memoWarningAlerts.length > 0">
<span ng-repeat="alert in widget.memoWarningAlerts">
{{alert.title}} {{alert.text}}
</span>
</div>
Expand Down

0 comments on commit 176c6a9

Please sign in to comment.