Skip to content

Commit

Permalink
Set facet type to link in specialist document model
Browse files Browse the repository at this point in the history
  • Loading branch information
leenagupte committed Feb 25, 2025
1 parent b36017e commit afc41a3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
11 changes: 9 additions & 2 deletions app/models/specialist_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ def facet_values
f = {
key: selected_facet["key"],
name: selected_facet["name"],
type: selected_facet["type"],
filterable: selected_facet["filterable"],
}

metadata_facet_value = metadata[selected_facet["key"]]
Expand All @@ -35,6 +33,15 @@ def facet_values
else
metadata_facet_value
end

f[:type] = if selected_facet["type"] == "text" &&
f[:value].is_a?(Array) &&
selected_facet["filterable"] == true
"link"
else
selected_facet["type"]
end

f
end
end
Expand Down
17 changes: 4 additions & 13 deletions spec/models/specialist_document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@
{
key: "aircraft_category",
name: "Aircraft category",
type: "text",
filterable: true,
type: "link",
value: [{
label: "Sport aviation and balloons",
value: "sport-aviation-and-balloons",
Expand All @@ -121,8 +120,7 @@
{
key: "report_type",
name: "Report type",
type: "text",
filterable: true,
type: "link",
value: [{
label: "Bulletin - Correspondence investigation",
value: "correspondence-investigation",
Expand All @@ -132,28 +130,24 @@
key: "date_of_occurrence",
name: "Date of occurrence",
type: "date",
filterable: true,
value: "2015-08-08",
},
{
key: "aircraft_type",
name: "Aircraft type",
type: "text",
filterable: false,
value: "Rotorsport UK Calidus",
},
{
key: "location",
name: "Location",
type: "text",
filterable: false,
value: "Damyns Hall Aerodrome, Essex",
},
{
key: "registration",
name: "Registration",
type: "text",
filterable: false,
value: "G-PCPC",
},
]
Expand All @@ -170,8 +164,7 @@
{
key: "alert_type",
name: "Alert type",
type: "text",
filterable: true,
type: "link",
value: [{
label: "Medical device alert",
value: "devices",
Expand All @@ -180,8 +173,7 @@
{
key: "medical_specialism",
name: "Medical specialty",
type: "text",
filterable: true,
type: "link",
value: [
{
label: "Critical care",
Expand Down Expand Up @@ -209,7 +201,6 @@
key: "issued_date",
name: "Issued",
type: "date",
filterable: true,
value: "2015-07-06",
},
]
Expand Down

0 comments on commit afc41a3

Please sign in to comment.