Move order links partial to a component

This way the changes we have in mind we'll be easier to implement.
This commit is contained in:
Javi Martín
2021-06-27 16:58:29 +02:00
parent 5214d89c88
commit 5137913565
3 changed files with 20 additions and 11 deletions

View File

@@ -0,0 +1,11 @@
<ul class="no-bullet submenu order-links">
<% valid_orders.each do |order| %>
<li class="inline-block">
<%= link_to current_path_with_query_params(order: order, page: 1), class: order == current_order ? "is-active" : "" do %>
<%= content_tag(order == current_order ? :h2 : :span) do %>
<%= t("#{i18n_namespace}.orders.#{order}") %>
<% end %>
<% end %>
</li>
<% end %>
</ul>

View File

@@ -0,0 +1,8 @@
class Shared::OrderLinksComponent < ApplicationComponent
attr_reader :i18n_namespace
delegate :current_path_with_query_params, :current_order, :valid_orders, to: :helpers
def initialize(i18n_namespace)
@i18n_namespace = i18n_namespace
end
end

View File

@@ -1,11 +1 @@
<ul class="no-bullet submenu order-links">
<% @valid_orders.each do |order| %>
<li class="inline-block">
<%= link_to current_path_with_query_params(order: order, page: 1), class: order == @current_order ? "is-active" : "" do %>
<%= content_tag(order == @current_order ? :h2 : :span) do %>
<%= t("#{i18n_namespace}.orders.#{order}") %>
<% end %>
<% end %>
</li>
<% end %>
</ul>
<%= render Shared::OrderLinksComponent.new(i18n_namespace) %>