Move admin proposals index view to a component
This way we can use the `header` method to simplify it a bit.
This commit is contained in:
39
app/components/admin/proposals/index_component.html.erb
Normal file
39
app/components/admin/proposals/index_component.html.erb
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<% provide :main_class, "admin-proposals-index" %>
|
||||||
|
|
||||||
|
<%= header %>
|
||||||
|
|
||||||
|
<% if proposals.any? %>
|
||||||
|
<%= render Admin::SearchComponent.new(label: t("admin.shared.search.label.proposals")) %>
|
||||||
|
|
||||||
|
<h3><%= page_entries_info proposals %></h3>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="text-center"><%= t("admin.proposals.index.id") %></th>
|
||||||
|
<th><%= Proposal.human_attribute_name(:title) %></th>
|
||||||
|
<th><%= t("admin.proposals.index.author") %></th>
|
||||||
|
<th><%= t("admin.proposals.index.milestones") %></th>
|
||||||
|
<th><%= t("admin.proposals.index.selected") %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<% proposals.each do |proposal| %>
|
||||||
|
<tr id="<%= dom_id(proposal) %>" class="proposal">
|
||||||
|
<td class="text-center"><%= proposal.id %></td>
|
||||||
|
<td><%= link_to proposal.title, admin_proposal_path(proposal) %></td>
|
||||||
|
<td><%= proposal.author.username %></td>
|
||||||
|
<td><%= proposal.milestones.count %></td>
|
||||||
|
<td><%= render Admin::Proposals::ToggleSelectionComponent.new(proposal) %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<%= paginate proposals %>
|
||||||
|
<% else %>
|
||||||
|
<div class="callout primary">
|
||||||
|
<%= t("admin.proposals.index.no_proposals") %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
12
app/components/admin/proposals/index_component.rb
Normal file
12
app/components/admin/proposals/index_component.rb
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
class Admin::Proposals::IndexComponent < ApplicationComponent
|
||||||
|
include Header
|
||||||
|
attr_reader :proposals
|
||||||
|
|
||||||
|
def initialize(proposals)
|
||||||
|
@proposals = proposals
|
||||||
|
end
|
||||||
|
|
||||||
|
def title
|
||||||
|
t("admin.proposals.index.title")
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,41 +1 @@
|
|||||||
<% provide(:title) do %>
|
<%= render Admin::Proposals::IndexComponent.new(@proposals) %>
|
||||||
<%= t("admin.header.title") %> - <%= t("admin.proposals.index.title") %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<h2><%= t("admin.proposals.index.title") %></h2>
|
|
||||||
|
|
||||||
<% if @proposals.any? %>
|
|
||||||
<%= render Admin::SearchComponent.new(label: t("admin.shared.search.label.proposals")) %>
|
|
||||||
|
|
||||||
<h3><%= page_entries_info @proposals %></h3>
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="text-center"><%= t("admin.proposals.index.id") %></th>
|
|
||||||
<th><%= Proposal.human_attribute_name(:title) %></th>
|
|
||||||
<th><%= t("admin.proposals.index.author") %></th>
|
|
||||||
<th><%= t("admin.proposals.index.milestones") %></th>
|
|
||||||
<th><%= t("admin.proposals.index.selected") %></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
|
||||||
<% @proposals.each do |proposal| %>
|
|
||||||
<tr id="<%= dom_id(proposal) %>" class="proposal">
|
|
||||||
<td class="text-center"><%= proposal.id %></td>
|
|
||||||
<td><%= link_to proposal.title, admin_proposal_path(proposal) %></td>
|
|
||||||
<td><%= proposal.author.username %></td>
|
|
||||||
<td><%= proposal.milestones.count %></td>
|
|
||||||
<td><%= render Admin::Proposals::ToggleSelectionComponent.new(proposal) %></td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<%= paginate @proposals %>
|
|
||||||
<% else %>
|
|
||||||
<div class="callout primary">
|
|
||||||
<%= t("admin.proposals.index.no_proposals") %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user