Added search functionality.

This commit is contained in:
Alexander Weidinger 2016-03-08 00:40:11 +01:00 committed by Hendrik Leppelsack
parent a9cb3dd6d1
commit 0c2fc1d64e
5 changed files with 62 additions and 1 deletions

View File

@ -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() {

View File

@ -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() {

38
js/searchproxy.js Normal file
View File

@ -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, _);

View File

@ -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>

View File

@ -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');