Skip to content

Commit

Permalink
add search (and aliases) to disease admin. closes #872
Browse files Browse the repository at this point in the history
  • Loading branch information
acoffman committed Aug 25, 2023
1 parent 722504c commit 3d909f4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions server/app/admin/diseases_admin.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
Trestle.resource(:diseases) do
collection do
Disease.eager_load(:disease_aliases)
end

menu do
item :diseases, icon: "fa fa-disease"
end

search do |q|
q ? collection.where("diseases.doid ILIKE ? OR diseases.name ILIKE ? OR disease_aliases.name ILIKE ?", "%#{q}%", "%#{q}%", "%#{q}%") : collection
end

scope :all, default: true
scope :without_doid, -> { Disease.where(doid: nil) }

Expand All @@ -11,6 +19,9 @@
column :id
column :doid
column :name
column :aliases do |disease|
disease.disease_aliases.map(&:name).join(", ")
end
end

# Customize the form fields shown on the new/edit views.
Expand Down

0 comments on commit 3d909f4

Please sign in to comment.