From c215b3c15e23370d3c609036f69f63c2bdef3c8d Mon Sep 17 00:00:00 2001
From: Gustavo Maximiliano Cortez
Date: Sun, 30 Nov 2014 18:28:55 -0300
Subject: [PATCH] Remove filter noFractionNumber from views. Fix conversionRate
from send.
---
js/controllers/history.js | 9 ++++-----
js/controllers/send.js | 11 +++++++++--
views/history.html | 4 ++--
views/includes/transaction.html | 6 +++---
views/send.html | 10 +++++-----
5 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/js/controllers/history.js b/js/controllers/history.js
index 8a592f370..81dd8bcef 100644
--- a/js/controllers/history.js
+++ b/js/controllers/history.js
@@ -2,7 +2,7 @@
var bitcore = require('bitcore');
angular.module('copayApp.controllers').controller('HistoryController',
- function($scope, $rootScope) {
+ function($scope, $rootScope, $filter) {
var w = $rootScope.wallet;
$rootScope.title = 'History';
@@ -138,6 +138,7 @@ angular.module('copayApp.controllers').controller('HistoryController',
_.each(items, function(tx) {
tx.ts = tx.minedTs || tx.sentTs;
tx.rateTs = Math.floor((tx.ts || now) / 1000);
+ tx.amount = $filter('noFractionNumber')(tx.amount);
});
var index = _.indexBy(items, 'rateTs');
@@ -145,7 +146,8 @@ angular.module('copayApp.controllers').controller('HistoryController',
if (!err && res) {
_.each(res, function(r) {
var tx = index[r.ts];
- tx.alternativeAmount = r.rate != null ? tx.amountSat * rateService.SAT_TO_BTC * r.rate : null;
+ tx.alternativeAmount = $filter('noFractionNumber')(
+ (r.rate != null ? tx.amountSat * rateService.SAT_TO_BTC * r.rate : null);
});
setTimeout(function() {
$scope.$digest();
@@ -153,13 +155,10 @@ angular.module('copayApp.controllers').controller('HistoryController',
}
});
-
-
$scope.blockchain_txs = w.cached_txs = items;
$scope.nbPages = res.nbPages;
$scope.totalItems = res.nbItems;
-
$scope.loading = false;
setTimeout(function() {
$scope.$digest();
diff --git a/js/controllers/send.js b/js/controllers/send.js
index 2dfb47571..01437ee40 100644
--- a/js/controllers/send.js
+++ b/js/controllers/send.js
@@ -3,7 +3,7 @@ var bitcore = require('bitcore');
var preconditions = require('preconditions').singleton();
angular.module('copayApp.controllers').controller('SendController',
- function($scope, $rootScope, $window, $timeout, $modal, isMobile, notification, rateService) {
+ function($scope, $rootScope, $window, $timeout, $modal, $filter, isMobile, notification, rateService) {
var w = $rootScope.wallet;
preconditions.checkState(w);
preconditions.checkState(w.settings.unitToSatoshi);
@@ -53,6 +53,11 @@ angular.module('copayApp.controllers').controller('SendController',
var domain = /^(?:https?)?:\/\/([^\/:]+).*$/.exec(url)[1];
tx.merchant.domain = domain;
}
+ if (tx.outs) {
+ _.each(tx.outs, function(out) {
+ out.value = $filter('noFractionNumber')(out.value);
+ });
+ }
});
$scope.txps = res.txs;
};
@@ -115,7 +120,9 @@ angular.module('copayApp.controllers').controller('SendController',
var pp = $rootScope.pendingPayment;
$scope.address = pp.address + '';
var amount = pp.data.amount / w.settings.unitToSatoshi * 100000000;
- $scope.amount = amount;
+ $scope.amount = $filter('noFractionNumber')(amount);
+ var alternativeAmount = rateService.toFiat((amount + defaultFee) * unitToSatoshi, alternativeIsoCode);
+ $scope.alternativeAmountPayPro = $filter('noFractionNumber')(alternativeAmount, 2);
$scope.commentText = pp.data.message;
}
diff --git a/views/history.html b/views/history.html
index b34e01940..178dce042 100644
--- a/views/history.html
+++ b/views/history.html
@@ -45,8 +45,8 @@
'text-primary' : btx.action == 'received',
'text-warning': btx.action == 'sent',
'text-gray': btx.action == 'moved'}">
- {{btx.amount| noFractionNumber}} {{$root.wallet.settings.unitName}}
- {{btx.alternativeAmount| noFractionNumber}} {{$root.wallet.settings.alternativeIsoCode}}
+ {{btx.amount}} {{$root.wallet.settings.unitName}}
+ {{btx.alternativeAmount}} {{$root.wallet.settings.alternativeIsoCode}}
diff --git a/views/includes/transaction.html b/views/includes/transaction.html
index aca03ead0..8eca6d50c 100644
--- a/views/includes/transaction.html
+++ b/views/includes/transaction.html
@@ -9,9 +9,9 @@
- {{out.value |noFractionNumber}} {{$root.wallet.settings.unitName}}
+ {{out.value}} {{$root.wallet.settings.unitName}}
- {{out.alternativeAmount|noFractionNumber}} {{out.alternativeIsoCode}}
+ {{out.alternativeAmount}} {{out.alternativeIsoCode}}
@@ -106,7 +106,7 @@
{{tx.missingSignatures}} signatures missing
- Fee: {{tx.fee|noFractionNumber}} {{$root.wallet.settings.unitName}}
+ Fee: {{tx.fee}} {{$root.wallet.settings.unitName}}
Proposal ID: {{tx.ntxid}}
diff --git a/views/send.html b/views/send.html
index 1c20a48b6..71593ac12 100644
--- a/views/send.html
+++ b/views/send.html
@@ -136,13 +136,13 @@
- {{amount + defaultFee |noFractionNumber}} {{$root.wallet.settings.unitName}}
+ {{amount + defaultFee}} {{$root.wallet.settings.unitName}}
- {{ rateService.toFiat((amount + defaultFee) * unitToSatoshi, alternativeIsoCode) | noFractionNumber: 2 }} {{ alternativeIsoCode }}
+ {{ alternativeAmountPayPro }} {{ alternativeIsoCode }}
(Including fee of
- {{defaultFee|noFractionNumber}}
+ {{defaultFee}}
{{$root.wallet.settings.unitName}})
@@ -185,10 +185,10 @@
-
+
- 1 BTC = {{alternativeConversionRate|noFractionNumber:2}} {{alternativeIsoCode}}
+ 1 BTC = {{$root.wallet.balanceInfo.alternativeConversionRate}} {{alternativeIsoCode}}