Add QR modal at address list and clean deprecated code

This commit is contained in:
Yemel Jardi 2014-07-18 11:23:45 -03:00
parent 372fb469c8
commit 0ffbd585f8
2 changed files with 34 additions and 36 deletions

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('AddressesController', angular.module('copayApp.controllers').controller('AddressesController',
function($scope, $rootScope, $timeout, controllerUtils) { function($scope, $rootScope, $timeout, $modal, controllerUtils) {
$scope.loading = false; $scope.loading = false;
var w = $rootScope.wallet; var w = $rootScope.wallet;
@ -16,8 +16,21 @@ angular.module('copayApp.controllers').controller('AddressesController',
}); });
}; };
$scope.selectAddress = function(addr) { $scope.openAddressModal = function(address) {
$scope.selectedAddr = addr; var ModalInstanceCtrl = function ($scope, $modalInstance, address) {
$scope.address = address;
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
};
$modal.open({
templateUrl: 'addressModal.html',
controller: ModalInstanceCtrl,
resolve: {
address: function() { return address; }
}
});
}; };
$rootScope.$watch('addrInfos', function() { $rootScope.$watch('addrInfos', function() {
@ -37,9 +50,7 @@ angular.module('copayApp.controllers').controller('AddressesController',
'owned': addrinfo.owned 'owned': addrinfo.owned
}); });
} }
$scope.selectedAddr = $scope.addresses[0];
$scope.addrWithFund = $rootScope.receivedFund ? $rootScope.receivedFund[1] : null;
$rootScope.receivedFund = null;
} }
} }
}); }
);

View File

@ -8,53 +8,40 @@
<div class="large-12 medium-12" ng-if="!!(addresses|removeEmpty).length"> <div class="large-12 medium-12" ng-if="!!(addresses|removeEmpty).length">
<div class="large-12 medium-12" ng-init="showAll=0"> <div class="large-12 medium-12" ng-init="showAll=0">
<ul> <ul>
<li class="panel radius db" ng-repeat="addr in addresses|removeEmpty|limitAddress:showAll" <li class="panel radius db" ng-repeat="addr in addresses|removeEmpty|limitAddress:showAll">
ng-click="selectAddress(addr)"
ng-class="{selected : addr.address == selectedAddr.address}">
<span><contact address="{{addr.address}}" tooltip-popup-delay="500" tooltip tooltip-placement="right"/></span> <span><contact address="{{addr.address}}" tooltip-popup-delay="500" tooltip tooltip-placement="right"/></span>
<small ng-if="addr.isChange">change</small> <small ng-if="addr.isChange">change</small>
<a href="#" ng-click="openAddressModal(addr)">Show QR</a>
<span class="right"> <span class="right">
<span ng-if="addrWithFund == addr.address"> <span ng-if="$root.updatingBalance">
<span ng-if="$root.updatingBalance"> <i class="fi-bitcoin-circle icon-rotate spinner"></i>
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
</span>
<span ng-if="!$root.updatingBalance">
{{$root.balanceByAddr[addr.address] || 0|noFractionNumber}} {{$root.unitName}}
</span>
</span> </span>
<span ng-if="addrWithFund != addr.address"> <span ng-if="!$root.updatingBalance">
{{addr.balance || 0|noFractionNumber}} {{$root.unitName}} {{addr.balance || 0|noFractionNumber}} {{$root.unitName}}
</span> </span>
</span> </span>
<a href="#" data-reveal-id="view-qr">Click Me For A Modal</a>
</li> </li>
</ul> </ul>
<a class="secondary radius" ng-click="showAll=!showAll" ng-show="(addresses|removeEmpty).length != (addresses|removeEmpty|limitAddress).length"> <a class="secondary radius" ng-click="showAll=!showAll" ng-show="(addresses|removeEmpty).length != (addresses|removeEmpty|limitAddress).length">
<span ng-if="!showAll">Show all</span> <span ng-if="!showAll">Show all</span>
<span ng-if="showAll">Show less</span> <span ng-if="showAll">Show less</span>
</a> </a>
</div> </div>
<div id="view-qr" class="reveal-modal" data-reveal> <script type="text/ng-template" id="addressModal.html">
<qrcode size="160" data="{{selectedAddr.address}}"></qrcode> <qrcode size="160" data="{{address.address}}"></qrcode>
<p class="m10t"> Address: {{address.address}}<br/>
<strong> <span ng-if="$root.updatingBalance">
<span ng-if="addrWithFund == selectedAddr.address">
<span ng-if="$root.updatingBalance">
<i class="fi-bitcoin-circle icon-rotate spinner"></i> <i class="fi-bitcoin-circle icon-rotate spinner"></i>
</span> </span>
<span ng-if="!$root.updatingBalance">{{balanceByAddr[selectedAddr.address] || 0 | noFractionNumber}} <span ng-if="!$root.updatingBalance">
</span> Balance: {{address.balance || 0|noFractionNumber}} {{$root.unitName}}
</span> </span>
<span ng-if="addrWithFund != selectedAddr.address"> <a class="close-reveal-modal" ng-click="cancel()">&#215;</a>
{{selectedAddr.address}}<br/> </script>
{{selectedAddr.balance || 0|noFractionNumber}} {{$root.unitName}}
</span>
</strong>
</p>
</div>
</div> </div>
</div> </div>
</div> </div>