mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 12:09:21 +00:00
Can update conversation color
This commit is contained in:
parent
e32f114179
commit
98906334a7
@ -606,15 +606,11 @@ const ConvChatWindow = {
|
|||||||
showConversationSettings: function(conversation){
|
showConversationSettings: function(conversation){
|
||||||
|
|
||||||
//First, check conversation settings button and pane don't exists yet
|
//First, check conversation settings button and pane don't exists yet
|
||||||
if(conversation.box.settingsButton){
|
if(conversation.box.settingsButton && conversation.box.settingsButton.remove){
|
||||||
if(conversation.box.settingsButton.remove){
|
conversation.box.settingsButton.remove();
|
||||||
conversation.box.settingsButton.remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(conversation.box.settingsPane){
|
if(conversation.box.settingsPane && conversation.box.settingsPane.remove){
|
||||||
if(conversation.box.settingsPane.remove){
|
conversation.box.settingsPane.remove();
|
||||||
conversation.box.settingsPane.remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create and display conversation settings button wheel
|
//Create and display conversation settings button wheel
|
||||||
@ -658,6 +654,12 @@ const ConvChatWindow = {
|
|||||||
//Update conversation name
|
//Update conversation name
|
||||||
if(conversation.infos.name)
|
if(conversation.infos.name)
|
||||||
settingsForm.conversationNameInput.value = conversation.infos.name;
|
settingsForm.conversationNameInput.value = conversation.infos.name;
|
||||||
|
|
||||||
|
// Apply conversation color
|
||||||
|
if (conversation.infos.color) {
|
||||||
|
settingsForm.conversationColorInput.value = "#" + conversation.infos.color;
|
||||||
|
settingsForm.conversationColorInput.dispatchEvent(new CustomEvent("change"))
|
||||||
|
}
|
||||||
|
|
||||||
//Update conversation members
|
//Update conversation members
|
||||||
ComunicWeb.components.userSelect.pushEntries(settingsForm.usersElement, conversation.infos.members.map(m => m.user_id));
|
ComunicWeb.components.userSelect.pushEntries(settingsForm.usersElement, conversation.infos.members.map(m => m.user_id));
|
||||||
@ -669,8 +671,8 @@ const ConvChatWindow = {
|
|||||||
|
|
||||||
//Check if user is a conversation moderator or not
|
//Check if user is a conversation moderator or not
|
||||||
if(!conversation.infos.members.find(m => m.user_id == userID()).is_admin) {
|
if(!conversation.infos.members.find(m => m.user_id == userID()).is_admin) {
|
||||||
//We disable name field
|
settingsForm.conversationNameInput.disabled = true;
|
||||||
settingsForm.conversationNameInput.disabled = "true";
|
settingsForm.conversationColorInput.parentNode.parentNode.style.display = "none";
|
||||||
|
|
||||||
settingsForm.allowEveryoneToAddMembers.parentNode.parentNode.remove();
|
settingsForm.allowEveryoneToAddMembers.parentNode.parentNode.remove();
|
||||||
}
|
}
|
||||||
@ -731,10 +733,13 @@ const ConvChatWindow = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Add other fields if the user is a conversation moderator
|
//Add other fields if the user is a conversation moderator
|
||||||
if(conversation.infos.ID_owner == userID()){
|
if(conversation.infos.members.find(m => m.user_id == userID()).is_admin){
|
||||||
//Specify conversation name
|
//Specify conversation name
|
||||||
var nameValue = conversation.settingsForm.conversationNameInput.value
|
let nameValue = conversation.settingsForm.conversationNameInput.value
|
||||||
newValues.name = (nameValue === "" ? false : nameValue);
|
newValues.name = (nameValue === "" ? false : nameValue);
|
||||||
|
|
||||||
|
let colorValue = conversation.settingsForm.conversationColorInput.value
|
||||||
|
newValues.color = (colorValue == "" ? null : colorValue)
|
||||||
|
|
||||||
newValues.canEveryoneAddMembers = conversation.settingsForm.allowEveryoneToAddMembers.checked;
|
newValues.canEveryoneAddMembers = conversation.settingsForm.allowEveryoneToAddMembers.checked;
|
||||||
|
|
||||||
|
@ -110,9 +110,8 @@ const ConversationsInterface = {
|
|||||||
* @info {Integer} conversationID The ID of the conversation to update
|
* @info {Integer} conversationID The ID of the conversation to update
|
||||||
* @info {Boolean} following Specify if the user is following the conversation or not
|
* @info {Boolean} following Specify if the user is following the conversation or not
|
||||||
* @info {String} name Specify a new name for the conversation
|
* @info {String} name Specify a new name for the conversation
|
||||||
* @info {array} members Specify the new list of members for the conversation
|
* @info {String} color Specify a new color for the conversation
|
||||||
* @param {function} callback The function callback
|
* @param {function} callback The function callback
|
||||||
* @return {Boolean} True for a success
|
|
||||||
*/
|
*/
|
||||||
updateSettings: function(infos, callback){
|
updateSettings: function(infos, callback){
|
||||||
//Prepare the API request
|
//Prepare the API request
|
||||||
@ -125,10 +124,6 @@ const ConversationsInterface = {
|
|||||||
if(infos.name !== undefined)
|
if(infos.name !== undefined)
|
||||||
params.name = infos.name;
|
params.name = infos.name;
|
||||||
|
|
||||||
//Add conversation members (if specified)
|
|
||||||
if(infos.members)
|
|
||||||
params.members = infos.members;
|
|
||||||
|
|
||||||
//Add conversation following status (if specified)
|
//Add conversation following status (if specified)
|
||||||
if(infos.following !== undefined)
|
if(infos.following !== undefined)
|
||||||
params.following = infos.following;
|
params.following = infos.following;
|
||||||
@ -136,22 +131,18 @@ const ConversationsInterface = {
|
|||||||
if(infos.canEveryoneAddMembers !== undefined)
|
if(infos.canEveryoneAddMembers !== undefined)
|
||||||
params.canEveryoneAddMembers = infos.canEveryoneAddMembers;
|
params.canEveryoneAddMembers = infos.canEveryoneAddMembers;
|
||||||
|
|
||||||
|
if(infos.color !== undefined)
|
||||||
|
params.color = infos.color == null ? "" : infos.color.replace("#", "").toUpperCase();
|
||||||
|
|
||||||
//Perform API request
|
//Perform API request
|
||||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, function(result){
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, function(result){
|
||||||
//Empty the cache (considered as deprecated)
|
//Empty the cache (considered as deprecated)
|
||||||
ComunicWeb.components.conversations.interface.emptyCache(true);
|
ComunicWeb.components.conversations.interface.emptyCache(true);
|
||||||
|
|
||||||
//Check for error
|
|
||||||
if(result.error)
|
|
||||||
ComunicWeb.debug.logMessage("Error! An error occured while trying to update conversation settings !");
|
|
||||||
|
|
||||||
//Perform next action
|
//Perform next action
|
||||||
callback(result);
|
callback(result);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//Success
|
|
||||||
return true;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user