diff --git a/src/components/send/send.js b/src/components/send/send.js index a057d2ebe..f3c8fbdd3 100644 --- a/src/components/send/send.js +++ b/src/components/send/send.js @@ -10,7 +10,7 @@ app.component('send', { template: require('./send.pug')(), bindings: { recipientId: '<', - transferAmount: '<', + sendAmount: '<', }, /** * The send component constructor class @@ -40,8 +40,8 @@ app.component('send', { /** * @todo Check if it's possible to replace these watchers with filters. */ - if ($scope.$ctrl.transferAmount) { - this.amount.value = parseInt(lsk.normalize($scope.$ctrl.transferAmount), 10); + if ($scope.$ctrl.sendAmount) { + this.amount.value = parseFloat(lsk.normalize($scope.$ctrl.sendAmount), 10); } this.$scope.$watch('$ctrl.amount.value', () => { diff --git a/src/components/send/sendModalDirective.js b/src/components/send/sendModalDirective.js index 0e3de34ac..f0e864036 100644 --- a/src/components/send/sendModalDirective.js +++ b/src/components/send/sendModalDirective.js @@ -15,7 +15,9 @@ app.directive('showSendModal', (SendModal) => { */ const ShowSendModalLink = function (scope, element) { element.bind('click', () => { - SendModal.show(scope.recipientId, scope.amount); + if (scope.amount === undefined || scope.amount > 0) { + SendModal.show(scope.recipientId, scope.amount); + } }); }; diff --git a/src/components/send/sendModalService.js b/src/components/send/sendModalService.js index 4132a8b7c..dca4cd2da 100644 --- a/src/components/send/sendModalService.js +++ b/src/components/send/sendModalService.js @@ -33,7 +33,7 @@ app.factory('SendModal', ($mdDialog) => { bindToController: true, controller: ['$scope', ($scope) => { $scope.recipientId = recipientId; - $scope.amount = amount; + $scope.sendAmount = amount; }], controllerAs: 'ms', })); diff --git a/src/components/top/top.js b/src/components/top/top.js index 1b86edcd4..d81d7f7a8 100644 --- a/src/components/top/top.js +++ b/src/components/top/top.js @@ -9,9 +9,14 @@ import './top.less'; app.component('top', { template: require('./top.pug')(), controller: class top { - constructor(Peers, Account) { + constructor($scope, Peers, Account) { this.peers = Peers; this.account = Account; + + $scope.$on('accountChange', () => { + this.totalSendable = this.account.get().balance > 1e7 ? + this.account.get().balance - 1e7 : 0; + }); } }, }); diff --git a/src/components/top/top.less b/src/components/top/top.less index 5aecee13b..8c9bb3f3b 100644 --- a/src/components/top/top.less +++ b/src/components/top/top.less @@ -42,4 +42,12 @@ top { font-size: 120%; font-weight: bold; } + + .balance-wrapper { + display: inline-block; + line-height: 41px; + &.has-send-modal { + cursor: pointer; + } + } } diff --git a/src/components/top/top.pug b/src/components/top/top.pug index 02e844056..3ff78ea05 100644 --- a/src/components/top/top.pug +++ b/src/components/top/top.pug @@ -21,4 +21,6 @@ md-content(layout='column', layout-gt-xs='row') md-card.offline-hide(flex-gt-xs=33) md-card-content(layout='column', layout-align='center center') span.md-title.title Balance - lsk.balance.value(amount='$ctrl.account.get().balance', nocolor, append) + div(class='balance-wrapper', data-show-send-modal, data-amount='$ctrl.totalSendable', data-ng-class='{"has-send-modal": $ctrl.totalSendable > 0}') + lsk.balance.value(amount='$ctrl.account.get().balance', nocolor, append) + md-tooltip(md-direction='top', md-delay='350', data-ng-if='$ctrl.account.get().balance > 0') Send all funds diff --git a/src/components/transactions/transactions.less b/src/components/transactions/transactions.less index 972a25591..9603a0f25 100644 --- a/src/components/transactions/transactions.less +++ b/src/components/transactions/transactions.less @@ -75,6 +75,10 @@ transactions { } } + .has-send-modal { + cursor: pointer; + } + .expanding-button { color: #555; cursor: pointer; diff --git a/src/components/transactions/transactions.pug b/src/components/transactions/transactions.pug index fd19017ea..74dbb5e07 100644 --- a/src/components/transactions/transactions.pug +++ b/src/components/transactions/transactions.pug @@ -11,7 +11,6 @@ md-card.offline-hide th(md-column) Time th(md-column) Transaction ID th(md-column) From / To - th(md-column) Send to this th(md-column) th(md-column) Amount th(md-column) Fee @@ -32,17 +31,24 @@ md-card.offline-hide span.tx(ng-switch-when='6') Send Lisk to Blockchain Application span.tx(ng-switch-when='7') Send Lisk from Blockchain Application span(ng-switch-default) - span(ng-bind='transaction.senderId', ng-if='transaction.senderId !== $ctrl.account.get().address') - span(ng-bind='transaction.recipientId', ng-if='transaction.senderId === $ctrl.account.get().address') - td(md-cell) - i.material-icons.expanding-button(ng-if='transaction.senderId !== $ctrl.account.get().address', data-show-send-modal, data-recipient-id='transaction.senderId') arrow_forward - i.material-icons.expanding-button(ng-if='transaction.senderId === $ctrl.account.get().address', data-show-send-modal, data-recipient-id='transaction.recipientId') arrow_forward + span(ng-bind='transaction.senderId', ng-if='transaction.senderId !== $ctrl.account.get().address', + data-show-send-modal, data-recipient-id='transaction.senderId', class='has-send-modal') + span(ng-bind='transaction.recipientId', ng-if='transaction.senderId === $ctrl.account.get().address', + data-show-send-modal, data-recipient-id='transaction.recipientId', class='has-send-modal') + md-tooltip(md-direction='top', md-delay='350') Send to this recipient td(md-cell) i.material-icons(ng-if='transaction.type === 0 && transaction.senderId === transaction.recipientId') replay i.material-icons.in(ng-if='transaction.senderId !== $ctrl.account.get().address') call_received i.material-icons.out(ng-if='transaction.type !== 0 || transaction.recipientId !== $ctrl.account.get().address') call_made td(md-cell) - .amount(ng-class='{ neutral:transaction.type === 0 && transaction.senderId === transaction.recipientId, positive: transaction.senderId !== $ctrl.account.get().address, negative: transaction.type !== 0 || transaction.recipientId !== $ctrl.account.get().address }') + .amount.negative(data-ng-if='transaction.type !== 0 || transaction.recipientId !== $ctrl.account.get().address', + data-ng-class='{"has-send-modal": transaction.amount > 0}', + data-show-send-modal, data-amount='transaction.amount', data-recipient-id='transaction.recipientId') + lsk.value(amount='transaction.amount') + md-tooltip(md-direction='top', md-delay='350', data-ng-if='transaction.amount > 0') Repeat the transaction + .amount.positive(data-ng-if='transaction.senderId !== $ctrl.account.get().address') + lsk.value(amount='transaction.amount') + .amount.neutral(ng-if='transaction.type === 0 && transaction.senderId === transaction.recipientId') lsk.value(amount='transaction.amount') td(md-cell) .fee