mirror of https://github.com/BTCPrivate/copay.git
refactor call tx modal
This commit is contained in:
parent
64b879fcd3
commit
1cfd4c733f
|
@ -19,7 +19,7 @@
|
|||
|
||||
<div ng-if="!fetchingNotifications">
|
||||
<div class="list card">
|
||||
<div class="item" ng-repeat="x in notifications" ng-click="x.action()">
|
||||
<div class="item" ng-repeat="notification in notifications" ng-click="openTxModal(notification)">
|
||||
<span ng-include="'views/includes/walletActivity.html'"></span>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</ion-header-bar>
|
||||
|
||||
<ion-content>
|
||||
<div class="header-modal text-center" ng-if="!loadingTxInfo" ng-init="showRate = false">
|
||||
<div class="header-modal text-center" ng-init="showRate = false">
|
||||
<div ng-show="btx.action != 'invalid'">
|
||||
|
||||
<i class="icon big-icon-svg">
|
||||
|
@ -53,7 +53,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list" ng-if="!loadingTxInfo">
|
||||
<div class="list">
|
||||
<div class="item item-icon-left" ng-show="btx.action == 'sent'">
|
||||
<i class="icon ion-social-bitcoin-outline"></i>
|
||||
<div ng-if="!btx.hasMultiplesOutputs && btx.addressTo && btx.addressTo != 'N/A'" copy-to-clipboard="btx.addressTo">
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<span class="badge badge-assertive" ng-show="txpsN>3" translate> {{txpsN}}</span>
|
||||
</a>
|
||||
|
||||
<a ng-repeat="tx in txps" class="item" ng-click="openTxpModal(tx)">
|
||||
<a ng-repeat="tx in txps" class="item" ng-click="openTxpModal(tx)">
|
||||
<span ng-include="'views/includes/txp.html'"></span>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('activityController',
|
||||
function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo) {
|
||||
var self = this;
|
||||
|
||||
|
||||
function($timeout, $scope, $log, $ionicModal, lodash, profileService, walletService, ongoingProcess, popupService, gettextCatalog) {
|
||||
$scope.init = function() {
|
||||
$scope.fetchingNotifications = true;
|
||||
profileService.getNotifications(50, function(err, n) {
|
||||
|
@ -19,4 +16,32 @@ angular.module('copayApp.controllers').controller('activityController',
|
|||
}, 1);
|
||||
});
|
||||
}
|
||||
|
||||
$scope.openTxModal = function(n) {
|
||||
var wallet = profileService.getWallet(n.walletId);
|
||||
|
||||
ongoingProcess.set('loadingTxInfo', true);
|
||||
walletService.getTx(wallet, n.txid, function(err, tx) {
|
||||
ongoingProcess.set('loadingTxInfo', false);
|
||||
|
||||
if (err) {
|
||||
$log.error(err);
|
||||
return popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
}
|
||||
|
||||
if (!tx) {
|
||||
$log.warn('No tx found');
|
||||
return popupService.showAlert(gettextCatalog.getString('Transaction not found'), null);
|
||||
}
|
||||
|
||||
$scope.wallet = wallet;
|
||||
$scope.btx = lodash.cloneDeep(tx);
|
||||
$ionicModal.fromTemplateUrl('views/modals/tx-details.html', {
|
||||
scope: $scope
|
||||
}).then(function(modal) {
|
||||
$scope.txDetailsModal = modal;
|
||||
$scope.txDetailsModal.show();
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,64 +1,32 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('txDetailsController', function($log, $timeout, $scope, $filter, $stateParams, ongoingProcess, walletService, lodash, gettextCatalog, profileService, configService, txFormatService, externalLinkService, popupService) {
|
||||
var self = $scope.self;
|
||||
var wallet = profileService.getWallet($stateParams.walletId || $scope.walletId);
|
||||
var config = configService.getSync();
|
||||
var configWallet = config.wallet;
|
||||
var walletSettings = configWallet.settings;
|
||||
var wallet;
|
||||
$scope.title = gettextCatalog.getString('Transaction');
|
||||
$scope.loadingTxInfo = false;
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.loadingTxInfo = true;
|
||||
ongoingProcess.set('loadingTxInfo', true);
|
||||
findTx($scope.txid, function(err, tx) {
|
||||
ongoingProcess.set('loadingTxInfo', false);
|
||||
$scope.loadingTxInfo = false;
|
||||
if (err) {
|
||||
$log.error(err);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return $scope.cancel();
|
||||
}
|
||||
wallet = $scope.wallet;
|
||||
$scope.alternativeIsoCode = walletSettings.alternativeIsoCode;
|
||||
$scope.color = wallet.color;
|
||||
$scope.copayerId = wallet.credentials.copayerId;
|
||||
$scope.isShared = wallet.credentials.n > 1;
|
||||
$scope.btx.feeLevel = walletSettings.feeLevel;
|
||||
|
||||
if (!tx) {
|
||||
$log.warn('No tx found');
|
||||
popupService.showAlert(gettextCatalog.getString('Transaction not found'), null);
|
||||
return $scope.cancel();
|
||||
}
|
||||
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.btx = lodash.cloneDeep(tx);
|
||||
$scope.alternativeIsoCode = walletSettings.alternativeIsoCode;
|
||||
$scope.color = wallet.color;
|
||||
$scope.copayerId = wallet.credentials.copayerId;
|
||||
$scope.isShared = wallet.credentials.n > 1;
|
||||
$scope.btx.feeLevel = walletSettings.feeLevel;
|
||||
initActionList();
|
||||
getAlternativeAmount();
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
initActionList();
|
||||
getAlternativeAmount();
|
||||
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 10);
|
||||
});
|
||||
};
|
||||
|
||||
function findTx(txid, cb) {
|
||||
walletService.getTxHistory(wallet, {}, function(err, txHistory) {
|
||||
if (err) return cb(err);
|
||||
|
||||
var tx = lodash.find(txHistory, {
|
||||
txid: txid
|
||||
});
|
||||
|
||||
return cb(null, tx);
|
||||
});
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
};
|
||||
|
||||
function initActionList() {
|
||||
|
@ -158,8 +126,5 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
|
|||
|
||||
$scope.cancel = function() {
|
||||
$scope.txDetailsModal.hide();
|
||||
$timeout(function() {
|
||||
$scope.txDetailsModal.remove();
|
||||
}, 10);
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('tabHomeController',
|
||||
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, lodash, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window) {
|
||||
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, gettextCatalog, lodash, popupService, ongoingProcess, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window) {
|
||||
$scope.externalServices = {};
|
||||
$scope.bitpayCardEnabled = true; // TODO
|
||||
$scope.openTxpModal = txpModalService.open;
|
||||
|
@ -17,13 +17,30 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
});
|
||||
|
||||
$scope.openTxModal = function(n) {
|
||||
$scope.txid = n.txid;
|
||||
$scope.walletId = n.walletId;
|
||||
$ionicModal.fromTemplateUrl('views/modals/tx-details.html', {
|
||||
scope: $scope
|
||||
}).then(function(modal) {
|
||||
$scope.txDetailsModal = modal;
|
||||
$scope.txDetailsModal.show();
|
||||
var wallet = profileService.getWallet(n.walletId);
|
||||
|
||||
ongoingProcess.set('loadingTxInfo', true);
|
||||
walletService.getTx(wallet, n.txid, function(err, tx) {
|
||||
ongoingProcess.set('loadingTxInfo', false);
|
||||
|
||||
if (err) {
|
||||
$log.error(err);
|
||||
return popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
}
|
||||
|
||||
if (!tx) {
|
||||
$log.warn('No tx found');
|
||||
return popupService.showAlert(gettextCatalog.getString('Transaction not found'), null);
|
||||
}
|
||||
|
||||
$scope.wallet = wallet;
|
||||
$scope.btx = lodash.cloneDeep(tx);
|
||||
$ionicModal.fromTemplateUrl('views/modals/tx-details.html', {
|
||||
scope: $scope
|
||||
}).then(function(modal) {
|
||||
$scope.txDetailsModal = modal;
|
||||
$scope.txDetailsModal.show();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -131,18 +131,13 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
$scope.close = function() {
|
||||
$scope.searchModal.hide();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$scope.openTxModal = function(btx) {
|
||||
var self = this;
|
||||
|
||||
$scope.btx = lodash.cloneDeep(btx);
|
||||
$scope.self = self;
|
||||
|
||||
$scope.walletId = wallet.id;
|
||||
$ionicModal.fromTemplateUrl('views/modals/tx-details.html', {
|
||||
scope: $scope,
|
||||
hideDelay: 500
|
||||
scope: $scope
|
||||
}).then(function(modal) {
|
||||
$scope.txDetailsModal = modal;
|
||||
$scope.txDetailsModal.show();
|
||||
|
|
|
@ -502,6 +502,17 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
});
|
||||
};
|
||||
|
||||
root.getTx = function(wallet, txid, cb) {
|
||||
root.getTxHistory(wallet, {}, function(err, txHistory) {
|
||||
if (err) return cb(err);
|
||||
|
||||
var tx = lodash.find(txHistory, {
|
||||
txid: txid
|
||||
});
|
||||
|
||||
return cb(null, tx);
|
||||
});
|
||||
};
|
||||
|
||||
root.getTxHistory = function(wallet, opts, cb) {
|
||||
opts = opts || {};
|
||||
|
|
Loading…
Reference in New Issue