activeadmin 1.0.0.pre1 → 1.0.0.pre2
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/.travis.yml +18 -16
- data/CHANGELOG.md +18 -1013
- data/Gemfile +18 -11
- data/LICENSE +0 -5
- data/README.md +0 -2
- data/activeadmin.gemspec +3 -1
- data/app/assets/javascripts/active_admin/application.js.coffee +8 -3
- data/app/assets/javascripts/active_admin/base.js.coffee +1 -6
- data/app/assets/javascripts/active_admin/jquery_ui.js.erb +11 -0
- data/app/assets/javascripts/active_admin/lib/flash.js.coffee +1 -1
- data/app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee +11 -3
- data/app/assets/javascripts/active_admin/lib/per_page.js.coffee +5 -1
- data/app/assets/stylesheets/active_admin/_base.scss +1 -4
- data/app/assets/stylesheets/active_admin/_forms.scss +13 -8
- data/app/assets/stylesheets/active_admin/components/_buttons.scss +0 -5
- data/app/assets/stylesheets/active_admin/mixins/_all.scss +0 -1
- data/app/assets/stylesheets/active_admin/mixins/_sections.scss +0 -1
- data/app/assets/stylesheets/active_admin/mixins/_typography.scss +1 -1
- data/app/assets/stylesheets/active_admin/mixins/_variables.scss +1 -1
- data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +0 -5
- data/app/views/layouts/active_admin_logged_out.html.erb +4 -0
- data/config/locales/ar.yml +14 -2
- data/config/locales/de-CH.yml +2 -0
- data/config/locales/de.yml +15 -0
- data/config/locales/en.yml +10 -2
- data/config/locales/es.yml +26 -4
- data/config/locales/fr.yml +5 -0
- data/config/locales/id.yml +135 -0
- data/config/locales/ja.yml +21 -3
- data/config/locales/ko.yml +66 -36
- data/config/locales/nl.yml +14 -1
- data/config/locales/pt-BR.yml +11 -0
- data/config/locales/ru.yml +15 -1
- data/config/locales/sv-SE.yml +45 -5
- data/config/locales/uk.yml +16 -4
- data/config/locales/zh-CN.yml +5 -0
- data/config/locales/zh-TW.yml +32 -1
- data/docs/0-installation.md +7 -1
- data/docs/1-general-configuration.md +9 -0
- data/docs/10-custom-pages.md +10 -0
- data/docs/12-arbre-components.md +1 -1
- data/docs/14-gotchas.md +2 -2
- data/docs/2-resource-customization.md +5 -3
- data/docs/3-index-pages.md +7 -0
- data/docs/3-index-pages/index-as-table.md +4 -0
- data/docs/6-show-pages.md +1 -1
- data/docs/7-sidebars.md +8 -0
- data/features/index/batch_actions.feature +21 -2
- data/features/index/pagination.feature +16 -12
- data/features/meta_tags.feature +21 -0
- data/features/registering_assets.feature +1 -2
- data/features/show/columns.feature +40 -0
- data/features/show/default_content.feature +2 -1
- data/features/step_definitions/asset_steps.rb +3 -3
- data/features/step_definitions/batch_action_steps.rb +11 -2
- data/features/step_definitions/column_steps.rb +8 -0
- data/features/step_definitions/configuration_steps.rb +2 -2
- data/features/step_definitions/factory_steps.rb +3 -2
- data/features/step_definitions/meta_tag_steps.rb +3 -0
- data/features/step_definitions/pagination_steps.rb +8 -0
- data/features/step_definitions/table_steps.rb +2 -1
- data/lib/active_admin.rb +3 -3
- data/lib/active_admin/application.rb +66 -16
- data/lib/active_admin/batch_actions.rb +0 -1
- data/lib/active_admin/batch_actions/controller.rb +2 -2
- data/lib/active_admin/batch_actions/resource_extension.rb +3 -1
- data/lib/active_admin/callbacks.rb +1 -1
- data/lib/active_admin/csv_builder.rb +2 -2
- data/lib/active_admin/dependency.rb +18 -16
- data/lib/active_admin/devise.rb +1 -1
- data/lib/active_admin/dsl.rb +1 -1
- data/lib/active_admin/event.rb +8 -17
- data/lib/active_admin/filters/active.rb +29 -0
- data/lib/active_admin/filters/forms.rb +6 -1
- data/lib/active_admin/filters/humanized.rb +68 -0
- data/lib/active_admin/filters/resource_extension.rb +48 -1
- data/lib/active_admin/form_builder.rb +4 -4
- data/lib/active_admin/generators/boilerplate.rb +37 -0
- data/lib/active_admin/helpers/routes/url_helpers.rb +1 -1
- data/lib/active_admin/inputs.rb +1 -0
- data/lib/active_admin/inputs/filters/date_picker_input.rb +13 -0
- data/lib/active_admin/inputs/filters/date_range_input.rb +1 -1
- data/lib/active_admin/menu.rb +1 -0
- data/lib/active_admin/menu_item.rb +1 -1
- data/lib/active_admin/namespace.rb +5 -5
- data/lib/active_admin/orm/active_record/comments.rb +10 -1
- data/lib/active_admin/orm/active_record/comments/comment.rb +1 -1
- data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +11 -0
- data/lib/active_admin/resource.rb +9 -3
- data/lib/active_admin/resource/action_items.rb +13 -3
- data/lib/active_admin/resource/belongs_to.rb +6 -2
- data/lib/active_admin/resource/pagination.rb +4 -0
- data/lib/active_admin/resource_collection.rb +3 -1
- data/lib/active_admin/resource_controller/data_access.rb +6 -11
- data/lib/active_admin/resource_controller/decorators.rb +1 -1
- data/lib/active_admin/resource_dsl.rb +8 -2
- data/lib/active_admin/sidebar_section.rb +4 -12
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +1 -2
- data/lib/active_admin/view_helpers.rb +0 -1
- data/lib/active_admin/view_helpers/display_helper.rb +3 -4
- data/lib/active_admin/view_helpers/method_or_proc_helper.rb +3 -3
- data/lib/active_admin/views/components/active_admin_form.rb +3 -3
- data/lib/active_admin/views/components/columns.rb +9 -4
- data/lib/active_admin/views/components/dropdown_menu.rb +0 -2
- data/lib/active_admin/views/components/paginated_collection.rb +35 -13
- data/lib/active_admin/views/components/panel.rb +1 -3
- data/lib/active_admin/views/components/sidebar_section.rb +6 -1
- data/lib/active_admin/views/components/status_tag.rb +3 -2
- data/lib/active_admin/views/components/table_for.rb +2 -1
- data/lib/active_admin/views/index_as_table.rb +2 -2
- data/lib/active_admin/views/pages/base.rb +4 -0
- data/lib/active_admin/views/pages/show.rb +1 -1
- data/lib/generators/active_admin/assets/assets_generator.rb +1 -1
- data/lib/generators/active_admin/assets/templates/{active_admin.css.scss → active_admin.scss} +0 -0
- data/lib/generators/active_admin/devise/devise_generator.rb +7 -19
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +29 -0
- data/lib/generators/active_admin/page/templates/page.rb +1 -1
- data/lib/generators/active_admin/resource/resource_generator.rb +6 -0
- data/lib/generators/active_admin/resource/templates/admin.rb +34 -13
- data/spec/rails_helper.rb +6 -2
- data/spec/requests/memory_spec.rb +1 -3
- data/spec/support/active_admin_request_helpers.rb +27 -0
- data/spec/support/detect_rails_version.rb +1 -1
- data/spec/support/rails_template.rb +7 -0
- data/spec/unit/application_spec.rb +29 -4
- data/spec/unit/batch_actions/resource_spec.rb +5 -0
- data/spec/unit/belongs_to_spec.rb +14 -0
- data/spec/unit/comments_spec.rb +24 -2
- data/spec/unit/controller_filters_spec.rb +25 -28
- data/spec/unit/dsl_spec.rb +1 -1
- data/spec/unit/filters/humanized_spec.rb +56 -0
- data/spec/unit/filters/resource_spec.rb +1 -1
- data/spec/unit/form_builder_spec.rb +71 -11
- data/spec/unit/generators/install_spec.rb +3 -2
- data/spec/unit/pretty_format_spec.rb +15 -1
- data/spec/unit/resource_collection_spec.rb +17 -0
- data/spec/unit/resource_controller_spec.rb +2 -2
- data/spec/unit/resource_registration_spec.rb +3 -3
- data/spec/unit/resource_spec.rb +53 -2
- data/spec/unit/view_factory_spec.rb +0 -2
- data/spec/unit/view_helpers/display_name_spec.rb +6 -4
- data/spec/unit/views/components/{batch_action_popover_spec.rb → batch_action_selector_spec.rb} +9 -13
- data/spec/unit/views/components/columns_spec.rb +17 -0
- data/spec/unit/views/components/paginated_collection_spec.rb +16 -2
- data/spec/unit/views/components/panel_spec.rb +1 -5
- data/spec/unit/views/components/sidebar_section_spec.rb +21 -0
- data/spec/unit/views/components/status_tag_spec.rb +15 -1
- data/spec/unit/views/components/table_for_spec.rb +45 -0
- data/tasks/parallel_tests.rake +1 -1
- data/tasks/test.rake +4 -4
- metadata +29 -30
- data/app/assets/javascripts/active_admin/lib/popover.js.coffee +0 -68
- data/app/assets/stylesheets/active_admin/components/_popovers.scss +0 -122
- data/app/assets/stylesheets/active_admin/mixins/_icons.scss +0 -20
- data/lib/active_admin/batch_actions/views/batch_action_popover.rb +0 -28
- data/lib/active_admin/iconic.rb +0 -53
- data/lib/active_admin/iconic/icons.rb +0 -142
- data/lib/active_admin/view_helpers/icon_helper.rb +0 -12
- data/lib/active_admin/views/components/action_list_popover.rb +0 -29
- data/lib/active_admin/views/components/popover.rb +0 -27
- data/spec/javascripts/coffeescripts/jquery.aa.popover-spec.js.coffee +0 -82
- data/spec/support/integration_example_group.rb +0 -31
- data/spec/unit/event_spec.rb +0 -47
- data/spec/unit/views/components/action_list_popover_spec.rb +0 -40
- data/spec/unit/views/components/popover_spec.rb +0 -33
@@ -8,7 +8,6 @@ ActiveAdmin.before_load do |app|
|
|
8
8
|
|
9
9
|
# Require all the views
|
10
10
|
require "active_admin/batch_actions/views/batch_action_form"
|
11
|
-
require "active_admin/batch_actions/views/batch_action_popover"
|
12
11
|
require "active_admin/batch_actions/views/selection_cells"
|
13
12
|
require "active_admin/batch_actions/views/batch_action_selector"
|
14
13
|
|
@@ -27,10 +27,10 @@ module ActiveAdmin
|
|
27
27
|
|
28
28
|
COLLECTION_APPLIES = [
|
29
29
|
:authorization_scope,
|
30
|
-
:collection_decorator,
|
31
30
|
:filtering,
|
32
31
|
:scoping,
|
33
|
-
:includes
|
32
|
+
:includes,
|
33
|
+
:collection_decorator
|
34
34
|
].freeze
|
35
35
|
|
36
36
|
def batch_action_collection(only = COLLECTION_APPLIES)
|
@@ -53,7 +53,9 @@ module ActiveAdmin
|
|
53
53
|
|
54
54
|
# Path to the batch action itself
|
55
55
|
def batch_action_path(params = {})
|
56
|
-
[route_collection_path(params), "batch_action"].join("/")
|
56
|
+
path = [route_collection_path(params), "batch_action"].join("/")
|
57
|
+
query = params.slice(:q, :scope).to_param
|
58
|
+
[path, query].reject(&:blank?).join("?")
|
57
59
|
end
|
58
60
|
|
59
61
|
private
|
@@ -7,7 +7,7 @@ module ActiveAdmin
|
|
7
7
|
# Simple callback system. Implements before and after callbacks for
|
8
8
|
# use within the controllers.
|
9
9
|
#
|
10
|
-
# We didn't use the ActiveSupport callbacks
|
10
|
+
# We didn't use the ActiveSupport callbacks because they do not support
|
11
11
|
# passing in any arbitrary object into the callback method (which we
|
12
12
|
# need to do)
|
13
13
|
|
@@ -6,8 +6,8 @@ module ActiveAdmin
|
|
6
6
|
# csv_builder = CSVBuilder.new
|
7
7
|
# csv_builder.column :id
|
8
8
|
# csv_builder.column("Name") { |resource| resource.full_name }
|
9
|
-
# csv_builder.column(:name,
|
10
|
-
# csv_builder.column("name",
|
9
|
+
# csv_builder.column(:name, humanize_name: false)
|
10
|
+
# csv_builder.column("name", humanize_name: false) { |resource| resource.full_name }
|
11
11
|
#
|
12
12
|
# csv_builder = CSVBuilder.new col_sep: ";"
|
13
13
|
# csv_builder = CSVBuilder.new humanize_name: false
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module ActiveAdmin
|
2
2
|
module Dependency
|
3
|
-
|
3
|
+
module Requirements
|
4
|
+
DEVISE = '~> 3.2'
|
5
|
+
end
|
4
6
|
|
5
7
|
# Provides a clean interface to check for gem dependencies at runtime.
|
6
8
|
#
|
@@ -54,38 +56,38 @@ module ActiveAdmin
|
|
54
56
|
end
|
55
57
|
|
56
58
|
class Matcher
|
59
|
+
attr_reader :name
|
60
|
+
|
57
61
|
def initialize(name)
|
58
|
-
@name
|
62
|
+
@name = name
|
63
|
+
end
|
64
|
+
|
65
|
+
def spec
|
66
|
+
@spec ||= Gem.loaded_specs[name]
|
67
|
+
end
|
68
|
+
|
69
|
+
def spec!
|
70
|
+
spec || raise(DependencyError, "To use #{name} you need to specify it in your Gemfile.")
|
59
71
|
end
|
60
72
|
|
61
73
|
def match?(*reqs)
|
62
|
-
|
74
|
+
!!spec && Gem::Requirement.create(reqs).satisfied_by?(spec.version)
|
63
75
|
end
|
64
76
|
|
65
77
|
def match!(*reqs)
|
66
|
-
unless @spec
|
67
|
-
raise DependencyError, "To use #{@name} you need to specify it in your Gemfile."
|
68
|
-
end
|
69
|
-
|
70
78
|
unless match? reqs
|
71
|
-
raise DependencyError, "You provided #{
|
79
|
+
raise DependencyError, "You provided #{spec!.name} #{spec!.version} but we need: #{reqs.join ', '}."
|
72
80
|
end
|
73
81
|
end
|
74
82
|
|
75
83
|
include Comparable
|
76
84
|
|
77
85
|
def <=>(other)
|
78
|
-
|
79
|
-
@spec.version <=> Gem::Version.create(other)
|
80
|
-
else
|
81
|
-
# you'd otherwise get an unhelpful error message:
|
82
|
-
# ArgumentError: comparison of ActiveAdmin::Dependency::Matcher with 2 failed
|
83
|
-
raise DependencyError, "To use #{@name} you need to specify it in your Gemfile."
|
84
|
-
end
|
86
|
+
spec!.version <=> Gem::Version.create(other)
|
85
87
|
end
|
86
88
|
|
87
89
|
def inspect
|
88
|
-
info =
|
90
|
+
info = spec ? "#{spec.name} #{spec.version}" : '(missing)'
|
89
91
|
"<ActiveAdmin::Dependency::Matcher for #{info}>"
|
90
92
|
end
|
91
93
|
end
|
data/lib/active_admin/devise.rb
CHANGED
data/lib/active_admin/dsl.rb
CHANGED
@@ -128,7 +128,7 @@ module ActiveAdmin
|
|
128
128
|
config.menu_item_options = options
|
129
129
|
end
|
130
130
|
|
131
|
-
# Set the name of the navigation menu to display. This is mainly used in
|
131
|
+
# Set the name of the navigation menu to display. This is mainly used in conjunction with the
|
132
132
|
# `#belongs_to` functionality.
|
133
133
|
#
|
134
134
|
# @param [Symbol] menu_name The name of the menu to display as the global navigation
|
data/lib/active_admin/event.rb
CHANGED
@@ -1,33 +1,24 @@
|
|
1
1
|
module ActiveAdmin
|
2
2
|
|
3
3
|
class EventDispatcher
|
4
|
-
def initialize
|
5
|
-
@events = {}
|
6
|
-
end
|
7
|
-
|
8
|
-
def clear_all_subscribers!
|
9
|
-
@events = {}
|
10
|
-
end
|
11
|
-
|
12
4
|
def subscribe(*event_names, &block)
|
5
|
+
Deprecation.warn "`ActiveAdmin::Event.subscribe` is deprecated, use `ActiveSupport::Notifications.subscribe`"
|
13
6
|
event_names.each do |event|
|
14
|
-
|
15
|
-
|
7
|
+
ActiveSupport::Notifications.subscribe event,
|
8
|
+
&wrap_block_for_active_support_notifications(block)
|
16
9
|
end
|
17
10
|
end
|
18
11
|
|
19
|
-
def
|
20
|
-
|
12
|
+
def dispatch(event, *args)
|
13
|
+
Deprecation.warn "`ActiveAdmin::Event.dispatch` is deprecated, use `ActiveSupport::Notifications.publish`"
|
14
|
+
ActiveSupport::Notifications.publish event, *args
|
21
15
|
end
|
22
16
|
|
23
|
-
def
|
24
|
-
|
25
|
-
subscriber.call(*args)
|
26
|
-
end
|
17
|
+
def wrap_block_for_active_support_notifications block
|
18
|
+
proc { |event, *args| block.call *args }
|
27
19
|
end
|
28
20
|
end
|
29
21
|
|
30
22
|
# ActiveAdmin::Event is set to a dispatcher
|
31
23
|
Event = EventDispatcher.new
|
32
|
-
|
33
24
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'active_admin/filters/humanized'
|
2
|
+
|
3
|
+
module ActiveAdmin
|
4
|
+
module Filters
|
5
|
+
|
6
|
+
class Active
|
7
|
+
attr_accessor :filters, :scope
|
8
|
+
|
9
|
+
def initialize(resource_class, params)
|
10
|
+
@resource_class, @params = resource_class, params
|
11
|
+
@scope = humanize_scope
|
12
|
+
@filters = build_filters
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def build_filters
|
18
|
+
@params[:q] ||= []
|
19
|
+
@params[:q].map { |param| Humanized.new(param) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def humanize_scope
|
23
|
+
scope = @params['scope']
|
24
|
+
scope ? scope.humanize : "All"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -65,13 +65,18 @@ module ActiveAdmin
|
|
65
65
|
buttons = content_tag :div, class: "buttons" do
|
66
66
|
f.submit(I18n.t('active_admin.filters.buttons.filter')) +
|
67
67
|
link_to(I18n.t('active_admin.filters.buttons.clear'), '#', class: 'clear_filters_btn') +
|
68
|
-
hidden_field_tags_for(params, except:
|
68
|
+
hidden_field_tags_for(params, except: except_hidden_fields)
|
69
69
|
end
|
70
70
|
|
71
71
|
f.template.concat buttons
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
+
private
|
76
|
+
|
77
|
+
def except_hidden_fields
|
78
|
+
[:q, :page]
|
79
|
+
end
|
75
80
|
end
|
76
81
|
|
77
82
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Filters
|
3
|
+
|
4
|
+
class Humanized
|
5
|
+
include ActiveAdmin::ViewHelpers
|
6
|
+
|
7
|
+
def initialize(param)
|
8
|
+
@body = param[0]
|
9
|
+
@value = param[1]
|
10
|
+
end
|
11
|
+
|
12
|
+
def value
|
13
|
+
@value.is_a?(::Array) ? @value.compact.join(', ') : @value
|
14
|
+
end
|
15
|
+
|
16
|
+
def body
|
17
|
+
predicate = ransack_predicate_translation
|
18
|
+
|
19
|
+
if current_predicate.nil?
|
20
|
+
predicate = @body.titleize
|
21
|
+
elsif translation_missing?(predicate)
|
22
|
+
predicate = active_admin_predicate_translation
|
23
|
+
end
|
24
|
+
|
25
|
+
"#{parse_parameter_body} #{predicate}".strip
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def parse_parameter_body
|
31
|
+
return if current_predicate.nil?
|
32
|
+
|
33
|
+
# Accounting for strings that might contain other predicates. Example:
|
34
|
+
# 'requires_approval' contains the substring 'eq'
|
35
|
+
split_string = "_#{current_predicate}"
|
36
|
+
|
37
|
+
@body.split(split_string)
|
38
|
+
.first
|
39
|
+
.gsub('_', ' ')
|
40
|
+
.strip
|
41
|
+
.titleize
|
42
|
+
.gsub('Id', 'ID')
|
43
|
+
end
|
44
|
+
|
45
|
+
def current_predicate
|
46
|
+
@current_predicate ||= predicates.detect { |p| @body.include?(p) }
|
47
|
+
end
|
48
|
+
|
49
|
+
def predicates
|
50
|
+
Ransack::Predicate.names_by_decreasing_length
|
51
|
+
end
|
52
|
+
|
53
|
+
def ransack_predicate_translation
|
54
|
+
I18n.t("ransack.predicates.#{current_predicate}")
|
55
|
+
end
|
56
|
+
|
57
|
+
def active_admin_predicate_translation
|
58
|
+
translation = I18n.t("active_admin.filters.predicates.#{current_predicate}").downcase
|
59
|
+
end
|
60
|
+
|
61
|
+
def translation_missing?(predicate)
|
62
|
+
predicate.downcase.include?('translation missing')
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'active_admin/filters/active'
|
2
|
+
|
1
3
|
module ActiveAdmin
|
2
4
|
module Filters
|
3
5
|
|
@@ -12,10 +14,11 @@ module ActiveAdmin
|
|
12
14
|
def initialize(*)
|
13
15
|
super
|
14
16
|
add_filters_sidebar_section
|
17
|
+
add_search_status_sidebar_section
|
15
18
|
end
|
16
19
|
|
17
20
|
# Returns the filters for this resource. If filters are not enabled,
|
18
|
-
# it will always return an empty
|
21
|
+
# it will always return an empty hash.
|
19
22
|
#
|
20
23
|
# @return [Hash] Filters that apply for this resource
|
21
24
|
def filters
|
@@ -29,11 +32,23 @@ module ActiveAdmin
|
|
29
32
|
@filters_enabled = bool
|
30
33
|
end
|
31
34
|
|
35
|
+
# Setter to enable/disable showing current filters on this resource.
|
36
|
+
#
|
37
|
+
# Set to `nil` to inherit the setting from the namespace
|
38
|
+
def current_filters=(bool)
|
39
|
+
@current_filters_enabled = bool
|
40
|
+
end
|
41
|
+
|
32
42
|
# @return [Boolean] If filters are enabled for this resource
|
33
43
|
def filters_enabled?
|
34
44
|
@filters_enabled.nil? ? namespace.filters : @filters_enabled
|
35
45
|
end
|
36
46
|
|
47
|
+
# @return [Boolean] If show current filters are enabled for this resource
|
48
|
+
def current_filters_enabled?
|
49
|
+
@current_filters_enabled.nil? ? namespace.current_filters : @current_filters_enabled
|
50
|
+
end
|
51
|
+
|
37
52
|
def preserve_default_filters!
|
38
53
|
@preserve_default_filters = true
|
39
54
|
end
|
@@ -137,6 +152,38 @@ module ActiveAdmin
|
|
137
152
|
end
|
138
153
|
end
|
139
154
|
|
155
|
+
def add_search_status_sidebar_section
|
156
|
+
if current_filters_enabled?
|
157
|
+
self.sidebar_sections << search_status_section
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
def search_status_section
|
162
|
+
ActiveAdmin::SidebarSection.new :search_status, only: :index, if: -> { params[:q] || params[:scope] } do
|
163
|
+
active = ActiveAdmin::Filters::Active.new(resource_class, params)
|
164
|
+
|
165
|
+
span do
|
166
|
+
h4 I18n.t("active_admin.search_status.headline"), style: 'display: inline'
|
167
|
+
b active.scope, style: "display: inline"
|
168
|
+
|
169
|
+
div style: "margin-top: 10px" do
|
170
|
+
h4 I18n.t("active_admin.search_status.current_filters"), style: 'margin-bottom: 10px'
|
171
|
+
ul do
|
172
|
+
if active.filters.blank?
|
173
|
+
li I18n.t("active_admin.search_status.no_current_filters")
|
174
|
+
else
|
175
|
+
active.filters.each do |filter|
|
176
|
+
li do
|
177
|
+
span filter.body
|
178
|
+
b filter.value
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
140
187
|
end
|
141
188
|
|
142
189
|
end
|
@@ -4,7 +4,7 @@ module Formtastic
|
|
4
4
|
module Base
|
5
5
|
def input_wrapping(&block)
|
6
6
|
html = super
|
7
|
-
template.concat(html) if template.output_buffer && template.assigns[
|
7
|
+
template.concat(html) if template.output_buffer && template.assigns[:has_many_block]
|
8
8
|
html
|
9
9
|
end
|
10
10
|
end
|
@@ -60,8 +60,8 @@ module ActiveAdmin
|
|
60
60
|
template.concat has_many_actions(has_many_form, builder_options, "".html_safe)
|
61
61
|
end
|
62
62
|
|
63
|
-
template.assign(
|
64
|
-
contents = without_wrapper { inputs(options, &form_block) }
|
63
|
+
template.assign(has_many_block: true)
|
64
|
+
contents = without_wrapper { inputs(options, &form_block) } || "".html_safe
|
65
65
|
|
66
66
|
if builder_options[:new_record]
|
67
67
|
contents << js_for_has_many(assoc, form_block, template, builder_options[:new_record], options[:class])
|
@@ -93,7 +93,7 @@ module ActiveAdmin
|
|
93
93
|
has_many_form.input builder_options[:sortable], as: :hidden
|
94
94
|
|
95
95
|
contents << template.content_tag(:li, class: 'handle') do
|
96
|
-
|
96
|
+
"MOVE"
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Generators
|
3
|
+
class Boilerplate
|
4
|
+
def initialize(class_name)
|
5
|
+
@class_name = class_name
|
6
|
+
end
|
7
|
+
|
8
|
+
def attributes
|
9
|
+
@class_name.constantize.new.attributes.keys
|
10
|
+
end
|
11
|
+
|
12
|
+
def rows
|
13
|
+
attributes.map { |a| row(a) }.join("\n")
|
14
|
+
end
|
15
|
+
|
16
|
+
def row(name)
|
17
|
+
"# row :#{name.gsub(/_id$/, '')}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def columns
|
21
|
+
attributes.map { |a| column(a) }.join("\n")
|
22
|
+
end
|
23
|
+
|
24
|
+
def column(name)
|
25
|
+
"# column :#{name.gsub(/_id$/, '')}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def filters
|
29
|
+
attributes.map { |a| filter(a) }.join("\n")
|
30
|
+
end
|
31
|
+
|
32
|
+
def filter(name)
|
33
|
+
"# filter :#{name.gsub(/_id$/, '')}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|