Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add disease search to admin #878

Merged
merged 2 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 0 additions & 1 deletion server/app/admin/variants_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
end

scope :all
scope :with_evidence, -> { Variant.joins(:evidence_items).distinct }, default: true
scope :flagged, -> { Variant.where(flagged: true) }

# Customize the table columns shown on the index view.
Expand Down