show more in search box
This commit is contained in:
parent
9e439e8543
commit
aa71a34dec
2 changed files with 40 additions and 22 deletions
|
|
@ -280,11 +280,17 @@
|
||||||
|
|
||||||
<div class="m20t text-center">
|
<div class="m20t text-center">
|
||||||
<a class="text-gray size-12"
|
<a class="text-gray size-12"
|
||||||
ng-show="index.historyShowMore"
|
ng-show="index.historyShowMore && !index.isSearching"
|
||||||
ng-click="index.showMore()">
|
ng-click="index.showMore()" >
|
||||||
<span translate>Show more</span> ({{index.completeHistory.length - index.txHistory.length}})
|
{{index.completeHistory.length - index.txHistory.length}}<span translate>more</span>
|
||||||
<i class="icon-arrow-down4"></i>
|
<i class="icon-arrow-down4"></i>
|
||||||
</a>
|
</a>
|
||||||
|
<a class="text-gray size-12"
|
||||||
|
ng-show="index.historyShowMore && index.isSearching"
|
||||||
|
ng-click="index.showMore()">
|
||||||
|
{{index.result.length - index.txHistoryToList.length}} <span translate>more</span>
|
||||||
|
<i class="icon-arrow-down4"></i>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -896,8 +896,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
self.completeHistory = newHistory;
|
self.completeHistory = newHistory;
|
||||||
self.setCompactTxHistory();
|
self.setCompactTxHistory();
|
||||||
self.txHistory = newHistory.slice(0, self.historyShowLimit);
|
self.txHistory = newHistory.slice(0, self.historyShowLimit);
|
||||||
self.historyShowMore = newHistory.length > self.historyShowLimit;
|
|
||||||
self.txHistoryToList = self.txHistory;
|
self.txHistoryToList = self.txHistory;
|
||||||
|
self.historyShowMore = newHistory.length > self.historyShowLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
return storageService.setTxHistory(JSON.stringify(newHistory), walletId, function() {
|
return storageService.setTxHistory(JSON.stringify(newHistory), walletId, function() {
|
||||||
|
|
@ -910,27 +910,36 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
}
|
}
|
||||||
|
|
||||||
self.showMore = function() {
|
self.showMore = function() {
|
||||||
$timeout(function() {
|
if (self.isSearching) {
|
||||||
self.txHistory = self.completeHistory.slice(0, self.nextTxHistory);
|
$timeout(function() {
|
||||||
self.txHistoryToList = self.txHistory;
|
self.txHistoryToList = self.result.slice(0, self.nextTxHistory);
|
||||||
$log.debug('Total txs: ', self.txHistory.length + '/' + self.completeHistory.length);
|
$log.debug('Total txs: ', self.txHistoryToList.length + '/' + self.result.length);
|
||||||
self.nextTxHistory += self.historyShowMoreLimit;
|
self.nextTxHistory += self.historyShowMoreLimit;
|
||||||
if (self.txHistory.length >= self.completeHistory.length)
|
if (self.txHistoryToList.length >= self.result.length)
|
||||||
self.historyShowMore = false;
|
self.historyShowMore = false;
|
||||||
}, 100);
|
}, 100);
|
||||||
|
} else {
|
||||||
|
$timeout(function() {
|
||||||
|
self.txHistory = self.completeHistory.slice(0, self.nextTxHistory);
|
||||||
|
self.txHistoryToList = self.txHistory;
|
||||||
|
$log.debug('Total txs: ', self.txHistory.length + '/' + self.completeHistory.length);
|
||||||
|
self.nextTxHistory += self.historyShowMoreLimit;
|
||||||
|
if (self.txHistory.length >= self.completeHistory.length)
|
||||||
|
self.historyShowMore = false;
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.startSearch = function(){
|
self.startSearch = function(){
|
||||||
self.isSearching = true;
|
self.isSearching = true;
|
||||||
self.txHistoryToList = [];
|
self.txHistoryToList = [];
|
||||||
if(self.historyShowShowAll) self.txHistory = self.completeHistory;
|
self.historyShowMore = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.cancelSearch = function(){
|
self.cancelSearch = function(){
|
||||||
self.isSearching = false;
|
self.isSearching = false;
|
||||||
if(self.txHistory.length > self.historyShowLimit)
|
self.txHistoryToList = self.completeHistory.slice(0, self.historyShowLimit);
|
||||||
self.txHistoryToList = self.txHistory.slice(0, self.historyShowLimit);
|
self.historyShowMore = self.completeHistory.length > self.historyShowLimit;
|
||||||
else self.txHistoryToList = self.txHistory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.updateSearchInput = function(search){
|
self.updateSearchInput = function(search){
|
||||||
|
|
@ -943,7 +952,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
self.throttleSearch = lodash.throttle(function() {
|
self.throttleSearch = lodash.throttle(function() {
|
||||||
|
|
||||||
function filter(search) {
|
function filter(search) {
|
||||||
var result = [];
|
self.result = [];
|
||||||
function formatDate(date) {
|
function formatDate(date) {
|
||||||
var day = ('0' + date.getDate()).slice(-2).toString();
|
var day = ('0' + date.getDate()).slice(-2).toString();
|
||||||
var month = ('0' + (date.getMonth() + 1)).slice(-2).toString();
|
var month = ('0' + (date.getMonth() + 1)).slice(-2).toString();
|
||||||
|
|
@ -953,7 +962,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
|
|
||||||
if (lodash.isEmpty(search)) return;
|
if (lodash.isEmpty(search)) return;
|
||||||
|
|
||||||
result = lodash.filter(self.txHistory, function(tx) {
|
self.result = lodash.filter(self.completeHistory, function(tx) {
|
||||||
return lodash.includes(tx.amountStr, search) ||
|
return lodash.includes(tx.amountStr, search) ||
|
||||||
lodash.includes(tx.message, search) ||
|
lodash.includes(tx.message, search) ||
|
||||||
lodash.includes(self.addressbook ? self.addressbook[tx.addressTo] : null, search) ||
|
lodash.includes(self.addressbook ? self.addressbook[tx.addressTo] : null, search) ||
|
||||||
|
|
@ -961,10 +970,13 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
lodash.isEqual(formatDate(new Date(tx.time * 1000)), search);
|
lodash.isEqual(formatDate(new Date(tx.time * 1000)), search);
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
if (self.result.length > self.historyShowLimit) self.historyShowMore = true;
|
||||||
|
else self.historyShowMore = false;
|
||||||
|
|
||||||
|
return self.result;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.txHistoryToList = filter(self.search);
|
self.txHistoryToList = filter(self.search).slice(0, self.historyShowLimit);
|
||||||
if (isCordova)
|
if (isCordova)
|
||||||
window.plugins.toast.showShortBottom(gettextCatalog.getString('Matches: ' + self.txHistoryToList.length));
|
window.plugins.toast.showShortBottom(gettextCatalog.getString('Matches: ' + self.txHistoryToList.length));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue