mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-10-07 04:47:14 +00:00
Use sgSearch directive in addressbook module
This commit is contained in:
1 parent
44164c0f43
commit
01d4134a23
3 files changed
+14
-43
No files matched your search
@@ -175,9 +175,8 @@
|
||||
sort: 'c_cn',
|
||||
asc: 'true'
|
||||
};
|
||||
if (options && options.excludeLists) {
|
||||
params.excludeLists = true;
|
||||
}
|
||||
if (options)
|
||||
angular.extend(params, options);
|
||||
|
||||
return this.$id().then(function(addressbookId) {
|
||||
var futureAddressBookData = AddressBook.$$resource.fetch(addressbookId, 'view', params);
|
||||
|
||||
@@ -93,14 +93,10 @@
|
||||
$scope.addressbooks = stateAddressbooks;
|
||||
$rootScope.addressbook = stateAddressbook;
|
||||
|
||||
// $scope objects
|
||||
$scope.search = { status: null, filter: null, lastFilter: null };
|
||||
|
||||
// Adjust search status depending on addressbook type
|
||||
currentAddressbook = _.find($scope.addressbooks, function(o) {
|
||||
return o.id == $stateParams.addressbookId;
|
||||
});
|
||||
$scope.search.status = (currentAddressbook && currentAddressbook.isRemote)? 'remote-addressbook' : '';
|
||||
|
||||
// $scope functions
|
||||
$scope.select = function(rowIndex) {
|
||||
@@ -243,31 +239,6 @@
|
||||
}]
|
||||
});
|
||||
};
|
||||
$scope.doSearch = function(keyEvent) {
|
||||
if ($scope.search.filter != $scope.search.lastFilter) {
|
||||
if ($scope.search.filter.length > 2) {
|
||||
$rootScope.addressbook.$filter($scope.search.filter).then(function(data) {
|
||||
if (data.length == 0)
|
||||
$scope.search.status = 'no-result';
|
||||
else
|
||||
$scope.search.status = '';
|
||||
});
|
||||
}
|
||||
else if ($scope.search.filter.length == 0) {
|
||||
$rootScope.addressbook = AddressBook.$find($stateParams.addressbookId);
|
||||
// Extend resulting model instance with parameters from addressbooks listing
|
||||
var o = _.find($scope.addressbooks, function(o) {
|
||||
return o.id == $stateParams.addressbookId;
|
||||
});
|
||||
$scope.search.status = (o.isRemote)? 'remote-addressbook' : '';
|
||||
}
|
||||
else {
|
||||
$scope.search.status = 'min-char';
|
||||
$rootScope.addressbook.cards = [];
|
||||
}
|
||||
}
|
||||
$scope.search.lastFilter = $scope.search.filter;
|
||||
};
|
||||
|
||||
/**
|
||||
* subscribeToFolder - Callback of sgSubscribe directive
|
||||
|
||||
Reference in new issue
Block a user