avo-hq / avo

Build Ruby on Rails apps 10x faster
https://avohq.io
Other
1.52k stars 251 forks source link

Add sidebar to has many fields panels #2349

Open Paul-Bob opened 10 months ago

Paul-Bob commented 10 months ago

Feature

Add the possibility to add a sidebar to a has_many field panel.

Current workarounds

    panel do
      field :posts, as: :has_many
      sidebar panel_wrapper: false do
        tool Avo::ResourceTools::SidebarTool, render_panel: true
      end
    end

This is creating a panel around the has_many and the sidebar, leading to white_panel_classes on the has_many panel background and also the buttons are not above the sidebar. Ideally we should be able to insert the sidebar inside the has_many field

Screenshots or screen recordings

image

adrianthedev commented 10 months ago

Maybe we can add a sidebar to the Index view ...

An alternative DSL would be something like this.

field :posts, as: :has_many, sidebar: -> do
  tool Avo::ResourceTools::SidebarTool
end
Paul-Bob commented 10 months ago

I was thinking the same but it have a minor issue, forcing to only 1 sidebar on that panel.

Maybe something like:

field :posts, as: :has_many, panel: -> do
  field # this render the field :posts, as: :has_many
  sidebar panel_wrapper: false do
    tool Avo::ResourceTools::SidebarTool, render_panel: true
  end
end

Not great, the idea is to allow multiple sidebars

Paul-Bob commented 10 months ago

Or maybe

field :posts, as: :has_many, sidebars: -> do
  sidebar do
    tool Avo::ResourceTools::SidebarTool
  end
end
github-actions[bot] commented 9 months ago

This issue has been marked as stale because there was no activity for the past 15 days.

iyerushalmi commented 8 months ago

We currently use the following format:

main_panel do
    field :subrecords, as: :has_many
    sidebar do
        field :sidebar_field, as: :text
    end
end

The problem is the has_many field is in a wrapper. Is there any way to turn off the wrapper as a temporary workaround until this feature is released?

adrianthedev commented 8 months ago

No, there isn't a woraround for that yet.

Would you be open to send in a PR for this @iyerushalmi?