Made wording more clear, refactored read_all

This commit is contained in:
jaideng123 2014-08-17 11:16:30 -05:00
parent 6456a441fe
commit 406397988b
3 changed files with 15 additions and 11 deletions

View file

@ -65,22 +65,22 @@ class NotificationsController < ApplicationController
end
def read_all
if params[:type]
Notification.where(:recipient_id => current_user.id, :type => Notification.types[params[:type]]).update_all(:unread => false)
else
Notification.where(:recipient_id => current_user.id).update_all(:unread => false)
end
current_type = Notification.types[params[:type]]
notifications = Notification.where(:recipient_id => current_user.id)
notifications = notifications.where(:type => current_type) if params[:type]
notifications.update_all(:unread => false)
respond_to do |format|
if current_user.unread_notifications.count > 0
format.html { redirect_to notifications_path}
format.mobile{ redirect_to notifications_path}
format.html { redirect_to notifications_path }
format.mobile { redirect_to notifications_path }
else
format.html { redirect_to stream_path }
format.mobile{ redirect_to stream_path}
format.mobile { redirect_to stream_path }
end
format.xml { render :xml => {}.to_xml }
format.json { render :json => {}.to_json }
format.xml { render :xml => {}.to_xml }
format.json { render :json => {}.to_json }
end
end
end

View file

@ -37,7 +37,10 @@
%a.btn.btn-default{ :class => ('active' if params[:show] == 'unread'), :href => '/notifications?show=unread' + (params[:type] ? '&type=' + params[:type] : '') }
= t('.show_unread')
%a.btn.btn-default{:href => read_all_notifications_path(:type => params[:type] ), :class => ('disabled' unless @unread_notification_count > 0)}
= t('.mark_all_as_read')
-if params[:type]
= t('.mark_all_shown_as_read')
-else
= t('.mark_all_as_read')
- @group_days.each do |day, notes|
.day_group.row-fluid
.date.span2

View file

@ -708,6 +708,7 @@ en:
index:
notifications: "Notifications"
mark_all_as_read: "Mark all as read"
mark_all_shown_as_read: "Mark all shown as read"
mark_read: "Mark read"
mark_unread: "Mark unread"
show_all: "show all"