mirror of https://github.com/nextcloud/contacts
Added search functionality.
This commit is contained in:
parent
a9cb3dd6d1
commit
0c2fc1d64e
|
@ -7,6 +7,16 @@ app.controller('contactlistCtrl', function($scope, $filter, $route, $routeParams
|
|||
};
|
||||
|
||||
ctrl.contactList = [];
|
||||
ctrl.query = '';
|
||||
|
||||
$scope.query = function(contact) {
|
||||
return contact.fullName().toLowerCase().indexOf(ctrl.query) !== -1;
|
||||
};
|
||||
|
||||
SearchProxy.setFilter(function(query) {
|
||||
ctrl.query = query.toLowerCase();
|
||||
$scope.$apply();
|
||||
});
|
||||
|
||||
ContactService.registerObserverCallback(function(ev) {
|
||||
$scope.$apply(function() {
|
||||
|
|
|
@ -349,6 +349,16 @@ app.controller('contactlistCtrl', ['$scope', '$filter', '$route', '$routeParams'
|
|||
};
|
||||
|
||||
ctrl.contactList = [];
|
||||
ctrl.query = '';
|
||||
|
||||
$scope.query = function(contact) {
|
||||
return contact.fullName().toLowerCase().indexOf(ctrl.query) !== -1;
|
||||
};
|
||||
|
||||
SearchProxy.setFilter(function(query) {
|
||||
ctrl.query = query.toLowerCase();
|
||||
$scope.$apply();
|
||||
});
|
||||
|
||||
ContactService.registerObserverCallback(function(ev) {
|
||||
$scope.$apply(function() {
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/* global OC, _ */
|
||||
|
||||
/**
|
||||
* ownCloud - Contacts
|
||||
*
|
||||
* This file is licensed under the Affero General Public License
|
||||
version 3 or
|
||||
* later. See the COPYING file.
|
||||
*
|
||||
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
* @author Alexander Weidinger <alexwegoo@gmail.com>
|
||||
* @copyright Christoph Wurst 2015
|
||||
*/
|
||||
|
||||
var SearchProxy = {};
|
||||
|
||||
(function(OC, _) {
|
||||
'use strict';
|
||||
|
||||
var filter = function() {};
|
||||
|
||||
SearchProxy = {
|
||||
attach: function(search) {
|
||||
search.setFilter('contacts', this.filterProxy);
|
||||
},
|
||||
filterProxy: function(query) {
|
||||
filter(query);
|
||||
},
|
||||
setFilter: function(newFilter) {
|
||||
filter = newFilter;
|
||||
}
|
||||
};
|
||||
|
||||
if (!_.isUndefined(OC.Plugins)) {
|
||||
OC.Plugins.register('OCA.Search', SearchProxy);
|
||||
}
|
||||
|
||||
})(OC, _);
|
|
@ -1,6 +1,6 @@
|
|||
<button class="app-content-list-button" type="button" name="button" ng-click="ctrl.createContact()">{{ctrl.t.addContact}}</button>
|
||||
<div class="app-content-list-item"
|
||||
ng-repeat="contact in ctrl.contactList = (ctrl.contacts | contactGroupFilter:ctrl.routeParams.gid | orderBy:'fullName()') track by contact.uid()"
|
||||
ng-repeat="contact in ctrl.contactList = (ctrl.contacts | contactGroupFilter:ctrl.routeParams.gid | orderBy:'fullName()' | filter:query) track by contact.uid()"
|
||||
contact data="contact"
|
||||
ng-click="setSelected(contact.uid())" ng-class="{active: contact.uid() === selectedContactId}">
|
||||
</div>
|
||||
|
|
|
@ -18,6 +18,9 @@ script('contacts', 'vendor/angular-bootstrap/ui-bootstrap.min');
|
|||
script('contacts', 'vendor/angular-bootstrap/ui-bootstrap-tpls.min');
|
||||
script('contacts', 'vendor/jquery-timepicker/jquery.ui.timepicker');
|
||||
|
||||
// search
|
||||
script('contacts', 'searchproxy');
|
||||
|
||||
// all styles
|
||||
style('contacts', 'public/style');
|
||||
vendor_style('select2/select2');
|
||||
|
|
Loading…
Reference in New Issue