activeadmin 1.0.0.pre4 → 1.0.0.pre5
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.
- checksums.yaml +4 -4
- data/.gitignore +3 -3
- data/.travis.yml +48 -26
- data/Appraisals +103 -0
- data/CHANGELOG.md +12 -1
- data/CONTRIBUTING.md +85 -32
- data/Gemfile +13 -38
- data/README.md +10 -26
- data/Rakefile +41 -9
- data/activeadmin.gemspec +7 -4
- data/app/assets/javascripts/active_admin/initializers/filters.js.coffee +10 -3
- data/app/assets/javascripts/active_admin/jquery_ui.js.erb +11 -4
- data/app/assets/javascripts/active_admin/lib/checkbox-toggler.js.coffee +8 -0
- data/app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee +1 -1
- data/app/assets/javascripts/active_admin/lib/per_page.js.coffee +14 -3
- data/app/assets/stylesheets/active_admin/_forms.scss +1 -0
- data/app/views/active_admin/devise/registrations/new.html.erb +1 -1
- data/codecov.yml +23 -0
- data/config/locales/es-MX.yml +1 -1
- data/config/locales/es.yml +1 -1
- data/config/locales/ru.yml +1 -0
- data/config/locales/sk.yml +110 -0
- data/docs/0-installation.md +3 -0
- data/docs/1-general-configuration.md +11 -0
- data/docs/10-custom-pages.md +25 -0
- data/docs/11-decorators.md +3 -0
- data/docs/12-arbre-components.md +3 -0
- data/docs/13-authorization-adapter.md +3 -0
- data/docs/14-gotchas.md +19 -0
- data/docs/2-resource-customization.md +21 -2
- data/docs/3-index-pages.md +21 -0
- data/docs/3-index-pages/custom-index.md +3 -0
- data/docs/3-index-pages/index-as-block.md +3 -0
- data/docs/3-index-pages/index-as-blog.md +3 -0
- data/docs/3-index-pages/index-as-grid.md +3 -0
- data/docs/3-index-pages/index-as-table.md +22 -0
- data/docs/4-csv-format.md +15 -0
- data/docs/5-forms.md +7 -3
- data/docs/6-show-pages.md +3 -0
- data/docs/7-sidebars.md +3 -0
- data/docs/8-custom-actions.md +3 -0
- data/docs/9-batch-actions.md +4 -1
- data/docs/CNAME +1 -0
- data/docs/Gemfile +2 -0
- data/docs/_config.yml +2 -0
- data/docs/_includes/footer.html +8 -0
- data/docs/_includes/google-analytics.html +16 -0
- data/docs/_includes/head.html +7 -0
- data/docs/_includes/toc.html +97 -0
- data/docs/_includes/top-menu.html +9 -0
- data/docs/_layouts/default.html +21 -0
- data/docs/documentation.md +62 -0
- data/docs/images/activeadmin.png +0 -0
- data/docs/images/code-header.png +0 -0
- data/docs/images/divider.png +0 -0
- data/docs/images/features.png +0 -0
- data/docs/index.html +130 -0
- data/docs/stylesheets/main.css +1199 -0
- data/features/action_item.feature +2 -2
- data/features/authorization_cancan.feature +3 -3
- data/features/belongs_to.feature +60 -2
- data/features/comments/commenting.feature +7 -7
- data/features/development_reloading.feature +1 -1
- data/features/edit_page.feature +9 -9
- data/features/footer.feature +28 -0
- data/features/i18n.feature +11 -0
- data/features/index/batch_actions.feature +28 -6
- data/features/index/filters.feature +31 -11
- data/features/index/format_as_csv.feature +13 -13
- data/features/index/formats.feature +4 -4
- data/features/index/index_as_block.feature +1 -1
- data/features/index/index_as_blog.feature +6 -6
- data/features/index/index_as_grid.feature +3 -3
- data/features/index/index_as_table.feature +11 -11
- data/features/index/index_blank_slate.feature +4 -4
- data/features/index/index_parameters.feature +10 -10
- data/features/index/index_scope_to.feature +3 -3
- data/features/index/index_scopes.feature +37 -18
- data/features/index/page_title.feature +3 -3
- data/features/index/pagination.feature +1 -1
- data/features/index/switch_index_view.feature +8 -8
- data/features/menu.feature +3 -3
- data/features/new_page.feature +8 -8
- data/features/registering_assets.feature +1 -1
- data/features/registering_pages.feature +73 -2
- data/features/registering_resources.feature +1 -1
- data/features/renamed_resource.feature +1 -1
- data/features/show/page_title.feature +3 -3
- data/features/sidebar_sections.feature +6 -6
- data/features/specifying_actions.feature +29 -4
- data/features/step_definitions/factory_steps.rb +1 -1
- data/features/step_definitions/footer_steps.rb +11 -0
- data/features/step_definitions/i18n_steps.rb +8 -0
- data/features/step_definitions/index_scope_steps.rb +4 -0
- data/features/step_definitions/sidebar_steps.rb +1 -3
- data/features/step_definitions/table_steps.rb +1 -5
- data/features/step_definitions/user_steps.rb +7 -0
- data/features/support/env.rb +6 -33
- data/features/support/paths.rb +5 -0
- data/features/users/logging_in.feature +2 -0
- data/gemfiles/rails_32.gemfile +54 -0
- data/gemfiles/rails_40.gemfile +53 -0
- data/gemfiles/rails_41.gemfile +53 -0
- data/gemfiles/rails_42.gemfile +53 -0
- data/gemfiles/rails_50.gemfile +46 -0
- data/lib/active_admin.rb +1 -0
- data/lib/active_admin/application.rb +11 -0
- data/lib/active_admin/batch_actions/resource_extension.rb +0 -8
- data/lib/active_admin/batch_actions/views/batch_action_form.rb +1 -1
- data/lib/active_admin/batch_actions/views/batch_action_selector.rb +1 -1
- data/lib/active_admin/dsl.rb +0 -6
- data/lib/active_admin/filters/active.rb +9 -1
- data/lib/active_admin/filters/formtastic_addons.rb +1 -1
- data/lib/active_admin/filters/humanized.rb +1 -1
- data/lib/active_admin/filters/resource_extension.rb +2 -4
- data/lib/active_admin/form_builder.rb +12 -6
- data/lib/active_admin/helpers/collection.rb +2 -0
- data/lib/active_admin/inputs.rb +1 -0
- data/lib/active_admin/inputs/filters/date_range_input.rb +9 -4
- data/lib/active_admin/inputs/filters/text_input.rb +26 -0
- data/lib/active_admin/localizers.rb +11 -0
- data/lib/active_admin/localizers/resource_localizer.rb +35 -0
- data/lib/active_admin/namespace.rb +1 -1
- data/lib/active_admin/order_clause.rb +29 -7
- data/lib/active_admin/page.rb +18 -4
- data/lib/active_admin/page_dsl.rb +4 -0
- data/lib/active_admin/resource.rb +16 -1
- data/lib/active_admin/resource/action_items.rb +7 -4
- data/lib/active_admin/resource/belongs_to.rb +4 -0
- data/lib/active_admin/resource/menu.rb +1 -1
- data/lib/active_admin/resource/ordering.rb +11 -0
- data/lib/active_admin/resource/routes.rb +34 -13
- data/lib/active_admin/resource/scopes.rb +1 -0
- data/lib/active_admin/resource_controller/data_access.rb +3 -10
- data/lib/active_admin/resource_dsl.rb +28 -1
- data/lib/active_admin/router.rb +5 -3
- data/lib/active_admin/scope.rb +3 -3
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_helpers/auto_link_helper.rb +2 -2
- data/lib/active_admin/view_helpers/display_helper.rb +8 -3
- data/lib/active_admin/view_helpers/method_or_proc_helper.rb +5 -1
- data/lib/active_admin/views/components/active_admin_form.rb +11 -10
- data/lib/active_admin/views/components/attributes_table.rb +1 -1
- data/lib/active_admin/views/components/columns.rb +3 -3
- data/lib/active_admin/views/components/dropdown_menu.rb +2 -2
- data/lib/active_admin/views/components/index_list.rb +4 -1
- data/lib/active_admin/views/components/paginated_collection.rb +1 -0
- data/lib/active_admin/views/components/scopes.rb +8 -1
- data/lib/active_admin/views/components/site_title.rb +2 -2
- data/lib/active_admin/views/components/table_for.rb +3 -3
- data/lib/active_admin/views/footer.rb +17 -3
- data/lib/active_admin/views/index_as_table.rb +3 -3
- data/lib/active_admin/views/pages/base.rb +4 -2
- data/lib/active_admin/views/pages/form.rb +2 -3
- data/lib/active_admin/views/pages/show.rb +2 -1
- data/lib/bug_report_templates/rails_5_master.rb +120 -0
- data/lib/generators/active_admin/devise/devise_generator.rb +6 -3
- data/lib/generators/active_admin/install/install_generator.rb +1 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +15 -1
- data/lib/generators/active_admin/install/templates/migrations/{create_active_admin_comments.rb → create_active_admin_comments.rb.erb} +14 -1
- data/lib/ransack_ext.rb +2 -2
- data/spec/bug_report_templates_spec.rb +27 -0
- data/spec/javascripts/support/jasmine_runner.rb +4 -17
- data/spec/rails_helper.rb +20 -109
- data/spec/requests/default_namespace_spec.rb +16 -28
- data/spec/requests/javascript_spec.rb +1 -1
- data/spec/requests/memory_spec.rb +5 -1
- data/spec/requests/stylesheets_spec.rb +1 -1
- data/spec/spec_helper.rb +5 -10
- data/spec/support/active_admin_integration_spec_helper.rb +66 -0
- data/spec/support/active_admin_request_helpers.rb +12 -0
- data/spec/support/rails_template.rb +42 -15
- data/spec/support/rails_template_with_data.rb +24 -5
- data/spec/support/templates/manifest.js +3 -0
- data/spec/support/templates/policies/application_policy.rb +1 -1
- data/spec/unit/abstract_view_factory_spec.rb +1 -1
- data/spec/unit/action_builder_spec.rb +3 -12
- data/spec/unit/active_admin_spec.rb +1 -1
- data/spec/unit/application_spec.rb +5 -1
- data/spec/unit/asset_registration_spec.rb +1 -1
- data/spec/unit/authorization/authorization_adapter_spec.rb +1 -1
- data/spec/unit/authorization/controller_authorization_spec.rb +13 -9
- data/spec/unit/authorization/index_overriding_spec.rb +6 -6
- data/spec/unit/auto_link_spec.rb +48 -24
- data/spec/unit/batch_actions/resource_spec.rb +1 -14
- data/spec/unit/batch_actions/settings_spec.rb +1 -1
- data/spec/unit/belongs_to_spec.rb +9 -1
- data/spec/unit/cancan_adapter_spec.rb +1 -1
- data/spec/unit/comments_spec.rb +26 -19
- data/spec/unit/component_spec.rb +1 -1
- data/spec/unit/config_shared_examples.rb +1 -1
- data/spec/unit/controller_filters_spec.rb +1 -1
- data/spec/unit/csv_builder_spec.rb +5 -5
- data/spec/unit/dependency_spec.rb +1 -1
- data/spec/unit/devise_spec.rb +17 -3
- data/spec/unit/dsl_spec.rb +2 -2
- data/spec/unit/filters/active_spec.rb +21 -0
- data/spec/unit/filters/filter_form_builder_spec.rb +98 -31
- data/spec/unit/filters/humanized_spec.rb +9 -1
- data/spec/unit/filters/resource_spec.rb +5 -4
- data/spec/unit/form_builder_spec.rb +180 -33
- data/spec/unit/generators/install_spec.rb +12 -5
- data/spec/unit/helpers/collection_spec.rb +10 -7
- data/spec/unit/helpers/scope_chain_spec.rb +1 -1
- data/spec/unit/helpers/settings_spec.rb +1 -1
- data/spec/unit/i18n_spec.rb +1 -1
- data/spec/unit/localizers/resource_localizer_spec.rb +36 -0
- data/spec/unit/menu_collection_spec.rb +1 -1
- data/spec/unit/menu_item_spec.rb +1 -1
- data/spec/unit/menu_spec.rb +1 -1
- data/spec/unit/namespace/authorization_spec.rb +1 -1
- data/spec/unit/namespace/register_page_spec.rb +28 -2
- data/spec/unit/namespace/register_resource_spec.rb +3 -1
- data/spec/unit/namespace_spec.rb +23 -1
- data/spec/unit/order_clause_spec.rb +7 -7
- data/spec/unit/page_controller_spec.rb +1 -1
- data/spec/unit/page_spec.rb +55 -2
- data/spec/unit/pretty_format_spec.rb +8 -7
- data/spec/unit/pundit_adapter_spec.rb +1 -1
- data/spec/unit/resource/action_items_spec.rb +1 -1
- data/spec/unit/resource/includes_spec.rb +1 -1
- data/spec/unit/resource/menu_spec.rb +1 -1
- data/spec/unit/resource/naming_spec.rb +1 -1
- data/spec/unit/resource/ordering_spec.rb +38 -0
- data/spec/unit/resource/page_presenters_spec.rb +1 -1
- data/spec/unit/resource/pagination_spec.rb +1 -1
- data/spec/unit/resource/routes_spec.rb +101 -53
- data/spec/unit/resource/scopes_spec.rb +1 -1
- data/spec/unit/resource/sidebars_spec.rb +1 -1
- data/spec/unit/resource_collection_spec.rb +1 -1
- data/spec/unit/resource_controller/data_access_spec.rb +50 -1
- data/spec/unit/resource_controller/decorators_spec.rb +2 -2
- data/spec/unit/resource_controller/sidebars_spec.rb +16 -17
- data/spec/unit/resource_controller_spec.rb +50 -56
- data/spec/unit/resource_registration_spec.rb +9 -4
- data/spec/unit/resource_spec.rb +9 -1
- data/spec/unit/routing_spec.rb +30 -2
- data/spec/unit/scope_spec.rb +26 -2
- data/spec/unit/settings_spec.rb +2 -2
- data/spec/unit/view_factory_spec.rb +1 -1
- data/spec/unit/view_helpers/breadcrumbs_spec.rb +1 -1
- data/spec/unit/view_helpers/display_helper_spec.rb +18 -3
- data/spec/unit/view_helpers/download_format_links_helper_spec.rb +1 -1
- data/spec/unit/view_helpers/fields_for_spec.rb +1 -1
- data/spec/unit/view_helpers/flash_helper_spec.rb +1 -1
- data/spec/unit/view_helpers/form_helper_spec.rb +1 -1
- data/spec/unit/view_helpers/method_or_proc_helper_spec.rb +1 -1
- data/spec/unit/views/components/attributes_table_spec.rb +1 -1
- data/spec/unit/views/components/batch_action_selector_spec.rb +1 -1
- data/spec/unit/views/components/blank_slate_spec.rb +1 -1
- data/spec/unit/views/components/columns_spec.rb +1 -1
- data/spec/unit/views/components/index_list_spec.rb +18 -4
- data/spec/unit/views/components/index_table_for_spec.rb +1 -1
- data/spec/unit/views/components/paginated_collection_spec.rb +1 -1
- data/spec/unit/views/components/panel_spec.rb +1 -1
- data/spec/unit/views/components/sidebar_section_spec.rb +1 -1
- data/spec/unit/views/components/site_title_spec.rb +1 -1
- data/spec/unit/views/components/status_tag_spec.rb +1 -1
- data/spec/unit/views/components/table_for_spec.rb +9 -7
- data/spec/unit/views/components/tabs_spec.rb +1 -1
- data/spec/unit/views/components/unsupported_browser_spec.rb +3 -3
- data/spec/unit/views/index_as_blog_spec.rb +1 -1
- data/spec/unit/views/pages/form_spec.rb +1 -1
- data/spec/unit/views/pages/index_spec.rb +1 -1
- data/spec/unit/views/pages/layout_spec.rb +1 -1
- data/spec/unit/views/pages/show_spec.rb +1 -1
- data/spec/unit/views/tabbed_navigation_spec.rb +2 -2
- data/tasks/local.rake +25 -0
- data/tasks/parallel_tests.rake +4 -4
- data/tasks/test.rake +8 -53
- metadata +61 -18
- data/Guardfile +0 -8
- data/script/local +0 -53
- data/script/travis_cache +0 -107
- data/script/use_rails +0 -53
- data/spec/javascripts/support/jasmine_config.rb +0 -23
- data/spec/support/detect_rails_version.rb +0 -34
data/lib/active_admin.rb
CHANGED
@@ -36,6 +36,7 @@ module ActiveAdmin
|
|
36
36
|
autoload :Event, 'active_admin/event'
|
37
37
|
autoload :FormBuilder, 'active_admin/form_builder'
|
38
38
|
autoload :Inputs, 'active_admin/inputs'
|
39
|
+
autoload :Localizers, 'active_admin/localizers'
|
39
40
|
autoload :Menu, 'active_admin/menu'
|
40
41
|
autoload :MenuCollection, 'active_admin/menu_collection'
|
41
42
|
autoload :MenuItem, 'active_admin/menu_item'
|
@@ -41,6 +41,9 @@ module ActiveAdmin
|
|
41
41
|
# Set the site title image displayed in the main layout (has precendence over :site_title)
|
42
42
|
inheritable_setting :site_title_image, ""
|
43
43
|
|
44
|
+
# Set the site footer text (defaults to Powered by ActiveAdmin text with version)
|
45
|
+
inheritable_setting :footer, ""
|
46
|
+
|
44
47
|
# Set a favicon
|
45
48
|
inheritable_setting :favicon, false
|
46
49
|
|
@@ -80,6 +83,9 @@ module ActiveAdmin
|
|
80
83
|
# Options that a passed to root_to.
|
81
84
|
inheritable_setting :root_to_options, {}
|
82
85
|
|
86
|
+
# Options passed to the routes, i.e. { path: '/custom' }
|
87
|
+
inheritable_setting :route_options, {}
|
88
|
+
|
83
89
|
# Display breadcrumbs
|
84
90
|
inheritable_setting :breadcrumb, true
|
85
91
|
|
@@ -101,6 +107,9 @@ module ActiveAdmin
|
|
101
107
|
# Whether to display 'Current Filters' on search screen
|
102
108
|
inheritable_setting :current_filters, true
|
103
109
|
|
110
|
+
# class to handle ordering
|
111
|
+
inheritable_setting :order_clause, ActiveAdmin::OrderClause
|
112
|
+
|
104
113
|
# Request parameters that are permitted by default
|
105
114
|
inheritable_setting :permitted_params, [
|
106
115
|
:utf8, :_method, :authenticity_token, :commit, :id
|
@@ -117,6 +126,8 @@ module ActiveAdmin
|
|
117
126
|
|
118
127
|
# Active Admin makes educated guesses when displaying objects, this is
|
119
128
|
# the list of methods it tries calling in order
|
129
|
+
# Note that Formtastic also has 'collection_label_methods' similar to this
|
130
|
+
# used by auto generated dropdowns in filter or belongs_to field of Active Admin
|
120
131
|
setting :display_name_methods, [ :display_name,
|
121
132
|
:full_name,
|
122
133
|
:name,
|
@@ -51,14 +51,6 @@ module ActiveAdmin
|
|
51
51
|
@batch_actions = {}
|
52
52
|
end
|
53
53
|
|
54
|
-
# Path to the batch action itself
|
55
|
-
def batch_action_path(params = {})
|
56
|
-
path = [route_collection_path(params), "batch_action"].join("/")
|
57
|
-
query = params.slice(:q, :scope)
|
58
|
-
query = query.permit!.to_h if query.respond_to? :permit!
|
59
|
-
[path, query.to_param].reject(&:blank?).join("?")
|
60
|
-
end
|
61
|
-
|
62
54
|
private
|
63
55
|
|
64
56
|
# @return [ActiveAdmin::BatchAction] The default "delete" action
|
@@ -15,7 +15,7 @@ module ActiveAdmin
|
|
15
15
|
# Open a form with two hidden input fields:
|
16
16
|
# batch_action => name of the specific action called
|
17
17
|
# batch_action_inputs => a JSON string of any requested confirmation values
|
18
|
-
text_node form_tag active_admin_config.
|
18
|
+
text_node form_tag active_admin_config.route_batch_action_path(params, url_options), id: options[:id]
|
19
19
|
input name: :batch_action, id: :batch_action, type: :hidden
|
20
20
|
input name: :batch_action_inputs, id: :batch_action_inputs, type: :hidden
|
21
21
|
|
@@ -15,7 +15,7 @@ module ActiveAdmin
|
|
15
15
|
end
|
16
16
|
|
17
17
|
# We don't want to wrap the action list (or any other children) in
|
18
|
-
# an
|
18
|
+
# an unnecessary div, so instead we just return the children
|
19
19
|
def to_s
|
20
20
|
children.to_s
|
21
21
|
end
|
data/lib/active_admin/dsl.rb
CHANGED
@@ -163,11 +163,5 @@ module ActiveAdmin
|
|
163
163
|
config.sidebar_sections << ActiveAdmin::SidebarSection.new(name, options, &block)
|
164
164
|
end
|
165
165
|
|
166
|
-
def decorate_with(decorator_class)
|
167
|
-
# Force storage as a string. This will help us with reloading issues.
|
168
|
-
# Assuming decorator_class.to_s will return the name of the class allows
|
169
|
-
# us to handle a string or a class.
|
170
|
-
config.decorator_class_name = "::#{ decorator_class }"
|
171
|
-
end
|
172
166
|
end
|
173
167
|
end
|
@@ -8,13 +8,21 @@ module ActiveAdmin
|
|
8
8
|
|
9
9
|
def initialize(resource_class, params)
|
10
10
|
@resource_class = resource_class
|
11
|
-
@params = params
|
11
|
+
@params = normalize_params(params)
|
12
12
|
@scope = humanize_scope
|
13
13
|
@filters = build_filters
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
+
def normalize_params(params)
|
19
|
+
if params.is_a?(HashWithIndifferentAccess)
|
20
|
+
params
|
21
|
+
else
|
22
|
+
params.to_unsafe_h
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
18
26
|
def build_filters
|
19
27
|
filters = @params[:q] || []
|
20
28
|
filters.map{ |param| Humanized.new(param) }
|
@@ -157,13 +157,11 @@ module ActiveAdmin
|
|
157
157
|
end
|
158
158
|
|
159
159
|
def add_search_status_sidebar_section
|
160
|
-
|
161
|
-
self.sidebar_sections << search_status_section
|
162
|
-
end
|
160
|
+
self.sidebar_sections << search_status_section
|
163
161
|
end
|
164
162
|
|
165
163
|
def search_status_section
|
166
|
-
ActiveAdmin::SidebarSection.new I18n.t("active_admin.search_status.headline"), only: :index, if: -> { params[:q] || params[:scope] } do
|
164
|
+
ActiveAdmin::SidebarSection.new I18n.t("active_admin.search_status.headline"), only: :index, if: -> {active_admin_config.current_filters_enabled? && (params[:q] || params[:scope]) } do
|
167
165
|
active = ActiveAdmin::Filters::Active.new(resource_class, params)
|
168
166
|
|
169
167
|
span do
|
@@ -13,6 +13,8 @@ end
|
|
13
13
|
|
14
14
|
module ActiveAdmin
|
15
15
|
class FormBuilder < ::Formtastic::FormBuilder
|
16
|
+
include MethodOrProcHelper
|
17
|
+
|
16
18
|
self.input_namespaces = [::Object, ::ActiveAdmin::Inputs, ::Formtastic::Inputs]
|
17
19
|
|
18
20
|
# TODO: remove both class finders after formtastic 4 (where it will be default)
|
@@ -53,14 +55,16 @@ module ActiveAdmin
|
|
53
55
|
end
|
54
56
|
|
55
57
|
html << template.capture do
|
56
|
-
contents = "".html_safe
|
57
58
|
form_block = proc do |has_many_form|
|
58
59
|
index = parent_child_index options[:parent] if options[:parent]
|
59
|
-
|
60
|
+
block_contents = template.capture do
|
61
|
+
block.call(has_many_form, index)
|
62
|
+
end
|
63
|
+
template.concat(block_contents)
|
60
64
|
template.concat has_many_actions(has_many_form, builder_options, "".html_safe)
|
61
65
|
end
|
62
|
-
|
63
|
-
template.
|
66
|
+
|
67
|
+
template.assigns[:has_many_block] = true
|
64
68
|
contents = without_wrapper { inputs(options, &form_block) } || "".html_safe
|
65
69
|
|
66
70
|
if builder_options[:new_record]
|
@@ -83,7 +87,10 @@ module ActiveAdmin
|
|
83
87
|
contents << template.content_tag(:li) do
|
84
88
|
template.link_to I18n.t('active_admin.has_many_remove'), "#", class: 'button has_many_remove'
|
85
89
|
end
|
86
|
-
elsif
|
90
|
+
elsif call_method_or_proc_on(has_many_form.object,
|
91
|
+
builder_options[:allow_destroy],
|
92
|
+
exec: false)
|
93
|
+
|
87
94
|
has_many_form.input(:_destroy, as: :boolean,
|
88
95
|
wrapper_html: {class: 'has_many_delete'},
|
89
96
|
label: I18n.t('active_admin.has_many_delete'))
|
@@ -136,6 +143,5 @@ module ActiveAdmin
|
|
136
143
|
html: CGI.escapeHTML(html).html_safe, placeholder: placeholder
|
137
144
|
}
|
138
145
|
end
|
139
|
-
|
140
146
|
end
|
141
147
|
end
|
@@ -4,6 +4,8 @@ module ActiveAdmin
|
|
4
4
|
# 1. removes `select` and `order` to prevent invalid SQL
|
5
5
|
# 2. correctly handles the Hash returned when `group by` is used
|
6
6
|
def collection_size(c = collection)
|
7
|
+
return c.count if c.is_a?(Array)
|
8
|
+
|
7
9
|
c = c.except :select, :order
|
8
10
|
|
9
11
|
c.group_values.present? ? c.count.count : c.count
|
data/lib/active_admin/inputs.rb
CHANGED
@@ -15,20 +15,25 @@ module ActiveAdmin
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def gt_input_name
|
18
|
-
"#{method}
|
18
|
+
column && column.type == :date ? "#{method}_gteq" : "#{method}_gteq_datetime"
|
19
19
|
end
|
20
20
|
alias :input_name :gt_input_name
|
21
21
|
|
22
22
|
def lt_input_name
|
23
|
-
"#{method}
|
23
|
+
column && column.type == :date ? "#{method}_lteq" : "#{method}_lteq_datetime"
|
24
24
|
end
|
25
25
|
|
26
26
|
def input_html_options(input_name = gt_input_name)
|
27
|
-
current_value =
|
27
|
+
current_value = begin
|
28
|
+
#cast value to date object before rendering input
|
29
|
+
@object.public_send(input_name).to_s.to_date
|
30
|
+
rescue
|
31
|
+
nil
|
32
|
+
end
|
28
33
|
{ size: 12,
|
29
34
|
class: "datepicker",
|
30
35
|
maxlength: 10,
|
31
|
-
value: current_value
|
36
|
+
value: current_value ? current_value.strftime("%Y-%m-%d") : "" }
|
32
37
|
end
|
33
38
|
end
|
34
39
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Inputs
|
3
|
+
module Filters
|
4
|
+
class TextInput < ::Formtastic::Inputs::TextInput
|
5
|
+
include Base
|
6
|
+
include Base::SearchMethodSelect
|
7
|
+
|
8
|
+
def input_html_options
|
9
|
+
{
|
10
|
+
:cols => builder.default_text_area_width,
|
11
|
+
:rows => builder.default_text_area_height
|
12
|
+
}.merge(super)
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_html
|
16
|
+
input_wrapping do
|
17
|
+
label_html <<
|
18
|
+
builder.text_area(method, input_html_options)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Localizers
|
3
|
+
class ResourceLocalizer
|
4
|
+
class << self
|
5
|
+
def from_resource(resource_config)
|
6
|
+
new(resource_config.resource_name.i18n_key, resource_config.resource_label)
|
7
|
+
end
|
8
|
+
|
9
|
+
def translate(key, options)
|
10
|
+
new(options.delete(:model_name), options.delete(:model)).translate(key, options)
|
11
|
+
end
|
12
|
+
alias_method :t, :translate
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(model_name, model = nil)
|
16
|
+
@model_name = model_name
|
17
|
+
@model = model || model_name.to_s.titleize
|
18
|
+
end
|
19
|
+
|
20
|
+
def translate(key, options = {})
|
21
|
+
scope = options.delete(:scope)
|
22
|
+
specific_key = array_to_key('resources', @model_name, scope, key)
|
23
|
+
defaults = [array_to_key(scope, key), key.to_s.titleize]
|
24
|
+
::I18n.t specific_key, options.reverse_merge(model: @model, default: defaults, scope: 'active_admin')
|
25
|
+
end
|
26
|
+
alias_method :t, :translate
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
def array_to_key(*arr)
|
31
|
+
arr.flatten.compact.join('.').to_sym
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -194,7 +194,7 @@ module ActiveAdmin
|
|
194
194
|
resources.each do |resource|
|
195
195
|
parent = (module_name || 'Object').constantize
|
196
196
|
name = resource.controller_name.split('::').last
|
197
|
-
parent.send(:remove_const, name) if parent.const_defined?
|
197
|
+
parent.send(:remove_const, name) if parent.const_defined?(name, false)
|
198
198
|
|
199
199
|
# Remove circular references
|
200
200
|
resource.controller.active_admin_config = nil
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module ActiveAdmin
|
2
2
|
class OrderClause
|
3
|
-
attr_reader :field, :order
|
3
|
+
attr_reader :field, :order, :active_admin_config
|
4
4
|
|
5
|
-
def initialize(clause)
|
5
|
+
def initialize(active_admin_config, clause)
|
6
6
|
clause =~ /^([\w\_\.]+)(->'\w+')?_(desc|asc)$/
|
7
7
|
@column = $1
|
8
8
|
@op = $2
|
9
9
|
@order = $3
|
10
|
-
|
10
|
+
@active_admin_config = active_admin_config
|
11
11
|
@field = [@column, @op].compact.join
|
12
12
|
end
|
13
13
|
|
@@ -15,12 +15,34 @@ module ActiveAdmin
|
|
15
15
|
@field.present? && @order.present?
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
[table, active_admin_config.resource_quoted_column_name(@column)].compact.join(".")
|
18
|
+
def apply(chain)
|
19
|
+
chain.reorder(sql)
|
20
|
+
end
|
22
21
|
|
22
|
+
def to_sql
|
23
23
|
[table_column, @op, ' ', @order].compact.join
|
24
24
|
end
|
25
|
+
|
26
|
+
def table
|
27
|
+
active_admin_config.resource_column_names.include?(@column) ? active_admin_config.resource_table_name : nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def table_column
|
31
|
+
(@column =~ /\./) ? @column :
|
32
|
+
[table, active_admin_config.resource_quoted_column_name(@column)].compact.join(".")
|
33
|
+
end
|
34
|
+
|
35
|
+
def sql
|
36
|
+
custom_sql || to_sql
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
def custom_sql
|
42
|
+
if active_admin_config.ordering[@column].present?
|
43
|
+
active_admin_config.ordering[@column].call(self)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
25
47
|
end
|
26
48
|
end
|
data/lib/active_admin/page.rb
CHANGED
@@ -73,10 +73,6 @@ module ActiveAdmin
|
|
73
73
|
false
|
74
74
|
end
|
75
75
|
|
76
|
-
def belongs_to?
|
77
|
-
false
|
78
|
-
end
|
79
|
-
|
80
76
|
def add_default_action_items
|
81
77
|
end
|
82
78
|
|
@@ -88,5 +84,23 @@ module ActiveAdmin
|
|
88
84
|
@page_actions = []
|
89
85
|
end
|
90
86
|
|
87
|
+
def belongs_to(target, options = {})
|
88
|
+
@belongs_to = Resource::BelongsTo.new(self, target, options)
|
89
|
+
self.navigation_menu_name = target unless @belongs_to.optional?
|
90
|
+
controller.send :belongs_to, target, options.dup
|
91
|
+
end
|
92
|
+
|
93
|
+
def belongs_to_config
|
94
|
+
@belongs_to
|
95
|
+
end
|
96
|
+
|
97
|
+
# Do we belong to another resource?
|
98
|
+
def belongs_to?
|
99
|
+
!!belongs_to_config
|
100
|
+
end
|
101
|
+
|
102
|
+
def breadcrumb
|
103
|
+
instance_variable_defined?(:@breadcrumb) ? @breadcrumb : namespace.breadcrumb
|
104
|
+
end
|
91
105
|
end
|
92
106
|
end
|
@@ -10,6 +10,7 @@ require 'active_admin/resource/includes'
|
|
10
10
|
require 'active_admin/resource/scope_to'
|
11
11
|
require 'active_admin/resource/sidebars'
|
12
12
|
require 'active_admin/resource/belongs_to'
|
13
|
+
require 'active_admin/resource/ordering'
|
13
14
|
|
14
15
|
module ActiveAdmin
|
15
16
|
|
@@ -50,6 +51,9 @@ module ActiveAdmin
|
|
50
51
|
# Set breadcrumb builder
|
51
52
|
attr_writer :breadcrumb
|
52
53
|
|
54
|
+
#Set order clause
|
55
|
+
attr_writer :order_clause
|
56
|
+
|
53
57
|
# Store a reference to the DSL so that we can dereference it during garbage collection.
|
54
58
|
attr_accessor :dsl
|
55
59
|
|
@@ -82,6 +86,7 @@ module ActiveAdmin
|
|
82
86
|
include ScopeTo
|
83
87
|
include Sidebars
|
84
88
|
include Routes
|
89
|
+
include Ordering
|
85
90
|
|
86
91
|
# The class this resource wraps. If you register the Post model, Resource#resource_class
|
87
92
|
# will point to the Post class
|
@@ -129,6 +134,12 @@ module ActiveAdmin
|
|
129
134
|
@belongs_to
|
130
135
|
end
|
131
136
|
|
137
|
+
def belongs_to_param
|
138
|
+
if belongs_to? && belongs_to_config.required?
|
139
|
+
belongs_to_config.to_param
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
132
143
|
# Do we belong to another resource?
|
133
144
|
def belongs_to?
|
134
145
|
!!belongs_to_config
|
@@ -143,9 +154,13 @@ module ActiveAdmin
|
|
143
154
|
instance_variable_defined?(:@breadcrumb) ? @breadcrumb : namespace.breadcrumb
|
144
155
|
end
|
145
156
|
|
157
|
+
def order_clause
|
158
|
+
@order_clause || namespace.order_clause
|
159
|
+
end
|
160
|
+
|
146
161
|
def find_resource(id)
|
147
162
|
resource = resource_class.public_send *method_for_find(id)
|
148
|
-
decorator_class ? decorator_class.new(resource) : resource
|
163
|
+
(decorator_class && resource) ? decorator_class.new(resource) : resource
|
149
164
|
end
|
150
165
|
|
151
166
|
private
|