Skip to content

Commit

Permalink
Get clever with the enum_text type
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBAshton committed Jan 2, 2025
1 parent 5c6d396 commit 18f0848
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,22 @@ def confirm_facets
@params["facets"].delete(facet)
end

if facet["type"] == "enum_text"
facet.delete("allowed_values")
facet["type"] = "text"
end
if facet["display_as_result_metadata"]
facet["display_as_result_metadata"] = facet["display_as_result_metadata"] == "true"
end
if facet["filterable"]
facet["filterable"] = facet["filterable"] == "true"
end
if facet["preposition"] == ""
facet.delete("preposition")
end
if facet["short_name"] == ""
facet.delete("short_name")
end

if facet["allowed_values"]
facet["allowed_values"] = facet["allowed_values"].gsub('\\"', '"').split('",').map do |str|
Expand Down
7 changes: 6 additions & 1 deletion app/views/admin/_facet_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@
label: "Type",
heading_size: "s",
options: [
{
text: "Radio button",
value: "enum_text", # 'enum_text' only used to hide the 'filter options' field (TODO).
selected: facet["type"] == "text",
},
{
text: "Text",
value: "text",
selected: facet["type"] == "text",
selected: facet["type"] == "text" && facet["allowed_values"].nil?,
},
{
text: "Date",
Expand Down

0 comments on commit 18f0848

Please sign in to comment.