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.
- data/.travis.yml +8 -5
- data/CHANGELOG.md +151 -0
- data/Gemfile +16 -16
- data/LICENSE +1 -1
- data/activeadmin.gemspec +1 -0
- data/app/assets/images/active_admin/index_list_icons/block_icon.svg +10 -0
- data/app/assets/images/active_admin/index_list_icons/blog_icon.svg +4 -0
- data/app/assets/images/active_admin/index_list_icons/grid_icon.svg +13 -0
- data/app/assets/images/active_admin/index_list_icons/table_icon.svg +3 -0
- data/app/assets/javascripts/active_admin/components/jquery.aa.checkbox-toggler.js.coffee +17 -44
- data/app/assets/javascripts/active_admin/components/jquery.aa.dropdown-menu.js.coffee +2 -4
- data/app/assets/javascripts/active_admin/components/jquery.aa.popover.js.coffee +0 -3
- data/app/assets/javascripts/active_admin/components/jquery.aa.table-checkbox-toggler.js.coffee +10 -12
- data/app/assets/javascripts/active_admin/pages/application.js.coffee +13 -10
- data/app/assets/javascripts/active_admin/pages/batch_actions.js.coffee +3 -3
- data/app/assets/stylesheets/active_admin/_base.css.scss +1 -0
- data/app/assets/stylesheets/active_admin/_header.css.scss +5 -2
- data/app/assets/stylesheets/active_admin/components/_dropdown_menu.scss +2 -2
- data/app/assets/stylesheets/active_admin/components/_index_list.scss +12 -0
- data/app/assets/stylesheets/active_admin/components/_popovers.css.scss +2 -2
- data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +2 -2
- data/app/assets/stylesheets/active_admin/mixins/_buttons.css.scss +4 -4
- data/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss +5 -4
- data/app/assets/stylesheets/active_admin/mixins/_sections.css.scss +1 -1
- data/app/assets/stylesheets/active_admin/pages/_logged_out.scss +1 -1
- data/app/assets/stylesheets/active_admin/print.css.scss +2 -2
- data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +1 -1
- data/app/views/active_admin/devise/unlocks/new.html.erb +14 -12
- data/docs/1-general-configuration.md +13 -0
- data/docs/10-custom-pages.md +40 -28
- data/docs/11-decorators.md +6 -4
- data/docs/12-arbre-components.md +1 -1
- data/docs/13-authorization-adapter.md +206 -0
- data/docs/2-resource-customization.md +129 -14
- data/docs/3-index-pages.md +65 -0
- data/docs/3-index-pages/create-an-index.md +29 -0
- data/docs/3-index-pages/index-as-table.md +35 -11
- data/docs/5-forms.md +2 -2
- data/features/authorization.feature +64 -0
- data/features/authorization_cancan.feature +52 -0
- data/features/belongs_to.feature +41 -5
- data/features/index/batch_actions.feature +27 -3
- data/features/index/formats.feature +27 -0
- data/features/index/index_as_table.feature +74 -2
- data/features/index/index_parameters.feature +69 -0
- data/features/index/index_scopes.feature +7 -11
- data/features/index/page_title.feature +18 -0
- data/features/index/switch_index_view.feature +73 -0
- data/features/menu.feature +27 -0
- data/features/registering_pages.feature +21 -0
- data/features/step_definitions/additional_web_steps.rb +4 -0
- data/features/step_definitions/batch_action_steps.rb +16 -6
- data/features/step_definitions/index_scope_steps.rb +3 -3
- data/features/step_definitions/index_views_steps.rb +3 -0
- data/features/step_definitions/menu_steps.rb +4 -0
- data/features/support/env.rb +4 -0
- data/features/support/paths.rb +3 -0
- data/lib/active_admin.rb +4 -0
- data/lib/active_admin/application.rb +43 -76
- data/lib/active_admin/authorization_adapter.rb +128 -0
- data/lib/active_admin/base_controller.rb +18 -1
- data/lib/active_admin/base_controller/authorization.rb +153 -0
- data/lib/active_admin/base_controller/menu.rb +8 -3
- data/lib/active_admin/batch_actions/resource_extension.rb +8 -7
- data/lib/active_admin/batch_actions/views/batch_action_form.rb +1 -1
- data/lib/active_admin/cancan_adapter.rb +40 -0
- data/lib/active_admin/dashboards.rb +4 -5
- data/lib/active_admin/dashboards/dashboard_controller.rb +1 -1
- data/lib/active_admin/devise.rb +22 -7
- data/lib/active_admin/dsl.rb +18 -5
- data/lib/active_admin/engine.rb +1 -1
- data/lib/active_admin/filters/dsl.rb +1 -1
- data/lib/active_admin/filters/forms.rb +9 -7
- data/lib/active_admin/filters/resource_extension.rb +20 -15
- data/lib/active_admin/form_builder.rb +44 -49
- data/lib/active_admin/helpers/optional_display.rb +4 -8
- data/lib/active_admin/inputs/filter_boolean_input.rb +1 -1
- data/lib/active_admin/inputs/filter_string_input.rb +5 -1
- data/lib/active_admin/locales/bg.yml +1 -1
- data/lib/active_admin/locales/ca.yml +1 -1
- data/lib/active_admin/locales/cs.yml +26 -25
- data/lib/active_admin/locales/da.yml +1 -1
- data/lib/active_admin/locales/de.yml +1 -1
- data/lib/active_admin/locales/en.yml +11 -1
- data/lib/active_admin/locales/es.yml +16 -16
- data/lib/active_admin/locales/fr.yml +1 -1
- data/lib/active_admin/locales/he.yml +1 -1
- data/lib/active_admin/locales/hr.yml +1 -1
- data/lib/active_admin/locales/hu.yml +1 -1
- data/lib/active_admin/locales/it.yml +1 -1
- data/lib/active_admin/locales/ja.yml +4 -1
- data/lib/active_admin/locales/ko.yml +1 -1
- data/lib/active_admin/locales/lt.yml +1 -1
- data/lib/active_admin/locales/lv.yml +12 -1
- data/lib/active_admin/locales/nl.yml +2 -2
- data/lib/active_admin/locales/no-NB.yml +22 -1
- data/lib/active_admin/locales/pl.yml +1 -1
- data/lib/active_admin/locales/pt-BR.yml +1 -1
- data/lib/active_admin/locales/pt-PT.yml +81 -0
- data/lib/active_admin/locales/ro.yml +1 -1
- data/lib/active_admin/locales/ru.yml +1 -1
- data/lib/active_admin/locales/sv-SE.yml +1 -1
- data/lib/active_admin/locales/tr.yml +1 -1
- data/lib/active_admin/locales/vi.yml +1 -1
- data/lib/active_admin/locales/zh-CN.yml +1 -1
- data/lib/active_admin/locales/zh-TW.yml +1 -1
- data/lib/active_admin/menu.rb +76 -38
- data/lib/active_admin/menu_collection.rb +96 -0
- data/lib/active_admin/menu_item.rb +61 -71
- data/lib/active_admin/namespace.rb +67 -5
- data/lib/active_admin/page.rb +6 -0
- data/lib/active_admin/page_controller.rb +13 -3
- data/lib/active_admin/resource.rb +11 -20
- data/lib/active_admin/resource/action_items.rb +3 -3
- data/lib/active_admin/resource/controllers.rb +0 -17
- data/lib/active_admin/resource/menu.rb +52 -24
- data/lib/active_admin/resource/naming.rb +6 -10
- data/lib/active_admin/resource/page_presenters.rb +57 -3
- data/lib/active_admin/resource/routes.rb +46 -0
- data/lib/active_admin/resource_controller.rb +2 -17
- data/lib/active_admin/resource_controller/data_access.rb +299 -0
- data/lib/active_admin/resource_controller/decorators.rb +2 -1
- data/lib/active_admin/resource_dsl.rb +12 -14
- data/lib/active_admin/router.rb +61 -56
- data/lib/active_admin/scope.rb +28 -18
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +0 -1
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +13 -19
- data/lib/active_admin/view_helpers/fields_for.rb +2 -0
- data/lib/active_admin/view_helpers/form_helper.rb +1 -1
- data/lib/active_admin/view_helpers/method_or_proc_helper.rb +66 -11
- data/lib/active_admin/views/components/attributes_table.rb +7 -4
- data/lib/active_admin/views/components/index_list.rb +68 -0
- data/lib/active_admin/views/components/paginated_collection.rb +13 -9
- data/lib/active_admin/views/components/scopes.rb +2 -8
- data/lib/active_admin/views/components/table_for.rb +1 -1
- data/lib/active_admin/views/footer.rb +1 -1
- data/lib/active_admin/views/header.rb +3 -2
- data/lib/active_admin/views/index_as_block.rb +4 -0
- data/lib/active_admin/views/index_as_blog.rb +4 -0
- data/lib/active_admin/views/index_as_grid.rb +4 -0
- data/lib/active_admin/views/index_as_table.rb +49 -7
- data/lib/active_admin/views/pages/index.rb +19 -4
- data/lib/active_admin/views/tabbed_navigation.rb +10 -54
- data/lib/generators/active_admin/install/install_generator.rb +5 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +58 -0
- data/spec/integration/{default_namespace.rb → default_namespace_spec.rb} +0 -16
- data/spec/spec_helper.rb +3 -0
- data/spec/support/detect_rails_version.rb +10 -3
- data/spec/support/rails_template.rb +1 -1
- data/spec/support/templates/post_decorator.rb +6 -6
- data/spec/unit/application_spec.rb +5 -5
- data/spec/unit/authorization/authorization_adapter_spec.rb +61 -0
- data/spec/unit/authorization/controller_authorization_spec.rb +47 -0
- data/spec/unit/base_controller_spec.rb +0 -2
- data/spec/unit/batch_actions/resource_spec.rb +1 -1
- data/spec/unit/breadcrumbs_spec.rb +3 -3
- data/spec/unit/cancan_adapter_spec.rb +35 -0
- data/spec/unit/config_shared_examples.rb +9 -30
- data/spec/unit/devise_spec.rb +29 -0
- data/spec/unit/dsl_spec.rb +61 -0
- data/spec/unit/filters/filter_form_builder_spec.rb +58 -4
- data/spec/unit/filters/resource_spec.rb +17 -5
- data/spec/unit/form_builder_spec.rb +15 -0
- data/spec/unit/menu_collection_spec.rb +62 -0
- data/spec/unit/menu_item_spec.rb +51 -37
- data/spec/unit/menu_spec.rb +33 -29
- data/spec/unit/namespace/authorization_spec.rb +31 -0
- data/spec/unit/namespace/register_page_spec.rb +6 -28
- data/spec/unit/namespace/register_resource_spec.rb +11 -34
- data/spec/unit/namespace_spec.rb +63 -2
- data/spec/unit/page_controller_spec.rb +0 -3
- data/spec/unit/reloader_spec.rb +5 -5
- data/spec/unit/resource/menu_spec.rb +1 -13
- data/spec/unit/resource/naming_spec.rb +20 -2
- data/spec/unit/resource/page_presenters_spec.rb +14 -2
- data/spec/unit/resource_controller/{collection_spec.rb → data_access_spec.rb} +31 -13
- data/spec/unit/resource_controller_spec.rb +4 -5
- data/spec/unit/resource_spec.rb +33 -11
- data/spec/unit/routing_spec.rb +43 -0
- data/spec/unit/scope_spec.rb +13 -0
- data/spec/unit/view_factory_spec.rb +0 -1
- data/spec/unit/view_helpers/fields_for_spec.rb +4 -0
- data/spec/unit/view_helpers/form_helper_spec.rb +6 -2
- data/spec/unit/view_helpers/method_or_proc_helper_spec.rb +97 -0
- data/spec/unit/views/components/attributes_table_spec.rb +11 -0
- data/spec/unit/views/components/index_list_spec.rb +32 -0
- data/spec/unit/views/tabbed_navigation_spec.rb +42 -40
- data/tasks/test.rake +1 -1
- metadata +127 -40
- data/lib/active_admin/menu_builder.rb +0 -65
- data/lib/active_admin/resource_controller/callbacks.rb +0 -59
- data/lib/active_admin/resource_controller/collection.rb +0 -158
- data/lib/active_admin/views/utility_nav.rb +0 -41
- data/spec/unit/base_controller_shared_examples.rb +0 -25
- data/spec/unit/dsl_include_spec.rb +0 -20
data/lib/active_admin/devise.rb
CHANGED
@@ -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
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
data/lib/active_admin/dsl.rb
CHANGED
@@ -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.
|
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.
|
data/lib/active_admin/engine.rb
CHANGED
@@ -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#
|
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
|
-
|
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 |
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
-
@
|
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
|
-
#
|
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
|
-
|
13
|
-
|
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
|
-
#
|
19
|
-
#
|
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
|
23
|
-
|
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 =
|
28
|
-
|
29
|
-
|
30
|
-
form_buffers.last << template.content_tag(:li,
|
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
|
-
|
35
|
-
block_given? ? super : super
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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 <<
|
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
|
-
|
175
|
-
|
176
|
-
placeholder
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
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
|
-
|
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
|
-
|
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
|
@@ -3,7 +3,7 @@ bg:
|
|
3
3
|
dashboard: Табло
|
4
4
|
dashboard_welcome:
|
5
5
|
welcome: "Добре дошли в Active Admin. Това е таблото по подразбиране."
|
6
|
-
call_to_action: "За да добавите секции, проверете 'app/admin/
|
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/
|
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/
|
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: "
|
12
|
-
create_model: "
|
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: "
|
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: "
|
32
|
+
powered_by: "%{active_admin} %{version}"
|
33
33
|
sidebars:
|
34
|
-
filters: "
|
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} - %{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: "
|
49
|
-
delete_confirmation: "Jste si jisti, že chcete odstranit tyto %{plural_model}?
|
49
|
+
button_label: "Hromadné akce"
|
50
|
+
delete_confirmation: "Jste si jisti, že chcete odstranit tyto %{plural_model}?"
|
50
51
|
succesfully_destroyed:
|
51
|
-
one: "
|
52
|
-
|
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: "
|
55
|
-
action_label: "%{title}
|
56
|
+
link: "Vytvořit"
|
57
|
+
action_label: "%{title}"
|
56
58
|
labels:
|
57
|
-
destroy: "
|
59
|
+
destroy: "Vymazat"
|
58
60
|
comments:
|
59
|
-
body: "
|
60
|
-
author: "
|
61
|
-
title: "
|
61
|
+
body: "Tělo"
|
62
|
+
author: "Autor"
|
63
|
+
title: "Komentář"
|
62
64
|
add: "Přidat komentář"
|
63
|
-
resource: "
|
64
|
-
no_comments_yet: "Žádný
|
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: "
|
71
|
-
remember_me: "
|
72
|
-
submit: "
|
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
|
-
|