Wallet/src/js/controllers/preferencesBitpayCard.js

37 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-08-10 15:29:31 -03:00
'use strict';
angular.module('copayApp.controllers').controller('preferencesBitpayCardController',
2017-01-27 17:54:41 -03:00
function($scope, $state, $timeout, $ionicHistory, bitpayCardService, popupService, gettextCatalog, $log) {
2016-08-10 15:29:31 -03:00
2016-11-11 18:11:52 -05:00
$scope.remove = function(card) {
2016-11-14 16:58:54 -05:00
var msg = gettextCatalog.getString('Are you sure you would like to remove your BitPay Card ({{lastFourDigits}}) from this device?', {
lastFourDigits: card.lastFourDigits
});
2016-10-05 11:42:40 -03:00
popupService.showConfirm(null, msg, null, null, function(res) {
2017-01-27 17:54:41 -03:00
$log.info('Removing bitpay card:' + card.eid)
if (res)
remove(card.eid);
});
};
2017-01-27 17:54:41 -03:00
var remove = function(cardEid) {
bitpayCardService.remove(cardEid, function(err) {
if (err) {
return popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not remove card'));
}
2016-11-14 15:17:05 -03:00
$ionicHistory.clearHistory();
$timeout(function() {
2016-09-28 21:09:41 -03:00
$state.go('tabs.home');
}, 100);
2016-08-10 15:29:31 -03:00
});
};
$scope.$on("$ionicView.beforeEnter", function(event, data) {
2017-01-27 17:54:41 -03:00
bitpayCardService.getCards(function(err, data) {
if (err) return;
2017-01-27 17:54:41 -03:00
2016-11-11 18:11:52 -05:00
$scope.bitpayCards = data;
});
});
2016-08-10 15:29:31 -03:00
});