From e5fd3c38f427d801ea4a4e6d09f9125a073eae07 Mon Sep 17 00:00:00 2001 From: Yemel Jardi Date: Thu, 31 Jul 2014 14:06:55 -0300 Subject: [PATCH 1/2] Fix open external in new tab and fix typo --- js/controllers/addresses.js | 7 ------- js/directives.js | 32 +++++++++++++++++++------------- views/modals/qr-address.html | 4 ++-- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/js/controllers/addresses.js b/js/controllers/addresses.js index 907bfc7ef..c81a10fc3 100644 --- a/js/controllers/addresses.js +++ b/js/controllers/addresses.js @@ -20,13 +20,6 @@ angular.module('copayApp.controllers').controller('AddressesController', var ModalInstanceCtrl = function ($scope, $modalInstance, address) { $scope.address = address; - $scope.openExternal = function(address) { - var url = 'bitcoin:' + address; - if (window.cordova) return window.open(url, '_blank'); - - window.location = url; - } - $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; diff --git a/js/directives.js b/js/directives.js index b1d6c3b35..3fac18f34 100644 --- a/js/directives.js +++ b/js/directives.js @@ -198,24 +198,31 @@ angular.module('copayApp.directives') } }; }) -// From https://gist.github.com/asafge/7430497 -.directive('ngReallyClick', [ - - function() { + .directive('openExternal', function() { return { restrict: 'A', link: function(scope, element, attrs) { element.bind('click', function() { - var message = attrs.ngReallyMessage; - if (message && confirm(message)) { - scope.$apply(attrs.ngReallyClick); - } + window.open('bitcoin:'+attrs.address, '_blank'); }); } } - } -]) - + }) + // From https://gist.github.com/asafge/7430497 + .directive('ngReallyClick', [function() { + return { + restrict: 'A', + link: function(scope, element, attrs) { + element.bind('click', function() { + var message = attrs.ngReallyMessage; + if (message && confirm(message)) { + scope.$apply(attrs.ngReallyClick); + } + }); + } + } + } + ]) .directive('match', function () { return { require: 'ngModel', @@ -231,5 +238,4 @@ angular.module('copayApp.directives') }); } }; - }) -; + }); diff --git a/views/modals/qr-address.html b/views/modals/qr-address.html index ca80055e5..7919d1454 100644 --- a/views/modals/qr-address.html +++ b/views/modals/qr-address.html @@ -9,8 +9,8 @@ {{address.balance || 0|noFractionNumber}} {{$root.unitName}}
- -   Open in external aplication + +   Open in external application
From 59a03c1f2548751bdc7f8354226b5540a377bb3a Mon Sep 17 00:00:00 2001 From: Yemel Jardi Date: Thu, 31 Jul 2014 11:55:53 -0300 Subject: [PATCH 2/2] Change available balance to locked --- js/services/controllerUtils.js | 4 ++++ test/unit/services/servicesSpec.js | 4 ++++ views/includes/sidebar-mobile.html | 8 ++++---- views/includes/sidebar.html | 8 ++++---- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js index 7bae6bdce..ea670355b 100644 --- a/js/services/controllerUtils.js +++ b/js/services/controllerUtils.js @@ -212,6 +212,10 @@ angular.module('copayApp.services') $rootScope.totalBalanceBTC = (balanceSat / COIN); $rootScope.availableBalance = safeBalanceSat * satToUnit; $rootScope.availableBalanceBTC = (safeBalanceSat / COIN); + + $rootScope.lockedBalance = (balanceSat - safeBalanceSat) * satToUnit; + $rootScope.lockedBalanceBTC = (balanceSat - safeBalanceSat) / COIN; + var balanceByAddr = {}; for (var ii in balanceByAddrSat) { balanceByAddr[ii] = balanceByAddrSat[ii] * satToUnit; diff --git a/test/unit/services/servicesSpec.js b/test/unit/services/servicesSpec.js index 0358d1b74..aa7f7e2c8 100644 --- a/test/unit/services/servicesSpec.js +++ b/test/unit/services/servicesSpec.js @@ -93,8 +93,12 @@ describe("Unit: controllerUtils", function() { controllerUtils.updateBalance(function() { expect($rootScope.totalBalanceBTC).to.be.equal(1.00000001); expect($rootScope.availableBalanceBTC).to.be.equal(0.90000002); + expect($rootScope.lockedBalanceBTC).to.be.equal(0.09999999); + expect($rootScope.totalBalance).to.be.equal(1000000.01); expect($rootScope.availableBalance).to.be.equal(900000.02); + expect($rootScope.lockedBalance).to.be.equal(99999.99); + expect($rootScope.addrInfos).not.to.equal(null); expect($rootScope.addrInfos[0].address).to.equal(Waddr); }); diff --git a/views/includes/sidebar-mobile.html b/views/includes/sidebar-mobile.html index 5b634fe1a..506fcc54a 100644 --- a/views/includes/sidebar-mobile.html +++ b/views/includes/sidebar-mobile.html @@ -24,16 +24,16 @@
- Available + Locked {{availableBalance || 0|noFractionNumber}} {{$root.unitName}} - + tooltip-placement="bottom">{{lockedBalance || 0|noFractionNumber}} {{$root.unitName}} +  
diff --git a/views/includes/sidebar.html b/views/includes/sidebar.html index ae82b4c46..aec0fd242 100644 --- a/views/includes/sidebar.html +++ b/views/includes/sidebar.html @@ -32,16 +32,16 @@ |noFractionNumber}} {{$root.unitName}}
- Available + Locked   {{availableBalance || 0|noFractionNumber}} {{$root.unitName}} - + tooltip-placement="bottom">{{lockedBalance || 0|noFractionNumber}} {{$root.unitName}} +