mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 13:59:23 +00:00
Improved conversations rendering
This commit is contained in:
parent
5e3bdad501
commit
3d1dd2cbed
11
assets/css/components/conversations/list.css
Normal file
11
assets/css/components/conversations/list.css
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* Conversations list
|
||||||
|
*
|
||||||
|
* @author Pierre HUBERT
|
||||||
|
*/
|
||||||
|
|
||||||
|
.conversations-list-box .last-activity {
|
||||||
|
margin-left: 5px;
|
||||||
|
color: #777;
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
@ -367,6 +367,11 @@ var ComunicWeb = {
|
|||||||
* Given a query, search for users and return the result
|
* Given a query, search for users and return the result
|
||||||
*/
|
*/
|
||||||
search: function(query, afterSearch){},
|
search: function(query, afterSearch){},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given user IDs (in an array) the function return their names in a string
|
||||||
|
*/
|
||||||
|
getNames: function(usersID, afterNames){},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -49,6 +49,6 @@ function userID(){
|
|||||||
* @param {Boolean} forceRequest Force the request to be made
|
* @param {Boolean} forceRequest Force the request to be made
|
||||||
* @return {Boolean} True for a success
|
* @return {Boolean} True for a success
|
||||||
*/
|
*/
|
||||||
function getUsersInfos(usersID, afterGetUserInfos, forceRequest){
|
function getMultipleUsersInfos(usersID, afterGetUserInfos, forceRequest){
|
||||||
ComunicWeb.user.userInfos.getMultipleUsersInfos(usersID, afterGetUserInfos, forceRequest);
|
ComunicWeb.user.userInfos.getMultipleUsersInfos(usersID, afterGetUserInfos, forceRequest);
|
||||||
}
|
}
|
@ -22,6 +22,9 @@ ComunicWeb.components.conversations.list = {
|
|||||||
//Change box title
|
//Change box title
|
||||||
listBox.boxTitle.innerHTML = "Conversations";
|
listBox.boxTitle.innerHTML = "Conversations";
|
||||||
|
|
||||||
|
//Change box root elem class
|
||||||
|
listBox.rootElem.className += " conversations-list-box";
|
||||||
|
|
||||||
//Remove footer
|
//Remove footer
|
||||||
listBox.boxFooter.remove();
|
listBox.boxFooter.remove();
|
||||||
|
|
||||||
@ -243,6 +246,19 @@ ComunicWeb.components.conversations.list = {
|
|||||||
|
|
||||||
console.log(conversationInfos); //DEBUG - temporary
|
console.log(conversationInfos); //DEBUG - temporary
|
||||||
|
|
||||||
|
|
||||||
|
//Add conversations last activity
|
||||||
|
var lastActivityElem = createElem("small", linkElem);
|
||||||
|
lastActivityElem.className = "pull-right last-activity";
|
||||||
|
var lastActivityIcon = createElem("i", lastActivityElem);
|
||||||
|
lastActivityIcon.className = "fa fa-clock-o";
|
||||||
|
var lastActivityValueElem = createElem("span", lastActivityElem);
|
||||||
|
|
||||||
|
//Calculate last conversation activity
|
||||||
|
var currentTime = ComunicWeb.common.date.time();
|
||||||
|
lastActivityValueElem.innerHTML = " "+ComunicWeb.common.date.diffToStr(currentTime - conversationInfos.last_active);
|
||||||
|
|
||||||
|
|
||||||
//Create the conversation name element
|
//Create the conversation name element
|
||||||
var conversationNameElem = createElem("strong", linkElem);
|
var conversationNameElem = createElem("strong", linkElem);
|
||||||
|
|
||||||
@ -274,31 +290,17 @@ ComunicWeb.components.conversations.list = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Get users informations
|
//Get users informations
|
||||||
getUsersInfos(firstMembers, function(usersInfo){
|
ComunicWeb.user.userInfos.getNames(firstMembers, function(usersName){
|
||||||
//Prepare conversation name
|
|
||||||
var conversationName = "";
|
|
||||||
|
|
||||||
//Process users informations
|
//For conversations with many members (more than 3 - we musn't forget current user)
|
||||||
for(i in usersInfo){
|
if(conversationInfos.members.length > 3)
|
||||||
if(usersInfo[i].firstName)
|
usersName += ", ...";
|
||||||
|
|
||||||
//Add a coma if required
|
|
||||||
if(conversationName != "")
|
|
||||||
conversationName += ", ";
|
|
||||||
|
|
||||||
conversationName += usersInfo[i].firstName + " " + usersInfo[i].lastName;
|
|
||||||
}
|
|
||||||
|
|
||||||
//For converstions with many members
|
|
||||||
if(conversationInfos.members.length > 2)
|
|
||||||
conversationName += ", ...";
|
|
||||||
|
|
||||||
//Apply conversation name
|
//Apply conversation name
|
||||||
conversationNameElem.innerHTML = conversationName;
|
conversationNameElem.innerHTML = usersName;
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Success
|
//Success
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -164,5 +164,40 @@ ComunicWeb.user.userInfos = {
|
|||||||
afterSearch(usersInfos);
|
afterSearch(usersInfos);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given user IDs (in an array) the function return their names in a string
|
||||||
|
*
|
||||||
|
* @param {Array} usersID The users to return as a string
|
||||||
|
* @param {Function} afterNames What to do once we have got the names
|
||||||
|
* @return {Boolean} True for a success
|
||||||
|
*/
|
||||||
|
getNames: function(usersID, afterNames){
|
||||||
|
//Get users informations
|
||||||
|
this.getMultipleUsersInfos(usersID, function(usersInfo){
|
||||||
|
|
||||||
|
//Check for errors
|
||||||
|
if(usersInfo.error){
|
||||||
|
afterNames("Error");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Prepare conversation name
|
||||||
|
var usersName = "";
|
||||||
|
|
||||||
|
//Process users informations
|
||||||
|
for(i in usersInfo){
|
||||||
|
if(usersInfo[i].firstName)
|
||||||
|
|
||||||
|
//Add a coma if required
|
||||||
|
if(usersName != "")
|
||||||
|
usersName += ", ";
|
||||||
|
|
||||||
|
usersName += usersInfo[i].firstName + " " + usersInfo[i].lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Perform next action with result
|
||||||
|
afterNames(usersName);
|
||||||
|
});
|
||||||
|
},
|
||||||
}
|
}
|
@ -31,6 +31,7 @@ $config['CSSfiles'] = array(
|
|||||||
"%PATH_ASSETS%css/components/friends/friendsBar.css",
|
"%PATH_ASSETS%css/components/friends/friendsBar.css",
|
||||||
"%PATH_ASSETS%css/components/conversations/manager.css",
|
"%PATH_ASSETS%css/components/conversations/manager.css",
|
||||||
"%PATH_ASSETS%css/components/conversations/windows.css",
|
"%PATH_ASSETS%css/components/conversations/windows.css",
|
||||||
|
"%PATH_ASSETS%css/components/conversations/list.css",
|
||||||
"%PATH_ASSETS%css/components/userSelect/userSelect.css",
|
"%PATH_ASSETS%css/components/userSelect/userSelect.css",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user