mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
35 lines
1.1 KiB
Plaintext
35 lines
1.1 KiB
Plaintext
<% field[:value].each do |link_code| %>
|
|
<%
|
|
klass, id = link_code.split('-')
|
|
%>
|
|
|
|
<%#
|
|
In most cases, a user will be seeing their own content most of the time.
|
|
This allows us to primarily rely on @current_user_content but fall back
|
|
on js-load-page-name to fetch & load in post-page-load if the content isn't ours.
|
|
%>
|
|
<%
|
|
content = if user_signed_in?
|
|
@current_user_content.fetch(klass, []).detect do |page|
|
|
page.page_type === klass && page.id === id.to_i
|
|
end
|
|
else
|
|
nil
|
|
end
|
|
%>
|
|
|
|
<span
|
|
data-klass="<%= klass %>"
|
|
data-id="<%= id %>"
|
|
class="<%= 'js-load-page-name' if content.nil? %> inline-flex items-center px-2.5 py-0.5 rounded-md font-medium bg-gray-100 hover:bg-gray-50 text-gray-800"
|
|
>
|
|
<%= link_to send("#{klass.downcase}_path", id) do %>
|
|
<span class="<%= content_class_from_name(klass).text_color %>">
|
|
<i class="material-icons float-left mr-2">
|
|
<%= content_class_from_name(klass).icon %>
|
|
</i>
|
|
</span>
|
|
<%= content.try(:name) || "<em>Loading #{klass}</em>".html_safe %>
|
|
<% end %>
|
|
</span>
|
|
<% end %> |