Activeadmin: attributes_table with custom header?

Created on 21 Oct 2011  Â·  34Comments  Â·  Source: activeadmin/activeadmin

hey

maybe a good feature to have a customheader in the attributes table? currently i need to do an extra template, because its not supportet.

would be great to have something like

 attributes_table :header=>"Specifications" do
      rows :id, :name, :url, :title
    end
 attributes_table :header=>"other unimportant value" do
      rows :blubb
    end
# File 'lib/active_admin/views/pages/show.rb', line 30

def attributes_table(*args, &block)
  panel(active_admin_config.resource_name + " Details") do
    attributes_table_for resource, *args, &block
  end
end

Most helpful comment

There is a quick workaround to have a custom title for now:

show do |user|
  panel 'Address details' do
    attributes_table_for user do
      row :street do
        user.address.street
      end
    end
  end
end

All 34 comments

bump

bump

TTT!

+1

+1

shouldn't it be:

attributes_table :title => "Whatever" do
end

Instead of header?

Any updates on this? Looking at the source it seems the title can be configured?

+1! I need this because sometimes I have to use more than one attributes table on the same show screen, and the ability to customize the header or title would be great =D

There is a quick workaround to have a custom title for now:

show do |user|
  panel 'Address details' do
    attributes_table_for user do
      row :street do
        user.address.street
      end
    end
  end
end

I would be interested in this as well!

Hey guys, did you ever consider that in this entire project, there is no such thing as a table having a title? What you have instead is:

show :title => :title do
  panel "User's Jobs" do
    table_for user.jobs do
      # ...
    end
  end
end

index :title => 'Awesome Users' do
  #...
end

sidebar 'User Details', :only => :show do
  attributes_table_for user do
    # ...
  end
end

@Daxter wrote: "Hey guys, did you ever consider that in this entire project, there is no such thing as a table having a title?"

What people mean, I think, is that an h3 is generated for you with an attributes_tables table. Just look at what attributes_tables generates. It would be nice to be able to customize the h3, that's what I am saying.

I looked at the code -- I didn't see where the h3 was coming from -- so the fix isn't obvious to me. Would someone look?

again, +1

@bluemont, no, the h3 is generated for whatever is encompassing the attributes_table. Hence this example I gave earlier:

sidebar 'User Details', :only => :show do
  attributes_table_for user do
    # ...
  end
end

Thanks @jeroenj for the workaround

Peace!
Braga

@technicalypto, what's the point of a workaround? Please show me where the built-in functionality doesn't work for you.

@Daxter : Sure, here is an example where I want a custom header for my attributes. My model is a bit bulky (has around 30 rows) and displaying them vertically in the show page is not good as the user has to scroll a lot. Instead, I split it into two columns and group things with certain title. Have attached a preview to explain my case better. I was able to achieve this only through the workaround from @jeroenj unless you show me some other way to do this.
screen use case

Yep, I'm doing it for the exact same reason. Grouping attributes for models with a lot of attributes.

@technicalypto, @jeroenj, that's not a workaround. That's how it's intended to work.

@fu-media requested this when he opened this issue:

attributes_table :header => "Specifications" do
  rows :id, :name, :url, :title
end

But that doesn't make any sense because tables don't have titles. The HTML element _around_ the table (in this case, panel) is what holds the title.

@fu-media requested that the header: "Specifications" should be the
Panel with h3 "Specification"

Am 18.02.2013 18:16, schrieb Sean Ian Linsley:

@technicalypto https://github.com/technicalypto, @jeroenj
https://github.com/jeroenj, that's not a workaround. That's how it's
intended to work.

@fu-media https://github.com/fu-media requested this when he opened
this issue:

attributes_table :header=>"Specifications" do
rows :id, :name, :url, :title
end

But that doesn't make any sense because tables don't have titles. The
HTML element /around/ the table (in this case, panel) is what holds
the title.

—
Reply to this email directly or view it on GitHub
https://github.com/gregbell/active_admin/issues/660#issuecomment-13732381.

@fu-media, what you're really asking for is to abstract out the panel call, thus abstracting out the abstraction layer. I think that's a bit too much abstraction. It'll make it that much more difficult for the future maintainer of your project to understand what's going on.

@Daxter I got your point.

I would love for this issue to be resurrected @seanlinsley. When you've got lots of attributes on the same table, you want to break these up into logical groupings. The look and feel of the attributes table is great, but with lots of fields it generates a cumbersomely long list for a user to scroll down.

Alternatively, splitting up attributes with panels results in "panels within panels" and repetition of the resource name under them, in my case "opportunities" which results in ugly output (sorry!) like this:

Panel 1 "Logical grouping 1"
Attributes Table "Opportunity Details"
row 1
row 2

Panel 2 "Logical grouping 2"
Attributes Table "Opportunity Details"
row 4
row 5

If we could just pass a title to the attributes table, instead of always assuming this is merely "X Details", the problem would be fixed. Is there any practical reason this can't happen?

I love AA by the way - it's awesome!

Thanks in advance for your time.

i agree with swedishpotate

+1, also agree with @swedishpotato and everyone else

@ajw725 , @swedishpotato
what you want is this not to be hardcoded, so
I don't see a big problem here, create PR, add tests and it will be merged.

thanks for pointing to the right spot, @Fivell - on it. seems like a pretty simple change. already have it working locally, just going through the rest of the testing.

@Fivell - all of the current tests are passing, but I'll admit I'm not 100% confident on where/how to add new tests for this. Any guidance there?

@ajw725 , I think creating feature attributes_table.feature for show page example like this would be fine

ok, made a PR! #4940

5.5 years later. wow.

@krtschmr haha. well, it probably doesn't help the guy who opened the issue, but it seems like i wasn't the only one who still wanted this feature!

i am former @fu-media . was funny to read that i participated in this
topic - 5.5years ago. dang!

Am 28.04.2017 um 22:03 schrieb Andrew Weinstein:
>

@krtschmr https://github.com/krtschmr haha. well, it probably
doesn't help the guy who opened the issue, but it seems like i wasn't
the only one who still wanted this feature!

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/activeadmin/activeadmin/issues/660#issuecomment-298022723,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMv1uoIQnLuFskFjFBT6fqaMdJkqRigkks5r0f_RgaJpZM4AAVlb.


Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus

Still very much wanted!

Just what I was looking for! Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robotmay picture robotmay  Â·  61Comments

seanlinsley picture seanlinsley  Â·  31Comments

rebyn picture rebyn  Â·  34Comments

ghost picture ghost  Â·  37Comments

seanlinsley picture seanlinsley  Â·  46Comments