mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 22:09:21 +00:00
Can display notifications related to groups posts.
This commit is contained in:
parent
ede515f7a2
commit
bd888f0f47
@ -166,6 +166,13 @@ ComunicWeb.components.notifications.dropdown = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Get information about the groups
|
||||||
|
var groups_id = ComunicWeb.components.notifications.utils.get_groups_id(result);
|
||||||
|
getInfoMultipleGroups(groups_id, function(groups){
|
||||||
|
|
||||||
|
//Check for errors
|
||||||
|
if(groups.error)
|
||||||
|
return notify("Could not get groups information!", "danger");
|
||||||
|
|
||||||
//Empty the target list
|
//Empty the target list
|
||||||
list.innerHTML = "";
|
list.innerHTML = "";
|
||||||
@ -175,7 +182,7 @@ ComunicWeb.components.notifications.dropdown = {
|
|||||||
const notification = result[i];
|
const notification = result[i];
|
||||||
|
|
||||||
//Display the notification
|
//Display the notification
|
||||||
ComunicWeb.components.notifications.ui.display_notification(notification, list, users);
|
ComunicWeb.components.notifications.ui.display_notification(notification, list, users, groups);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Display a message if there isn't any notification to display
|
//Display a message if there isn't any notification to display
|
||||||
@ -185,6 +192,9 @@ ComunicWeb.components.notifications.dropdown = {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,8 +13,9 @@ ComunicWeb.components.notifications.ui = {
|
|||||||
* @param {HTMLElement} target The target of the notification
|
* @param {HTMLElement} target The target of the notification
|
||||||
* @param {Object} users Informations about users that might be required
|
* @param {Object} users Informations about users that might be required
|
||||||
* to display the notification
|
* to display the notification
|
||||||
|
* @param {Object} groups Information about the potential related groups
|
||||||
*/
|
*/
|
||||||
display_notification: function(data, target, users){
|
display_notification: function(data, target, users, groups){
|
||||||
|
|
||||||
//Generate the informations about the notifications
|
//Generate the informations about the notifications
|
||||||
var from_user = users["user-"+data.from_user_id];
|
var from_user = users["user-"+data.from_user_id];
|
||||||
@ -49,6 +50,7 @@ ComunicWeb.components.notifications.ui = {
|
|||||||
message += " ";
|
message += " ";
|
||||||
|
|
||||||
//Notification target
|
//Notification target
|
||||||
|
//User page
|
||||||
if(data.from_container_type == "user_page"){
|
if(data.from_container_type == "user_page"){
|
||||||
|
|
||||||
if(data.from_user_id == data.from_container_id)
|
if(data.from_user_id == data.from_container_id)
|
||||||
@ -58,6 +60,13 @@ ComunicWeb.components.notifications.ui = {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Group page
|
||||||
|
if(data.from_container_type == "group_page"){
|
||||||
|
message += "on the group "+groups[data.from_container_id].name+".";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Create notification action
|
//Create notification action
|
||||||
var action = function(){
|
var action = function(){
|
||||||
|
|
||||||
|
@ -28,6 +28,27 @@ ComunicWeb.components.notifications.utils = {
|
|||||||
|
|
||||||
return users;
|
return users;
|
||||||
|
|
||||||
}
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the ID of the groups related to the notifications
|
||||||
|
*
|
||||||
|
* @param {Array} list The list to process
|
||||||
|
* @return {Array} The list of target groups IDs
|
||||||
|
*/
|
||||||
|
get_groups_id: function(list){
|
||||||
|
|
||||||
|
var groups = [];
|
||||||
|
|
||||||
|
list.forEach(function(notif){
|
||||||
|
|
||||||
|
if(!groups.includes(notif.from_container_id) && notif.from_container_type == "group_page")
|
||||||
|
groups.push(notif.from_container_id);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return groups;
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user