From 882cc85532230f2412b489a94b91db2571c1ee14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 3 May 2023 18:18:19 +0200 Subject: [PATCH] Move geozones index view to a component This way we simplify the header and it will be easier to add more code and tests. --- .../admin/geozones/index_component.html.erb | 29 +++++++++++++++++ .../admin/geozones/index_component.rb | 14 +++++++++ app/views/admin/geozones/index.html.erb | 31 +------------------ 3 files changed, 44 insertions(+), 30 deletions(-) create mode 100644 app/components/admin/geozones/index_component.html.erb create mode 100644 app/components/admin/geozones/index_component.rb diff --git a/app/components/admin/geozones/index_component.html.erb b/app/components/admin/geozones/index_component.html.erb new file mode 100644 index 000000000..5ed12f1c1 --- /dev/null +++ b/app/components/admin/geozones/index_component.html.erb @@ -0,0 +1,29 @@ +<%= header do %> + <%= link_to t("admin.geozones.index.create"), new_admin_geozone_path %> +<% end %> + + + + + + + + + + + + + + <% geozones.each do |geozone| %> + + + + + + + + <% end %> + +
<%= t("admin.geozones.geozone.name") %><%= t("admin.geozones.geozone.external_code") %><%= t("admin.geozones.geozone.census_code") %><%= t("admin.geozones.geozone.coordinates") %><%= t("admin.actions.actions") %>
<%= geozone.name %><%= geozone.external_code %><%= geozone.census_code %><%= geozone.html_map_coordinates %> + <%= render Admin::TableActionsComponent.new(geozone) %> +
diff --git a/app/components/admin/geozones/index_component.rb b/app/components/admin/geozones/index_component.rb new file mode 100644 index 000000000..4701c84b8 --- /dev/null +++ b/app/components/admin/geozones/index_component.rb @@ -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 diff --git a/app/views/admin/geozones/index.html.erb b/app/views/admin/geozones/index.html.erb index c8dabf366..105224725 100644 --- a/app/views/admin/geozones/index.html.erb +++ b/app/views/admin/geozones/index.html.erb @@ -1,30 +1 @@ -<%= link_to t("admin.geozones.index.create"), - new_admin_geozone_path, class: "button float-right" %> - -

<%= t("admin.geozones.index.title") %>

- - - - - - - - - - - - - - <% @geozones.each do |geozone| %> - - - - - - - - <% end %> - -
<%= t("admin.geozones.geozone.name") %><%= t("admin.geozones.geozone.external_code") %><%= t("admin.geozones.geozone.census_code") %><%= t("admin.geozones.geozone.coordinates") %><%= t("admin.actions.actions") %>
<%= geozone.name %><%= geozone.external_code %><%= geozone.census_code %><%= geozone.html_map_coordinates %> - <%= render Admin::TableActionsComponent.new(geozone) %> -
+<%= render Admin::Geozones::IndexComponent.new(@geozones) %>