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:
11
app/components/shared/order_links_component.html.erb
Normal file
11
app/components/shared/order_links_component.html.erb
Normal 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>
|
||||
8
app/components/shared/order_links_component.rb
Normal file
8
app/components/shared/order_links_component.rb
Normal 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
|
||||
@@ -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) %>
|
||||
|
||||
Reference in New Issue
Block a user