notifications now can be read
This commit is contained in:
parent
c749d81fe9
commit
2e85a9fe66
4 changed files with 22 additions and 9 deletions
|
|
@ -6,10 +6,11 @@ class NotificationsController < ApplicationController
|
|||
before_filter :authenticate_user!
|
||||
respond_to :html
|
||||
|
||||
def destroy
|
||||
|
||||
def update
|
||||
note = Notification.find_by_user_id_and_id(current_user.id, params[:id])
|
||||
if note
|
||||
note.delete
|
||||
note.update_attributes(:unread => false)
|
||||
render :nothing => true
|
||||
else
|
||||
render :nothing => true, :code => 404
|
||||
|
|
@ -20,6 +21,5 @@ class NotificationsController < ApplicationController
|
|||
@notifications = Notification.for(current_user)
|
||||
@group_days = @notifications.group_by{|note| note.created_at.strftime("%B %d") }
|
||||
respond_with @notifications
|
||||
@notifications.find_all{|x| x.unread ==true}.each{|x| x.update_attributes(:unread => false)}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,11 +1,21 @@
|
|||
%ul
|
||||
:javascript
|
||||
$('.note a').live('click', function(evt){
|
||||
var note_id = $(this).closest('.note').attr('id');
|
||||
$.ajax({
|
||||
url: 'notifications/' + note_id,
|
||||
type: 'PUT'
|
||||
});
|
||||
});
|
||||
|
||||
%ul.notes
|
||||
- @group_days.each do |day, notes|
|
||||
%h3
|
||||
%ul
|
||||
%li
|
||||
= day
|
||||
- notes.each do |note|
|
||||
%li
|
||||
= link_to "#{note.person.name.titleize}", person_path(note.person)
|
||||
= object_link(note)
|
||||
%span.description=" #{t('ago', :time => time_ago_in_words(note.created_at))}"
|
||||
%li.note{:id => note.id}
|
||||
%h4{:class => "#{note.unread ? 'unread' : ''}"}
|
||||
= link_to "#{note.person.name.titleize}", person_path(note.person)
|
||||
= object_link(note)
|
||||
%span.description=" #{t('ago', :time => time_ago_in_words(note.created_at))}"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ Diaspora::Application.routes.draw do
|
|||
resources :requests, :only => [:destroy, :create]
|
||||
resources :services
|
||||
|
||||
resources :notifications, :only => [:destroy, :index]
|
||||
resources :notifications
|
||||
resources :posts, :only => [:show], :path => '/p/'
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -218,6 +218,9 @@ header
|
|||
:top 2px
|
||||
:display block
|
||||
|
||||
.unread
|
||||
:background-color #eee
|
||||
|
||||
.diaspora_header_logo
|
||||
:position relative
|
||||
:top 4px
|
||||
|
|
|
|||
Loading…
Reference in a new issue