Extract proposals table into a partial

This commit is contained in:
Javi Martín
2018-09-17 17:23:11 +02:00
parent a859de5d16
commit 9df201780d
2 changed files with 39 additions and 40 deletions

View File

@@ -0,0 +1,38 @@
<% if proposals.any? %>
<h3><%= page_entries_info proposals %></h3>
<%= render 'shared/wide_order_selector', i18n_namespace: "admin.legislation.processes.proposals" %>
<table class="stack" id="proposals_table">
<thead>
<tr>
<th class="text-center"><%= t("admin.legislation.proposals.index.id") %></th>
<th><%= t("admin.legislation.proposals.index.title") %></th>
<th class="text-center"><%= t("admin.legislation.proposals.index.supports") %></th>
<th><%= t("admin.legislation.proposals.index.selected") %></th>
</tr>
</thead>
<tbody>
<% proposals.each do |proposal| %>
<tr id="<%= dom_id(proposal) %>">
<td class="text-center"><%= proposal.id %></td>
<td><%= proposal.title %></td>
<td class="text-center"><%= proposal.cached_votes_up %></td>
<td>
<% if proposal.selected?
button_text = t("admin.legislation.proposals.index.selected")
clas = 'button expanded'
else
button_text = t("admin.legislation.proposals.index.select")
clas = 'button hollow expanded'
end %>
<%= link_to button_text, admin_legislation_process_proposal_path(@process, proposal), method: 'PUT', class: clas %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate proposals %>
<% end %>

View File

@@ -11,44 +11,5 @@
<%= render 'admin/legislation/processes/subnav', process: @process, active: 'proposals' %>
<%= render 'form' %>
<% if @proposals.any? %>
<h3><%= page_entries_info @proposals %></h3>
<%= render 'shared/wide_order_selector', i18n_namespace: "admin.legislation.processes.proposals" %>
<table class="stack" id="proposals_table">
<thead>
<tr>
<th class="text-center"><%= t("admin.legislation.proposals.index.id") %></th>
<th><%= t("admin.legislation.proposals.index.title") %></th>
<th class="text-center"><%= t("admin.legislation.proposals.index.supports") %></th>
<th><%= t("admin.legislation.proposals.index.selected") %></th>
</tr>
</thead>
<tbody>
<% @proposals.each do |proposal| %>
<tr id="<%= dom_id(proposal) %>">
<td class="text-center"><%= proposal.id %></td>
<td><%= proposal.title %></td>
<td class="text-center"><%= proposal.cached_votes_up %></td>
<td>
<% if proposal.selected?
button_text = t("admin.legislation.proposals.index.selected")
clas = 'button expanded'
else
button_text = t("admin.legislation.proposals.index.select")
clas = 'button hollow expanded'
end %>
<%= link_to button_text, admin_legislation_process_proposal_path(@process, proposal), method: 'PUT', class: clas %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @proposals %>
<% end %>
<%= render 'proposals', proposals: @proposals %>
</div>