filter contact list

This commit is contained in:
Javier 2016-08-12 16:30:50 -03:00
commit cdd8628cfe
2 changed files with 15 additions and 16 deletions

View file

@ -4,25 +4,12 @@
<label class="item item-input">
<i class="icon ion-search placeholder-icon"></i>
<input type="text" placeholder="Search">
<input type="text" placeholder="Search" ng-model="search" ng-change="findContact()">
</label>
<h2>Contacts</h2>
<div class="list card">
<!-- <a class="item item-icon-left" ng-repeat="contact in contactList" ng-click="openInputAmountModal(contact)">
<i class="icon ion-ios-person-outline"></i>
{{contact.label}}
</a>
<a class="item item-icon-left" ng-repeat="wallet in wallets" ng-click="openInputAmountModal(wallet)">
<i class="icon icon-wallet size-21" ng-style="{'color':wallet.color}"></i>
{{wallet.name || wallet.alias}}
<span class="item-note">
{{wallet.balance || '123,999.91 bits'}}
</span>
</a> -->
<a class="item item-icon-left" ng-repeat="item in list" ng-click="openInputAmountModal(item)">
<div ng-show="!item.id">
<i class="icon ion-ios-person-outline"></i>
@ -38,6 +25,5 @@
</div>
</a>
</div>
</ion-content>
</ion-view>

View file

@ -1,6 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $ionicModal, addressbookService, profileService, configService, lodash) {
var completeList;
$scope.init = function() {
addressbookService.list(function(err, ab) {
@ -41,7 +42,19 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
});
$scope.wallets = lodash.sortBy(ret, 'name');
$scope.list = $scope.contactList.concat($scope.wallets);
$scope.list = completeList = $scope.contactList.concat($scope.wallets);
};
$scope.findContact = function() {
var result = lodash.filter($scope.list, function(item) {
var val = item.label || item.alias || item.name;
return lodash.includes(val.toLowerCase(), $scope.search.toLowerCase());
});
if (lodash.isEmpty(result) || lodash.isEmpty($scope.search)) {
$scope.list = completeList;
return;
}
$scope.list = result;
};
$scope.openInputAmountModal = function(recipient) {