mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Can display notifications related to groups posts.
This commit is contained in:
parent
ede515f7a2
commit
bd888f0f47
@ -166,24 +166,34 @@ 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){
|
||||||
|
|
||||||
//Empty the target list
|
//Check for errors
|
||||||
list.innerHTML = "";
|
if(groups.error)
|
||||||
|
return notify("Could not get groups information!", "danger");
|
||||||
|
|
||||||
//Process the list of notifications
|
//Empty the target list
|
||||||
for (var i = 0; i < result.length; i++) {
|
list.innerHTML = "";
|
||||||
const notification = result[i];
|
|
||||||
|
|
||||||
//Display the notification
|
|
||||||
ComunicWeb.components.notifications.ui.display_notification(notification, list, users);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Display a message if there isn't any notification to display
|
//Process the list of notifications
|
||||||
if(result.length == 0){
|
for (var i = 0; i < result.length; i++) {
|
||||||
|
const notification = result[i];
|
||||||
|
|
||||||
|
//Display the notification
|
||||||
|
ComunicWeb.components.notifications.ui.display_notification(notification, list, users, groups);
|
||||||
|
}
|
||||||
|
|
||||||
list.innerHTML = "<li class='no-notification-msg'>You do not have any notification yet.</li>";
|
//Display a message if there isn't any notification to display
|
||||||
|
if(result.length == 0){
|
||||||
|
|
||||||
}
|
list.innerHTML = "<li class='no-notification-msg'>You do not have any notification yet.</li>";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}, 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