Improvement - 322 - "Search transactions" empty results case

This commit is contained in:
Sebastiaan Pasma 2018-05-15 15:07:31 +02:00
commit 17ad7e8e74
2 changed files with 40 additions and 1 deletions

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('searchController', function($scope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, $ionicScrollDelegate, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService) {
angular.module('copayApp.controllers').controller('searchController', function($scope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, $ionicScrollDelegate, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService, externalLinkService) {
var HISTORY_SHOW_LIMIT = 10;
var currentTxHistoryPage = 0;
@ -21,6 +21,8 @@ angular.module('copayApp.controllers').controller('searchController', function($
function filter(search) {
$scope.filteredTxHistory = [];
$scope.searchTermIsAddress = false;
$scope.searchTermIsTxId = false;
function computeSearchableString(tx) {
var addrbook = '';
@ -50,8 +52,15 @@ angular.module('copayApp.controllers').controller('searchController', function($
return lodash.includes(tx.searcheableString, search.toLowerCase());
});
if (search && (search.indexOf('bitcoincash:') >= 0 || search[0] === 'C' || search[0] === 'H' || search[0] === 'p' || search[0] === 'q') && search.replace('bitcoincash:', '').length === 42) {
$scope.searchTermIsAddress = true;
} else if (search && search.lengh === 64) {
$scope.searchTermIsTxId = true;
}
if ($scope.filteredTxHistory.length > HISTORY_SHOW_LIMIT) $scope.txHistoryShowMore = true;
else $scope.txHistoryShowMore = false;
return $scope.filteredTxHistory;
};
@ -77,4 +86,14 @@ angular.module('copayApp.controllers').controller('searchController', function($
$scope.txHistoryShowMore = $scope.filteredTxHistory.length > $scope.txHistorySearchResults.length;
};
$scope.searchOnBlockchain = function(searchTerm) {
var url = 'https://explorer.bitcoin.com/bch/search/' + searchTerm;
var optIn = true;
var title = null;
var message = gettextCatalog.getString('Search on Explorer.Bitcoin.com');
var okText = gettextCatalog.getString('Open Explorer');
var cancelText = gettextCatalog.getString('Go Back');
externalLinkService.open(url, optIn, title, message, okText, cancelText);
};
});

View file

@ -18,6 +18,26 @@
</div>
<div class="list">
<div class="wallet-details__list" ng-show="filteredTxHistory.length === 0 && search != ''">
<div class="text-gray text-center p10t">
{{'No results found'|translate}}
</div>
<div class="p10t text-center">
<button ng-if="searchTermIsAddress" class="button button-small button-primary" ng-click="searchOnBlockchain(search)" translate>
{{'Show Address on Blockchain'|translate}}
</button>
</div>
<div class="p10t text-center">
<button ng-if="searchTermIsTxId" class="button button-small button-primary" ng-click="searchOnBlockchain(search)" translate>
{{'Show Transaction on Blockchain'|translate}}
</button>
</div>
<div class="p10t text-center">
<button ng-if="!searchTermIsAddress && !searchTermIsTxId" class="button button-small button-primary" ng-click="searchOnBlockchain(search)" translate>
{{'Search on Blockchain'|translate}}
</button>
</div>
</div>
<div class="wallet-details__list" ng-show="txHistory[0]">
<div ng-repeat="btx in txHistorySearchResults track by $index" ng-click="openTx(btx)">
<span ng-include="'views/includes/walletHistory.html'"></span>