From 546747246deb5730b8c0625de2cc7c6e26bbdb82 Mon Sep 17 00:00:00 2001 From: Yong-Soo Chung Date: Wed, 6 May 2015 11:23:23 -0400 Subject: [PATCH] [TASK] Trust: Do not allow incoming lines with balance to disable rippling, show warning message when enabling rippling (RT-3371) --- src/js/tabs/trust.controller.js | 12 +++++++++++- src/templates/tabs/trust.jade | 26 ++++++++++++++++++++------ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/js/tabs/trust.controller.js b/src/js/tabs/trust.controller.js index 0d720a6f1..30a5efefe 100644 --- a/src/js/tabs/trust.controller.js +++ b/src/js/tabs/trust.controller.js @@ -384,7 +384,6 @@ TrustTab.prototype.angular = function (module) $scope.editing = false; }; - $scope.edit_account = function() { $scope.editing = true; @@ -638,6 +637,17 @@ TrustTab.prototype.angular = function (module) return ($scope.component.limit.is_zero() && !$scope.component.limit_peer.is_zero()); }; + $scope.ripplingEnabled = function() { + return !$scope.component.no_ripple; + } + + $scope.showEnableRipplingWarningMessage = function() { + return ($scope.isIncomingOnly() && + !$scope.ripplingEnabled() && + $scope.trust.rippling && + $scope.trust.balance !== '0'); + } + }]); }; diff --git a/src/templates/tabs/trust.jade b/src/templates/tabs/trust.jade index 80609c685..482fc712f 100644 --- a/src/templates/tabs/trust.jade +++ b/src/templates/tabs/trust.jade @@ -331,14 +331,28 @@ section.col-xs-12.content(ng-controller="TrustCtrl") .col-sm-2.col-md-2.inputPadding div.rippling-checkbox label(l10n) Rippling - input(name='rippling', type='checkbox', ng-model='trust.rippling', ng-disabled='trust.balance !== "0" && isIncomingOnly()') + input(name='rippling', type='checkbox', ng-model='trust.rippling', ng-disabled='trust.balance !== "0" && isIncomingOnly() && ripplingEnabled()') .col-sm-7.col-md-6 .row.row-padding-small - .col-xs-6.col-sm-5(ng-hide="trust.loading && trust.state==='removing'") - button.btn.btn-block.btn-primary#save(type='submit' - ng-disabled='accountForm.$invalid || trust.loading') - span(ng-hide="trust.loading", l10n) Save - span(ng-show="trust.loading && trust.state==='saving'", l10n) Saving... + div(ng-hide="trust.loading && trust.state==='removing'") + .col-xs-6.col-sm-5(ng-hide='showEnableRipplingWarningMessage()') + button.btn.btn-block.btn-primary#save(type='submit' + ng-disabled='accountForm.$invalid || trust.loading') + span(ng-hide="trust.loading", l10n) Save + span(ng-show="trust.loading && trust.state==='saving'", l10n) Saving... + .col-xs-6.col-sm-5(ng-show='showEnableRipplingWarningMessage()') + rp-confirm( + action-text="Are you sure you want to enable rippling? This is an incoming trust line with a balance. If you enable rippling, you will not be able to disable it." + action-button-text="Enable rippling and save" + action-button-css="btn btn-default btn-danger" + action-function="save_account()" + cancel-button-css="btn btn-cancel" + cancel-button-text="cancel" + ng-hide="showPassword==true") + button.btn.btn-block.btn-primary#save(type='submit' + ng-disabled='accountForm.$invalid || trust.loading') + span(ng-hide="trust.loading", l10n) Save + span(ng-show="trust.loading && trust.state==='saving'", l10n) Saving... .col-xs-6.col-sm-5(ng-show="trust.loading && trust.state==='removing'") .row .col-xs-12