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

attributes_table with custom header? #660

Closed
ghost opened this issue Oct 21, 2011 · 34 comments
Closed

attributes_table with custom header? #660

ghost opened this issue Oct 21, 2011 · 34 comments

Comments

@ghost
Copy link

ghost commented Oct 21, 2011

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
@ghost
Copy link
Author

ghost commented Nov 20, 2011

bump

1 similar comment
@mbessieres
Copy link

bump

@LeviRosol
Copy link

TTT!

@coreyward
Copy link
Contributor

+1

@robotex82
Copy link
Contributor

+1

shouldn't it be:


attributes_table :title => "Whatever" do
end

Instead of header?

@MSch
Copy link

MSch commented Apr 3, 2012

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

@javienen
Copy link

javienen commented May 8, 2012

+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

@jeroenj
Copy link

jeroenj commented May 9, 2012

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

@jfedick
Copy link

jfedick commented May 24, 2012

I would be interested in this as well!

@seanlinsley
Copy link
Contributor

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

@bluemont
Copy link

@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?

@ghost
Copy link
Author

ghost commented Jan 25, 2013

again, +1

@seanlinsley
Copy link
Contributor

@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

@ghost
Copy link
Author

ghost commented Feb 16, 2013

Thanks @jeroenj for the workaround

Peace!
Braga

@seanlinsley
Copy link
Contributor

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

@ghost
Copy link
Author

ghost commented Feb 18, 2013

@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

@jeroenj
Copy link

jeroenj commented Feb 18, 2013

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

@seanlinsley
Copy link
Contributor

@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.

@ghost
Copy link
Author

ghost commented Feb 18, 2013

@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
#660 (comment).

@seanlinsley
Copy link
Contributor

@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.

@ghost
Copy link
Author

ghost commented Feb 23, 2013

@daxter I got your point.

@swedishpotato
Copy link

swedishpotato commented Jan 30, 2017

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.

@ebizboy
Copy link

ebizboy commented Apr 13, 2017

i agree with swedishpotate

@ajw725
Copy link
Contributor

ajw725 commented Apr 19, 2017

+1, also agree with @swedishpotato and everyone else

@Fivell
Copy link
Member

Fivell commented Apr 20, 2017

@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.

@ajw725
Copy link
Contributor

ajw725 commented Apr 20, 2017

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.

@ajw725
Copy link
Contributor

ajw725 commented Apr 20, 2017

@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?

@Fivell
Copy link
Member

Fivell commented Apr 21, 2017

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

@ajw725
Copy link
Contributor

ajw725 commented Apr 25, 2017

ok, made a PR! #4940

@krtschmr
Copy link

5.5 years later. wow.

@ajw725
Copy link
Contributor

ajw725 commented Apr 28, 2017

@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!

@krtschmr
Copy link

krtschmr commented Apr 28, 2017 via email

@krivitsky
Copy link

Still very much wanted!

@Zhian
Copy link

Zhian commented Apr 14, 2018

Just what I was looking for! Thanks

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

No branches or pull requests