Refactor and extract code to partials.
This commit is contained in:
22
app/views/communities/_participant.html.erb
Normal file
22
app/views/communities/_participant.html.erb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<div class="comment-body">
|
||||||
|
<div class="comment-info">
|
||||||
|
|
||||||
|
<%= avatar_image( participant, seed: participant.id, size: 32, class: 'author-photo') %>
|
||||||
|
|
||||||
|
<div class="comment-info">
|
||||||
|
|
||||||
|
<span class="user-name">
|
||||||
|
<%= link_to participant.name, user_path(participant)%>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<% if is_author?(@community, participant) %>
|
||||||
|
•
|
||||||
|
<span class="label round is-author">
|
||||||
|
<%= t("comments.comment.author") %>
|
||||||
|
</span>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -14,28 +14,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<% @participants.each do |participant| %>
|
<% @participants.each do |participant| %>
|
||||||
<div class="comment-body">
|
<%= render 'participant', participant: participant %>
|
||||||
<div class="comment-info">
|
|
||||||
|
|
||||||
<%= avatar_image( participant, seed: participant.id, size: 32, class: 'author-photo') %>
|
|
||||||
|
|
||||||
<div class="comment-info">
|
|
||||||
|
|
||||||
<span class="user-name">
|
|
||||||
<%= link_to participant.name, user_path(participant)%>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<% if is_author?(@community, participant) %>
|
|
||||||
•
|
|
||||||
<span class="label round is-author">
|
|
||||||
<%= t("comments.comment.author") %>
|
|
||||||
</span>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
11
app/views/topics/_informative_text.html.erb
Normal file
11
app/views/topics/_informative_text.html.erb
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<h3><%= t("community.show.create_first_community_topic.first_theme") %></h3>
|
||||||
|
|
||||||
|
<% if user_signed_in? %>
|
||||||
|
<%= t("community.show.create_first_community_topic.first_theme_not_logged_in") %>
|
||||||
|
<% else %>
|
||||||
|
<div class="callout primary">
|
||||||
|
<%= t("community.show.create_first_community_topic.sub_first_theme",
|
||||||
|
link: link_to(t("community.show.create_first_community_topic.sign_link",
|
||||||
|
org_name: setting['org_name']), new_user_session_path)).html_safe %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
25
app/views/topics/_topic.html.erb
Normal file
25
app/views/topics/_topic.html.erb
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<div id="<%= dom_id(topic) %>" class="panel column">
|
||||||
|
|
||||||
|
<div class="small-8 column">
|
||||||
|
|
||||||
|
<h3><%= link_to topic.title, community_topic_path(@community, topic) %></h3>
|
||||||
|
|
||||||
|
<p class="topic-info">
|
||||||
|
<span class="icon-comments"></span>
|
||||||
|
<%= link_to t("community.show.topic.comments", count: topic.comments_count), community_topic_path(@community, topic, anchor: "comments") %>
|
||||||
|
<span class="bullet"> • </span>
|
||||||
|
<%= I18n.l topic.created_at.to_date %>
|
||||||
|
<span class="bullet"> • </span>
|
||||||
|
<%= topic.author.name %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="small-4 column text-right">
|
||||||
|
<% if topic.author == current_user %>
|
||||||
|
<%= link_to t("community.show.topic.edit_button"), edit_community_topic_path(@community.id, topic), class: 'button small hollow' %>
|
||||||
|
<%= link_to t("community.show.topic.destroy_button"), community_topic_path(@community.id, topic), method: :delete, class: 'button hollow alert small' %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
@@ -1,49 +1,13 @@
|
|||||||
<% if topics.any? %>
|
<% if topics.any? %>
|
||||||
|
|
||||||
<div class="row column">
|
<div class="row column">
|
||||||
<div class="order">
|
<div class="order">
|
||||||
<%= render 'shared/wide_order_selector', i18n_namespace: "comments" %>
|
<%= render 'shared/wide_order_selector', i18n_namespace: "comments" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% topics.each do |topic| %>
|
|
||||||
|
|
||||||
<div id="<%= dom_id(topic) %>" class="panel column">
|
|
||||||
<div class="small-8 column">
|
|
||||||
|
|
||||||
<h3><%= link_to topic.title, community_topic_path(@community, topic) %></h3>
|
|
||||||
|
|
||||||
<p class="topic-info">
|
|
||||||
<span class="icon-comments"></span>
|
|
||||||
<%= link_to t("community.show.topic.comments", count: topic.comments_count), community_topic_path(@community, topic, anchor: "comments") %>
|
|
||||||
<span class="bullet"> • </span>
|
|
||||||
<%= I18n.l topic.created_at.to_date %>
|
|
||||||
<span class="bullet"> • </span>
|
|
||||||
<%= topic.author.name %>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="small-4 column text-right">
|
|
||||||
<% if topic.author == current_user %>
|
|
||||||
<%= link_to t("community.show.topic.edit_button"), edit_community_topic_path(@community.id, topic), class: 'button small hollow' %>
|
|
||||||
<%= link_to t("community.show.topic.destroy_button"), community_topic_path(@community.id, topic), method: :delete, class: 'button hollow alert small' %>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% else %>
|
<% else %>
|
||||||
<h3><%= t("community.show.create_first_community_topic.first_theme") %></h3>
|
<%= render 'topics/informative_text', topics: topics %>
|
||||||
<% if user_signed_in? %>
|
<% end %>
|
||||||
<%= t("community.show.create_first_community_topic.first_theme_not_logged_in") %>
|
|
||||||
<% else %>
|
<% topics.each do |topic| %>
|
||||||
<div class="callout primary">
|
<%= render 'topics/topic', topic: topic %>
|
||||||
<%= t("community.show.create_first_community_topic.sub_first_theme",
|
|
||||||
link: link_to(t("community.show.create_first_community_topic.sign_link",
|
|
||||||
org_name: setting['org_name']), new_user_session_path)).html_safe %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
Reference in New Issue
Block a user