Split refresh list method and create box method

This commit is contained in:
Pierre 2018-05-16 07:00:06 +02:00
parent ec13b6902b
commit b9cc47f05d
2 changed files with 51 additions and 19 deletions

View File

@ -43,15 +43,33 @@ ComunicWeb.pages.conversations.listPane = {
class: "box-body no-padding"
});
//Loading message
//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: boxBody,
appendTo: target,
type: "div",
class: "conv-list-loading-msg",
innerHTML: "Loading, please wait..."
});
}
else
//Create empty division
var loadingMsg = document.createElement("div");
//Load the list of conversations
//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

View File

@ -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);
}
}