From 7a5d32a2692292a1f80decddae1dd464f609f3e9 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Thu, 13 Jul 2017 10:23:42 -0300 Subject: [PATCH] Fix location and iconName --- src/js/controllers/bitpayCard.js | 25 ------------------------- src/js/services/bitpayCardService.js | 26 ++++++++++++++++++++++++++ www/views/includes/cardActivity.html | 4 +--- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/js/controllers/bitpayCard.js b/src/js/controllers/bitpayCard.js index c200bbc3a..55e2b14aa 100644 --- a/src/js/controllers/bitpayCard.js +++ b/src/js/controllers/bitpayCard.js @@ -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) { diff --git a/src/js/services/bitpayCardService.js b/src/js/services/bitpayCardService.js index 643ddb97c..ea0965b2a 100644 --- a/src/js/services/bitpayCardService.js +++ b/src/js/services/bitpayCardService.js @@ -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; }; diff --git a/www/views/includes/cardActivity.html b/www/views/includes/cardActivity.html index 406cf311c..a5562bee7 100644 --- a/www/views/includes/cardActivity.html +++ b/www/views/includes/cardActivity.html @@ -8,9 +8,7 @@
{{tx.merchant.name || 'Unknown Merchant'}}
-
- {{tx.merchant.location}} -
+
{{tx.merchant.location}}
View Confirmation Status