Move geozones index view to a component
This way we simplify the header and it will be easier to add more code and tests.
This commit is contained in:
29
app/components/admin/geozones/index_component.html.erb
Normal file
29
app/components/admin/geozones/index_component.html.erb
Normal file
@@ -0,0 +1,29 @@
|
||||
<%= header do %>
|
||||
<%= link_to t("admin.geozones.index.create"), new_admin_geozone_path %>
|
||||
<% end %>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("admin.geozones.geozone.name") %></th>
|
||||
<th><%= t("admin.geozones.geozone.external_code") %></th>
|
||||
<th><%= t("admin.geozones.geozone.census_code") %></th>
|
||||
<th><%= t("admin.geozones.geozone.coordinates") %></th>
|
||||
<th><%= t("admin.actions.actions") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% geozones.each do |geozone| %>
|
||||
<tr id="<%= dom_id(geozone) %>">
|
||||
<td><%= geozone.name %></td>
|
||||
<td><%= geozone.external_code %></td>
|
||||
<td><%= geozone.census_code %></td>
|
||||
<td class="break"><%= geozone.html_map_coordinates %></td>
|
||||
<td>
|
||||
<%= render Admin::TableActionsComponent.new(geozone) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
14
app/components/admin/geozones/index_component.rb
Normal file
14
app/components/admin/geozones/index_component.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
class Admin::Geozones::IndexComponent < ApplicationComponent
|
||||
include Header
|
||||
attr_reader :geozones
|
||||
|
||||
def initialize(geozones)
|
||||
@geozones = geozones
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def title
|
||||
t("admin.geozones.index.title")
|
||||
end
|
||||
end
|
||||
@@ -1,30 +1 @@
|
||||
<%= link_to t("admin.geozones.index.create"),
|
||||
new_admin_geozone_path, class: "button float-right" %>
|
||||
|
||||
<h2 class="inline-block"><%= t("admin.geozones.index.title") %></h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("admin.geozones.geozone.name") %></th>
|
||||
<th><%= t("admin.geozones.geozone.external_code") %></th>
|
||||
<th><%= t("admin.geozones.geozone.census_code") %></th>
|
||||
<th><%= t("admin.geozones.geozone.coordinates") %></th>
|
||||
<th><%= t("admin.actions.actions") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @geozones.each do |geozone| %>
|
||||
<tr id="<%= dom_id(geozone) %>">
|
||||
<td><%= geozone.name %></td>
|
||||
<td><%= geozone.external_code %></td>
|
||||
<td><%= geozone.census_code %></td>
|
||||
<td class="break"><%= geozone.html_map_coordinates %></td>
|
||||
<td>
|
||||
<%= render Admin::TableActionsComponent.new(geozone) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<%= render Admin::Geozones::IndexComponent.new(@geozones) %>
|
||||
|
||||
Reference in New Issue
Block a user