instantly search
This commit is contained in:
parent
037e4d18fc
commit
5ca10f777d
3 changed files with 32 additions and 28 deletions
|
|
@ -203,7 +203,7 @@
|
||||||
<div class="small-11 columns">
|
<div class="small-11 columns">
|
||||||
<div class="searchLabel">
|
<div class="searchLabel">
|
||||||
<i class="fi-magnifying-glass size-14"></i>
|
<i class="fi-magnifying-glass size-14"></i>
|
||||||
<form ng-submit="index.filter(search)">
|
<form>
|
||||||
<input name="search"
|
<input name="search"
|
||||||
type="search"
|
type="search"
|
||||||
placeholder="{{'Search transactions' | translate}}"
|
placeholder="{{'Search transactions' | translate}}"
|
||||||
|
|
@ -213,10 +213,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-1 columns">
|
<div class="small-1 columns">
|
||||||
<a ng-click="index.isSearching = false">Cancel</a>
|
<a ng-click="index.isSearching = false" translate>Cancel</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div ng-repeat="btx in index.txHistoryToShow() track by btx.txid"
|
<div ng-repeat="btx in index.txHistoryToShow(search) track by btx.txid"
|
||||||
ng-click="home.openTxModal(btx)"
|
ng-click="home.openTxModal(btx)"
|
||||||
class="row collapse last-transactions-content">
|
class="row collapse last-transactions-content">
|
||||||
<div class="large-6 medium-6 small-6 columns size-14">
|
<div class="large-6 medium-6 small-6 columns size-14">
|
||||||
|
|
|
||||||
|
|
@ -939,35 +939,38 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
self.txHistoryToShow = function() {
|
self.txHistoryToShow = function(search) {
|
||||||
if (!self.isSearching) {
|
|
||||||
self.result = [];
|
|
||||||
return self.txHistory;
|
|
||||||
} else return self.result;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.filter = function(search) {
|
function filter(search) {
|
||||||
self.result = [];
|
var 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();
|
||||||
var year = date.getFullYear();
|
var year = date.getFullYear();
|
||||||
return [month, day, year].join('/');
|
return [month, day, year].join('/');
|
||||||
|
};
|
||||||
|
|
||||||
|
if (lodash.isEmpty(search)) return;
|
||||||
|
|
||||||
|
result = lodash.filter(self.txHistory, function(tx) {
|
||||||
|
return lodash.includes(tx.amountStr, search) ||
|
||||||
|
lodash.includes(tx.message, search) ||
|
||||||
|
lodash.includes(self.addressbook ? self.addressbook[tx.addressTo] : null, search) ||
|
||||||
|
lodash.includes(tx.addressTo, search) ||
|
||||||
|
lodash.isEqual(formatDate(new Date(tx.time * 1000)), search);
|
||||||
|
});
|
||||||
|
if (isCordova)
|
||||||
|
window.plugins.toast.showShortBottom(gettextCatalog.getString('Matches: ' + result.length));
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (lodash.isEmpty(search)) return;
|
if (!self.isSearching) {
|
||||||
|
return self.txHistory;
|
||||||
self.result = lodash.filter(self.txHistory, function(tx) {
|
} else {
|
||||||
return lodash.includes(tx.amountStr, search) ||
|
return filter(search);;
|
||||||
lodash.includes(tx.message, search) ||
|
}
|
||||||
lodash.includes(self.addressbook[tx.addressTo], search) ||
|
}
|
||||||
lodash.includes(tx.addressTo, search) ||
|
|
||||||
lodash.isEqual(formatDate(new Date(tx.time * 1000)), search);
|
|
||||||
});
|
|
||||||
if (isCordova)
|
|
||||||
window.plugins.toast.showShortBottom(gettextCatalog.getString('Matches: ' + self.result.length));
|
|
||||||
};
|
|
||||||
|
|
||||||
self.getTxsFromServer = function(client, skip, endingTxid, limit, cb) {
|
self.getTxsFromServer = function(client, skip, endingTxid, limit, cb) {
|
||||||
var res = [];
|
var res = [];
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
var disableFocusListener = $rootScope.$on('Local/NewFocusedWallet', function() {
|
var disableFocusListener = $rootScope.$on('Local/NewFocusedWallet', function() {
|
||||||
self.addr = null;
|
self.addr = null;
|
||||||
self.resetForm();
|
self.resetForm();
|
||||||
|
$scope.search = '';
|
||||||
$rootScope.$emit('Local/Searching', false);
|
$rootScope.$emit('Local/Searching', false);
|
||||||
|
|
||||||
if (profileService.focusedClient) {
|
if (profileService.focusedClient) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue