Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Merge pull request #271 from LiskHQ/270-send-from-address-or-amount
Browse files Browse the repository at this point in the history
Send from address or amount - Closes #270
  • Loading branch information
reyraa authored May 30, 2017
2 parents c891c96 + 26956b7 commit d066f8f
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/components/send/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ app.component('send', {
template: require('./send.pug')(),
bindings: {
recipientId: '<',
transferAmount: '<',
sendAmount: '<',
},
/**
* The send component constructor class
Expand Down Expand Up @@ -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', () => {
Expand Down
4 changes: 3 additions & 1 deletion src/components/send/sendModalDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/send/sendModalService.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ app.factory('SendModal', ($mdDialog) => {
bindToController: true,
controller: ['$scope', ($scope) => {
$scope.recipientId = recipientId;
$scope.amount = amount;
$scope.sendAmount = amount;
}],
controllerAs: 'ms',
}));
Expand Down
7 changes: 6 additions & 1 deletion src/components/top/top.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
},
});
8 changes: 8 additions & 0 deletions src/components/top/top.less
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,12 @@ top {
font-size: 120%;
font-weight: bold;
}

.balance-wrapper {
display: inline-block;
line-height: 41px;
&.has-send-modal {
cursor: pointer;
}
}
}
4 changes: 3 additions & 1 deletion src/components/top/top.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions src/components/transactions/transactions.less
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ transactions {
}
}

.has-send-modal {
cursor: pointer;
}

.expanding-button {
color: #555;
cursor: pointer;
Expand Down
20 changes: 13 additions & 7 deletions src/components/transactions/transactions.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit d066f8f

Please sign in to comment.