Merge pull request #4984 from cmgustavo/bug/tx-details-01

Fix tx-detail
This commit is contained in:
Javier Donadío 2016-11-08 16:35:37 -03:00 committed by GitHub
commit 97ec2200b6
5 changed files with 32 additions and 46 deletions

View file

@ -1,27 +1,21 @@
'use strict';
angular.module('copayApp.controllers').controller('txDetailsController', function($log, $timeout, $ionicHistory, $scope, $filter, $stateParams, ongoingProcess, walletService, lodash, gettextCatalog, profileService, configService, txFormatService, externalLinkService, popupService) {
var config = configService.getSync();
var configWallet = config.wallet;
var walletSettings = configWallet.settings;
var wallet = profileService.getWallet($stateParams.walletId);
angular.module('copayApp.controllers').controller('txDetailsController', function($log, $timeout, $ionicHistory, $scope, $stateParams, walletService, lodash, gettextCatalog, profileService, configService, externalLinkService, popupService) {
$scope.wallet = wallet;
$scope.title = gettextCatalog.getString('Transaction');
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$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;
$scope.init = function() {
$scope.alternativeIsoCode = walletSettings.alternativeIsoCode;
$scope.color = wallet.color;
$scope.copayerId = wallet.credentials.copayerId;
$scope.isShared = wallet.credentials.n > 1;
walletService.getTx(wallet, $stateParams.txid, function(err, tx) {
walletService.getTx($scope.wallet, $stateParams.txid, function(err, tx) {
if (err) {
$log.warn('Could not get tx');
$ionicHistory.goBack();
return;
}
$scope.btx = tx;
$scope.btx.feeLevel = walletSettings.feeLevel;
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');
@ -34,7 +28,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
updateMemo();
initActionList();
});
};
});
function getDisplayAmount(amountStr) {
return amountStr.split(' ')[0];
@ -45,7 +39,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
}
function updateMemo() {
walletService.getTxNote(wallet, $scope.btx.txid, function(err, note) {
walletService.getTxNote($scope.wallet, $scope.btx.txid, function(err, note) {
if (err) {
$log.warn('Could not fetch transaction note: ' + err);
return;
@ -53,18 +47,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
if (!note) return;
$scope.btx.note = note;
walletService.getTx(wallet, $scope.btx.txid, function(err, tx) {
if (err) {
$log.error(err);
return;
}
tx.note = note;
$timeout(function() {
$scope.$apply();
});
});
$scope.$apply();
});
}
@ -109,9 +92,12 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
}
if ($scope.btx.note && $scope.btx.note.body) opts.defaultText = $scope.btx.note.body;
popupService.showPrompt(wallet.name, gettextCatalog.getString('Memo'), opts, function(text) {
popupService.showPrompt($scope.wallet.name, gettextCatalog.getString('Memo'), opts, function(text) {
if (typeof text == "undefined") return;
$scope.btx.note = {
body: text
};
$log.debug('Saving memo');
var args = {
@ -119,17 +105,10 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
body: text
};
walletService.editTxNote(wallet, args, function(err, res) {
walletService.editTxNote($scope.wallet, args, function(err, res) {
if (err) {
$log.debug('Could not save tx comment ' + err);
return;
}
// This is only to refresh the current screen data
updateMemo();
$scope.btx.searcheableString = null;
$timeout(function() {
$scope.$apply();
});
});
});
};
@ -147,7 +126,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
};
$scope.getShortNetworkName = function() {
var n = wallet.credentials.network;
var n = $scope.wallet.credentials.network;
return n.substring(0, 4);
};
@ -155,5 +134,4 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
$scope.txDetailsModal.hide();
};
$scope.init();
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, profileService, lodash, configService, gettextCatalog, platformInfo, walletService, txpModalService, externalLinkService, popupService, addressbookService) {
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, $ionicHistory, profileService, lodash, configService, gettextCatalog, platformInfo, walletService, txpModalService, externalLinkService, popupService, addressbookService) {
var HISTORY_SHOW_LIMIT = 10;
var currentTxHistoryPage = 0;
@ -87,6 +87,14 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
$scope.close = function() {
$scope.searchModal.hide();
};
$scope.openTx = function(tx) {
$ionicHistory.nextViewOptions({
disableAnimate: true
});
$scope.searchModal.hide();
$scope.openTxModal(tx);
};
};
$scope.openTxModal = function(btx) {

View file

@ -182,7 +182,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
views: {
'tab-home@tabs': {
controller: 'txDetailsController',
templateUrl: 'views/modals/tx-details.html'
templateUrl: 'views/tx-details.html'
}
}
})

View file

@ -18,7 +18,7 @@
</div>
<div class="list">
<div class="item" ng-repeat="btx in txHistorySearchResults track by btx.txid" ng-click="openTxModal(btx)">
<div class="item" ng-repeat="btx in txHistorySearchResults track by btx.txid" ng-click="openTx(btx)">
<span class="item-note text-right">
<span class="size-16" ng-class="{'text-bold': btx.recent}">

View file

@ -47,14 +47,14 @@
{{btx.creatorName}} <time>{{ (btx.ts || btx.createdOn ) * 1000 | amDateFormat:'MM/DD/YYYY hh:mm a'}}</time>
</span>
</div>
<a class="item single-line item-icon-right" ng-hide="insuffientFunds" ng-click="showCommentPopup()">
<a class="item single-line item-icon-right" ng-click="showCommentPopup()">
<span class="label" translate>Memo</span>
<span class="item-note m10l">
{{btx.note.body || btx.message}}
</span>
<i class="icon bp-arrow-right"></i>
</a>
<div class="item single-line" ng-hide="insuffientFunds">
<div class="item single-line">
<span class="label" translate>Fee</span>
<span class="item-note">
{{btx.feeStr}}