mirror of
https://github.com/pierre42100/ComunicWeb
synced 2025-06-19 20:35:16 +00:00
Conversation window can be opened and closed
This commit is contained in:
@ -539,6 +539,13 @@ var ComunicWeb = {
|
||||
//TODO : implement
|
||||
},
|
||||
|
||||
/**
|
||||
* Conversation chat window functions
|
||||
*/
|
||||
chatWindows: {
|
||||
//TODO : implement
|
||||
},
|
||||
|
||||
/**
|
||||
* Interface between conversation UI and the API
|
||||
*/
|
||||
@ -552,6 +559,13 @@ var ComunicWeb = {
|
||||
cachingOpened:{
|
||||
//TODO : implement
|
||||
},
|
||||
|
||||
/**
|
||||
* Conversation service file
|
||||
*/
|
||||
service:{
|
||||
//TODO : implement
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -54,6 +54,21 @@ ComunicWeb.components.conversations.cachingOpened = {
|
||||
//Save the new values
|
||||
var conversationsString = conversations.join(";");
|
||||
sessionStorage.setItem(this.__varName, conversationsString);
|
||||
|
||||
//Success
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Check is a conversation ID is open or not
|
||||
*
|
||||
* @param {Integer} conversationID The ID of the conversation to check
|
||||
* @return {Boolean} Depends of the presence of the conversation
|
||||
*/
|
||||
isopen: function(conversationID){
|
||||
var conversations = this.getAll();
|
||||
|
||||
return conversations.includes(conversationID.toString());
|
||||
},
|
||||
|
||||
/**
|
||||
|
42
assets/js/components/conversations/chatWindows.js
Normal file
42
assets/js/components/conversations/chatWindows.js
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Conversation chat window functions
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
ComunicWeb.components.conversations.chatWindows = {
|
||||
/**
|
||||
* Create a new chat window
|
||||
*
|
||||
* @param {Object} infos Informations required for the new chat window
|
||||
* @info {HTMLElement} target The target of the new chat window
|
||||
* @info {Integer} conversationID The ID of the target conversation
|
||||
* @return {Object} Informations about the new chat window
|
||||
*/
|
||||
create: function(infos){
|
||||
|
||||
//Log action
|
||||
ComunicWeb.debug.logMessage("Create a new chat window");
|
||||
|
||||
//First, create the generic conversation window
|
||||
var infosBox = ComunicWeb.components.conversations.windows.create(infos.target.children[0]);
|
||||
|
||||
infosBox.conversationID = infos.conversationID;
|
||||
|
||||
//Adapt close button behaviour
|
||||
infosBox.closeFunction = function(){
|
||||
|
||||
//Remove root element
|
||||
infosBox.rootElem.remove();
|
||||
|
||||
//Remove the conversation from opened ones
|
||||
ComunicWeb.components.conversations.cachingOpened.remove(infosBox.conversationID);
|
||||
}
|
||||
|
||||
infosBox.closeButton.onclick = infosBox.closeFunction;
|
||||
|
||||
//Return informations about the chat window
|
||||
return infosBox;
|
||||
|
||||
},
|
||||
}
|
@ -5,6 +5,12 @@
|
||||
*/
|
||||
|
||||
ComunicWeb.components.conversations.manager = {
|
||||
|
||||
/**
|
||||
* @var {String} The ID of the conversation contener
|
||||
*/
|
||||
__conversationsContenerID: "conversationsElem",
|
||||
|
||||
/**
|
||||
* Display conversations manager
|
||||
*
|
||||
@ -13,7 +19,7 @@ ComunicWeb.components.conversations.manager = {
|
||||
display: function(){
|
||||
|
||||
//Try to get conversation manager
|
||||
var conversationsContainerElem = byId("conversationsElem");
|
||||
var conversationsContainerElem = byId(this.__conversationsContenerID);
|
||||
|
||||
//Check if element exists or not
|
||||
if(conversationsContainerElem){
|
||||
@ -27,7 +33,7 @@ ComunicWeb.components.conversations.manager = {
|
||||
|
||||
//Create conversations manager element
|
||||
var conversationsContainerElem = createElem("div");
|
||||
conversationsContainerElem.id = "conversationsElem";
|
||||
conversationsContainerElem.id = this.__conversationsContenerID;
|
||||
|
||||
//Insert the element at the right place
|
||||
var pageTarget = byId("pageTarget");
|
||||
@ -100,11 +106,23 @@ ComunicWeb.components.conversations.manager = {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Check if the conversation is already open or not
|
||||
if(ComunicWeb.components.conversations.cachingOpened.isopen(conversationID)){
|
||||
ComunicWeb.debug.logMessage("The conversation " + conversationID + " is already opened !");
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log action
|
||||
ComunicWeb.debug.logMessage("Opening conversation " + conversationID);
|
||||
|
||||
//Save conversation ID in session storage
|
||||
|
||||
ComunicWeb.components.conversations.cachingOpened.add(conversationID);
|
||||
|
||||
//Create a conversation windows
|
||||
ComunicWeb.components.conversations.chatWindows.create({
|
||||
target: byId(this.__conversationsContenerID),
|
||||
conversationID: conversationID
|
||||
});
|
||||
|
||||
//Success
|
||||
return true;
|
||||
|
11
assets/js/components/conversations/service.js
Normal file
11
assets/js/components/conversations/service.js
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Conversation service file
|
||||
*
|
||||
* Ensure that the content of the conversations is up to date
|
||||
*
|
||||
* @author Pierre HUBER
|
||||
*/
|
||||
|
||||
ComunicWeb.components.conversations.service = {
|
||||
|
||||
}
|
@ -56,6 +56,7 @@ ComunicWeb.components.conversations.windows = {
|
||||
var boxElements ={
|
||||
rootElem: conversationBox,
|
||||
closeFunction: closeBox,
|
||||
closeButton: closeButton,
|
||||
boxTitle: boxTitle,
|
||||
boxTools: boxTools,
|
||||
boxBody: boxBody,
|
||||
|
Reference in New Issue
Block a user