mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 05:49:22 +00:00
Perform a request on the server to delete the entire list of notifications.
This commit is contained in:
parent
7277274943
commit
a3223a190d
10
assets/css/components/notifications/dropdown.css
Normal file
10
assets/css/components/notifications/dropdown.css
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Notifications dropdown stylesheet
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
.no-notification-msg {
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
}
|
@ -64,6 +64,49 @@ ComunicWeb.components.notifications.dropdown = {
|
||||
class: "menu"
|
||||
});
|
||||
|
||||
//Add dropdown bottom
|
||||
var dropdownBottom = createElem2({
|
||||
appendTo: dropdownMenu,
|
||||
type: "li",
|
||||
class: "footer"
|
||||
});
|
||||
|
||||
//Add a button to offer the user to delete all his notifications
|
||||
var deleteAllLink = createElem2({
|
||||
appendTo: dropdownBottom,
|
||||
type: "a",
|
||||
href: "#",
|
||||
innerHTML: "Delete all"
|
||||
});
|
||||
|
||||
//Make the delete all notifications link lives
|
||||
deleteAllLink.onclick = function(){
|
||||
|
||||
ComunicWeb.common.messages.confirm("Are you sure do you want to delete all the notifications ? This operation can not be cancelled !", function(accept){
|
||||
|
||||
//We continue only if the user confirmed the operation
|
||||
if(!accept)
|
||||
return;
|
||||
|
||||
//Perform a request to the server through the interface
|
||||
ComunicWeb.components.notifications.interface.delete_all(function(result){
|
||||
|
||||
//Check for errors
|
||||
if(result.error){
|
||||
ComunicWeb.common.notificationSystem.showNotification("An error occured while trying to delete all the notifications !", "danger");
|
||||
return;
|
||||
}
|
||||
|
||||
//Display success
|
||||
ComunicWeb.common.notificationSystem.showNotification("The entire list of notification has been cleared.", "success");
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
//Enable slimscroll
|
||||
$(notificationsList).slimScroll({
|
||||
height: '100%'
|
||||
@ -121,6 +164,13 @@ ComunicWeb.components.notifications.dropdown = {
|
||||
ComunicWeb.components.notifications.ui.display_notification(notification, list, users);
|
||||
}
|
||||
|
||||
//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);
|
||||
|
||||
|
||||
|
@ -58,4 +58,19 @@ ComunicWeb.components.notifications.interface = {
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete all the notifications of the user
|
||||
*
|
||||
* @param {function} callback
|
||||
*/
|
||||
delete_all: function(callback){
|
||||
|
||||
//Perform an API request
|
||||
var apiURI = "notifications/delete_all";
|
||||
var params = {};
|
||||
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||
|
||||
}
|
||||
}
|
@ -147,6 +147,7 @@ class Dev {
|
||||
"css/components/comments/form.css",
|
||||
|
||||
//Notifications component
|
||||
"css/components/notifications/dropdown.css",
|
||||
"css/components/notifications/ui.css",
|
||||
|
||||
//Pages stylesheets
|
||||
|
Loading…
Reference in New Issue
Block a user