Active Admin - Add multiple index pages to a resource #1745

Closed
wants to merge 16 commits into
from

Projects

None yet

5 participants

@joshuacollins85
Contributor

Multiple index pages can exist for a single resource so that a user can toggle between different views. The switching mechanism follows the design of scopes. Documentation has been updated.

@gregbell gregbell commented on an outdated diff Nov 7, 2012
docs/12-arbre-components.md
@@ -0,0 +1,113 @@
+# Arbre Components
+
+Arbre allows the creation of shareable and extendable HTML components and is used throughout Active Admin to create view components.
@gregbell
gregbell Nov 7, 2012 Contributor

Can you please update these to a better column length. We shouldn't have to wrap to view the docs.

@gregbell gregbell commented on an outdated diff Nov 7, 2012
docs/3-index-pages/create-an-index.md
@@ -0,0 +1,31 @@
+<!-- Please don't edit this file. It will be clobbered. -->
@gregbell
gregbell Nov 7, 2012 Contributor

This line can be removed since it won't be clobbered.

@gregbell gregbell commented on the diff Nov 7, 2012
features/index/switch_index_view.feature
+ Scenario: Show default Page Presenter
+ Given a post with the title "Hello World from Table" exists
+ And an index configuration of:
+ """
+ ActiveAdmin.register Post do
+ index :as => :table do
+ column :title
+ end
+ index :as => :block do |post|
+ span(link_to(post.title, admin_post_path(post)))
+ end
+ end
+ """
+ Then I should see "Hello World from Table" within ".index_as_table"
+
+ Scenario: Show default Page Presenter
@gregbell
gregbell Nov 7, 2012 Contributor

The title name should reflect the difference between this scenario and the one above. Maybe "Show default Page Presenter when specified"

@gregbell gregbell commented on an outdated diff Nov 7, 2012
lib/active_admin/resource/page_presenters.rb
end
# Returns a stored page config
#
# @param [Symbol, String] action The action to get the config for
# @returns [PagePresenter, nil]
- def get_page_presenter(action)
- page_presenters[action.to_sym]
+ def get_page_presenter(action, type=nil)
@gregbell
gregbell Nov 7, 2012 Contributor

Please update the docs above to include the type

@gregbell gregbell commented on an outdated diff Nov 7, 2012
lib/active_admin/views/components/index_list.rb
+ # Renders a collection of index view available to the resource
+ # as a list with a separator
+ class IndexList < ActiveAdmin::Component
+ builder_method :index_list_renderer
+
+ include ::ActiveAdmin::Helpers::Collection
+
+ def default_class_name
+ "indexes table_tools_segmented_control"
+ end
+
+ def tag_name
+ 'ul'
+ end
+
+ def build(index_classes)
@gregbell
gregbell Nov 7, 2012 Contributor

Please add some documentation as to what index_classes is. An array of what? from where?

@gregbell gregbell commented on an outdated diff Nov 15, 2012
lib/active_admin/views/components/index_list.rb
+
+ def build(index_classes)
+ unless current_filter_search_empty?
+ index_classes.each do |index_class|
+ build_index_list(index_class)
+ end
+ end
+ end
+
+ protected
+
+ def build_index_list(index_class)
+ li :class => classes_for_index(index_class) do
+ a :href => url_for(params.merge(:as => index_class.index_name.to_sym)), :class => "table_tools_button" do
+ name = index_class.index_name
+ t("active_admin.index_list.#{name}", :default => name.to_s.titleize)
@gregbell
gregbell Nov 15, 2012 Contributor

Please use I18n.t() since using just t will interfere with the textilize helper method in Redcloth.

@pcreux
Contributor
pcreux commented Dec 11, 2012

@joshuacollins85 Could you rebase this against master?

@macfanatic
Contributor

This seems like a great idea, love to see it integrated.

@seanlinsley seanlinsley commented on the diff Mar 6, 2013
lib/active_admin/resource_dsl.rb
@@ -49,7 +49,7 @@ def index(options = {}, &block)
options[:as] ||= :table
config.set_page_presenter :index, ActiveAdmin::PagePresenter.new(options, &block)
end
-
+
@seanlinsley
seanlinsley Mar 6, 2013 Member

I see whitespace :[

@seanlinsley
Member

@joshuacollins85 are you still alive? This really needs to be rebased on master.

@gregbell
Contributor
gregbell commented Apr 3, 2013

I squashed and merged this into master in 3d722c3.

@gregbell gregbell closed this Apr 3, 2013
@macovsky macovsky added a commit to macovsky/active_admin that referenced this pull request Jul 14, 2013
@macovsky macovsky Merge tag 'tags/v0.6.0'
Version 0.6.0

* tag 'tags/v0.6.0': (98 commits)
  Bump to 0.6.0
  Fixed support for Ruby 1.8
  Added more contributions to the Changelog
  Refactored the fix for #2043: nil/false namespace
  Updated CHANGELOG
  Support `config.default_namespace = false` (#2043)
  Added parent menu item customization docs
  Merge pull request #1745 from joshuacollins85/aa-index-view-change
  Categorized the changes in the Changelog
  Pimped thy changelog
  properly translate renamed resources
  improved gradient browser support
  update specs
  add multiple http verbs for member actions
  update docs to include associated sorting
  fix MenuItem label sorting of procs
  pt-PT translation
  fix potential bug
  Added batch action feature scenario for testing batch action usage with a nested resource.
  * Fixed feature step for submitting batch action form to properly pass the selected rows. * Corrected the tests in the 'Use default (destroy) batch action' scenario in the batch_actions feature.
  ...
29e482d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment