Ionic modals. Fix select wallet to buy/sell
This commit is contained in:
parent
cd87d9628d
commit
2b60bc3066
6 changed files with 243 additions and 298 deletions
|
|
@ -1,9 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('amazonController',
|
||||
function($rootScope, $scope, $timeout, $modal, profileService, configService, amazonService, animationService, lodash) {
|
||||
|
||||
window.ignoreMobilePause = true;
|
||||
function($scope, $timeout, $ionicModal, configService, amazonService) {
|
||||
|
||||
this.init = function() {
|
||||
var self = this;
|
||||
|
|
@ -21,90 +19,15 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
this.openCardModal = function(card) {
|
||||
$rootScope.modalOpened = true;
|
||||
var self = this;
|
||||
var fc = profileService.focusedClient;
|
||||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||
$scope.card = card;
|
||||
$scope.card = card;
|
||||
|
||||
$scope.cancelGiftCard = function() {
|
||||
$scope.refresh = true;
|
||||
var dataSrc = {
|
||||
creationRequestId: $scope.card.creationRequestId,
|
||||
gcId: $scope.card.gcId,
|
||||
bitpayInvoiceId: $scope.card.bitpayInvoiceId,
|
||||
bitpayInvoiceUrl: $scope.card.bitpayInvoiceUrl,
|
||||
date: $scope.card.date
|
||||
};
|
||||
$scope.loading = true;
|
||||
amazonService.cancelGiftCard(dataSrc, function(err, data) {
|
||||
$scope.loading = null;
|
||||
if (err || data.status != 'SUCCESS') {
|
||||
$scope.error = err || data.status;
|
||||
return;
|
||||
}
|
||||
$scope.refreshGiftCard();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.remove = function() {
|
||||
amazonService.saveGiftCard($scope.card, {remove: true}, function(err) {
|
||||
$modalInstance.close(true);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.refreshGiftCard = function() {
|
||||
$scope.refresh = true;
|
||||
var dataSrc = {
|
||||
creationRequestId: $scope.card.creationRequestId,
|
||||
amount: $scope.card.cardInfo.value.amount,
|
||||
currencyCode: $scope.card.cardInfo.value.currencyCode,
|
||||
bitpayInvoiceId: $scope.card.bitpayInvoiceId,
|
||||
bitpayInvoiceUrl: $scope.card.bitpayInvoiceUrl,
|
||||
date: $scope.card.date
|
||||
};
|
||||
$scope.loading = true;
|
||||
amazonService.createGiftCard(dataSrc, function(err, data) {
|
||||
$scope.loading = null;
|
||||
if (err) {
|
||||
$scope.error = err;
|
||||
return;
|
||||
}
|
||||
$scope.card = data;
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = lodash.debounce(function() {
|
||||
$modalInstance.close($scope.refresh);
|
||||
}, 0, 1000);
|
||||
|
||||
};
|
||||
|
||||
var modalInstance = $modal.open({
|
||||
templateUrl: 'views/modals/amazon-card-details.html',
|
||||
windowClass: animationService.modalAnimated.slideRight,
|
||||
controller: ModalInstanceCtrl,
|
||||
$ionicModal.fromTemplateUrl('views/modals/amazon-card-details.html', {
|
||||
scope: $scope
|
||||
}).then(function(modal) {
|
||||
$scope.amazonCardDetailsModal = modal;
|
||||
$scope.amazonCardDetailsModal.show();
|
||||
});
|
||||
|
||||
var disableCloseModal = $rootScope.$on('closeModal', function() {
|
||||
modalInstance.close($scope.refresh);
|
||||
});
|
||||
|
||||
modalInstance.result.finally(function() {
|
||||
$rootScope.modalOpened = false;
|
||||
disableCloseModal();
|
||||
var m = angular.element(document.getElementsByClassName('reveal-modal'));
|
||||
m.addClass(animationService.modalAnimated.slideOutRight);
|
||||
});
|
||||
|
||||
modalInstance.result.then(function(refresh) {
|
||||
if (refresh) self.init();
|
||||
}, function() {});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue