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: callable default_view_type #2657

Merged
merged 2 commits into from Apr 3, 2024
Merged

Conversation

Paul-Bob
Copy link
Contributor

@Paul-Bob Paul-Bob commented Apr 3, 2024

Description

This enables the possibility to define a proc on default_view_type option. It's useful when we want different default view types according to the user or used device.

class Avo::Resources::Post < Avo::BaseResource
  self.default_view_type = -> {
    mobile_user = request.user_agent =~ /Mobile/

    mobile_user ? :table : :grid
  }
end

Checklist:

@Paul-Bob Paul-Bob self-assigned this Apr 3, 2024
Copy link

codeclimate bot commented Apr 3, 2024

Code Climate has analyzed commit 5554981 and detected 0 issues on this pull request.

View more on Code Climate.

@Paul-Bob Paul-Bob merged commit 048ce1c into main Apr 3, 2024
15 of 20 checks passed
@Paul-Bob Paul-Bob deleted the feature/default_view_type branch April 3, 2024 17:06
Copy link
Contributor

github-actions bot commented Apr 3, 2024

This PR has been merged into main. The functionality will be available in the next release.

Please check the release guide for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant