2016-08-10 15:29:31 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
angular.module('copayApp.controllers').controller('preferencesBitpayCardController',
|
2016-10-07 15:51:15 -03:00
|
|
|
function($scope, $state, $timeout, $ionicHistory, bitpayCardService, popupService, gettextCatalog) {
|
2016-08-10 15:29:31 -03:00
|
|
|
|
2016-11-11 18:11:52 -05:00
|
|
|
$scope.remove = function(card) {
|
2016-10-07 15:51:15 -03:00
|
|
|
var msg = gettextCatalog.getString('Are you sure you would like to remove your BitPay Card account from this device?');
|
2016-10-05 11:42:40 -03:00
|
|
|
popupService.showConfirm(null, msg, null, null, function(res) {
|
2016-11-11 18:11:52 -05:00
|
|
|
if (res) remove(card);
|
2016-09-06 15:14:07 -03:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2016-11-11 18:11:52 -05:00
|
|
|
var remove = function(card) {
|
2016-11-21 15:10:59 -05:00
|
|
|
bitpayCardService.remove(card, function(err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
$scope.error = gettextCatalog.getString('Could not remove card');
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-11-14 15:17:05 -03:00
|
|
|
$ionicHistory.clearHistory();
|
2016-09-06 15:14:07 -03:00
|
|
|
$timeout(function() {
|
2016-09-28 21:09:41 -03:00
|
|
|
$state.go('tabs.home');
|
2016-09-06 15:14:07 -03:00
|
|
|
}, 100);
|
2016-08-10 15:29:31 -03:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2016-10-07 15:51:15 -03:00
|
|
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
|
|
|
|
bitpayCardService.getBitpayDebitCards(function(err, data) {
|
|
|
|
|
if (err) return;
|
2016-11-11 18:11:52 -05:00
|
|
|
$scope.bitpayCards = data;
|
2016-10-07 15:51:15 -03:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2016-08-10 15:29:31 -03:00
|
|
|
});
|