activeadmin 0.5.1 → 0.6.0

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 (196) hide show
  1. data/.travis.yml +8 -5
  2. data/CHANGELOG.md +151 -0
  3. data/Gemfile +16 -16
  4. data/LICENSE +1 -1
  5. data/activeadmin.gemspec +1 -0
  6. data/app/assets/images/active_admin/index_list_icons/block_icon.svg +10 -0
  7. data/app/assets/images/active_admin/index_list_icons/blog_icon.svg +4 -0
  8. data/app/assets/images/active_admin/index_list_icons/grid_icon.svg +13 -0
  9. data/app/assets/images/active_admin/index_list_icons/table_icon.svg +3 -0
  10. data/app/assets/javascripts/active_admin/components/jquery.aa.checkbox-toggler.js.coffee +17 -44
  11. data/app/assets/javascripts/active_admin/components/jquery.aa.dropdown-menu.js.coffee +2 -4
  12. data/app/assets/javascripts/active_admin/components/jquery.aa.popover.js.coffee +0 -3
  13. data/app/assets/javascripts/active_admin/components/jquery.aa.table-checkbox-toggler.js.coffee +10 -12
  14. data/app/assets/javascripts/active_admin/pages/application.js.coffee +13 -10
  15. data/app/assets/javascripts/active_admin/pages/batch_actions.js.coffee +3 -3
  16. data/app/assets/stylesheets/active_admin/_base.css.scss +1 -0
  17. data/app/assets/stylesheets/active_admin/_header.css.scss +5 -2
  18. data/app/assets/stylesheets/active_admin/components/_dropdown_menu.scss +2 -2
  19. data/app/assets/stylesheets/active_admin/components/_index_list.scss +12 -0
  20. data/app/assets/stylesheets/active_admin/components/_popovers.css.scss +2 -2
  21. data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +2 -2
  22. data/app/assets/stylesheets/active_admin/mixins/_buttons.css.scss +4 -4
  23. data/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss +5 -4
  24. data/app/assets/stylesheets/active_admin/mixins/_sections.css.scss +1 -1
  25. data/app/assets/stylesheets/active_admin/pages/_logged_out.scss +1 -1
  26. data/app/assets/stylesheets/active_admin/print.css.scss +2 -2
  27. data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +1 -1
  28. data/app/views/active_admin/devise/unlocks/new.html.erb +14 -12
  29. data/docs/1-general-configuration.md +13 -0
  30. data/docs/10-custom-pages.md +40 -28
  31. data/docs/11-decorators.md +6 -4
  32. data/docs/12-arbre-components.md +1 -1
  33. data/docs/13-authorization-adapter.md +206 -0
  34. data/docs/2-resource-customization.md +129 -14
  35. data/docs/3-index-pages.md +65 -0
  36. data/docs/3-index-pages/create-an-index.md +29 -0
  37. data/docs/3-index-pages/index-as-table.md +35 -11
  38. data/docs/5-forms.md +2 -2
  39. data/features/authorization.feature +64 -0
  40. data/features/authorization_cancan.feature +52 -0
  41. data/features/belongs_to.feature +41 -5
  42. data/features/index/batch_actions.feature +27 -3
  43. data/features/index/formats.feature +27 -0
  44. data/features/index/index_as_table.feature +74 -2
  45. data/features/index/index_parameters.feature +69 -0
  46. data/features/index/index_scopes.feature +7 -11
  47. data/features/index/page_title.feature +18 -0
  48. data/features/index/switch_index_view.feature +73 -0
  49. data/features/menu.feature +27 -0
  50. data/features/registering_pages.feature +21 -0
  51. data/features/step_definitions/additional_web_steps.rb +4 -0
  52. data/features/step_definitions/batch_action_steps.rb +16 -6
  53. data/features/step_definitions/index_scope_steps.rb +3 -3
  54. data/features/step_definitions/index_views_steps.rb +3 -0
  55. data/features/step_definitions/menu_steps.rb +4 -0
  56. data/features/support/env.rb +4 -0
  57. data/features/support/paths.rb +3 -0
  58. data/lib/active_admin.rb +4 -0
  59. data/lib/active_admin/application.rb +43 -76
  60. data/lib/active_admin/authorization_adapter.rb +128 -0
  61. data/lib/active_admin/base_controller.rb +18 -1
  62. data/lib/active_admin/base_controller/authorization.rb +153 -0
  63. data/lib/active_admin/base_controller/menu.rb +8 -3
  64. data/lib/active_admin/batch_actions/resource_extension.rb +8 -7
  65. data/lib/active_admin/batch_actions/views/batch_action_form.rb +1 -1
  66. data/lib/active_admin/cancan_adapter.rb +40 -0
  67. data/lib/active_admin/dashboards.rb +4 -5
  68. data/lib/active_admin/dashboards/dashboard_controller.rb +1 -1
  69. data/lib/active_admin/devise.rb +22 -7
  70. data/lib/active_admin/dsl.rb +18 -5
  71. data/lib/active_admin/engine.rb +1 -1
  72. data/lib/active_admin/filters/dsl.rb +1 -1
  73. data/lib/active_admin/filters/forms.rb +9 -7
  74. data/lib/active_admin/filters/resource_extension.rb +20 -15
  75. data/lib/active_admin/form_builder.rb +44 -49
  76. data/lib/active_admin/helpers/optional_display.rb +4 -8
  77. data/lib/active_admin/inputs/filter_boolean_input.rb +1 -1
  78. data/lib/active_admin/inputs/filter_string_input.rb +5 -1
  79. data/lib/active_admin/locales/bg.yml +1 -1
  80. data/lib/active_admin/locales/ca.yml +1 -1
  81. data/lib/active_admin/locales/cs.yml +26 -25
  82. data/lib/active_admin/locales/da.yml +1 -1
  83. data/lib/active_admin/locales/de.yml +1 -1
  84. data/lib/active_admin/locales/en.yml +11 -1
  85. data/lib/active_admin/locales/es.yml +16 -16
  86. data/lib/active_admin/locales/fr.yml +1 -1
  87. data/lib/active_admin/locales/he.yml +1 -1
  88. data/lib/active_admin/locales/hr.yml +1 -1
  89. data/lib/active_admin/locales/hu.yml +1 -1
  90. data/lib/active_admin/locales/it.yml +1 -1
  91. data/lib/active_admin/locales/ja.yml +4 -1
  92. data/lib/active_admin/locales/ko.yml +1 -1
  93. data/lib/active_admin/locales/lt.yml +1 -1
  94. data/lib/active_admin/locales/lv.yml +12 -1
  95. data/lib/active_admin/locales/nl.yml +2 -2
  96. data/lib/active_admin/locales/no-NB.yml +22 -1
  97. data/lib/active_admin/locales/pl.yml +1 -1
  98. data/lib/active_admin/locales/pt-BR.yml +1 -1
  99. data/lib/active_admin/locales/pt-PT.yml +81 -0
  100. data/lib/active_admin/locales/ro.yml +1 -1
  101. data/lib/active_admin/locales/ru.yml +1 -1
  102. data/lib/active_admin/locales/sv-SE.yml +1 -1
  103. data/lib/active_admin/locales/tr.yml +1 -1
  104. data/lib/active_admin/locales/vi.yml +1 -1
  105. data/lib/active_admin/locales/zh-CN.yml +1 -1
  106. data/lib/active_admin/locales/zh-TW.yml +1 -1
  107. data/lib/active_admin/menu.rb +76 -38
  108. data/lib/active_admin/menu_collection.rb +96 -0
  109. data/lib/active_admin/menu_item.rb +61 -71
  110. data/lib/active_admin/namespace.rb +67 -5
  111. data/lib/active_admin/page.rb +6 -0
  112. data/lib/active_admin/page_controller.rb +13 -3
  113. data/lib/active_admin/resource.rb +11 -20
  114. data/lib/active_admin/resource/action_items.rb +3 -3
  115. data/lib/active_admin/resource/controllers.rb +0 -17
  116. data/lib/active_admin/resource/menu.rb +52 -24
  117. data/lib/active_admin/resource/naming.rb +6 -10
  118. data/lib/active_admin/resource/page_presenters.rb +57 -3
  119. data/lib/active_admin/resource/routes.rb +46 -0
  120. data/lib/active_admin/resource_controller.rb +2 -17
  121. data/lib/active_admin/resource_controller/data_access.rb +299 -0
  122. data/lib/active_admin/resource_controller/decorators.rb +2 -1
  123. data/lib/active_admin/resource_dsl.rb +12 -14
  124. data/lib/active_admin/router.rb +61 -56
  125. data/lib/active_admin/scope.rb +28 -18
  126. data/lib/active_admin/version.rb +1 -1
  127. data/lib/active_admin/view_factory.rb +0 -1
  128. data/lib/active_admin/view_helpers/breadcrumb_helper.rb +13 -19
  129. data/lib/active_admin/view_helpers/fields_for.rb +2 -0
  130. data/lib/active_admin/view_helpers/form_helper.rb +1 -1
  131. data/lib/active_admin/view_helpers/method_or_proc_helper.rb +66 -11
  132. data/lib/active_admin/views/components/attributes_table.rb +7 -4
  133. data/lib/active_admin/views/components/index_list.rb +68 -0
  134. data/lib/active_admin/views/components/paginated_collection.rb +13 -9
  135. data/lib/active_admin/views/components/scopes.rb +2 -8
  136. data/lib/active_admin/views/components/table_for.rb +1 -1
  137. data/lib/active_admin/views/footer.rb +1 -1
  138. data/lib/active_admin/views/header.rb +3 -2
  139. data/lib/active_admin/views/index_as_block.rb +4 -0
  140. data/lib/active_admin/views/index_as_blog.rb +4 -0
  141. data/lib/active_admin/views/index_as_grid.rb +4 -0
  142. data/lib/active_admin/views/index_as_table.rb +49 -7
  143. data/lib/active_admin/views/pages/index.rb +19 -4
  144. data/lib/active_admin/views/tabbed_navigation.rb +10 -54
  145. data/lib/generators/active_admin/install/install_generator.rb +5 -1
  146. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +58 -0
  147. data/spec/integration/{default_namespace.rb → default_namespace_spec.rb} +0 -16
  148. data/spec/spec_helper.rb +3 -0
  149. data/spec/support/detect_rails_version.rb +10 -3
  150. data/spec/support/rails_template.rb +1 -1
  151. data/spec/support/templates/post_decorator.rb +6 -6
  152. data/spec/unit/application_spec.rb +5 -5
  153. data/spec/unit/authorization/authorization_adapter_spec.rb +61 -0
  154. data/spec/unit/authorization/controller_authorization_spec.rb +47 -0
  155. data/spec/unit/base_controller_spec.rb +0 -2
  156. data/spec/unit/batch_actions/resource_spec.rb +1 -1
  157. data/spec/unit/breadcrumbs_spec.rb +3 -3
  158. data/spec/unit/cancan_adapter_spec.rb +35 -0
  159. data/spec/unit/config_shared_examples.rb +9 -30
  160. data/spec/unit/devise_spec.rb +29 -0
  161. data/spec/unit/dsl_spec.rb +61 -0
  162. data/spec/unit/filters/filter_form_builder_spec.rb +58 -4
  163. data/spec/unit/filters/resource_spec.rb +17 -5
  164. data/spec/unit/form_builder_spec.rb +15 -0
  165. data/spec/unit/menu_collection_spec.rb +62 -0
  166. data/spec/unit/menu_item_spec.rb +51 -37
  167. data/spec/unit/menu_spec.rb +33 -29
  168. data/spec/unit/namespace/authorization_spec.rb +31 -0
  169. data/spec/unit/namespace/register_page_spec.rb +6 -28
  170. data/spec/unit/namespace/register_resource_spec.rb +11 -34
  171. data/spec/unit/namespace_spec.rb +63 -2
  172. data/spec/unit/page_controller_spec.rb +0 -3
  173. data/spec/unit/reloader_spec.rb +5 -5
  174. data/spec/unit/resource/menu_spec.rb +1 -13
  175. data/spec/unit/resource/naming_spec.rb +20 -2
  176. data/spec/unit/resource/page_presenters_spec.rb +14 -2
  177. data/spec/unit/resource_controller/{collection_spec.rb → data_access_spec.rb} +31 -13
  178. data/spec/unit/resource_controller_spec.rb +4 -5
  179. data/spec/unit/resource_spec.rb +33 -11
  180. data/spec/unit/routing_spec.rb +43 -0
  181. data/spec/unit/scope_spec.rb +13 -0
  182. data/spec/unit/view_factory_spec.rb +0 -1
  183. data/spec/unit/view_helpers/fields_for_spec.rb +4 -0
  184. data/spec/unit/view_helpers/form_helper_spec.rb +6 -2
  185. data/spec/unit/view_helpers/method_or_proc_helper_spec.rb +97 -0
  186. data/spec/unit/views/components/attributes_table_spec.rb +11 -0
  187. data/spec/unit/views/components/index_list_spec.rb +32 -0
  188. data/spec/unit/views/tabbed_navigation_spec.rb +42 -40
  189. data/tasks/test.rake +1 -1
  190. metadata +127 -40
  191. data/lib/active_admin/menu_builder.rb +0 -65
  192. data/lib/active_admin/resource_controller/callbacks.rb +0 -59
  193. data/lib/active_admin/resource_controller/collection.rb +0 -158
  194. data/lib/active_admin/views/utility_nav.rb +0 -41
  195. data/spec/unit/base_controller_shared_examples.rb +0 -25
  196. data/spec/unit/dsl_include_spec.rb +0 -20
@@ -39,7 +39,7 @@ module ActiveAdmin
39
39
 
40
40
  # Return the current menu for the view. This is a helper method
41
41
  def current_menu
42
- active_admin_namespace.menu
42
+ active_admin_namespace.fetch_menu(:default)
43
43
  end
44
44
 
45
45
  def active_admin_namespace
@@ -21,7 +21,8 @@ module ActiveAdmin
21
21
  def self.controllers
22
22
  {
23
23
  :sessions => "active_admin/devise/sessions",
24
- :passwords => "active_admin/devise/passwords"
24
+ :passwords => "active_admin/devise/passwords",
25
+ :unlocks => "active_admin/devise/unlocks"
25
26
  }
26
27
  end
27
28
 
@@ -34,12 +35,22 @@ module ActiveAdmin
34
35
 
35
36
  # Redirect to the default namespace on logout
36
37
  def root_path
37
- (Rails.configuration.action_controller[:relative_url_root] || '') +
38
- if ActiveAdmin.application.default_namespace
39
- "/#{ActiveAdmin.application.default_namespace}"
40
- else
41
- "/"
42
- end
38
+ namespace = ActiveAdmin.application.default_namespace.presence
39
+ root_path_method = [namespace, :root_path].compact.join('_')
40
+
41
+ url_helpers = Rails.application.routes.url_helpers
42
+
43
+ path = if url_helpers.respond_to? root_path_method
44
+ url_helpers.send root_path_method
45
+ else
46
+ # Guess a root_path when url_helpers not helpful
47
+ "/#{namespace}"
48
+ end
49
+
50
+ # NOTE: `relative_url_root` is deprecated by rails.
51
+ # Remove prefix here if it is removed completely.
52
+ prefix = Rails.configuration.action_controller[:relative_url_root] || ''
53
+ prefix + path
43
54
  end
44
55
  end
45
56
 
@@ -51,5 +62,9 @@ module ActiveAdmin
51
62
  include ::ActiveAdmin::Devise::Controller
52
63
  end
53
64
 
65
+ class UnlocksController < ::Devise::UnlocksController
66
+ include ::ActiveAdmin::Devise::Controller
67
+ end
68
+
54
69
  end
55
70
  end
@@ -86,7 +86,7 @@ module ActiveAdmin
86
86
  def action_item(options = {}, &block)
87
87
  config.add_action_item(options, &block)
88
88
  end
89
-
89
+
90
90
  # Add a new batch action item to the resource
91
91
  # Provide a symbol/string to register the action, options, & block to execute on request
92
92
  #
@@ -99,7 +99,6 @@ module ActiveAdmin
99
99
  # => :confirm is a string which the user will have to accept in order to process the action
100
100
  #
101
101
  def batch_action(title, options = {}, &block)
102
-
103
102
  # Create symbol & title information
104
103
  if title.is_a?( String )
105
104
  sym = title.titleize.gsub(' ', '').underscore.to_sym
@@ -114,13 +113,27 @@ module ActiveAdmin
114
113
  else
115
114
  config.remove_batch_action sym
116
115
  end
117
-
118
116
  end
119
117
 
118
+ # Set the options that are available for the item that will be placed in the global
119
+ # navigation of the menu.
120
120
  def menu(options = {})
121
- config.menu(options)
121
+ config.menu_item_options = options
122
122
  end
123
-
123
+
124
+ # Set the name of the navigation menu to display. This is mainly used in conjuction with the
125
+ # `#belongs_to` functionality.
126
+ #
127
+ # @param [Symbol] menu_name The name of the menu to display as the global navigation
128
+ # when viewing this resource. Defaults to a menu named `:default`.
129
+ #
130
+ # Pass a block returning the name of a menu you want rendered for the request, being
131
+ # executed in the context of the controller
132
+ #
133
+ def navigation_menu(menu_name=nil, &block)
134
+ config.navigation_menu_name = menu_name || block
135
+ end
136
+
124
137
  # Rewrite breadcrumb links.
125
138
  # Block will be executed inside controller.
126
139
  # Block must return an array if you want to rewrite breadcrumb links.
@@ -1,7 +1,7 @@
1
1
  module ActiveAdmin
2
2
  class Engine < Rails::Engine
3
3
  if Rails.version > "3.1"
4
- initializer "ActiveAdmin precompile hook" do |app|
4
+ initializer "ActiveAdmin precompile hook", :group => :all do |app|
5
5
  app.config.assets.precompile += %w(active_admin.js active_admin.css active_admin/print.css)
6
6
  end
7
7
  end
@@ -7,7 +7,7 @@ module ActiveAdmin
7
7
  config.add_filter(attribute, options)
8
8
  end
9
9
 
10
- # For docs, please see ActiveAdmin::Filters::ResourceExtension#delete_filter
10
+ # For docs, please see ActiveAdmin::Filters::ResourceExtension#remove_filter
11
11
  def remove_filter(attribute)
12
12
  config.remove_filter(attribute)
13
13
  end
@@ -6,9 +6,8 @@ module ActiveAdmin
6
6
  class FormBuilder < ::ActiveAdmin::FormBuilder
7
7
 
8
8
  def filter(method, options = {})
9
- return "" if method.blank?
10
- options[:as] ||= default_input_type(method)
11
- return "" unless options[:as]
9
+ return "" if method.blank? ||
10
+ (options[:as] ||= default_input_type(method)).nil?
12
11
  content = input(method, options)
13
12
  form_buffers.last << content.html_safe if content
14
13
  end
@@ -73,10 +72,13 @@ module ActiveAdmin
73
72
  options[:as] = :q
74
73
  clear_link = link_to(I18n.t('active_admin.clear_filters'), "#", :class => "clear_filters_btn")
75
74
  form_for search, options do |f|
76
- filters.each do |filter_options|
77
- filter_options = filter_options.dup
78
- attribute = filter_options.delete(:attribute)
79
- f.filter attribute, filter_options
75
+ filters.group_by{ |o| o[:attribute] }.each do |attribute, array|
76
+ options = array.last # grab last-defined `filter` call from DSL
77
+ if_block = options[:if] || proc{ true }
78
+ unless_block = options[:unless] || proc{ false }
79
+ if call_method_or_proc_on(self, if_block) && !call_method_or_proc_on(self, unless_block)
80
+ f.filter options[:attribute], options.except(:attribute, :if, :unless)
81
+ end
80
82
  end
81
83
 
82
84
  buttons = content_tag :div, :class => "buttons" do
@@ -14,16 +14,7 @@ module ActiveAdmin
14
14
  # @return [Array] Filters that apply for this resource
15
15
  def filters
16
16
  return [] unless filters_enabled?
17
-
18
- if @filters.present?
19
- if preserve_default_filters?
20
- @filters + default_filters
21
- else
22
- @filters
23
- end
24
- else
25
- default_filters
26
- end
17
+ filter_lookup
27
18
  end
28
19
 
29
20
  # Setter to enable / disable filters on this resource.
@@ -55,9 +46,8 @@ module ActiveAdmin
55
46
  raise RuntimeError, "Can't remove a filter when filters are disabled. Enable filters with 'config.filters = true'"
56
47
  end
57
48
 
58
- @filters ||= default_filters
59
-
60
- @filters.delete_if { |f| f.fetch(:attribute) == attribute }
49
+ @filters_to_remove ||= []
50
+ @filters_to_remove << attribute
61
51
  end
62
52
 
63
53
  # Add a filter for this resource. If filters are not enabled, this method
@@ -72,18 +62,33 @@ module ActiveAdmin
72
62
  end
73
63
 
74
64
  @filters ||= []
75
-
76
65
  @filters << options.merge({ :attribute => attribute })
77
66
  end
78
67
 
79
68
  # Reset the filters to use defaults
80
69
  def reset_filters!
81
70
  @filters = nil
71
+ @filters_to_remove = nil
82
72
  end
83
73
 
84
74
  private
85
75
 
86
- # @return [Array] The array of default for filters for this resource
76
+ # Collapses the waveform, if you will, of which filters should be displayed.
77
+ # Removes filters and adds in default filters as desired.
78
+ def filter_lookup
79
+ filters = @filters.try(:dup) || []
80
+ filters.push *default_filters if filters.empty? || preserve_default_filters?
81
+
82
+ if @filters_to_remove
83
+ @filters_to_remove.each do |attr|
84
+ filters.delete_if{ |f| f.fetch(:attribute) == attr }
85
+ end
86
+ end
87
+
88
+ filters
89
+ end
90
+
91
+ # @return [Array] The array of default filters for this resource
87
92
  def default_filters
88
93
  default_association_filters + default_content_filters
89
94
  end
@@ -9,37 +9,31 @@ module ActiveAdmin
9
9
  end
10
10
 
11
11
  def inputs(*args, &block)
12
- # Store that we are creating inputs without a block
13
- @inputs_with_block = block_given? ? true : false
14
- content = with_new_form_buffer { super }
15
- form_buffers.last << content.html_safe
12
+ @inputs_with_block = block_given?
13
+ form_buffers.last << with_new_form_buffer{ super }
16
14
  end
17
15
 
18
- # The input method returns a properly formatted string for
19
- # its contents, so we want to skip the internal buffering
20
- # while building up its contents
16
+ # If this `input` call is inside a `inputs` block, add the content
17
+ # to the form buffer. Else, return it directly.
21
18
  def input(method, *args)
22
- content = with_new_form_buffer { super }
23
- return content.html_safe unless @inputs_with_block
24
- form_buffers.last << content.html_safe
19
+ content = with_new_form_buffer{ super }
20
+ @inputs_with_block ? form_buffers.last << content : content
25
21
  end
26
22
 
27
- def cancel_link(url = nil, html_options = {}, li_attributes = {})
28
- li_attributes[:class] ||= "cancel"
29
- url ||= {:action => "index"}
30
- form_buffers.last << template.content_tag(:li, (template.link_to I18n.t('active_admin.cancel'), url, html_options), li_attributes)
23
+ def cancel_link(url = {:action => "index"}, html_options = {}, li_attrs = {})
24
+ li_attrs[:class] ||= "cancel"
25
+ li_content = template.link_to I18n.t('active_admin.cancel'), url, html_options
26
+ form_buffers.last << template.content_tag(:li, li_content, li_attrs)
31
27
  end
32
28
 
33
29
  def actions(*args, &block)
34
- content = with_new_form_buffer do
35
- block_given? ? super : super { commit_action_with_cancel_link }
30
+ form_buffers.last << with_new_form_buffer do
31
+ block_given? ? super : super{ commit_action_with_cancel_link }
36
32
  end
37
- form_buffers.last << content.html_safe
38
33
  end
39
34
 
40
35
  def action(*args)
41
- content = with_new_form_buffer { super }
42
- form_buffers.last << content.html_safe
36
+ form_buffers.last << with_new_form_buffer{ super }
43
37
  end
44
38
 
45
39
  def commit_action_with_cancel_link
@@ -71,21 +65,18 @@ module ActiveAdmin
71
65
  contents
72
66
  end
73
67
 
74
- content = with_new_form_buffer do
68
+ form_buffers.last << with_new_form_buffer do
75
69
  template.content_tag :div, :class => "has_many #{association}" do
76
70
  form_buffers.last << template.content_tag(:h3, object.class.reflect_on_association(association).klass.model_name.human(:count => 1.1))
77
71
  inputs options, &form_block
78
72
 
79
- js = js_for_has_many(association, form_block, template)
80
- form_buffers.last << js.html_safe
73
+ form_buffers.last << js_for_has_many(association, form_block, template)
81
74
  end
82
75
  end
83
- form_buffers.last << content.html_safe
84
76
  end
85
-
77
+
86
78
  def semantic_errors(*args)
87
- content = with_new_form_buffer { super }
88
- form_buffers.last << content.html_safe unless content.nil?
79
+ form_buffers.last << with_new_form_buffer{ super }
89
80
  end
90
81
 
91
82
  # These methods are deprecated and removed from Formtastic, however are
@@ -135,9 +126,9 @@ module ActiveAdmin
135
126
  if ::Object.const_defined?(input_class_name)
136
127
  input_class_name.constantize
137
128
  elsif ActiveAdmin::Inputs.const_defined?(input_class_name)
138
- active_admin_input_class_name(as).constantize
129
+ active_admin_input_class_name(as).constantize
139
130
  elsif Formtastic::Inputs.const_defined?(input_class_name)
140
- standard_input_class_name(as).constantize
131
+ standard_input_class_name(as).constantize
141
132
  else
142
133
  raise Formtastic::UnknownInputError
143
134
  end
@@ -160,36 +151,40 @@ module ActiveAdmin
160
151
  raise Formtastic::UnknownInputError
161
152
  end
162
153
 
154
+ # This method calls the block it's passed (in our case, the `f.inputs` block)
155
+ # and wraps the resulting HTML in a fieldset. If your block happens to return
156
+ # nil (but it otherwise built the form correctly), the below override passes
157
+ # the most recent part of the Active Admin form buffer.
158
+ def field_set_and_list_wrapping(*args, &block)
159
+ block_given? ? super{ yield || form_buffers.last } : super
160
+ end
161
+
163
162
  private
164
163
 
165
164
  def with_new_form_buffer
166
- form_buffers << "".html_safe
167
- return_value = yield
165
+ form_buffers << ''.html_safe
166
+ return_value = (yield || '').html_safe
168
167
  form_buffers.pop
169
168
  return_value
170
169
  end
171
170
 
172
171
  # Capture the ADD JS
173
172
  def js_for_has_many(association, form_block, template)
174
- association_reflection = object.class.reflect_on_association(association)
175
- association_human_name = association_reflection.klass.model_name.human
176
- placeholder = "NEW_#{association_human_name.upcase.split(' ').join('_')}_RECORD"
177
-
178
- js = with_new_form_buffer do
179
- inputs_for_nested_attributes :for => [association, association_reflection.klass.new],
180
- :class => "inputs has_many_fields",
181
- :for_options => { :child_index => placeholder },
182
- &form_block
183
- end
184
-
185
- js = template.escape_javascript(js)
186
-
187
- text = I18n.t 'active_admin.has_many_new', :model => association_human_name
188
- onclick = "$(this).siblings('li.input').append('#{js}'.replace(/#{placeholder}/g, new Date().getTime())); return false;"
189
-
190
- template.link_to text, "#",
191
- :onclick => onclick,
192
- :class => "button"
173
+ assoc_reflection = object.class.reflect_on_association(association)
174
+ assoc_name = assoc_reflection.klass.model_name
175
+ placeholder = "NEW_#{assoc_name.upcase.split(' ').join('_')}_RECORD"
176
+ opts = {
177
+ :for => [association, assoc_reflection.klass.new],
178
+ :class => "inputs has_many_fields",
179
+ :for_options => { :child_index => placeholder }
180
+ }
181
+ js = with_new_form_buffer{ inputs_for_nested_attributes opts, &form_block }
182
+ js = template.escape_javascript js
183
+
184
+ onclick = "$(this).before('#{js}'.replace(/#{placeholder}/g, new Date().getTime())); return false;"
185
+ text = I18n.t 'active_admin.has_many_new', :model => assoc_name.human
186
+
187
+ template.link_to(text, "#", :onclick => onclick, :class => "button").html_safe
193
188
  end
194
189
 
195
190
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveAdmin
2
-
2
+
3
3
  # Shareable module to give a #display_on?(action) method
4
4
  # which returns true or false depending on an options hash.
5
5
  #
@@ -23,7 +23,7 @@ module ActiveAdmin
23
23
  when Symbol, String
24
24
  render_context ? render_context.send(symbol_or_proc) : self.send(symbol_or_proc)
25
25
  when Proc
26
- render_context ? render_context.instance_exec(&symbol_or_proc) : instance_exec(&symbol_or_proc)
26
+ render_context ? render_context.instance_exec(&symbol_or_proc) : instance_exec(&symbol_or_proc)
27
27
  else symbol_or_proc
28
28
  end
29
29
  end
@@ -33,12 +33,8 @@ module ActiveAdmin
33
33
  private
34
34
 
35
35
  def normalize_display_options!
36
- if @options[:only]
37
- @options[:only] = @options[:only].is_a?(Array) ? @options[:only] : [@options[:only]]
38
- end
39
- if @options[:except]
40
- @options[:except] = @options[:except].is_a?(Array) ? @options[:except] : [@options[:except]]
41
- end
36
+ @options[:only] = Array(@options[:only]) if @options[:only]
37
+ @options[:except] = Array(@options[:except]) if @options[:except]
42
38
  end
43
39
  end
44
40
  end
@@ -32,7 +32,7 @@ module ActiveAdmin
32
32
  end
33
33
 
34
34
  def metasearch_conditions
35
- /is_true|is_false|is_present/
35
+ /(is_true|is_false|is_present|is_blank|is_null|is_not_null)$/
36
36
  end
37
37
 
38
38
  end
@@ -15,7 +15,11 @@ module ActiveAdmin
15
15
  end
16
16
 
17
17
  def input_name
18
- "#{super}_contains"
18
+ method.to_s.match(metasearch_conditions) ? method : "#{method}_contains"
19
+ end
20
+
21
+ def metasearch_conditions
22
+ /starts_with|ends_with/
19
23
  end
20
24
  end
21
25
  end
@@ -3,7 +3,7 @@ bg:
3
3
  dashboard: Табло
4
4
  dashboard_welcome:
5
5
  welcome: "Добре дошли в Active Admin. Това е таблото по подразбиране."
6
- call_to_action: "За да добавите секции, проверете 'app/admin/dashboards.rb'"
6
+ call_to_action: "За да добавите секции, проверете 'app/admin/dashboard.rb'"
7
7
  view: "Преглед"
8
8
  edit: "Редакция"
9
9
  delete: "Изтриване"
@@ -4,7 +4,7 @@ ca:
4
4
  dashboard: Tauler
5
5
  dashboard_welcome:
6
6
  welcome: "Benvingut a Active Admin. Aquest és el tauler per defecte."
7
- call_to_action: "Mira l'arxiu 'app/admin/dashboards.rb' per afegir seccions al tauler"
7
+ call_to_action: "Mira l'arxiu 'app/admin/dashboard.rb' per afegir seccions al tauler"
8
8
  view: "Mostra"
9
9
  edit: "Edita"
10
10
  delete: "Elimina"
@@ -3,15 +3,15 @@ cs:
3
3
  dashboard: Úvod
4
4
  dashboard_welcome:
5
5
  welcome: "Vítejte v Active Admin. Toto je nástěnka."
6
- call_to_action: "Pro přidání sekcí nástěnky se podívejte do 'app/admin/dashboards.rb'"
6
+ call_to_action: "Pro přidání sekcí nástěnky se podívejte do 'app/admin/dashboard.rb'"
7
7
  view: "Zobrazit"
8
8
  edit: "Upravit"
9
9
  delete: "Smazat"
10
10
  delete_confirmation: "Jste si jistí, že chcete tuto položku smazat?"
11
- new_model: "Nový"
12
- create_model: "Nový"
11
+ new_model: "Vytvořit"
12
+ create_model: "Vytvořit %{model}"
13
13
  edit_model: "Upravit"
14
- update_model: "Upravit"
14
+ update_model: "Upravit %{model}"
15
15
  delete_model: "Smazat"
16
16
  details: "Detaily"
17
17
  cancel: "Zrušit"
@@ -21,17 +21,17 @@ cs:
21
21
  download: "Stáhnout:"
22
22
  has_many_new: "Přidat nový"
23
23
  has_many_delete: "Odstranit"
24
- filter: "Filtr"
24
+ filter: "Filtrovat"
25
25
  clear_filters: "Vyčistit filtry"
26
- search_field: "%{field}"
26
+ search_field: "Prohledat %{field}"
27
27
  equal_to: "Přesně"
28
28
  greater_than: "Větší než"
29
29
  less_than: "Menší než"
30
30
  main_content: "Prosím implementujte %{model}#main_content pro zobrazení obsahu."
31
31
  logout: "Odhlášení"
32
- powered_by: "Powered by %{active_admin} %{version}"
32
+ powered_by: "%{active_admin} %{version}"
33
33
  sidebars:
34
- filters: "Filtr"
34
+ filters: "Filtry"
35
35
  pagination:
36
36
  empty: "Nenalezen."
37
37
  one: "Zobrazena <b>1</b> položka"
@@ -39,37 +39,39 @@ cs:
39
39
  multiple: "<b>%{from}&nbsp;-&nbsp;%{to}</b> z <b>%{total}</b>"
40
40
  entry:
41
41
  one: "položka"
42
+ few: "položky"
42
43
  other: "položky"
43
44
  any: "Kterákoliv"
44
45
  blank_slate:
45
46
  content: "Zatím zde není žádný obsah."
46
47
  link: "Vytvořit"
47
48
  batch_actions:
48
- button_label: "dávkové Akce"
49
- delete_confirmation: "Jste si jisti, že chcete odstranit tyto %{plural_model}? Nebudete moci vrátit zpět to."
49
+ button_label: "Hromadné akce"
50
+ delete_confirmation: "Jste si jisti, že chcete odstranit tyto %{plural_model}?"
50
51
  succesfully_destroyed:
51
- one: "úspěšně zničil 1 %{model}"
52
- other: "úspěšně zničil %{count} %{plural_model}"
52
+ one: "Úspěšně smazán %{model}"
53
+ few: "Úspěšně smazány %{count} %{plural_model}"
54
+ other: "Úspěšně smazáno %{count} %{plural_model}"
53
55
  selection_toggle_explanation: "(Změnit výběr)"
54
- link: "vytvořit jeden"
55
- action_label: "%{title} vybraný"
56
+ link: "Vytvořit"
57
+ action_label: "%{title}"
56
58
  labels:
57
- destroy: "vymazat"
59
+ destroy: "Vymazat"
58
60
  comments:
59
- body: "tělo"
60
- author: "autor"
61
- title: "komentář"
61
+ body: "Tělo"
62
+ author: "Autor"
63
+ title: "Komentář"
62
64
  add: "Přidat komentář"
63
- resource: "zdroj"
64
- no_comments_yet: "Žádný nový komentář"
65
- title_content: "Komentáře (%{count})"
65
+ resource: "Zdroj"
66
+ no_comments_yet: "Žádný komentář"
67
+ title_content: "Komentáře administrátorů (%{count})"
66
68
  errors:
67
69
  empty_text: "Komentář nebyl uložen, je prázdný."
68
70
  devise:
69
71
  login:
70
- title: "přihlášení"
71
- remember_me: "Zapamatuj si mě"
72
- submit: "přihlášení"
72
+ title: "Přihlášení"
73
+ remember_me: "Zapamatovat si mě"
74
+ submit: "Přihlásit"
73
75
  reset_password:
74
76
  title: "Zapomněli jste heslo?"
75
77
  submit: "Obnovit heslo"
@@ -79,4 +81,3 @@ cs:
79
81
  links:
80
82
  sign_in: "Přihlásit se"
81
83
  forgot_your_password: "Zapomněli jste heslo?"
82
-