Skip to content

Commit

Permalink
restore bugfix for missing @page_facets
Browse files Browse the repository at this point in the history
fixes #305
Jessica previously fixed this bug but the fix wasn't applied to the new method
  • Loading branch information
wkdewey committed Oct 4, 2024
1 parent f431a1c commit 2b4a9e3
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions app/helpers/orchid/facet_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@ def create_label(key, default="No Label")
# used for URL creation and translation matching
# label: non normalized value ("Willa Cather", '"Yellowstone Kelly"')
def facet_label(type: nil, normalized: nil, label: nil)
# determine if translation needed
info = @page_facets[type]
if info && info["flags"] && info["flags"].include?("translate")
# do not need "label" since that will be found in the locale info
facet_label_translation(type: type, normalized: normalized)
# if @page_facets are not present, for example if a search_preset
# view or a custom action are using the metadata method,
# do not error but just skip possible translations
if @page_facets.present?
# determine if translation needed
info = @page_facets[type]
if info && info["flags"] && info["flags"].include?("translate")
# do not need "label" since that will be found in the locale info
facet_label_translation(type: type, normalized: normalized)
else
# if there is no label specified, use the normalized version
sanitize(label) || normalized
end
else
# if there is no label specified, use the normalized version
sanitize(label) || normalized
label
end
end

Expand Down

0 comments on commit 2b4a9e3

Please sign in to comment.