From a27addfdc3041401241bee482fe98c335484974b Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Tue, 7 Mar 2017 15:23:02 -0300 Subject: [PATCH] Ref tx-details. Transition smoother. Show date on receive tx. Pre-load exchange rate. Click on confirmation line to refresh tx --- src/js/controllers/tx-details.js | 77 ++++++++++++++++---------------- www/views/tx-details.html | 22 ++++++--- 2 files changed, 53 insertions(+), 46 deletions(-) diff --git a/src/js/controllers/tx-details.js b/src/js/controllers/tx-details.js index 9b27d2f0d..c2f45b882 100644 --- a/src/js/controllers/tx-details.js +++ b/src/js/controllers/tx-details.js @@ -2,39 +2,16 @@ angular.module('copayApp.controllers').controller('txDetailsController', function($log, $ionicHistory, $scope, $timeout, walletService, lodash, gettextCatalog, profileService, configService, externalLinkService, popupService, ongoingProcess, txFormatService) { + var txId; + $scope.$on("$ionicView.beforeEnter", function(event, data) { + txId = data.stateParams.txid; $scope.title = gettextCatalog.getString('Transaction'); $scope.wallet = profileService.getWallet(data.stateParams.walletId); $scope.color = $scope.wallet.color; $scope.copayerId = $scope.wallet.credentials.copayerId; $scope.isShared = $scope.wallet.credentials.n > 1; - - ongoingProcess.set('loadingTxInfo', true); - walletService.getTx($scope.wallet, data.stateParams.txid, function(err, tx) { - ongoingProcess.set('loadingTxInfo', false); - if (err) { - $log.warn('Could not get tx'); - $ionicHistory.goBack(); - return popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Transaction not found')); - } - - $scope.btx = txFormatService.processTx(tx); - - if ($scope.btx.action != 'invalid') { - if ($scope.btx.action == 'sent') $scope.title = gettextCatalog.getString('Sent Funds'); - if ($scope.btx.action == 'received') $scope.title = gettextCatalog.getString('Received Funds'); - if ($scope.btx.action == 'moved') $scope.title = gettextCatalog.getString('Moved Funds'); - } - - $scope.displayAmount = getDisplayAmount($scope.btx.amountStr); - $scope.displayUnit = getDisplayUnit($scope.btx.amountStr); - - updateMemo(); - initActionList(); - $timeout(function() { - $scope.$apply(); - }); - }); + $scope.updateTx(); }); function getDisplayAmount(amountStr) { @@ -96,6 +73,36 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio }, 10); } + $scope.updateTx = function() { + ongoingProcess.set('loadingTxInfo', true); + walletService.getTx($scope.wallet, txId, function(err, tx) { + ongoingProcess.set('loadingTxInfo', false); + if (err) { + $log.warn('Could not get tx'); + $ionicHistory.goBack(); + return popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Transaction not found')); + } + + $scope.btx = txFormatService.processTx(tx); + + if ($scope.btx.action != 'invalid') { + if ($scope.btx.action == 'sent') $scope.title = gettextCatalog.getString('Sent Funds'); + if ($scope.btx.action == 'received') $scope.title = gettextCatalog.getString('Received Funds'); + if ($scope.btx.action == 'moved') $scope.title = gettextCatalog.getString('Moved Funds'); + } + + $scope.displayAmount = getDisplayAmount($scope.btx.amountStr); + $scope.displayUnit = getDisplayUnit($scope.btx.amountStr); + + updateMemo(); + initActionList(); + getFiatRate(); + $timeout(function() { + $scope.$apply(); + }); + }); + }; + $scope.showCommentPopup = function() { var opts = {}; if ($scope.btx.message) { @@ -140,29 +147,21 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio return n.substring(0, 4); }; - $scope.getFiatRate = function() { - if ($scope.rateDate) return; - var alternativeIsoCode = $scope.wallet.status.alternativeIsoCode; - $scope.loadingRate = true; + var getFiatRate = function() { + $scope.alternativeIsoCode = $scope.wallet.status.alternativeIsoCode; $scope.wallet.getFiatRate({ - code: alternativeIsoCode, + code: $scope.alternativeIsoCode, ts: $scope.btx.time * 1000 }, function(err, res) { - $scope.loadingRate = false; if (err) { $log.debug('Could not get historic rate'); return; } if (res && res.rate) { $scope.rateDate = res.fetchedOn; - $scope.rateStr = res.rate + ' ' + alternativeIsoCode; - $scope.$apply(); + $scope.rate = res.rate; } }); }; - $scope.cancel = function() { - $scope.txDetailsModal.hide(); - }; - }); diff --git a/www/views/tx-details.html b/www/views/tx-details.html index 876629110..8b2cded57 100644 --- a/www/views/tx-details.html +++ b/www/views/tx-details.html @@ -7,7 +7,7 @@ - +
@@ -25,11 +25,13 @@
{{displayAmount}} {{displayUnit}}
-
+
{{btx.alternativeAmountStr}} - {{rateStr}} ({{rateDate | amDateFormat:'MM/DD/YYYY HH:mm a'}}) - ... + ... + + {{rate| currency:'':2}} {{alternativeIsoCode}} ({{rateDate | amDateFormat:'MM/DD/YYYY HH:mm a'}}) +
@@ -56,10 +58,16 @@
{{wallet.name}}
-
+
Created by - {{btx.creatorName}} + {{btx.creatorName}} + +
+
+ Date + +
@@ -75,7 +83,7 @@ {{btx.feeStr}}
-
+
Confirmations