docbrown/app/views/notifications/_broadcast.html.erb
Jeremy Friesen a65954107f
Refactoring to add helper method (#16064)
* Refactoring to add helper method

Prior to this commit, we made view level calls to service modules.  This
refactor provides convenience methods on the model.

Furthermore, it addresses a few Rubocop violations that "come along for
the ride."

* Ensuring cached entity squaks like User

* Fixing broken spec

* Fixing typo
2022-01-12 11:21:44 -05:00

16 lines
1 KiB
Text

<div class="crayons-card notification notification--promoted">
<% json_data = notification.json_data %>
<% user = User.find_by(id: json_data["user"]["id"]) %>
<% cache "broadcast-html-#{notification.json_data['broadcast']['title']}" do %>
<a href="<%= json_data["user"]["path"] %>" class="crayons-avatar crayons-avatar--2xl m:crayons-avatar--3xl shrink-0 mb-4 m:mb-6">
<img src="<%= user.profile_image_url %>" class="crayons-avatar__image" alt="link to <%= json_data["user"]["username"] %>'s profile" width="128" height="128">
</a>
<div class="fs-base m:fs-l broadcast-content" id="<%= sanitized_broadcast_id(json_data["broadcast"]["title"]) %>">
<%= json_data["broadcast"]["processed_html"].html_safe %>
<% if notification.json_data['broadcast']['type_of'] == "Welcome" %>
<p class="fs-base pt-6 color-base-70"><%= t("views.notifications.broadcast.visit_html", settings: link_to(t("views.notifications.broadcast.settings"), user_settings_path(tab: :notifications))) %></p>
<% end %>
</div>
<% end %>
</div>