-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Match path fix for tabs in Solidus < 2.8
- Loading branch information
Showing
4 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# In versions of Solidus prior to 2.8, we override this class to | ||
# add the match_path option to the initializer. (Version 2.8 has | ||
# this option already.) This option is used in the tabs partial | ||
# to configure the paths for which a given tab is active. | ||
# | ||
if Spree.solidus_gem_version < Gem::Version.new('2.8') | ||
Spree::BackendConfiguration::MenuItem.class_eval do | ||
attr_reader :match_path | ||
|
||
def initialize( | ||
sections, | ||
icon, | ||
condition: nil, | ||
label: nil, | ||
partial: nil, | ||
url: nil, | ||
match_path: nil | ||
) | ||
|
||
@condition = condition || -> { true } | ||
@sections = sections | ||
@icon = icon | ||
@label = label || sections.first | ||
@partial = partial | ||
@url = url | ||
@match_path = match_path | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<% Spree::Backend::Config.menu_items.each do |menu_item| %> | ||
<% if instance_exec(&menu_item.condition) %> | ||
<%= | ||
tab( | ||
*menu_item.sections, | ||
icon: menu_item.icon, | ||
label: menu_item.label, | ||
url: menu_item.url.is_a?(Symbol) ? spree.public_send(menu_item.url) : menu_item.url, | ||
match_path: menu_item.match_path | ||
) do | ||
%> | ||
<%- render partial: menu_item.partial if menu_item.partial %> | ||
<%- end %> | ||
<% end %> | ||
<% end %> |