Using chips for adding/viewing contact categories

This commit is contained in:
Ludovic Marcotte
2015-04-27 13:18:05 -04:00
committed by Francis Lachapelle
parent 8557b2a161
commit a166d1b4cf
5 changed files with 40 additions and 37 deletions

View File

@@ -48,7 +48,8 @@
Card.$factory = ['$timeout', 'sgSettings', 'sgResource', function($timeout, Settings, Resource) {
angular.extend(Card, {
$$resource: new Resource(Settings.activeUser.folderURL + 'Contacts', Settings.activeUser),
$timeout: $timeout
$timeout: $timeout,
$categories: window.UserDefaults.SOGoContactsCategories
});
return Card; // return constructor
@@ -103,6 +104,20 @@
return Card.$unwrapCollection(futureCardData); // a collection of cards
};
/**
* @function filterCategories
* @memberof Card.prototype
* @desc Search for categories matching some criterias
* @param {string} search - the search string to match
* @returns a collection of strings
*/
Card.filterCategories = function(query) {
var re = new RegExp(query, 'i');
return _.filter(Card.$categories, function(category) {
return category.search(re) != -1;
});
};
/**
* @memberof Card
* @desc Unwrap to a collection of Card instances.
@@ -301,7 +316,6 @@
if (i == this.categories.length)
this.categories.push({value: category});
}
return this.categories.length - 1;
};
Card.prototype.$addEmail = function(type) {

View File

@@ -350,15 +350,12 @@
$scope.allTelTypes = Card.$TEL_TYPES;
$scope.allUrlTypes = Card.$URL_TYPES;
$scope.allAddressTypes = Card.$ADDRESS_TYPES;
$scope.categories = {};
$scope.addOrgUnit = function() {
var i = $scope.card.$addOrgUnit('');
focus('orgUnit_' + i);
};
$scope.addCategory = function() {
var i = $scope.card.$addCategory('');
focus('category_' + i);
};
$scope.addEmail = function() {
var i = $scope.card.$addEmail('');
focus('email_' + i);