Extract method to get the notifications link text
This commit is contained in:
@@ -8,23 +8,12 @@
|
||||
|
||||
<% if user.notifications.unread.count > 0 %>
|
||||
<span class="icon-circle" aria-hidden="true"></span>
|
||||
<span class="icon-notification" aria-hidden="true"
|
||||
title="<%= t("layouts.header.notification_item.new_notifications",
|
||||
count: user.notifications_count) %>">
|
||||
</span>
|
||||
<span class="show-for-small-only">
|
||||
<%= t("layouts.header.notification_item.new_notifications",
|
||||
count: user.notifications_count) %>
|
||||
</span>
|
||||
<span class="icon-notification" aria-hidden="true" title="<%= text %>"></span>
|
||||
<% else %>
|
||||
<span class="icon-no-notification" aria-hidden="true"
|
||||
title="<%= t("layouts.header.notification_item.no_notifications") %>">
|
||||
</span>
|
||||
<span class="show-for-small-only">
|
||||
<%= t("layouts.header.notification_item.no_notifications") %>
|
||||
</span>
|
||||
<span class="icon-no-notification" aria-hidden="true" title="<%= text %>"></span>
|
||||
<% end %>
|
||||
|
||||
<span class="show-for-small-only"><%= text %></span>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
@@ -4,4 +4,14 @@ class Layout::NotificationItemComponent < ApplicationComponent
|
||||
def initialize(user)
|
||||
@user = user
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def text
|
||||
if user.notifications.unread.count > 0
|
||||
t("layouts.header.notification_item.new_notifications", count: user.notifications_count)
|
||||
else
|
||||
t("layouts.header.notification_item.no_notifications")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user