added a notificaions read button
This commit is contained in:
parent
021bbc12ba
commit
9b6faa5644
5 changed files with 36 additions and 4 deletions
|
|
@ -23,4 +23,8 @@ class NotificationsController < ApplicationController
|
|||
respond_with @notifications
|
||||
end
|
||||
|
||||
def read_all
|
||||
Notification.where(:recipient_id => current_user.id).update_all(:unread => false)
|
||||
redirect_to :back
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,14 @@
|
|||
:javascript
|
||||
$('.mark_all_read').live('click', function(){
|
||||
$.ajax({
|
||||
url: 'notifications/read_all',
|
||||
success: function(data, status, xhr) {
|
||||
$('.message').removeClass('unread');
|
||||
$("#notification_badge_number").addClass("hidden");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.message').live('click', function(evt){
|
||||
var note = $(this).closest('.message'),
|
||||
note_id = note.attr('data-guid'),
|
||||
|
|
@ -23,9 +33,12 @@
|
|||
|
||||
.span-1
|
||||
= image_tag 'icons/mail_big.png', :height => 30, :width => 30, :style=>"margin-top:3px;"
|
||||
.span-23.last
|
||||
.span-10
|
||||
%h2
|
||||
= t('.notifications')
|
||||
.span-13.last.left
|
||||
.button.mark_all_read
|
||||
= link_to "Mark All as Read", "#"
|
||||
|
||||
.span-24.last
|
||||
%ul.stream.notifications
|
||||
|
|
|
|||
|
|
@ -8,11 +8,10 @@ Diaspora::Application.routes.draw do
|
|||
resources :requests, :only => [:destroy, :create]
|
||||
resources :services
|
||||
|
||||
resources :notifications
|
||||
match 'notifications/read_all' => 'notifications#read_all'
|
||||
resources :notifications, :only => [:index, :update]
|
||||
resources :posts, :only => [:show], :path => '/p/'
|
||||
|
||||
|
||||
|
||||
match '/people/share_with' => 'people#share_with', :as => 'share_with'
|
||||
resources :people do
|
||||
resources :status_messages
|
||||
|
|
|
|||
|
|
@ -2142,3 +2142,6 @@ ul.show_comments
|
|||
:margin
|
||||
:left 0.5em
|
||||
:right 0.5em
|
||||
.mark_all_read
|
||||
:position relative
|
||||
:top 10px
|
||||
|
|
|
|||
|
|
@ -32,4 +32,17 @@ describe NotificationsController do
|
|||
Notification.find(note.id).unread.should == true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#read_all" do
|
||||
it 'marks all notifications as read' do
|
||||
Notification.create(:recipient_id => user.id)
|
||||
Notification.create(:recipient_id => user.id)
|
||||
|
||||
Notification.where(:unread => true).count.should == 2
|
||||
get :read_all
|
||||
Notification.where(:unread => true).count.should == 0
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue