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

How do I selectively display a key/value pair? #133

Open
omarkamal opened this issue Mar 17, 2023 · 2 comments
Open

How do I selectively display a key/value pair? #133

omarkamal opened this issue Mar 17, 2023 · 2 comments

Comments

@omarkamal
Copy link

omarkamal commented Mar 17, 2023

Say I have a serializer like this :

class Device < Panko::Serializer
  attributes :id, :name
  has_many :lights, serializer: LightSerializer
  has_many :fans, serializer: FanSerializer
  has_many :curtains, serializer: CurtainSerializer
end

now every device need not have all three, some might have just a fan and a light, some might have just a light.

I don't want to display empty arrays every single time. How do I selectively hide them if the array size is zero? I tried adding if: -> { object.fans.count > 0 } but that didn't seem to work, I still got an empty array.

@kemalmutlu
Copy link

I have the same problem. Any news?

@yosiat
Copy link
Owner

yosiat commented Oct 23, 2023

Hey,

There is no option to have dynamic filters like you ask, the only way to do filtering is Nested Filters or Filters For.

Dynamic filters like this, might be something that I'll add in the future, right now it's not planned.

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

No branches or pull requests

3 participants