activeadmin 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activeadmin might be problematic. Click here for more details.

Files changed (57) hide show
  1. data/CHANGELOG.md +46 -0
  2. data/Gemfile +1 -0
  3. data/README.rdoc +1 -1
  4. data/activeadmin.gemspec +1 -1
  5. data/app/assets/stylesheets/active_admin/_base.css.scss +2 -1
  6. data/app/assets/stylesheets/active_admin/components/_columns.scss +3 -0
  7. data/app/assets/stylesheets/active_admin/mixins/_sections.css.scss +1 -1
  8. data/app/views/active_admin/devise/sessions/new.html.erb +1 -1
  9. data/docs/2-resource-customization.md +13 -0
  10. data/docs/3-index-pages.md +23 -0
  11. data/docs/3-index-pages/index-as-grid.md +2 -2
  12. data/docs/7-sidebars.md +7 -0
  13. data/docs/8-custom-actions.md +6 -0
  14. data/features/action_item.feature +73 -0
  15. data/features/index/filters.feature +55 -22
  16. data/features/index/index_parameters.feature +12 -0
  17. data/features/index/index_scope_to.feature +29 -0
  18. data/features/index/index_scopes.feature +13 -0
  19. data/features/index/pagination.feature +14 -5
  20. data/features/sidebar_sections.feature +45 -0
  21. data/features/step_definitions/action_item_steps.rb +4 -0
  22. data/features/step_definitions/factory_steps.rb +3 -2
  23. data/features/step_definitions/filter_steps.rb +17 -0
  24. data/features/step_definitions/format_steps.rb +4 -0
  25. data/features/step_definitions/index_scope_steps.rb +5 -0
  26. data/lib/active_admin/arbre/html/tag.rb +9 -1
  27. data/lib/active_admin/helpers/optional_display.rb +13 -3
  28. data/lib/active_admin/locales/da.yml +15 -0
  29. data/lib/active_admin/locales/es.yml +18 -2
  30. data/lib/active_admin/locales/he_il.yml +45 -0
  31. data/lib/active_admin/menu_item.rb +0 -21
  32. data/lib/active_admin/page.rb +9 -0
  33. data/lib/active_admin/page_controller.rb +4 -0
  34. data/lib/active_admin/page_dsl.rb +7 -0
  35. data/lib/active_admin/reloader.rb +0 -1
  36. data/lib/active_admin/resource.rb +6 -0
  37. data/lib/active_admin/resource/action_items.rb +2 -2
  38. data/lib/active_admin/resource/pagination.rb +19 -0
  39. data/lib/active_admin/resource/sidebars.rb +2 -2
  40. data/lib/active_admin/resource_controller/callbacks.rb +13 -1
  41. data/lib/active_admin/resource_controller/collection.rb +17 -10
  42. data/lib/active_admin/router.rb +3 -0
  43. data/lib/active_admin/version.rb +1 -1
  44. data/lib/active_admin/views/components/columns.rb +115 -12
  45. data/lib/active_admin/views/components/scopes.rb +4 -4
  46. data/lib/active_admin/views/index_as_table.rb +14 -2
  47. data/lib/active_admin/views/pages/base.rb +2 -2
  48. data/lib/active_admin/views/pages/index.rb +25 -13
  49. data/lib/active_admin/views/tabbed_navigation.rb +14 -2
  50. data/spec/unit/menu_item_spec.rb +0 -14
  51. data/spec/unit/namespace/register_resource_spec.rb +1 -1
  52. data/spec/unit/resource/pagination_spec.rb +38 -0
  53. data/spec/unit/resource_controller/collection_spec.rb +1 -1
  54. data/spec/unit/views/components/columns_spec.rb +61 -4
  55. data/spec/unit/views/tabbed_navigation_spec.rb +2 -2
  56. metadata +20 -11
  57. data/features/index/filter_with_check_boxes.feature +0 -25
@@ -1,3 +1,49 @@
1
+ ## Master (unreleased)
2
+
3
+ ## 0.4.1
4
+
5
+ ### Enhancements
6
+
7
+ * #865: Pages support the `#page_action` to add custom controller actions
8
+ to a page (@BoboFraggins)
9
+ * Columns component now supports column spans, max and min widths ([@gregbell][])
10
+ * #497: Custom pagination settings per resource (@pcreux)
11
+ * #993: Login form now focuses on email (@mattvague)
12
+ * #865: Add `:if` support to sidebar sections (@BoboFraggins)
13
+ * #865: Added `:scope_count => false` to the index to hide scope counts
14
+ in generated scopes (@BoboFraggins)
15
+
16
+ ### Bug Fixes
17
+
18
+ * #101: Global nav now works with RackBaseURI ([@gregbell][])
19
+ * #960: Global nav works when scoped in rails routes ([@gregbell][])
20
+ * #994: Fix index page check collection.limit(1).exists? causes exception when
21
+ ordering by virtual colum (@latortuga, @gregbell)
22
+ * #971: Fix SQL when sorting tables with a column named "group" (@ggilder)
23
+
24
+ ### Dependencies
25
+
26
+ * #978: Support for Inherited Resources 1.3.0 (@fabiormoura)
27
+
28
+ ### Contributors
29
+
30
+ 75 Commits by 12 authors
31
+
32
+ * Bruno Bonamin
33
+ * David Radcliffe
34
+ * Dinesh Majrekar
35
+ * Erik Michaels-Ober
36
+ * Fábio Maia
37
+ * Gabriel Gilder
38
+ * Greg Bell
39
+ * Kyle Macey
40
+ * Matt Vague
41
+ * Oldani Pablo
42
+ * Peter Fry
43
+ * Philippe Creux
44
+ * Søren Houen
45
+
46
+
1
47
  ## 0.4.0
2
48
 
3
49
  ### Upgrade Notes
data/Gemfile CHANGED
@@ -20,6 +20,7 @@ end
20
20
 
21
21
  group :development, :test do
22
22
  gem 'sqlite3-ruby', :require => 'sqlite3'
23
+
23
24
  gem 'rake', '~> 0.9.2.2', :require => false
24
25
  gem 'haml', '~> 3.1.1', :require => false
25
26
  gem 'yard'
@@ -4,7 +4,7 @@ Active Admin is a framework for creating administration style interfaces. It
4
4
  abstracts common business application patterns to make it simple for developers
5
5
  to implement beautiful and elegant interfaces with very little effort.
6
6
 
7
- {<img src="http://travis-ci.org/gregbell/active_admin.png" />}[http://travis-ci.org/gregbell/active_admin]
7
+ {<img src="https://secure.travis-ci.org/gregbell/active_admin.png" />}[http://travis-ci.org/gregbell/active_admin]
8
8
 
9
9
  == Documentation & Support
10
10
 
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.add_dependency("meta_search", ">= 0.9.2")
24
24
  s.add_dependency("devise", ">= 1.1.2")
25
25
  s.add_dependency("formtastic", ">= 2.0.0")
26
- s.add_dependency("inherited_resources", "< 1.3.0")
26
+ s.add_dependency("inherited_resources", "> 0")
27
27
  s.add_dependency("kaminari", ">= 0.13.0")
28
28
  s.add_dependency("sass", ">= 3.1.0")
29
29
  s.add_dependency("fastercsv", ">= 0")
@@ -18,6 +18,7 @@
18
18
  @import "active_admin/components/links";
19
19
  @import "active_admin/components/pagination";
20
20
  @import "active_admin/components/panels";
21
+ @import "active_admin/components/columns";
21
22
  @import "active_admin/components/scopes";
22
23
  @import "active_admin/components/status_tags";
23
24
  @import "active_admin/components/table_tools";
@@ -35,4 +36,4 @@ body {
35
36
  margin: 0;
36
37
  padding: 0;
37
38
  color: $text-color;
38
- }
39
+ }
@@ -0,0 +1,3 @@
1
+ .columns {
2
+ margin-bottom: 10px;
3
+ }
@@ -25,7 +25,7 @@
25
25
  @include section-background;
26
26
  margin-bottom: 20px;
27
27
 
28
- h3 { @include section-header; }
28
+ > h3 { @include section-header; }
29
29
 
30
30
  > div { padding: 3px $section-padding $section-padding $section-padding; }
31
31
 
@@ -4,7 +4,7 @@
4
4
  <% scope = Devise::Mapping.find_scope!(resource_name) %>
5
5
  <%= active_admin_form_for(resource, :as => resource_name, :url => send(:"#{scope}_session_path"), :html => { :id => "session_new" }) do |f|
6
6
  f.inputs do
7
- Devise.authentication_keys.each { |key| f.input key }
7
+ Devise.authentication_keys.each { |key| f.input key, :input_html => {:autofocus => true}}
8
8
  f.input :password
9
9
  f.input :remember_me, :as => :boolean, :if => false #devise_mapping.rememberable? }
10
10
  end
@@ -10,6 +10,19 @@ the <tt>:as</tt> option.
10
10
 
11
11
  The resource will then be available as /admin/articles
12
12
 
13
+ ## Customize the Namespace
14
+
15
+ By default, resources live in the "admin" namespace.
16
+
17
+ You can register resources in different namespaces:
18
+
19
+ # Available at /today/posts
20
+ ActiveAdmin.register Post, :namespace => "today"
21
+
22
+ # Available at /posts
23
+ ActiveAdmin.register Post, :namespace => false
24
+
25
+
13
26
  ## Customize the Menu
14
27
 
15
28
  The resource will be displayed in the global navigation by default. To disable
@@ -53,3 +53,26 @@ You can change the filter label by passing a label option:
53
53
  filter :author, :label => 'Author'
54
54
 
55
55
  By default, Active Admin will try to use ActiveModel I18n to determine the label.
56
+
57
+ ## Index default sort order
58
+
59
+ You can define the default sort order for index pages:
60
+
61
+ ActiveAdmin.register Post do
62
+ config.sort_order = "name_asc"
63
+ end
64
+
65
+ ## Index pagination
66
+
67
+
68
+ You can set the number of records per page per resources:
69
+
70
+ ActiveAdmin.register Post do
71
+ config.per_page = 10
72
+ end
73
+
74
+ You can also disable pagination:
75
+
76
+ ActiveAdmin.register Post do
77
+ config.paginate = false
78
+ end
@@ -7,7 +7,7 @@ Sometimes you want to display the index screen for a set of resources as a grid
7
7
  index block.
8
8
 
9
9
  index :as => :grid do |product|
10
- link_to(image_tag(product.image_path), admin_products_path(product))
10
+ link_to(image_tag(product.image_path), admin_product_path(product))
11
11
  end
12
12
 
13
13
  The block is rendered within a cell in the grid once for each resource in the
@@ -17,5 +17,5 @@ You can customize the number of colums that are rendered using the columns
17
17
  option:
18
18
 
19
19
  index :as => :grid, :columns => 5 do |product|
20
- link_to(image_tag(product.image_path), admin_products_path(product))
20
+ link_to(image_tag(product.image_path), admin_product_path(product))
21
21
  end
@@ -25,6 +25,13 @@ options.
25
25
  "Need help? Email us at help@example.com"
26
26
  end
27
27
 
28
+ If you want to conditionally display a sidebar section, use the :if option and
29
+ pass it a proc which will be rendered within the context of the view.
30
+
31
+ sidebar :help, :if => proc{ current_admin_user.super_admin? }
32
+ "Only for super admins!"
33
+ end
34
+
28
35
  If you only pass a symbol, Active Admin will attempt to locate a partial to render.
29
36
 
30
37
  # Will render app/views/admin/posts/_help_sidebar.html.erb
@@ -92,6 +92,12 @@ post:
92
92
  link_to('View on site', post_path(post)) if post.published?
93
93
  end
94
94
 
95
+ Actions items also accept the :if option to conditionally display them:
96
+
97
+ action_item :only => :show, :if => proc{ current_admin_user.super_admin? } do
98
+ "Only display this to super admins on the show screen"
99
+ end
100
+
95
101
  ### Page Titles
96
102
 
97
103
  The page title for the custom action will be the internationalized version of
@@ -0,0 +1,73 @@
1
+ Feature: Action Item
2
+
3
+ Creating and Configuring action items
4
+
5
+ Background:
6
+ Given I am logged in
7
+ And a post with the title "Hello World" exists
8
+
9
+ Scenario: Create an member action
10
+ Given a configuration of:
11
+ """
12
+ ActiveAdmin.register Post do
13
+ action_item do
14
+ link_to "Embiggen", '/'
15
+ end
16
+ end
17
+ """
18
+ When I am on the index page for posts
19
+ Then I should not see a member link to "Embiggen"
20
+
21
+ When I follow "View"
22
+ Then I should see an action item link to "Embiggen"
23
+
24
+ When I follow "Edit Post"
25
+ Then I should see an action item link to "Embiggen"
26
+
27
+ When I am on the index page for posts
28
+ When I follow "New Post"
29
+ Then I should see an action item link to "Embiggen"
30
+
31
+ Scenario: Create an member action with if clause that returns true
32
+ Given a configuration of:
33
+ """
34
+ ActiveAdmin.register Post do
35
+ action_item :if => proc{ !current_active_admin_user.nil? } do
36
+ link_to "Embiggen", '/'
37
+ end
38
+ end
39
+ """
40
+ When I am on the index page for posts
41
+ Then I should not see a member link to "Embiggen"
42
+
43
+ When I follow "View"
44
+ Then I should see an action item link to "Embiggen"
45
+
46
+ When I follow "Edit Post"
47
+ Then I should see an action item link to "Embiggen"
48
+
49
+ When I am on the index page for posts
50
+ When I follow "New Post"
51
+ Then I should see an action item link to "Embiggen"
52
+
53
+ Scenario: Create an member action with if clause that returns false
54
+ Given a configuration of:
55
+ """
56
+ ActiveAdmin.register Post do
57
+ action_item :if => proc{ current_active_admin_user.nil? } do
58
+ link_to "Embiggen", '/'
59
+ end
60
+ end
61
+ """
62
+ When I am on the index page for posts
63
+ Then I should not see a member link to "Embiggen"
64
+
65
+ When I follow "View"
66
+ Then I should not see an action item link to "Embiggen"
67
+
68
+ When I follow "Edit Post"
69
+ Then I should not see an action item link to "Embiggen"
70
+
71
+ When I am on the index page for posts
72
+ When I follow "New Post"
73
+ Then I should not see an action item link to "Embiggen"
@@ -1,35 +1,68 @@
1
- Feature: Index Pagination
1
+ Feature: Index Filtering
2
2
 
3
- Background:
4
- Given an index configuration of:
3
+ Scenario: Default Resources Filters
4
+ Given 3 posts exist
5
+ And an index configuration of:
5
6
  """
6
7
  ActiveAdmin.register Post
7
8
  """
8
- Scenario: Filtering posts
9
- Given 20 posts exist
10
9
  When I am on the index page for posts
11
- Then I should see "Displaying all 20 Posts"
12
- And I should see "Author" within ".filter_form"
13
- And I should see "Category" within ".filter_form"
14
- And I should see "Search Title" within ".filter_form"
15
- And I should see "Search Body" within ".filter_form"
16
- And I should see "Published at" within ".filter_form"
17
- And I should see "Created at" within ".filter_form"
18
- And I should see "Updated at" within ".filter_form"
19
-
20
- When I fill in "Search Title" with "Hello World 17"
10
+ Then I should see "Displaying all 3 Posts"
11
+ And I should see the following filters:
12
+ | Author | select |
13
+ | Category | select |
14
+ | Title | string |
15
+ | Body | string |
16
+ | Published at | date range |
17
+ | Created at | date range |
18
+ | Updated at | date range |
19
+
20
+ When I fill in "Search Title" with "Hello World 2"
21
21
  And I press "Filter"
22
22
  And I should see 1 posts in the table
23
- And I should see "Hello World 17" within ".index_table"
24
-
23
+ And I should see "Hello World 2" within ".index_table"
24
+
25
25
  Scenario: Filtering posts with no results
26
- Given 20 posts exist
26
+ Given 3 posts exist
27
+ And an index configuration of:
28
+ """
29
+ ActiveAdmin.register Post
30
+ """
27
31
  When I am on the index page for posts
28
- Then I should see "Displaying all 20 Posts"
32
+ Then I should see "Displaying all 3 Posts"
33
+
29
34
  When I fill in "Search Title" with "THIS IS NOT AN EXISTING TITLE!!"
30
35
  And I press "Filter"
31
-
32
- And I should not see ".index_table"
33
- Then I should not see a sortable table header
36
+ Then I should not see ".index_table"
37
+ And I should not see a sortable table header
34
38
  And I should not see pagination
35
39
  And I should see "No Posts found"
40
+
41
+ Scenario: Checkboxes - Filtering posts written by anyone
42
+ Given 1 post exists
43
+ And a post with the title "Hello World" written by "Jane Doe" exists
44
+ And an index configuration of:
45
+ """
46
+ ActiveAdmin.register Post do
47
+ filter :author, :as => :check_boxes
48
+ end
49
+ """
50
+ When I press "Filter"
51
+ Then I should see 2 posts in the table
52
+ And I should see "Hello World" within ".index_table"
53
+ And the "jane_doe" checkbox should not be checked
54
+
55
+ Scenario: Checkboxes - Filtering posts written by Jane Doe
56
+ Given 1 post exists
57
+ And a post with the title "Hello World" written by "Jane Doe" exists
58
+ And an index configuration of:
59
+ """
60
+ ActiveAdmin.register Post do
61
+ filter :author, :as => :check_boxes
62
+ end
63
+ """
64
+ When I check "jane_doe"
65
+ And I press "Filter"
66
+ Then I should see 1 posts in the table
67
+ And I should see "Hello World" within ".index_table"
68
+ And the "jane_doe" checkbox should be checked
@@ -0,0 +1,12 @@
1
+ Feature: Index Parameters
2
+
3
+ Scenario: Viewing index when download_links disabled
4
+ Given an index configuration of:
5
+ """
6
+ ActiveAdmin.register Post do
7
+ index :as => :table, :download_links => false
8
+ end
9
+ """
10
+ Given 31 posts exist
11
+ When I am on the index page for posts
12
+ Then I should not see a link to download "CSV"
@@ -0,0 +1,29 @@
1
+ Feature: Index Scope To
2
+
3
+ Viewing resource configs scoped to another object
4
+
5
+ Background:
6
+ Given 10 posts exist
7
+ And a post with the title "Hello World" written by "John Doe" exists
8
+ And a published post with the title "Hello World" written by "John Doe" exists
9
+ Given an index configuration of:
10
+ """
11
+ ActiveAdmin.register Post do
12
+ # Scope section to a specific author
13
+ scope_to do
14
+ User.find_by_first_name_and_last_name("John", "Doe")
15
+ end
16
+
17
+ # Setup some scopes
18
+ scope :all, :default => true
19
+ scope :published do |posts|
20
+ posts.where("published_at IS NOT NULL")
21
+ end
22
+ end
23
+ """
24
+
25
+ Scenario: Viewing the default scope counts
26
+ When I am on the index page for posts
27
+ Then I should see the scope "All" selected
28
+ And I should see the scope "All" with the count 2
29
+ And I should see 2 posts in the table
@@ -43,6 +43,19 @@ Feature: Index Scoping
43
43
  When I am on the index page for posts
44
44
  Then I should see the scope "All" selected
45
45
 
46
+ Scenario: Viewing resources with a scope but scope_count turned off
47
+ Given 10 posts exist
48
+ And an index configuration of:
49
+ """
50
+ ActiveAdmin.register Post do
51
+ scope :all, :default => true
52
+ index :as => :table, :scope_count => false
53
+ end
54
+ """
55
+ Then I should see the scope "All" selected
56
+ And I should see the scope "All" with no count
57
+ And I should see 10 posts in the table
58
+
46
59
  Scenario: Viewing resources when scoping
47
60
  Given 6 posts exist
48
61
  And 4 published posts exist
@@ -24,12 +24,21 @@ Feature: Index Pagination
24
24
  Given an index configuration of:
25
25
  """
26
26
  ActiveAdmin.register Post do
27
- before_filter :only => :index do |controller|
28
- @per_page = 10
29
- end
27
+ config.per_page = 2
30
28
  end
31
29
  """
32
- Given 11 posts exist
30
+ Given 3 posts exist
33
31
  When I am on the index page for posts
34
32
  Then I should see pagination with 2 pages
35
- And I should see "Displaying Posts 1 - 10 of 11 in total"
33
+ And I should see "Displaying Posts 1 - 2 of 3 in total"
34
+
35
+ Scenario: Viewing index with pagination disabled
36
+ Given an index configuration of:
37
+ """
38
+ ActiveAdmin.register Post do
39
+ config.paginate = false
40
+ end
41
+ """
42
+ Given 31 posts exist
43
+ When I am on the index page for posts
44
+ Then I should not see pagination