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

feature: remove all scope ( V2 ) #2323

Merged
merged 3 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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,
remove_scope_all: resource.entity_loader(:scope).remove_scope_all
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we pass the loader and have the component ask the loader if it should show the default scope or not?

I feel that adding arbitrary options to it every time we change the API is not the way to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can and it's better for scalability

)
end

Expand Down
2 changes: 0 additions & 2 deletions lib/avo/base_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,6 @@ def description_attributes
}
end

private

def entity_loader(entity)
instance_variable_get("@#{entity.to_s.pluralize}_loader")
end
Expand Down
2 changes: 1 addition & 1 deletion lib/avo/loaders/loader.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Avo
module Loaders
class Loader
attr_accessor :bag
attr_accessor :bag, :remove_scope_all
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's extract this to a separate ScopeLoader class.


def initialize
@bag = []
Expand Down
Loading