Fix location and iconName

This commit is contained in:
Gustavo Maximiliano Cortez 2017-07-13 10:23:42 -03:00
parent a9edb90fbe
commit 7a5d32a269
No known key found for this signature in database
GPG Key ID: 15EDAD8D9F2EB1AF
3 changed files with 27 additions and 28 deletions

View File

@ -62,8 +62,6 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
self.bitpayCardTransactionHistoryCompleted = null;
self.bitpayCardTransactionHistoryConfirming = null;
self.bitpayCardTransactionHistoryPreAuth = null;
self.underpaidInvoiceInList = null;
self.delayedInvoiceInList = null;
self.balance = null;
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get transactions'));
return;
@ -72,16 +70,6 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
setGetStarted(history, function() {
var txs = lodash.clone(history.txs);
for (var i = 0; i < txs.length; i++) {
txs[i].icon = _getIconName(txs[i]);
txs[i].desc = _processDescription(txs[i]);
if (txs[i].merchant.city && txs[i].merchant.state) {
txs[i].merchant.location = txs[i].merchant.city + ', ' + txs[i].merchant.state;
} else {
txs[i].merchant.location = txs[i].merchant.city || txs[i].merchant.state || '';
}
}
self.bitpayCardTransactionHistoryConfirming = bitpayCardService.filterTransactions('confirming', txs);
self.bitpayCardTransactionHistoryCompleted = bitpayCardService.filterTransactions('completed', txs);
@ -110,19 +98,6 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
});
};
var _getIconName = function(tx) {
var icon = tx.mcc || tx.category || null;
if (!icon || bitpayCardService.iconMap[icon] == undefined) return 'default';
return bitpayCardService.iconMap[icon];
};
var _processDescription = function(tx) {
if (lodash.isArray(tx.description)) {
return tx.description[0];
}
return tx.description;
};
$scope.createdWithinPastDay = function(tx) {
var result = false;
if (tx.date) {

View File

@ -38,6 +38,27 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log,
return tx;
};
var _getIconName = function(tx) {
var icon = tx.mcc || tx.category || null;
if (!icon || root.iconMap[icon] == undefined) return 'default';
return root.iconMap[icon];
};
var _processDescription = function(tx) {
if (lodash.isArray(tx.description)) {
return tx.description[0];
}
return tx.description;
};
var _processLocation = function(tx) {
if (tx.merchant.city && tx.merchant.state) {
return tx.merchant.city + ', ' + tx.merchant.state;
} else {
return tx.merchant.city || tx.merchant.state || '';
}
};
var _fromTransaction = function(txn, runningBalance) {
var dateTime = _buildDate(txn.date, txn.time);
var merchant = _lowercaseMerchant(txn.merchant);
@ -102,6 +123,11 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log,
}
}
}
for (var i = 0; i < activityList.length; i++) {
activityList[i].icon = _getIconName(activityList[i]);
activityList[i].desc = _processDescription(activityList[i]);
activityList[i].merchant['location'] = _processLocation(activityList[i]);
}
return activityList;
};

View File

@ -8,9 +8,7 @@
<div class="tx-title">
<div class="ellipsis">
<div class="tx-message ellipsis">{{tx.merchant.name || 'Unknown Merchant'}}</div>
<div class="tx-location ellipsis" ng-show="tx.merchant.city && tx.merchant.state">
{{tx.merchant.location}}
</div>
<div class="tx-location ellipsis">{{tx.merchant.location}}</div>
<div ng-show="tx.pending && tx.transactionId" class="size-12 tx-amount--pending">
<div ng-click="bitpayCard.viewOnBlockchain(tx.transactionId)">View Confirmation Status</div>
</div>