diff --git a/assets/css/components/notifications/dropdown.css b/assets/css/components/notifications/dropdown.css new file mode 100644 index 00000000..83b5b748 --- /dev/null +++ b/assets/css/components/notifications/dropdown.css @@ -0,0 +1,10 @@ +/** + * Notifications dropdown stylesheet + * + * @author Pierre HUBERT + */ + +.no-notification-msg { + text-align: center; + padding: 20px; +} \ No newline at end of file diff --git a/assets/js/components/notifications/dropdown.js b/assets/js/components/notifications/dropdown.js index 4f48896b..03469b3d 100644 --- a/assets/js/components/notifications/dropdown.js +++ b/assets/js/components/notifications/dropdown.js @@ -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 = "