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