Added working related contents list

Also separated related contents into partials.
This commit is contained in:
María Checa
2017-12-13 13:32:00 +01:00
parent ed8e5de094
commit 4f442792cc
4 changed files with 32 additions and 56 deletions

View File

@@ -106,7 +106,7 @@
<%= render 'shared/geozone', geozonable: @proposal %> <%= render 'shared/geozone', geozonable: @proposal %>
<%= render 'shared/related_content', relationable: @proposal %> <%= render 'relationable/related_content', relationable: @proposal %>
<div class="js-moderator-proposal-actions margin"> <div class="js-moderator-proposal-actions margin">
<%= render 'proposals/actions', proposal: @proposal %> <%= render 'proposals/actions', proposal: @proposal %>

View File

@@ -0,0 +1,15 @@
<div class="related-content padding">
<div class="margin-bottom">
<h2 class="inline-block">
<%= t("related_content.title") %>&nbsp;<span>(<%= relationable.relationed_contents.count %>)</span>
</h2>
<a data-toggle="related_content" class="add-related-content">
<%= t("related_content.add") %>
</a>
</div>
<%= render 'relationable/related_list', relationable: relationable %>
</div>

View File

@@ -0,0 +1,16 @@
<ul class="related-content-list" id="related-content-list">
<% relationable.relationed_contents.each do |related| %>
<li>
<a href="#" class="float-right flag">
<span class="icon-flag"></span> <!-- This should be similar to comments/flag_actions -->
</a>
<span><%= t("related_content.content_title.#{related.class.name.downcase}") %></span><br>
<h3 class="inline-block">
<%= link_to related.title, eval("#{related.class.name.downcase}_path(related)") %>
</h3>
</li>
<% end %>
</ul>
<!-- Add pagination here -->

View File

@@ -1,55 +0,0 @@
<div class="related-content padding">
<div class="margin-bottom">
<h2 class="inline-block">
<%= t("related_content.title") %>&nbsp;<span>(6)</span> <!-- Change number to related_content.count -->
</h2>
<a data-toggle="related_content" class="add-related-content">
<%= t("related_content.add") %>
</a>
</div>
<form id="related_content" class="hide" data-toggler=".hide"> <!-- Change to rails form, maintaining all Id/Classes -->
<label><%= t("related_content.label") %></label>
<p class="help-text" id="related_content_help_text">
<%= t("related_content.help", org: setting['org_name']) %>
</p>
<div class="input-group">
<div class="input-group-field">
<input type="text" name="related-content"
aria-describedby="related_content_help_text"
placeholder="<%= t("related_content.placeholder", url: setting['url']) %>">
</div>
<div class="input-group-button">
<input type="submit" class="button" value="<%= t("related_content.submit") %>">
</div>
</div>
</form>
<!-- Flash error -->
<div class="callout alert">
<%= t("related_content.error", url: setting['url']) %>
</div>
<!-- /. Flash error -->
<ul class="related-content-list">
<!-- Each related item do -->
<li>
<a href="#" class="float-right flag">
<span class="icon-flag"></span> <!-- This should be similar to comments/flag_actions -->
</a>
<span>DEBATE</span><br> <!-- This name has to change depending of item type -->
<h3 class="inline-block">
<%= link_to "Título del contenido relacionado", "#" %>
</h3>
</li>
<!-- /.Each related item do -->
</ul>
<!-- Add pagination here -->
</div>