instantly search

This commit is contained in:
Gabriel Bazán 2016-02-18 17:55:57 -03:00
commit 5ca10f777d
3 changed files with 32 additions and 28 deletions

View file

@ -203,7 +203,7 @@
<div class="small-11 columns">
<div class="searchLabel">
<i class="fi-magnifying-glass size-14"></i>
<form ng-submit="index.filter(search)">
<form>
<input name="search"
type="search"
placeholder="{{'Search transactions' | translate}}"
@ -213,10 +213,10 @@
</div>
</div>
<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 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)"
class="row collapse last-transactions-content">
<div class="large-6 medium-6 small-6 columns size-14">

View file

@ -939,15 +939,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}, 100);
};
self.txHistoryToShow = function() {
if (!self.isSearching) {
self.result = [];
return self.txHistory;
} else return self.result;
}
self.txHistoryToShow = function(search) {
self.filter = function(search) {
self.result = [];
function filter(search) {
var result = [];
function formatDate(date) {
var day = ('0' + date.getDate()).slice(-2).toString();
@ -958,17 +953,25 @@ angular.module('copayApp.controllers').controller('indexController', function($r
if (lodash.isEmpty(search)) return;
self.result = lodash.filter(self.txHistory, function(tx) {
result = lodash.filter(self.txHistory, function(tx) {
return lodash.includes(tx.amountStr, search) ||
lodash.includes(tx.message, search) ||
lodash.includes(self.addressbook[tx.addressTo], 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: ' + self.result.length));
window.plugins.toast.showShortBottom(gettextCatalog.getString('Matches: ' + result.length));
return result;
};
if (!self.isSearching) {
return self.txHistory;
} else {
return filter(search);;
}
}
self.getTxsFromServer = function(client, skip, endingTxid, limit, cb) {
var res = [];

View file

@ -51,6 +51,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
var disableFocusListener = $rootScope.$on('Local/NewFocusedWallet', function() {
self.addr = null;
self.resetForm();
$scope.search = '';
$rootScope.$emit('Local/Searching', false);
if (profileService.focusedClient) {