mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 12:09:21 +00:00
Split refresh list method and create box method
This commit is contained in:
parent
ec13b6902b
commit
b9cc47f05d
@ -43,15 +43,33 @@ ComunicWeb.pages.conversations.listPane = {
|
||||
class: "box-body no-padding"
|
||||
});
|
||||
|
||||
//Loading message
|
||||
var loadingMsg = createElem2({
|
||||
appendTo: boxBody,
|
||||
type: "div",
|
||||
class: "conv-list-loading-msg",
|
||||
innerHTML: "Loading, please wait..."
|
||||
});
|
||||
|
||||
//Load the list of conversations
|
||||
this.refresh_list(boxBody, args);
|
||||
},
|
||||
|
||||
/**
|
||||
* Refresh the list of conversations
|
||||
*
|
||||
* @param {HTMLElement} target The target for the list
|
||||
* @param {Object} args Additionnal arguments
|
||||
*/
|
||||
refresh_list: function(target, args){
|
||||
|
||||
//Loading message, if required
|
||||
if(target.childElementCount == 0){
|
||||
var loadingMsg = createElem2({
|
||||
appendTo: target,
|
||||
type: "div",
|
||||
class: "conv-list-loading-msg",
|
||||
innerHTML: "Loading, please wait..."
|
||||
});
|
||||
}
|
||||
else
|
||||
//Create empty division
|
||||
var loadingMsg = document.createElement("div");
|
||||
|
||||
|
||||
//Perform a request over the interface
|
||||
ComunicWeb.components.conversations.interface.getList(function(result){
|
||||
|
||||
//Check for errors
|
||||
@ -62,11 +80,12 @@ ComunicWeb.pages.conversations.listPane = {
|
||||
|
||||
//Remove loading message
|
||||
loadingMsg.remove();
|
||||
emptyElem(boxBody); //Remove any previously shown list
|
||||
emptyElem(target); //Remove any previously shown list
|
||||
|
||||
//Display the list of conversations
|
||||
ComunicWeb.pages.conversations.listPane._display_list(boxBody, result, args);
|
||||
ComunicWeb.pages.conversations.listPane._display_list(target, result, args);
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
||||
@ -128,7 +147,7 @@ ComunicWeb.pages.conversations.listPane = {
|
||||
});
|
||||
|
||||
//Check if it is the current conversation
|
||||
if(args.currConvID == info.ID)
|
||||
if(args.getCurrentID() == info.ID)
|
||||
convLink.className = " selected";
|
||||
|
||||
//Add conversation last activity on the rigth
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
ComunicWeb.pages.conversations.main = {
|
||||
|
||||
/**
|
||||
* Open settings page
|
||||
*
|
||||
@ -56,22 +57,34 @@ ComunicWeb.pages.conversations.main = {
|
||||
}
|
||||
|
||||
//Check if a conversation has to be opened
|
||||
var currConvID = 0;
|
||||
if(args.subfolder){
|
||||
|
||||
//Determine conversation ID
|
||||
var convID = args.subfolder;
|
||||
if(convID.includes("/"))
|
||||
convID = convID.split("/")[0];
|
||||
currConvID = Number(convID);
|
||||
//Open the conversation
|
||||
conversationOpener(currConvID);
|
||||
conversationOpener(ComunicWeb.pages.conversations.main.getCurrentConversationID());
|
||||
}
|
||||
|
||||
//Display the list of conversation
|
||||
ComunicWeb.pages.conversations.listPane.display(leftArea, {
|
||||
opener: conversationOpener,
|
||||
currConvID: currConvID
|
||||
getCurrentID: this.getCurrentConversationID
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine the current conversation ID
|
||||
*
|
||||
* @return {Number} The ID of the current conversation (0 if none found)
|
||||
*/
|
||||
getCurrentConversationID: function(){
|
||||
|
||||
var id = location.toString().split("/conversations/");
|
||||
id = id[id.length - 1];
|
||||
|
||||
//Check if no ID is specified
|
||||
if(id.length < 1)
|
||||
return 0;
|
||||
else
|
||||
return Number(id);
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user