don't extend helpers in the notifications index view; make notification_count and unread_message_count controller helper methods (now that we're not using vanna)
This commit is contained in:
parent
2c50de0726
commit
778683f3e3
3 changed files with 15 additions and 17 deletions
|
|
@ -7,14 +7,15 @@ class ApplicationController < ActionController::Base
|
||||||
protect_from_forgery :except => :receive
|
protect_from_forgery :except => :receive
|
||||||
|
|
||||||
before_filter :ensure_http_referer_is_set
|
before_filter :ensure_http_referer_is_set
|
||||||
before_filter :set_header_data, :except => [:create, :update, :destroy]
|
|
||||||
before_filter :set_locale
|
before_filter :set_locale
|
||||||
before_filter :set_git_header if (AppConfig[:git_update] && AppConfig[:git_revision])
|
before_filter :set_git_header if (AppConfig[:git_update] && AppConfig[:git_revision])
|
||||||
before_filter :set_grammatical_gender
|
before_filter :set_grammatical_gender
|
||||||
|
|
||||||
inflection_method :grammatical_gender => :gender
|
inflection_method :grammatical_gender => :gender
|
||||||
|
|
||||||
helper_method :all_aspects,
|
helper_method :notification_count,
|
||||||
|
:unread_message_count,
|
||||||
|
:all_aspects,
|
||||||
:all_contacts_count,
|
:all_contacts_count,
|
||||||
:my_contacts_count,
|
:my_contacts_count,
|
||||||
:only_sharing_count,
|
:only_sharing_count,
|
||||||
|
|
@ -22,13 +23,6 @@ class ApplicationController < ActionController::Base
|
||||||
:tags,
|
:tags,
|
||||||
:open_publisher
|
:open_publisher
|
||||||
|
|
||||||
def set_header_data
|
|
||||||
if user_signed_in? && request.format.html? && !params[:only_posts]
|
|
||||||
@notification_count = Notification.for(current_user, :unread =>true).count
|
|
||||||
@unread_message_count = ConversationVisibility.sum(:unread, :conditions => "person_id = #{current_user.person.id}")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def ensure_http_referer_is_set
|
def ensure_http_referer_is_set
|
||||||
request.env['HTTP_REFERER'] ||= '/aspects'
|
request.env['HTTP_REFERER'] ||= '/aspects'
|
||||||
end
|
end
|
||||||
|
|
@ -45,6 +39,14 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
##helpers
|
##helpers
|
||||||
|
def notification_count
|
||||||
|
@notification_count ||= Notification.for(current_user, :unread =>true).size
|
||||||
|
end
|
||||||
|
|
||||||
|
def unread_message_count
|
||||||
|
@unread_message_count ||= ConversationVisibility.sum(:unread, :conditions => "person_id = #{current_user.person.id}")
|
||||||
|
end
|
||||||
|
|
||||||
def all_aspects
|
def all_aspects
|
||||||
@all_aspects ||= current_user.aspects
|
@all_aspects ||= current_user.aspects
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -92,8 +92,8 @@
|
||||||
:javascript
|
:javascript
|
||||||
app.user({
|
app.user({
|
||||||
current_user: _.extend(#{current_user.person.as_api_response(:backbone).to_json}, {
|
current_user: _.extend(#{current_user.person.as_api_response(:backbone).to_json}, {
|
||||||
notifications_count : #{@notification_count},
|
notifications_count : #{notification_count},
|
||||||
unread_messages_count : #{@unread_message_count},
|
unread_messages_count : #{unread_message_count},
|
||||||
admin : #{current_user.admin?}
|
admin : #{current_user.admin?}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,8 @@
|
||||||
-self.extend AspectGlobalHelper
|
|
||||||
-self.extend AspectsHelper
|
|
||||||
-self.extend ApplicationHelper
|
|
||||||
-self.extend ErrorMessagesHelper
|
|
||||||
#notifications_content
|
#notifications_content
|
||||||
.span-13
|
.span-13
|
||||||
%h2
|
%h2
|
||||||
%span.notification_count{:class => ('unread' if @notification_count > 0)}
|
%span.notification_count{:class => ('unread' if notification_count > 0)}
|
||||||
= @notification_count
|
= notification_count
|
||||||
= t('.notifications')
|
= t('.notifications')
|
||||||
.span-8.last
|
.span-8.last
|
||||||
= link_to t('.mark_all_as_read'), notifications_read_all_path, :class => 'button'
|
= link_to t('.mark_all_as_read'), notifications_read_all_path, :class => 'button'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue