activeadmin 0.5.0 → 0.5.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 (117) hide show
  1. data/.travis.yml +1 -1
  2. data/CHANGELOG.md +92 -1
  3. data/CONTRIBUTING.md +3 -3
  4. data/Gemfile +6 -5
  5. data/README.rdoc +6 -1
  6. data/Rakefile +2 -2
  7. data/app/assets/stylesheets/active_admin/_forms.css.scss +13 -2
  8. data/app/assets/stylesheets/active_admin/components/_comments.css.scss +1 -0
  9. data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +2 -1
  10. data/app/views/active_admin/resource/index.csv.erb +4 -1
  11. data/app/views/layouts/active_admin_logged_out.html.erb +3 -3
  12. data/docs/0-installation.md +0 -7
  13. data/docs/1-general-configuration.md +37 -0
  14. data/docs/11-decorators.md +48 -0
  15. data/docs/12-arbre-components.md +145 -0
  16. data/docs/2-resource-customization.md +23 -6
  17. data/docs/3-index-pages.md +5 -0
  18. data/docs/4-csv-format.md +11 -2
  19. data/docs/8-custom-actions.md +2 -2
  20. data/features/breadcrumb.feature +27 -0
  21. data/features/decorators.feature +41 -0
  22. data/features/i18n.feature +7 -0
  23. data/features/index/format_as_csv.feature +40 -3
  24. data/features/index/index_as_table.feature +6 -6
  25. data/features/step_definitions/format_steps.rb +6 -1
  26. data/lib/active_admin.rb +1 -1
  27. data/lib/active_admin/application.rb +15 -7
  28. data/lib/active_admin/comments/comment.rb +4 -2
  29. data/lib/active_admin/csv_builder.rb +2 -1
  30. data/lib/active_admin/devise.rb +1 -0
  31. data/lib/active_admin/dsl.rb +25 -0
  32. data/lib/active_admin/filters/dsl.rb +9 -0
  33. data/lib/active_admin/filters/forms.rb +2 -0
  34. data/lib/active_admin/filters/resource_extension.rb +32 -2
  35. data/lib/active_admin/form_builder.rb +29 -12
  36. data/lib/active_admin/inputs.rb +1 -0
  37. data/lib/active_admin/inputs/filter_boolean_input.rb +40 -0
  38. data/lib/active_admin/inputs/filter_select_input.rb +5 -1
  39. data/lib/active_admin/locales/bg.yml +1 -0
  40. data/lib/active_admin/locales/ca.yml +1 -0
  41. data/lib/active_admin/locales/cs.yml +9 -1
  42. data/lib/active_admin/locales/da.yml +1 -0
  43. data/lib/active_admin/locales/de.yml +16 -3
  44. data/lib/active_admin/locales/en.yml +1 -0
  45. data/lib/active_admin/locales/es.yml +1 -0
  46. data/lib/active_admin/locales/fr.yml +5 -1
  47. data/lib/active_admin/locales/he.yml +3 -2
  48. data/lib/active_admin/locales/hr.yml +1 -0
  49. data/lib/active_admin/locales/hu.yml +1 -0
  50. data/lib/active_admin/locales/it.yml +5 -4
  51. data/lib/active_admin/locales/ja.yml +12 -12
  52. data/lib/active_admin/locales/ko.yml +1 -0
  53. data/lib/active_admin/locales/lt.yml +81 -0
  54. data/lib/active_admin/locales/lv.yml +2 -1
  55. data/lib/active_admin/locales/nl.yml +1 -0
  56. data/lib/active_admin/locales/no-NB.yml +1 -0
  57. data/lib/active_admin/locales/pl.yml +1 -0
  58. data/lib/active_admin/locales/pt-BR.yml +3 -2
  59. data/lib/active_admin/locales/ro.yml +1 -0
  60. data/lib/active_admin/locales/ru.yml +7 -6
  61. data/lib/active_admin/locales/sv-SE.yml +1 -0
  62. data/lib/active_admin/locales/tr.yml +3 -2
  63. data/lib/active_admin/locales/vi.yml +1 -0
  64. data/lib/active_admin/locales/zh-CN.yml +1 -0
  65. data/lib/active_admin/locales/zh-TW.yml +1 -0
  66. data/lib/active_admin/menu_item.rb +6 -0
  67. data/lib/active_admin/page.rb +3 -0
  68. data/lib/active_admin/page_presenter.rb +2 -0
  69. data/lib/active_admin/resource.rb +12 -1
  70. data/lib/active_admin/resource/menu.rb +8 -1
  71. data/lib/active_admin/resource_controller.rb +3 -1
  72. data/lib/active_admin/resource_controller/collection.rb +1 -1
  73. data/lib/active_admin/resource_controller/decorators.rb +19 -0
  74. data/lib/active_admin/resource_dsl.rb +1 -1
  75. data/lib/active_admin/version.rb +1 -1
  76. data/lib/active_admin/view_helpers.rb +1 -0
  77. data/lib/active_admin/view_helpers/breadcrumb_helper.rb +1 -1
  78. data/lib/active_admin/view_helpers/download_format_links_helper.rb +50 -0
  79. data/lib/active_admin/view_helpers/fields_for.rb +4 -0
  80. data/lib/active_admin/view_helpers/flash_helper.rb +13 -0
  81. data/lib/active_admin/views/components/paginated_collection.rb +2 -11
  82. data/lib/active_admin/views/components/table_for.rb +21 -27
  83. data/lib/active_admin/views/footer.rb +3 -1
  84. data/lib/active_admin/views/index_as_block.rb +1 -1
  85. data/lib/active_admin/views/index_as_grid.rb +1 -1
  86. data/lib/active_admin/views/pages/base.rb +3 -3
  87. data/lib/active_admin/views/pages/index.rb +1 -7
  88. data/lib/active_admin/views/title_bar.rb +6 -3
  89. data/lib/generators/active_admin/devise/devise_generator.rb +1 -1
  90. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +6 -3
  91. data/lib/generators/active_admin/install/templates/admin_user.rb.erb +1 -1
  92. data/lib/generators/active_admin/install/templates/dashboard.rb +2 -2
  93. data/lib/generators/active_admin/install/templates/migrations/2_move_admin_notes_to_comments.rb +2 -1
  94. data/spec/integration/memory_spec.rb +1 -1
  95. data/spec/support/rails_template.rb +41 -2
  96. data/spec/support/rails_template_with_data.rb +2 -1
  97. data/spec/support/templates/en.yml +2 -0
  98. data/spec/support/templates/post_decorator.rb +53 -0
  99. data/spec/unit/application_spec.rb +17 -4
  100. data/spec/unit/belongs_to_spec.rb +1 -1
  101. data/spec/unit/config_shared_examples.rb +15 -7
  102. data/spec/unit/controller_filters_spec.rb +8 -8
  103. data/spec/unit/csv_builder_spec.rb +10 -0
  104. data/spec/unit/devise_spec.rb +28 -7
  105. data/spec/unit/filters/filter_form_builder_spec.rb +24 -0
  106. data/spec/unit/filters/resource_spec.rb +15 -1
  107. data/spec/unit/form_builder_spec.rb +4 -0
  108. data/spec/unit/resource_controller_spec.rb +67 -3
  109. data/spec/unit/resource_spec.rb +17 -0
  110. data/spec/unit/view_helpers/download_format_links_helper_spec.rb +39 -0
  111. data/spec/unit/view_helpers/fields_for_spec.rb +5 -0
  112. data/spec/unit/views/components/table_for_spec.rb +31 -0
  113. data/spec/unit/views/pages/layout_spec.rb +1 -1
  114. data/spec/unit/views/pages/show_spec.rb +21 -0
  115. data/tasks/parallel_tests.rake +60 -0
  116. data/tasks/test.rake +2 -1
  117. metadata +44 -26
@@ -1,4 +1,4 @@
1
- script: bundle exec rake
1
+ script: bundle exec rake test
2
2
  rvm:
3
3
  - ree
4
4
  - 1.9.2
@@ -1,11 +1,73 @@
1
1
  ## Master (unreleased)
2
2
 
3
+ ## 0.5.1
4
+
5
+ ### Enhancements
6
+
7
+ * Developer can pass options for CSV generation. [#1626][] by [@rheaton][]
8
+ ```ruby
9
+ ActiveAdmin.register Post do
10
+ csv options: {force_quotes: true} do
11
+ column :title
12
+ end
13
+ end
14
+ ```
15
+
16
+ * Breadcrumb links can be customized by [@simonoff][]
17
+ ```ruby
18
+ ActiveAdmin.register Post do
19
+ breadcrumb do
20
+ [
21
+ link_to("My account", account_path(current_user))
22
+ ]
23
+ end
24
+ end
25
+ ```
26
+
27
+ * Support proc for parent options on menus [#1664][] by [@shell][]
28
+ ```ruby
29
+ ActiveAdmin.register Post do
30
+ menu parent: proc { I18n.t("admin") }
31
+ end
32
+ ```
33
+
34
+ * Support automatic use of Decorators. [#1117][] by [@amiel][] and [#1647][] by [@dapi][]
35
+ ```ruby
36
+ ActiveAdmin.register Post do
37
+ decorate_with PostDecorator
38
+ end
39
+ ```
40
+
41
+ * Allow blacklisting of filters with 'remove_filter' [#1609][] by [@tracedwax][]
42
+ ```ruby
43
+ ActiveAdmin.register Post do
44
+ remove_filter :author
45
+ end
46
+ ```
47
+
48
+ * ActiveAdmin i18n translations can be overwritten in your rails
49
+ application locales. [#1775][] by [@caifara][]
50
+ * Add "Powered by" to translations. [#1783][] by [@sunny][]
51
+ * Forms accept two level deeps has_many. [#1699][] by [@kerberoS][] and tests in [#1782][] by [@ptn][]
52
+ * Extract download_format_links into helper [#1752][] by [@randym][]
53
+ * Add support for semantic errors [#905][] by [@robdiciuccio][]
54
+ * Add support for boolean inputs [#1668][] by [@orendon][]
55
+ * Support subURI on logout [#1681][] by [@yawn][]
56
+
57
+ ### Bug fix
58
+ * Apply before_filter to BaseController [#1683][] by [@yorch][]
59
+ * ... and much more.
60
+
61
+ ### Contributions
62
+
63
+ 156 commits (49 Pull Requests) by 51 contributors.
64
+
3
65
  ## 0.5.0
4
66
 
5
67
  ### Enhancements
6
68
 
7
69
  * Created new view components (Footer, TitleBar, Header, UtilityNav) to more
8
- easily customize the views in Active Admin and per namespace. (@gregbell)
70
+ easily customize the views in Active Admin and per namespace. ([@gregbell][])
9
71
  * All CSS is now encapsulated under the `body.active_admin` class. This may
10
72
  change the precedence of styles that you created to override or use in
11
73
  other areas of your application.
@@ -566,6 +628,7 @@ of the highlights. 250 commits. Enough said.
566
628
  [#865]: https://github.com/gregbell/active_admin/issues/865
567
629
  [#869]: https://github.com/gregbell/active_admin/issues/869
568
630
  [#897]: https://github.com/gregbell/active_admin/issues/897
631
+ [#905]: https://github.com/gregbell/active_admin/issues/905
569
632
  [#931]: https://github.com/gregbell/active_admin/issues/931
570
633
  [#960]: https://github.com/gregbell/active_admin/issues/960
571
634
  [#971]: https://github.com/gregbell/active_admin/issues/971
@@ -580,12 +643,28 @@ of the highlights. 250 commits. Enough said.
580
643
  [#1033]: https://github.com/gregbell/active_admin/issues/1033
581
644
  [#1041]: https://github.com/gregbell/active_admin/issues/1041
582
645
  [#1063]: https://github.com/gregbell/active_admin/issues/1063
646
+ [#1117]: https://github.com/gregbell/active_admin/issues/1117
647
+ [#1609]: https://github.com/gregbell/active_admin/issues/1609
648
+ [#1626]: https://github.com/gregbell/active_admin/issues/1626
649
+ [#1647]: https://github.com/gregbell/active_admin/issues/1647
650
+ [#1664]: https://github.com/gregbell/active_admin/issues/1664
651
+ [#1668]: https://github.com/gregbell/active_admin/issues/1668
652
+ [#1681]: https://github.com/gregbell/active_admin/issues/1681
653
+ [#1683]: https://github.com/gregbell/active_admin/issues/1683
654
+ [#1699]: https://github.com/gregbell/active_admin/issues/1699
655
+ [#1752]: https://github.com/gregbell/active_admin/issues/1752
656
+ [#1775]: https://github.com/gregbell/active_admin/issues/1775
657
+ [#1782]: https://github.com/gregbell/active_admin/issues/1782
658
+ [#1783]: https://github.com/gregbell/active_admin/issues/1783
583
659
  [@BoboFraggins]: https://github.com/BoboFraggins
584
660
  [@DMajrekar]: https://github.com/DMajrekar
585
661
  [@MoritzMoritz]: https://github.com/MoritzMoritz
586
662
  [@ZequeZ]: https://github.com/ZequeZ
663
+ [@amiel]: https://github.com/amiel
587
664
  [@bobbytables]: https://github.com/bobbytables
665
+ [@caifara]: https://github.com/caifara
588
666
  [@comboy]: https://github.com/comboy
667
+ [@dapi]: https://github.com/dapi
589
668
  [@dhiemstra]: https://github.com/dhiemstra
590
669
  [@doug316]: https://github.com/doug316
591
670
  [@ebeigarts]: https://github.com/ebeigarts
@@ -600,6 +679,7 @@ of the highlights. 250 commits. Enough said.
600
679
  [@jancel]: https://github.com/jancel
601
680
  [@jbarket]: https://github.com/jbarket
602
681
  [@jschwindt]: https://github.com/jschwindt
682
+ [@kerberoS]: https://github.com/kerberoS
603
683
  [@knoopx]: https://github.com/knoopx
604
684
  [@krug]: https://github.com/krug
605
685
  [@latortuga]: https://github.com/latortuga
@@ -607,14 +687,25 @@ of the highlights. 250 commits. Enough said.
607
687
  [@mattvague]: https://github.com/mattvague
608
688
  [@mperham]: https://github.com/mperham
609
689
  [@mwindwer]: https://github.com/mwindwer
690
+ [@orendon]: https://github.com/orendon
610
691
  [@page_title]: https://github.com/page_title
611
692
  [@pcreux]: https://github.com/pcreux
612
693
  [@per_page]: https://github.com/per_page
694
+ [@ptn]: https://github.com/ptn
695
+ [@randym]: https://github.com/randym
696
+ [@rheaton]: https://github.com/rheaton
697
+ [@robdiciuccio]: https://github.com/robdiciuccio
613
698
  [@rolfb]: https://github.com/rolfb
614
699
  [@samvincent]: https://github.com/samvincent
615
700
  [@sftsang]: https://github.com/sftsang
616
701
  [@shayfrendt]: https://github.com/shayfrendt
702
+ [@shell]: https://github.com/shell
703
+ [@simonoff]: https://github.com/simonoff
704
+ [@sunny]: https://github.com/sunny
705
+ [@tracedwax]: https://github.com/tracedwax
617
706
  [@tricknotes]: https://github.com/tricknotes
618
707
  [@utkarshkukreti]: https://github.com/utkarshkukreti
619
708
  [@vairix]: https://github.com/vairix
620
709
  [@watson]: https://github.com/watson
710
+ [@yawn]: https://github.com/yawn
711
+ [@yorch]: https://github.com/yorch
@@ -3,10 +3,10 @@
3
3
  This is a guide to contributing to Active Admin. It should walk you through the
4
4
  major steps to contributing code to the project.
5
5
 
6
- ### 1. Create an Issue on Github
6
+ ### 1. Create an Issue on GitHub
7
7
 
8
8
  The first step to contributing to Active Admin is creating a ticket in our
9
- [ticketing system on Github](https://github.com/gregbell/active_admin/issues).
9
+ [ticketing system on GitHub](https://github.com/gregbell/active_admin/issues).
10
10
  The community has been hard at work already, so please take a second to search
11
11
  for the issue or feature before creating a new one.
12
12
 
@@ -107,5 +107,5 @@ up to date with Active Admin's master branch. If there were any changes, you
107
107
  should rebase your feature branch and make sure that it will merge correctly. If
108
108
  there are any merge conflicts, your pull request will not be merged in.
109
109
 
110
- Now push your changes up to your feature branch on github and make a pull request!
110
+ Now push your changes up to your feature branch on GitHub and make a pull request!
111
111
  We will pull your changes, run the test suite, review the code and merge it in.
data/Gemfile CHANGED
@@ -24,22 +24,23 @@ end
24
24
  group :development, :test do
25
25
  gem 'sqlite3'
26
26
 
27
- gem 'rake', '~> 0.9.2.2', :require => false
28
- gem 'haml', '~> 3.1.1', :require => false
27
+ gem 'rake', '~> 10.0.2', :require => false
28
+ gem 'haml', '~> 3.1.7', :require => false
29
29
  gem 'yard'
30
30
  gem 'rdiscount' # For yard
31
31
  gem "sprockets"
32
32
  gem 'rails-i18n' # Gives us default i18n for many languages
33
+ gem 'parallel_tests'
33
34
  end
34
35
 
35
36
  group :test do
36
37
  gem 'rspec-rails', '~> 2.9.0'
37
- gem 'cucumber-rails', '1.2.1', :require => false
38
+ gem 'cucumber-rails', '1.3.0', :require => false
38
39
  gem 'capybara', '1.1.2'
39
40
  gem 'database_cleaner'
40
- gem 'shoulda-matchers', '1.0.0'
41
+ gem 'shoulda-matchers'
41
42
  gem 'launchy'
42
- gem 'jslint_on_rails', '~> 1.0.6'
43
+ gem 'jslint_on_rails', '~> 1.1.1'
43
44
  gem 'guard-rspec'
44
45
  gem "guard-coffeescript"
45
46
  gem 'jasmine'
@@ -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="https://secure.travis-ci.org/gregbell/active_admin.png?branch=master" />}[http://travis-ci.org/gregbell/active_admin] {<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/gregbell/active_admin]
7
+ {<img src="https://secure.travis-ci.org/gregbell/active_admin.png?branch=master" />}[http://travis-ci.org/gregbell/active_admin] {<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/gregbell/active_admin] {<img src="https://gemnasium.com/gregbell/active_admin.png" />}[https://gemnasium.com/gregbell/active_admin]
8
8
 
9
9
  == Documentation & Support
10
10
 
@@ -78,6 +78,11 @@ Refresh your web browser to see the interface.
78
78
  When upgrading to a new version of ActiveAdmin you may need to run
79
79
  $> rails generate active_admin:assets
80
80
 
81
+ If you get:
82
+ uninitialized constant Admin::DashboardController
83
+ when trying to view the dashboard (at +/admin+), ensure +app/admin/dashboards.rb+ looks like the current {default}[https://raw.github.com/gregbell/active_admin/master/lib/generators/active_admin/install/templates/dashboard.rb].
84
+
85
+
81
86
  == Next Steps
82
87
 
83
88
  The best place to get documentation is at http://activeadmin.info/documentation.html.
data/Rakefile CHANGED
@@ -14,8 +14,8 @@ require File.expand_path('../spec/support/detect_rails_version', __FILE__)
14
14
  # Import all our rake tasks
15
15
  FileList['tasks/**/*.rake'].each { |task| import task }
16
16
 
17
- # Run the specs & cukes
18
- task :default => :test
17
+ # Run the specs & cukes using parallel_tests
18
+ task :default => :parallel_tests
19
19
 
20
20
  begin
21
21
  require 'jasmine'
@@ -107,7 +107,7 @@ form {
107
107
  }
108
108
 
109
109
  /* Date and Time Fields */
110
- &.date, &.time, &.datetime {
110
+ &.date, &.time, &.datetime, &.date_select {
111
111
  fieldset ol li {
112
112
  float:left; width:auto; margin:0 0.5em 0 0;
113
113
  label { display: none; }
@@ -145,7 +145,6 @@ form {
145
145
 
146
146
  /* Errors */
147
147
  p.inline-errors {
148
- text-transform:capitalize;
149
148
  color: $error-color;
150
149
  font-weight: bold;
151
150
  margin:0.3em 0 0 20%;
@@ -164,6 +163,18 @@ form {
164
163
  }
165
164
  }
166
165
 
166
+ /* semantic_errors */
167
+ ul.errors {
168
+ background: lighten($error-color, 60%);
169
+ @include rounded(4px);
170
+ color: $error-color;
171
+ font-weight: bold;
172
+ margin-bottom: 10px;
173
+ padding: 10px;
174
+ list-style:square;
175
+ li { margin-left:15px; padding:0; border:none; display:list-item; }
176
+ }
177
+
167
178
  /* Buttons */
168
179
 
169
180
  input[type=submit] {
@@ -10,6 +10,7 @@
10
10
  .active_admin_comment_meta {
11
11
  width: 130px;
12
12
  float: left;
13
+ overflow: hidden;
13
14
  font-size: 0.9em;
14
15
  color: lighten($primary-color, 10%);
15
16
  .active_admin_comment_author {
@@ -1,7 +1,8 @@
1
1
  .table_tools {
2
2
  display: block;
3
- margin-bottom: 14px;
3
+ margin-bottom: 16px;
4
4
  width: 100%;
5
+ height: 20px;
5
6
  }
6
7
 
7
8
  .table_tools {
@@ -7,7 +7,10 @@
7
7
  CSV
8
8
  end
9
9
 
10
- csv_output = csv_lib.generate(:col_sep => active_admin_config.csv_builder.column_separator || active_admin_application.csv_column_separator) do |csv|
10
+ col_sep = active_admin_config.csv_builder.column_separator || active_admin_application.csv_column_separator
11
+ options = (active_admin_config.csv_builder.options || active_admin_application.csv_options).merge(:col_sep => col_sep)
12
+
13
+ csv_output = csv_lib.generate(options) do |csv|
11
14
  columns = active_admin_config.csv_builder.columns
12
15
  csv << columns.map(&:name)
13
16
  collection.each do |resource|
@@ -6,7 +6,7 @@
6
6
  <title><%= [@page_title, render_or_call_method_or_proc_on(self, ActiveAdmin.application.site_title)].compact.join(" | ") %></title>
7
7
 
8
8
  <% ActiveAdmin.application.stylesheets.each do |style| %>
9
- <%= stylesheet_link_tag style.path, style.options %>
9
+ <%= stylesheet_link_tag style.path, style.options.dup %>
10
10
  <% end %>
11
11
  <% ActiveAdmin.application.javascripts.each do |path| %>
12
12
  <%= javascript_include_tag path %>
@@ -18,8 +18,8 @@
18
18
  <div id="wrapper">
19
19
 
20
20
  <div id="content_wrapper">
21
- <% if flash.keys.any? %>
22
- <% flash.each do |type, message| %>
21
+ <% if active_admin_flash_messages.any? %>
22
+ <% active_admin_flash_messages.each do |type, message| %>
23
23
  <%= content_tag :div, message, :class => "flash flash_#{type}" %>
24
24
  <% end %>
25
25
  <% end %>
@@ -6,13 +6,6 @@ your Gemfile:
6
6
  # Gemfile
7
7
  gem 'activeadmin'
8
8
 
9
- If you are using Rails >= 3.1, you must also include a beta version of
10
- MetaSearch and sass-rails:
11
-
12
- # Gemfile in Rails >= 3.1
13
- gem 'activeadmin'
14
- gem 'sass-rails'
15
-
16
9
  ## Running the Generator
17
10
 
18
11
  Once you have added the gem to your Gemfile (and any other dependencies), you
@@ -77,3 +77,40 @@ individually.
77
77
 
78
78
  Each setting available in the Active Admin setup block is configurable on a per
79
79
  namespace basis.
80
+
81
+ ## Load paths
82
+
83
+ By default Active Admin files go under '/app/admin'. You can change this
84
+ directory in the initializer file:
85
+
86
+ ActiveAdmin.setup do |config|
87
+ config.load_paths = [File.join(Rails.root, "app", "ui")]
88
+ end
89
+
90
+ ## Comments
91
+
92
+ By default Active Admin includes comments on resources. Sometimes, this is
93
+ undesired. To disable comments for the entire application:
94
+
95
+ ActiveAdmin.setup do |config|
96
+
97
+ config.allow_comments = false
98
+
99
+ end
100
+
101
+ If you would like to enable / disable comments for just a namespace, do the
102
+ following:
103
+
104
+ ActiveAdmin.setup do |config|
105
+
106
+ config.namespace :admin do |admin|
107
+ admin.allow_comments = false
108
+ end
109
+
110
+ end
111
+
112
+ You can also disable comments for a specific resource:
113
+
114
+ ActiveAdmin.register Post do
115
+ config.comments = false
116
+ end
@@ -0,0 +1,48 @@
1
+ # Decorators
2
+
3
+ Active Admin supports the use of decorators for resources. Resources will be
4
+ be decorated for the index and show blocks. The [draper](http://github.com/jcasimir/draper)
5
+ gem is recommended but not required (more on requirements below).
6
+
7
+ ## Configuration
8
+
9
+ ActiveAdmin.register Post do
10
+ decorate_with PostDecorator
11
+ end
12
+
13
+ ## Example Usage
14
+
15
+ This example uses [draper](http://github.com/jcasimir/draper).
16
+
17
+ # Gemfile
18
+ gem 'draper'
19
+
20
+ Assuming a post and a post decorator
21
+
22
+ class Post < ActiveRecord::Base; end
23
+
24
+ class PostDecorator < ApplicationDecorator
25
+ decorates :post
26
+
27
+ def image
28
+ h.image_tag model.image_url
29
+ end
30
+ end
31
+
32
+ Then the following is possible
33
+
34
+ ActiveAdmin.register Post do
35
+ decorate_with PostDecorator
36
+
37
+ index do
38
+ column(:title)
39
+ column(:image)
40
+ end
41
+
42
+ show do
43
+ attributes_table do
44
+ row(:title)
45
+ row(:image)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,145 @@
1
+ # Arbre Components
2
+
3
+ Arbre allows the creation of shareable and extendable HTML components and is
4
+ used throughout Active Admin to create view components.
5
+
6
+ ## Text Node
7
+
8
+ Sometimes it makes sense to insert something into a registered resource like a
9
+ non-breaking space or some text. The text_node method can be used to insert
10
+ these elements into the page inside of other Arbre components or resource
11
+ controller functions.
12
+
13
+ ActiveAdmin.register Post do
14
+ show do
15
+ panel "Post Details" do
16
+ row("") { post.id }
17
+ row("Tags") do
18
+ text_node link_to "#{tag}",
19
+ admin_post_path( q: { tagged_with_contains: tag } )
20
+ text_node "&nbsp".html_safe
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ ## Common Components
27
+
28
+ ### Panel Component
29
+
30
+ A panel is a component that takes up all available horizontal space and takes a
31
+ title and a hash of attributes as arguments. If a sidebar is present, a panel
32
+ will take up the remaining space.
33
+
34
+ The following code will create two stacked panels:
35
+
36
+ show do
37
+
38
+ panel "Post Details" do
39
+ render partial: "show_details", locals: {post: post}
40
+ end
41
+
42
+ panel "Post Tags" do
43
+ render partial: "show_enhancements", locals: {post: post}
44
+ end
45
+
46
+ end
47
+
48
+ ### Columns Component
49
+
50
+ The Columns component allows you draw content into scalable columns. All you
51
+ need to do is define the number of columns and the component will take care of
52
+ the rest.
53
+
54
+ #### Simple Columns
55
+
56
+ To create simple columnns, use the #columns method. Within the block, call the
57
+ #column method to create a new column.
58
+
59
+ columns do
60
+
61
+ column do
62
+ span "Column #1"
63
+ end
64
+
65
+ column do
66
+ span "Column #2"
67
+ end
68
+
69
+ end
70
+
71
+ #### Multiple Span Columns
72
+
73
+ To create columns that have multiple spans, pass the :span option to the column
74
+ method.
75
+
76
+ columns do
77
+ column :span => 2 do
78
+ span "Column # 1
79
+ end
80
+ column do
81
+ span "Column # 2
82
+ end
83
+ end
84
+
85
+ By default, each column spans 1 column. The above layout would have 2 columns,
86
+ the first being twice as large as the second.
87
+
88
+ #### Max and Mix Column Sizes
89
+
90
+ Active Admin uses a fluid width layout, causing column width to be defined
91
+ using percentages. Due to using this style of layout, columns can shrink or
92
+ expand past points that may not be desirable. To overcome this issue,
93
+ columns provide :max_width and :min_width options.
94
+
95
+ columns do
96
+ column :max_width => "200px", :min_width => "100px" do
97
+ span "Column # 1
98
+ end
99
+ column do
100
+ span "Column # 2
101
+ end
102
+ end
103
+
104
+ In the above example, the first column will not grow larger than 200px and will
105
+ not shrink less than 100px.
106
+
107
+ ### Table For Component
108
+
109
+ Table For provides the ability to create tables like those present in
110
+ #index_as_table. table_for takes a collection and a hash of options and then
111
+ uses #column to build the fields to show with the table.
112
+
113
+ table_for order.payments do
114
+ column "Payment Type" { |payment| payment.payment_type.titleize }
115
+ column "Received On", :created_at
116
+ column "Payment Details & Notes", :payment_details
117
+ column "Amount" { |payment| payment.amount_in_dollars }
118
+ end
119
+
120
+ the #column method can take a title as its first argument and data
121
+ (:your_method) as its second (or first if no title provided). Column also
122
+ takes a block.
123
+
124
+ ### Status tag
125
+
126
+ Status tags provide convenient syntactic sugar for styling items that have
127
+ status. A common example of where the status tag could be useful is for orders
128
+ that are complete or in progress. status_tag takes a status, like
129
+ "In Progress", a type, which defaults to nil, and a hash of options. The
130
+ status_tag will generate html markup that Active Admin css uses in styling.
131
+
132
+ status_tag('In Progress')
133
+ # => <span class='status_tag in_progress'>In Progress</span>
134
+
135
+ status_tag('active', :ok)
136
+ # => <span class='status_tag active ok'>Active</span>
137
+
138
+ status_tag (
139
+ 'active',
140
+ :ok,
141
+ :class => 'important',
142
+ :id => 'status_123',
143
+ :label => 'on'
144
+ )
145
+ # => <span class='status_tag active ok important' id='status_123'>on</span>