mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 13:59:23 +00:00
Created search user function
This commit is contained in:
parent
b7eb77b928
commit
c66b40a137
@ -352,6 +352,11 @@ var ComunicWeb = {
|
||||
* Remove all entries from user informations cache
|
||||
*/
|
||||
emptyUserInfosCache: function(){},
|
||||
|
||||
/**
|
||||
* Given a query, search for users and return the result
|
||||
*/
|
||||
search: function(query, afterSearch){},
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -136,4 +136,33 @@ ComunicWeb.user.userInfos = {
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Given a query, search for users and return the result
|
||||
*
|
||||
* @param {String} query The query to search
|
||||
* @param {Function} afterSearch What to do once we got results
|
||||
* @return {Boolean} True for a success
|
||||
*/
|
||||
search: function(query, afterSearch){
|
||||
//Perform a request on the server
|
||||
apiURI = "user/search";
|
||||
params = {
|
||||
query: query,
|
||||
};
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, function(response){
|
||||
|
||||
//Continue only in case of success
|
||||
if(response.error){
|
||||
afterSearch(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Preload users informations
|
||||
ComunicWeb.user.userInfos.getMultipleUsersInfos(response, function(usersInfos){
|
||||
//Go to next action
|
||||
afterSearch(usersInfos);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user