diff --git a/app/assets/javascripts/sidebar.js b/app/assets/javascripts/sidebar.js
index d0d8d2ae2..9f11fad3e 100644
--- a/app/assets/javascripts/sidebar.js
+++ b/app/assets/javascripts/sidebar.js
@@ -116,11 +116,31 @@
});
$('#sidebar-notification-list').append(notificationHtml);
+
+ $('li[notification-id=' + val.id + ']').find('#img-delete-notification').click(deleteNotification);
});
}
function deleteNotification(evt) {
- decrementNotificationCount();
+ evt.stopPropagation();
+
+ var notificationId = $(this).attr('notification-id');
+ alert(notificationId);
+
+ var url = "/api/users/" + context.JK.currentUserId + "/notifications/" + notificationId;
+ $.ajax({
+ type: "DELETE",
+ dataType: "json",
+ contentType: 'application/json',
+ url: url,
+ processData: false,
+ success: function(response) {
+ delete notifications[notificationId];
+ $('li[notification-id=' + notificationId + ']').hide();
+ decrementNotificationCount();
+ },
+ error: app.ajaxError
+ });
}
function initializeChatPanel() {
@@ -243,9 +263,7 @@
$('#sidebar-notification-count').html(count - 1);
}
- // TODO
- // (1) optimize so we're not hitting server on each keyup once > 2 characters are entered
- // (2) hide any expanded panels once search starts
+ // TODO: optimize so we're not hitting server on each keyup once > 2 characters are entered
function events() {
$('#search-input').keyup(function(evt) {
// ENTER KEY
@@ -304,9 +322,6 @@
"created_at": payload.created_at
};
- logger.debug("Added notification " + notifications[payload.notification_id].id + " to array");
- logger.debug("Notification size = " + notifications.length);
-
incrementNotificationCount();
var template = $("#template-notification-panel").html();
diff --git a/app/views/clients/_sidebar.html.erb b/app/views/clients/_sidebar.html.erb
index a03998b02..d38b50f0d 100644
--- a/app/views/clients/_sidebar.html.erb
+++ b/app/views/clients/_sidebar.html.erb
@@ -104,6 +104,19 @@
+
+
+
+
-
-
+
+
+