Skip to content

Commit

Permalink
minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianthedev committed Jan 27, 2025
1 parent 22093f1 commit 3b70313
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/avo/resources/resource_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ def fetch_resources
end

# All descendants from Avo::Resources::Base except the internal ones
Base.descendants - [Avo::BaseResource, Avo::Resources::ArrayResource]
Base.descendants - internal_resources
end

def internal_resources
[Avo::BaseResource, Avo::Resources::ArrayResource]
end

def load_resources_namespace
Expand Down
1 change: 1 addition & 0 deletions spec/dummy/app/avo/resources/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def fields
field :location, as: :belongs_to
end

# this field demonstrated how one can use the array field to display an arbitrary array of objects as a "has_many field"
field :attendees, as: :array do
[
{id: 1, name: "John Doe", role: "Software Developer", organization: "TechCorp"},
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/app/avo/resources/movie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def fields
field :id, as: :id
field :name, as: :text
field :release_date, as: :date
field :fun_fact, only_on: :index, visible: -> { resource.record.fun_fact.present? } do
field :fun_fact, only_on: :index, visible: -> { resource.record&.fun_fact.present? } do
record.fun_fact.truncate_words(10)
end

Expand Down

0 comments on commit 3b70313

Please sign in to comment.