Refactor and extract code to partials.

This commit is contained in:
taitus
2017-09-06 14:41:58 +02:00
parent 79d4a82bfa
commit f0667937fb
5 changed files with 64 additions and 63 deletions

View 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) %>
&nbsp;&bull;&nbsp;
<span class="label round is-author">
<%= t("comments.comment.author") %>
</span>
<% end %>
</div>
</div>
</div>

View File

@@ -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) %>
&nbsp;&bull;&nbsp;
<span class="label round is-author">
<%= t("comments.comment.author") %>
</span>
<% end %>
</div>
</div>
</div>
<% end %> <% end %>
</div> </div>

View 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 %>

View 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>&nbsp;
<%= link_to t("community.show.topic.comments", count: topic.comments_count), community_topic_path(@community, topic, anchor: "comments") %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<%= I18n.l topic.created_at.to_date %>
<span class="bullet">&nbsp;&bull;&nbsp;</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>

View File

@@ -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>&nbsp;
<%= link_to t("community.show.topic.comments", count: topic.comments_count), community_topic_path(@community, topic, anchor: "comments") %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<%= I18n.l topic.created_at.to_date %>
<span class="bullet">&nbsp;&bull;&nbsp;</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 %>