Merge pull request #151 from JDonadio/bug/memo

Txp/Tx Modal
This commit is contained in:
Gustavo Maximiliano Cortez 2016-09-21 19:17:57 -03:00 committed by GitHub
commit 745babcc1f
7 changed files with 75 additions and 38 deletions

View file

@ -56,13 +56,18 @@ angular.module('copayApp.controllers').controller('activityController',
return popupService.showAlert(null, gettextCatalog.getString('Transaction not found'));
}
$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();
walletService.getTxNote(wallet, n.txid, function(err, note) {
if (err) $log.debug(gettextCatalog.getString('Could not fetch transaction note'));
$scope.wallet = wallet;
$scope.btx = lodash.cloneDeep(tx);
$scope.btx.note = note;
$ionicModal.fromTemplateUrl('views/modals/tx-details.html', {
scope: $scope
}).then(function(modal) {
$scope.txDetailsModal = modal;
$scope.txDetailsModal.show();
});
});
});
};

View file

@ -24,10 +24,6 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
updateMemo();
initActionList();
getAlternativeAmount();
$timeout(function() {
$scope.$apply();
});
};
function updateMemo() {
@ -38,7 +34,6 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
$log.debug(gettextCatalog.getString('Could not fetch transaction note'));
return;
}
$scope.note = note;
$timeout(function() {
$scope.$apply();
@ -81,7 +76,12 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
};
$scope.showCommentPopup = function() {
popupService.showPrompt(gettextCatalog.getString('Memo'), ' ', {}, function(text) {
var opts = {};
if ($scope.btx.note && $scope.btx.note.body) opts.defaultText = $scope.btx.note.body;
popupService.showPrompt(null, gettextCatalog.getString('Memo'), opts, function(text) {
if (typeof text == "undefined") return;
$log.debug('Saving memo');
var args = {
@ -103,7 +103,6 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
$scope.btx.note.editedOn = Math.floor(Date.now() / 1000);
}
$scope.btx.searcheableString = null;
$timeout(function() {
$scope.$apply();
});
@ -127,7 +126,6 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
$scope.rateDate = res.fetchedOn;
$scope.rateStr = res.rate + ' ' + $scope.alternativeIsoCode;
$scope.alternativeAmountStr = $filter('formatFiatAmount')(alternativeAmountBtc * res.rate) + ' ' + $scope.alternativeIsoCode;
$scope.$apply();
}
});
};

View file

@ -2,6 +2,7 @@
angular.module('copayApp.controllers').controller('tabHomeController',
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, gettextCatalog, lodash, popupService, ongoingProcess, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window) {
var wallet;
$scope.externalServices = {};
$scope.bitpayCardEnabled = true; // TODO
$scope.openTxpModal = txpModalService.open;
@ -17,22 +18,33 @@ angular.module('copayApp.controllers').controller('tabHomeController',
});
$scope.openNotificationModal = function(n) {
wallet = profileService.getWallet(n.walletId);
if (n.txid) {
openTxModal(n);
} else {
var txp = lodash.find($scope.txps, {
id: n.txpId
});
if (txp) txpModalService.open(txp);
else {
$log.warn('No txp found');
return popupService.showAlert(null, gettextCatalog.getString('Transaction not found'));
if (txp) {
txpModalService.open(txp);
} else {
ongoingProcess.set('loadingTxInfo', true);
walletService.getTxp(wallet, n.txpId, function(err, txp) {
var _txp = txp;
ongoingProcess.set('loadingTxInfo', false);
if (err) {
$log.warn('No txp found');
return popupService.showAlert(null, gettextCatalog.getString('Transaction not found'));
}
txpModalService.open(_txp);
});
}
}
};
var openTxModal = function(n) {
var wallet = profileService.getWallet(n.walletId);
wallet = profileService.getWallet(n.walletId);
ongoingProcess.set('loadingTxInfo', true);
walletService.getTx(wallet, n.txid, function(err, tx) {
@ -48,13 +60,18 @@ angular.module('copayApp.controllers').controller('tabHomeController',
return popupService.showAlert(null, gettextCatalog.getString('Transaction not found'));
}
$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();
walletService.getTxNote(wallet, n.txid, function(err, note) {
if (err) $log.debug(gettextCatalog.getString('Could not fetch transaction note'));
$scope.wallet = wallet;
$scope.btx = lodash.cloneDeep(tx);
$scope.btx.note = note;
$ionicModal.fromTemplateUrl('views/modals/tx-details.html', {
scope: $scope
}).then(function(modal) {
$scope.txDetailsModal = modal;
$scope.txDetailsModal.show();
});
});
});
};