Skip to content

Commit

Permalink
feature: remove all scope ( V2 ) (#2323)
Browse files Browse the repository at this point in the history
* feature: remove all scope ( V2 )

* apply review suggestions

---------

Co-authored-by: Adrian Marin <adrian@adrianthedev.com>
  • Loading branch information
Paul-Bob and adrianthedev committed Jan 16, 2024
1 parent 549bd1d commit 4cbf642
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/components/avo/views/resource_index_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ def scopes_list
resource: resource,
turbo_frame: turbo_frame,
parent_record: parent_record,
query: query
query: query,
loader: resource.entity_loader(:scope)
)
end

Expand Down
9 changes: 6 additions & 3 deletions lib/avo/base_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,12 @@ def fields
define_method "get_#{plural_entity}" do
return entity_loader(entity).bag if entity_loader(entity).present?

instance_variable_set("@#{plural_entity}_loader", Avo::Loaders::Loader.new)
# ex: @actions_loader = Avo::Loaders::ActionsLoader.new
instance_variable_set(
"@#{plural_entity}_loader",
"Avo::Loaders::#{plural_entity.humanize}Loader".constantize.new
)

send plural_entity

entity_loader(entity).bag
Expand Down Expand Up @@ -561,8 +566,6 @@ def description_attributes
}
end

private

def entity_loader(entity)
instance_variable_get("@#{entity.to_s.pluralize}_loader")
end
Expand Down
7 changes: 7 additions & 0 deletions lib/avo/loaders/scopes_loader.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Avo
module Loaders
class ScopesLoader < Loader
attr_accessor :remove_scope_all
end
end
end

0 comments on commit 4cbf642

Please sign in to comment.