Updates tx modal

This commit is contained in:
Gustavo Maximiliano Cortez 2016-02-10 15:35:26 -05:00
commit 9fedae1a67
6 changed files with 27 additions and 105 deletions

View file

@ -1,7 +1,6 @@
<div
ng-controller="txController as txc"
class="txModal fix-modals-touch"
ng-class="{'animated': index.isCordova, 'slideInRight': modalOpening, 'slideOutRight': modalClosing}"
ng-swipe-disable-mouse
ng-swipe-right="txc.cancel()">

View file

@ -199,21 +199,7 @@
</div>
<div ng-repeat="btx in index.txHistory"
fast-click callback-fn="home.openNewTxModal({
txid: btx.txid,
action: btx.action,
hasMultiplesOutputs: btx.hasMultiplesOutputs,
addressTo: btx.addressTo,
merchant: btx.merchant,
labelTo: btx.labelTo,
recipientCount: btx.recipientCount,
outputs: btx.outputs,
message: btx.message,
time: btx.time,
confirmations: btx.confirmations,
safeConfirmed: btx.safeConfirmed,
amountStr: btx.amountStr
})"
fast-click callback-fn="home.openTxModal(btx)"
class="row collapse last-transactions-content">
<div class="large-6 medium-6 small-6 columns size-14">
<div class="m10r left">

View file

@ -73,7 +73,7 @@ h4.title a {
}
.preferences h4, .modal-content h4, .glidera h4 {
.preferences h4, .modal-content h4, .glidera h4, .txModal h4 {
background: #F6F7F9;
padding: 25px 0px 5px 10px;
text-transform: uppercase;
@ -88,7 +88,7 @@ h4.title a {
}
.preferences ul, .modal-content ul {
.preferences ul, .modal-content ul, .txModal ul {
font-size:14px;
background: white;
}
@ -1400,7 +1400,7 @@ input.ng-invalid-match, input.ng-invalid-match:focus {
}
.txModal {
background: #FFFFFF;
background: #f6f7f9;
border-radius: 5px;
position: absolute;
width: 100%;

View file

@ -1,21 +1,31 @@
'use strict';
angular.module('copayApp.controllers').controller('txController',
function($rootScope, $scope, $timeout, profileService, notification, go, gettext, isCordova, nodeWebkit) {
function($rootScope, $scope, $timeout, $filter, lodash, profileService, isCordova, nodeWebkit, configService, animationService) {
var fc = profileService.focusedClient;
var config = configService.getSync();
var configWallet = config.wallet;
var walletSettings = configWallet.settings;
var m = angular.element(document.getElementsByClassName('txModal'));
m.addClass(animationService.modalAnimated.slideRight);
this.alternativeIsoCode = walletSettings.alternativeIsoCode;
this.color = fc.backgroundColor;
this.copayerId = fc.credentials.copayerId;
this.isShared = fc.credentials.n > 1;
if (isCordova) {
$scope.modalOpening = true;
$timeout(function() {
$scope.modalOpening = false;
}, 300);
$rootScope.modalOpened = true;
var self = this;
var disableCloseModal = $rootScope.$on('closeModal', function() {
self.cancel();
});
}
this.getAlternativeAmount = function(btx) {
var self = this;
var satToBtc = 1 / 100000000;
fc.getFiatRate({
code: self.alternativeIsoCode,
@ -48,18 +58,19 @@ angular.module('copayApp.controllers').controller('txController',
} else if (nodeWebkit.isDefined()) {
nodeWebkit.writeToClipboard(addr);
}
};
};
this.cancel = function() {
this.cancel = lodash.debounce(function() {
m.addClass(animationService.modalAnimated.slideOutRight);
if (isCordova) {
$scope.modalClosing = true;
$rootScope.modalOpened = false;
disableCloseModal();
$timeout(function() {
$scope.modalClosing = false;
$rootScope.$emit('Local/TxModal', null);
}, 300);
}, 350);
} else {
$rootScope.$emit('Local/TxModal', null);
}
};
}, 0, 1000);
});

View file

@ -1149,83 +1149,10 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
return this.alternativeIsoCode;
};
this.openNewTxModal = function(tx) {
this.openTxModal = function(tx) {
$rootScope.$emit('Local/TxModal', tx);
};
this.openTxModal = function(btx) {
$rootScope.modalOpened = true;
var self = this;
var fc = profileService.focusedClient;
var ModalInstanceCtrl = function($scope, $filter, $log, $modalInstance) {
$scope.btx = btx;
$scope.settings = walletSettings;
$scope.color = fc.backgroundColor;
$scope.copayerId = fc.credentials.copayerId;
$scope.isShared = fc.credentials.n > 1;
$scope.getAlternativeAmount = function() {
var satToBtc = 1 / 100000000;
fc.getFiatRate({
code: self.alternativeIsoCode,
ts: btx.time * 1000
}, function(err, res) {
if (err) {
$log.debug('Could not get historic rate');
return;
}
if (res && res.rate) {
var alternativeAmountBtc = (btx.amount * satToBtc).toFixed(8);
$scope.rateDate = res.fetchedOn;
$scope.rateStr = res.rate + ' ' + self.alternativeIsoCode;
$scope.alternativeAmountStr = $filter('noFractionNumber')(alternativeAmountBtc * res.rate, 2) + ' ' + self.alternativeIsoCode;
$scope.$apply();
}
});
};
$scope.getAmount = function(amount) {
return self.getAmount(amount);
};
$scope.getUnitName = function() {
return self.getUnitName();
};
$scope.getShortNetworkName = function() {
var n = fc.credentials.network;
return n.substring(0, 4);
};
$scope.copyToClipboard = function(addr) {
if (!addr) return;
self.copyToClipboard(addr);
};
$scope.cancel = lodash.debounce(function() {
$modalInstance.dismiss('cancel');
}, 0, 1000);
};
var modalInstance = $modal.open({
templateUrl: 'views/modals/tx-details.html',
windowClass: animationService.modalAnimated.slideRight,
controller: ModalInstanceCtrl,
});
var disableCloseModal = $rootScope.$on('closeModal', function() {
modalInstance.dismiss('cancel');
});
modalInstance.result.finally(function() {
$rootScope.modalOpened = false;
disableCloseModal();
var m = angular.element(document.getElementsByClassName('reveal-modal'));
m.addClass(animationService.modalAnimated.slideOutRight);
});
};
this.hasAction = function(actions, action) {
return actions.hasOwnProperty('create');
};

View file

@ -326,7 +326,6 @@ angular.module('copayApp.directives')
if (!isCordova) {
element.on('click', function(){
scope.someCtrlFn();
console.log('click real');
});
} else {
var trackingClick = false;