Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Rendering paginated_collection in #show block reveals bug #412

Closed
samvincent opened this Issue Aug 24, 2011 · 6 comments

Comments

Projects
None yet
3 participants
Contributor

samvincent commented Aug 24, 2011

When rendering a table of a resources associated entries within the show context, The collection var in ActiveAdmin::Views::PaginatedCollection#page_entries_info is the main resource and not the passed collection.

show do
  collection = resource.items
  paginated_collection(collection) do
    table_for collection, {:sortable => true, :class => "index_table", :i18n => LineItem}
  end
end

There are no unit specs for PaginatedCollection and the style differs a bit from the other components I looked at (TableFor works as expected). Would you be able to enlighten me a little bit on why the collection I passed in isn't being respected so I can put a patch together?

The other thing is that there's no option to remove the download format links which aren't wanted here. They currently link to the show actions resource as well.

I'd like to write some specs for these two features, but I need to understand a little more about why rendering the paginated_collection within the show context is producing these results. Any help is much appreciated.

Contributor

gregbell commented Aug 26, 2011

Hi Sam!

This is actually a great find. The issue is in the #page_entries_info method. It calls the method #collection which is actually a helper provided by Active Admin to get the collection on the index page. Instead, that method should use the value set in @collection.

I think the simplest solution is to add some specs to that method and then an attr_reader :collection. If you've got the time to fork, branch and implement I'll pull it and release it in 0.3.1.

Thanks!

@samvincent samvincent closed this Aug 26, 2011

samvincent added a commit to samvincent/active_admin that referenced this issue Aug 29, 2011

Issue #412 - Fix scope issue with :collection for PaginatedCollection…
… component

When rendering a PaginatedCollection for an associated collection within the
show context (for example), the :collection method called was referring to the resource
rather than the passed in collection. Also raising error if collection has not been
scoped with Kaminari to help new users figure it out.

samvincent added a commit to samvincent/active_admin that referenced this issue Aug 29, 2011

Issue #412 - Added support for :param_name to PaginatedCollection
Setting :param_name allows you to put multiple paginated collections
on a single page. (eg. Show action)

samvincent added a commit to samvincent/active_admin that referenced this issue Aug 29, 2011

Issue #412 - Disable download links option for PaginatedCollection
When rendering a paginated collection on the show screen for example,
it does not make sense to include resource download links for the collection.

@samvincent samvincent reopened this Aug 29, 2011

Contributor

samvincent commented Aug 29, 2011

I have no idea how this closed it self. I've made some commits for the options I need. Commit messages explain why I need them. Making a pull request now.

samvincent added a commit to samvincent/active_admin that referenced this issue Aug 29, 2011

dawidw commented Sep 28, 2011

was this fix finally released in 0.3.1? because i'm still having this issue in 0.3.2.

Contributor

samvincent commented Sep 28, 2011

Hasn't been merged yet. I've forked the project and have been merging in various fixes for my production active admin. You can merge in my branch that fixes this if you need it right away.

dawidw commented Sep 28, 2011

not in a hurry, just curious ; )

Contributor

samvincent commented Oct 21, 2011

Closing as this has been merged in pull req #428

@samvincent samvincent closed this Oct 21, 2011

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