Input type number. Fix empty gift cards list

This commit is contained in:
Gustavo Maximiliano Cortez 2016-06-14 00:36:41 -03:00
commit 210bbc36cc
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
6 changed files with 33 additions and 45 deletions

View file

@ -27,7 +27,7 @@
<div ng-init="amazon.init()">
<div class="box-notification text-center size-12 text-warning m10t" ng-show="amazon.sandbox">
<div class="box-notification text-center size-12 text-warning" ng-show="amazon.sandbox">
<i class="fi-info"></i>
Sandbox version. Only for testing purpose
</div>

View file

@ -27,7 +27,7 @@
</div>
</div>
<div class="text-center">
<div class="text-center m20b">
<img src="img/a_generic.jpg" alt="Amazon.com Gift Card" width="200">
<div class="text-left size-12 m10t">
Use your Amazon.com Gift Card* to shop from a huge selection of books, electronics, music, movies, software, apparel, toys, and more.
@ -38,10 +38,16 @@
ng-submit="buy.createTx()"
novalidate>
<div class="m20v text-center">
<a class="amazon-select-amount" ng-click="buy.setAmount()">-</a>
<span class="amazon-amount">$ {{fiat}}</span>
<a class="amazon-select-amount" ng-click="buy.setAmount(1)">+</a>
<label>
Amount
</label>
<div class="input">
<input type="number" id="fiat"
name="fiat" ng-attr-placeholder="{{'Amount in USD'}}"
min="0.01" max="2000"
ng-model="fiat" autocomplete="off" required>
<a class="postfix button black">USD</a>
</div>
<div

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('amazonController',
function($scope, $timeout, $ionicModal, configService, amazonService) {
function($scope, $timeout, $ionicModal, lodash, configService, amazonService) {
this.init = function() {
var self = this;
@ -13,7 +13,7 @@ angular.module('copayApp.controllers').controller('amazonController',
self.error = err;
return;
}
self.giftCards = gcds;
self.giftCards = lodash.isEmpty(gcds) ? null : gcds;
$timeout(function() {
$scope.$digest();
});
@ -21,6 +21,7 @@ angular.module('copayApp.controllers').controller('amazonController',
};
this.openCardModal = function(card) {
var self = this;
$scope.card = card;
$ionicModal.fromTemplateUrl('views/modals/amazon-card-details.html', {
@ -29,5 +30,9 @@ angular.module('copayApp.controllers').controller('amazonController',
$scope.amazonCardDetailsModal = modal;
$scope.amazonCardDetailsModal.show();
});
$scope.$on('UpdateAmazonList', function(event) {
self.init();
});
};
});

View file

@ -5,10 +5,10 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
var self = this;
var client;
var minimumAmount = 5;
var stepAmount = 1;
var multiplierAmount = 5;
var maximumAmount = 500;
var limitsAllowed = {
min: 0.01,
max: 2000
};
var handleEncryptedWallet = function(client, cb) {
if (!walletService.isEncrypted(client)) return cb();
@ -19,7 +19,6 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
};
this.init = function() {
$scope.fiat = minimumAmount;
var network = configService.getSync().amazon.testnet ? 'testnet' : 'livenet';
amazonService.setCredentials(network);
amazonService.healthCheckRequest();
@ -35,6 +34,14 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
}
};
this.checkLimits = function() {
console.log('[buyAmazon.js:37]'); //TODO
if ($scope.fiat && $scope.fiat >= limitsAllowed.min && $scope.fiat <= limitsAllowed.max)
return true;
else
return false;
};
$scope.openWalletsModal = function(wallets) {
self.error = null;
@ -59,16 +66,6 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
});
};
this.setAmount = function(plus) {
if (plus && $scope.fiat < maximumAmount ) {
stepAmount = stepAmount + 1;
$scope.fiat = stepAmount * multiplierAmount;
} else if (!plus && $scope.fiat > minimumAmount) {
stepAmount = stepAmount - 1;
$scope.fiat = stepAmount * multiplierAmount;
}
};
this.createTx = function() {
self.error = null;
self.errorInfo = null;

View file

@ -23,6 +23,7 @@ angular.module('copayApp.controllers').controller('amazonCardDetailsController',
$scope.remove = function() {
amazonService.saveGiftCard($scope.card, {remove: true}, function(err) {
$scope.$emit('UpdateAmazonList');
$scope.cancel();
});
};
@ -43,6 +44,7 @@ angular.module('copayApp.controllers').controller('amazonCardDetailsController',
$scope.error = err;
return;
}
$scope.$emit('UpdateAmazonList');
$scope.card = data;
$timeout(function() {
$scope.$digest();

View file

@ -1,26 +1,4 @@
.amazon-select-amount {
display: inline-block;
padding: 3px 15px;
background-color: #4B6178;
color: #ffffff;
border-radius: 5px;
margin: 0 5px;
&:hover {
color: #ffffff;
}
}
.amazon-amount {
display: inline-block;
background-color: #E4E8EC;
padding: 3px 10px;
width: 80px;
text-align: center;
border: 1px solid #ccc;
border-radius: 5px;
}
ol.amazon-list {
list-style: decimal !important;
}