activeadmin 0.4.4 → 0.5.0.pre
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/.gitignore +3 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +50 -0
- data/CONTRIBUTING.md +2 -4
- data/Gemfile +10 -4
- data/Guardfile +0 -1
- data/LICENSE +1 -1
- data/README.rdoc +19 -8
- data/Rakefile +10 -1
- data/activeadmin.gemspec +2 -1
- data/app/assets/javascripts/active_admin/application.js +3 -9
- data/app/assets/javascripts/active_admin/base.js +1 -0
- data/app/assets/javascripts/active_admin/components/jquery.aa.checkbox-toggler.js.coffee +64 -0
- data/app/assets/javascripts/active_admin/components/jquery.aa.dropdown-menu.js.coffee +107 -0
- data/app/assets/javascripts/active_admin/components/jquery.aa.popover.js.coffee +100 -0
- data/app/assets/javascripts/active_admin/components/jquery.aa.table-checkbox-toggler.js.coffee +27 -0
- data/app/assets/javascripts/active_admin/lib/namespace.js.coffee +3 -0
- data/app/assets/javascripts/active_admin/pages/application.js.coffee +13 -0
- data/app/assets/javascripts/active_admin/pages/batch_actions.js.coffee +26 -0
- data/app/assets/stylesheets/active_admin/_base.css.scss +32 -26
- data/app/assets/stylesheets/active_admin/_forms.css.scss +12 -5
- data/app/assets/stylesheets/active_admin/_header.css.scss +1 -2
- data/app/assets/stylesheets/active_admin/_typography.css.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_batch_actions.css.scss +11 -0
- data/app/assets/stylesheets/active_admin/components/_buttons.scss +1 -2
- data/app/assets/stylesheets/active_admin/components/_dropdown_menu.scss +151 -0
- data/app/assets/stylesheets/active_admin/components/_flash_messages.css.scss +3 -3
- data/app/assets/stylesheets/active_admin/components/_popovers.css.scss +123 -0
- data/app/assets/stylesheets/active_admin/components/_status_tags.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +20 -27
- data/app/assets/stylesheets/active_admin/components/_tables.css.scss +1 -0
- data/app/assets/stylesheets/active_admin/mixins/_buttons.css.scss +38 -36
- data/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss +5 -5
- data/app/assets/stylesheets/active_admin/mixins/_icons.css.scss +7 -3
- data/app/assets/stylesheets/active_admin/mixins/_variables.css.scss +19 -17
- data/app/assets/stylesheets/active_admin/pages/_logged_out.scss +2 -2
- data/app/assets/stylesheets/active_admin/print.css.scss +290 -0
- data/app/views/active_admin/dashboard/index.html.arb +1 -1
- data/app/views/active_admin/devise/passwords/edit.html.erb +17 -14
- data/app/views/active_admin/devise/passwords/new.html.erb +4 -4
- data/app/views/active_admin/devise/sessions/new.html.erb +6 -6
- data/app/views/active_admin/devise/shared/_links.erb +6 -6
- data/app/views/active_admin/page/index.html.arb +1 -1
- data/app/views/active_admin/resource/edit.html.arb +1 -1
- data/app/views/active_admin/resource/index.csv.erb +1 -1
- data/app/views/active_admin/resource/index.html.arb +1 -1
- data/app/views/active_admin/resource/new.html.arb +1 -1
- data/app/views/active_admin/resource/show.html.arb +1 -1
- data/app/views/layouts/active_admin.html.arb +1 -1
- data/app/views/layouts/active_admin_logged_out.html.erb +2 -2
- data/cucumber.yml +1 -1
- data/docs/0-installation.md +10 -1
- data/docs/{9-custom-pages.md → 10-custom-pages.md} +0 -0
- data/docs/2-resource-customization.md +19 -1
- data/docs/3-index-pages.md +31 -0
- data/docs/4-csv-format.md +9 -0
- data/docs/6-show-screens.md +1 -1
- data/docs/9-batch-actions.md +161 -0
- data/features/dashboard.feature +31 -8
- data/features/development_reloading.feature +1 -1
- data/features/edit_page.feature +3 -3
- data/features/i18n.feature +35 -0
- data/features/index/batch_actions.feature +98 -0
- data/features/index/filters.feature +26 -0
- data/features/index/format_as_csv.feature +35 -0
- data/features/index/index_as_table.feature +30 -2
- data/features/index/index_blank_slate.feature +8 -3
- data/features/index/index_scopes.feature +130 -24
- data/features/index/page_title.feature +12 -0
- data/features/new_page.feature +3 -3
- data/features/registering_pages.feature +61 -0
- data/features/root_to.feature +17 -0
- data/features/show/default_content.feature +1 -1
- data/features/show/page_title.feature +14 -0
- data/features/sidebar_sections.feature +26 -0
- data/features/site_title.feature +1 -1
- data/features/specifying_actions.feature +7 -6
- data/features/step_definitions/action_link_steps.rb +1 -1
- data/features/step_definitions/additional_web_steps.rb +7 -1
- data/features/step_definitions/batch_action_steps.rb +94 -0
- data/features/step_definitions/configuration_steps.rb +30 -8
- data/features/step_definitions/factory_steps.rb +12 -0
- data/features/step_definitions/format_steps.rb +6 -2
- data/features/step_definitions/i18n_steps.rb +3 -0
- data/features/step_definitions/table_steps.rb +114 -0
- data/features/step_definitions/user_steps.rb +30 -4
- data/features/support/env.rb +54 -15
- data/features/support/paths.rb +2 -0
- data/features/users/logging_in.feature +1 -1
- data/features/users/logging_out.feature +2 -1
- data/features/users/resetting_password.feature +34 -0
- data/lib/active_admin.rb +46 -7
- data/lib/active_admin/application.rb +30 -15
- data/lib/active_admin/base_controller/menu.rb +3 -3
- data/lib/active_admin/batch_actions.rb +17 -0
- data/lib/active_admin/batch_actions/controller.rb +25 -0
- data/lib/active_admin/batch_actions/resource_extension.rb +126 -0
- data/lib/active_admin/batch_actions/views/batch_action_form.rb +35 -0
- data/lib/active_admin/batch_actions/views/batch_action_popover.rb +28 -0
- data/lib/active_admin/batch_actions/views/batch_action_selector.rb +63 -0
- data/lib/active_admin/batch_actions/views/selection_cells.rb +37 -0
- data/lib/active_admin/comments.rb +5 -2
- data/lib/active_admin/comments/comment.rb +4 -3
- data/lib/active_admin/comments/views/active_admin_comments.rb +5 -5
- data/lib/active_admin/component.rb +1 -18
- data/lib/active_admin/csv_builder.rb +8 -3
- data/lib/active_admin/dashboards.rb +21 -4
- data/lib/active_admin/dashboards/dashboard_controller.rb +1 -5
- data/lib/active_admin/dependency_checker.rb +1 -1
- data/lib/active_admin/dsl.rb +61 -4
- data/lib/active_admin/engine.rb +1 -1
- data/lib/active_admin/filters.rb +8 -0
- data/lib/active_admin/filters/dsl.rb +12 -0
- data/lib/active_admin/filters/forms.rb +93 -0
- data/lib/active_admin/filters/resource_extension.rb +92 -0
- data/lib/active_admin/form_builder.rb +88 -33
- data/lib/active_admin/helpers/collection.rb +23 -0
- data/lib/active_admin/helpers/optional_display.rb +1 -1
- data/lib/active_admin/inputs/filter_select_input.rb +1 -1
- data/lib/active_admin/locales/bg.yml +37 -1
- data/lib/active_admin/locales/ca.yml +36 -0
- data/lib/active_admin/locales/cs.yml +36 -0
- data/lib/active_admin/locales/da.yml +36 -0
- data/lib/active_admin/locales/de.yml +42 -0
- data/lib/active_admin/locales/en.yml +27 -2
- data/lib/active_admin/locales/es.yml +45 -4
- data/lib/active_admin/locales/fr.yml +22 -0
- data/lib/active_admin/locales/{he_il.yml → he.yml} +37 -2
- data/lib/active_admin/locales/hr.yml +49 -5
- data/lib/active_admin/locales/hu.yml +21 -0
- data/lib/active_admin/locales/it.yml +36 -1
- data/lib/active_admin/locales/ja.yml +36 -0
- data/lib/active_admin/locales/ko.yml +36 -1
- data/lib/active_admin/locales/lv.yml +28 -2
- data/lib/active_admin/locales/nl.yml +42 -1
- data/lib/active_admin/locales/no-NB.yml +15 -0
- data/lib/active_admin/locales/pl.yml +45 -1
- data/lib/active_admin/locales/pt-BR.yml +36 -1
- data/lib/active_admin/locales/ro.yml +67 -0
- data/lib/active_admin/locales/ru.yml +43 -3
- data/lib/active_admin/locales/sv-SE.yml +41 -1
- data/lib/active_admin/locales/tr.yml +80 -0
- data/lib/active_admin/locales/vi.yml +80 -0
- data/lib/active_admin/locales/{zh_cn.yml → zh-CN.yml} +42 -2
- data/lib/active_admin/locales/zh-TW.yml +36 -1
- data/lib/active_admin/menu.rb +55 -30
- data/lib/active_admin/menu_builder.rb +65 -0
- data/lib/active_admin/menu_item.rb +55 -14
- data/lib/active_admin/namespace.rb +25 -55
- data/lib/active_admin/page.rb +15 -10
- data/lib/active_admin/resource.rb +9 -0
- data/lib/active_admin/resource/action_items.rb +4 -4
- data/lib/active_admin/resource/controllers.rb +1 -1
- data/lib/active_admin/resource/menu.rb +19 -21
- data/lib/active_admin/resource/naming.rb +55 -45
- data/lib/active_admin/resource/sidebars.rb +0 -13
- data/lib/active_admin/resource_collection.rb +10 -10
- data/lib/active_admin/resource_controller.rb +5 -5
- data/lib/active_admin/resource_controller/actions.rb +2 -0
- data/lib/active_admin/resource_controller/collection.rb +13 -4
- data/lib/active_admin/resource_dsl.rb +12 -6
- data/lib/active_admin/router.rb +27 -8
- data/lib/active_admin/scope.rb +1 -0
- data/lib/active_admin/sidebar_section.rb +2 -6
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +18 -13
- data/lib/active_admin/view_helpers.rb +0 -2
- data/lib/active_admin/view_helpers/auto_link_helper.rb +2 -1
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +24 -25
- data/lib/active_admin/view_helpers/display_helper.rb +1 -1
- data/lib/active_admin/view_helpers/fields_for.rb +44 -0
- data/lib/active_admin/view_helpers/form_helper.rb +6 -0
- data/lib/active_admin/view_helpers/view_factory_helper.rb +1 -1
- data/lib/active_admin/views/components/action_list_popover.rb +29 -0
- data/lib/active_admin/views/components/attributes_table.rb +6 -2
- data/lib/active_admin/views/components/dropdown_menu.rb +73 -0
- data/lib/active_admin/views/components/paginated_collection.rb +13 -14
- data/lib/active_admin/views/components/popover.rb +27 -0
- data/lib/active_admin/views/components/scopes.rb +8 -13
- data/lib/active_admin/views/components/sidebar_section.rb +1 -1
- data/lib/active_admin/views/components/site_title.rb +55 -0
- data/lib/active_admin/views/components/status_tag.rb +4 -4
- data/lib/active_admin/views/components/table_for.rb +18 -18
- data/lib/active_admin/views/dashboard_section_renderer.rb +1 -1
- data/lib/active_admin/views/footer.rb +18 -0
- data/lib/active_admin/views/header.rb +31 -0
- data/lib/active_admin/views/index_as_block.rb +3 -0
- data/lib/active_admin/views/index_as_blog.rb +4 -0
- data/lib/active_admin/views/index_as_grid.rb +2 -0
- data/lib/active_admin/views/index_as_table.rb +19 -6
- data/lib/active_admin/views/pages/base.rb +14 -48
- data/lib/active_admin/views/pages/form.rb +3 -3
- data/lib/active_admin/views/pages/index.rb +56 -24
- data/lib/active_admin/views/pages/layout.rb +2 -2
- data/lib/active_admin/views/pages/page.rb +10 -4
- data/lib/active_admin/views/pages/show.rb +11 -8
- data/lib/active_admin/views/tabbed_navigation.rb +3 -3
- data/lib/active_admin/views/title_bar.rb +50 -0
- data/lib/active_admin/views/utility_nav.rb +41 -0
- data/lib/generators/active_admin/assets/assets_generator.rb +1 -1
- data/lib/generators/active_admin/assets/templates/3.0/active_admin.js +1 -0
- data/lib/generators/active_admin/assets/templates/3.1/active_admin.css.scss +26 -3
- data/lib/generators/active_admin/devise/devise_generator.rb +2 -2
- data/lib/generators/active_admin/install/install_generator.rb +10 -10
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +21 -1
- data/lib/generators/active_admin/install/templates/admin_user.rb.erb +20 -0
- data/lib/generators/active_admin/install/templates/dashboard.rb +33 -0
- data/lib/generators/active_admin/resource/templates/admin.rb +1 -1
- data/spec/integration/memory_spec.rb +1 -11
- data/spec/javascripts/coffeescripts/jquery.aa.checkbox-toggler-spec.js.coffee +50 -0
- data/spec/javascripts/coffeescripts/jquery.aa.popover-spec.js.coffee +82 -0
- data/spec/javascripts/coffeescripts/jquery.aa.table-checkbox-toggler-spec.js.coffee +34 -0
- data/spec/javascripts/compiled/jquery.aa.checkbox-toggler-spec.js +60 -0
- data/spec/javascripts/compiled/jquery.aa.popover-spec.js +106 -0
- data/spec/javascripts/compiled/jquery.aa.table-checkbox-toggler-spec.js +37 -0
- data/spec/javascripts/fixtures/checkboxes.html +9 -0
- data/spec/javascripts/fixtures/table_checkboxes.html +17 -0
- data/spec/javascripts/helpers/SpecHelper.js +3 -0
- data/spec/javascripts/helpers/vendor/jasmine-fixture-0.0.5.js +108 -0
- data/spec/javascripts/helpers/vendor/jasmine-jquery.js +288 -0
- data/spec/javascripts/helpers/vendor/sinon-1.2.0.js +2915 -0
- data/spec/javascripts/support/jasmine.yml +74 -0
- data/spec/javascripts/support/jasmine_config.rb +23 -0
- data/spec/javascripts/support/jasmine_runner.rb +32 -0
- data/spec/javascripts/support/jquery-ui-1.8.16.custom.min.js +34 -0
- data/spec/javascripts/support/jquery.min.js +4 -0
- data/spec/spec_helper.rb +13 -13
- data/spec/spec_helper_without_rails.rb +2 -3
- data/spec/support/detect_rails_version.rb +16 -10
- data/spec/support/rails_template.rb +13 -1
- data/spec/support/templates/admin/stores.rb +1 -0
- data/spec/support/templates/en.yml +6 -0
- data/spec/unit/action_builder_spec.rb +38 -0
- data/spec/unit/application_spec.rb +12 -16
- data/spec/unit/base_controller_shared_examples.rb +3 -6
- data/spec/unit/batch_actions/resource_spec.rb +91 -0
- data/spec/unit/batch_actions/settings_spec.rb +61 -0
- data/spec/unit/breadcrumbs_spec.rb +33 -0
- data/spec/unit/comments_spec.rb +6 -0
- data/spec/unit/config_shared_examples.rb +17 -64
- data/spec/unit/csv_builder_spec.rb +12 -2
- data/spec/unit/dashboard_controller_spec.rb +11 -5
- data/spec/unit/dsl_include_spec.rb +20 -0
- data/spec/unit/{filter_form_builder_spec.rb → filters/filter_form_builder_spec.rb} +10 -7
- data/spec/unit/filters/resource_spec.rb +60 -0
- data/spec/unit/form_builder_spec.rb +180 -28
- data/spec/unit/helpers/collection_spec.rb +65 -0
- data/spec/unit/menu_item_spec.rb +48 -53
- data/spec/unit/menu_spec.rb +46 -32
- data/spec/unit/namespace/register_page_spec.rb +0 -6
- data/spec/unit/namespace/register_resource_spec.rb +1 -8
- data/spec/unit/namespace_spec.rb +8 -2
- data/spec/unit/page_spec.rb +20 -8
- data/spec/unit/resource/naming_spec.rb +27 -26
- data/spec/unit/resource/sidebars_spec.rb +0 -7
- data/spec/unit/resource_collection_spec.rb +11 -11
- data/spec/unit/resource_controller/collection_spec.rb +23 -1
- data/spec/unit/resource_controller/sidebars_spec.rb +46 -0
- data/spec/unit/resource_controller_spec.rb +43 -0
- data/spec/unit/resource_registration_spec.rb +2 -13
- data/spec/unit/resource_spec.rb +0 -42
- data/spec/unit/routing_spec.rb +60 -14
- data/spec/unit/scope_spec.rb +7 -0
- data/spec/unit/view_factory_spec.rb +9 -6
- data/spec/unit/view_helpers/fields_for_spec.rb +41 -0
- data/spec/unit/view_helpers/form_helper_spec.rb +18 -0
- data/spec/unit/views/components/action_list_popover_spec.rb +30 -0
- data/spec/unit/views/components/attributes_table_spec.rb +32 -20
- data/spec/unit/views/components/batch_action_popover_spec.rb +33 -0
- data/spec/unit/views/components/blank_slate_spec.rb +5 -3
- data/spec/unit/views/components/columns_spec.rb +32 -22
- data/spec/unit/views/components/paginated_collection_spec.rb +54 -12
- data/spec/unit/views/components/panel_spec.rb +11 -6
- data/spec/unit/views/components/popover_spec.rb +33 -0
- data/spec/unit/views/components/sidebar_section_spec.rb +6 -6
- data/spec/unit/views/components/site_title_spec.rb +78 -0
- data/spec/unit/views/components/status_tag_spec.rb +17 -10
- data/spec/unit/views/components/table_for_spec.rb +37 -17
- data/spec/unit/views/pages/layout_spec.rb +51 -10
- data/spec/unit/views/tabbed_navigation_spec.rb +44 -23
- data/tasks/js.rake +32 -0
- data/tasks/test.rake +1 -1
- metadata +233 -200
- data/lib/active_admin/arbre.rb +0 -22
- data/lib/active_admin/arbre/builder.rb +0 -125
- data/lib/active_admin/arbre/context.rb +0 -45
- data/lib/active_admin/arbre/html/attributes.rb +0 -20
- data/lib/active_admin/arbre/html/class_list.rb +0 -24
- data/lib/active_admin/arbre/html/collection.rb +0 -27
- data/lib/active_admin/arbre/html/document.rb +0 -42
- data/lib/active_admin/arbre/html/element.rb +0 -161
- data/lib/active_admin/arbre/html/html5_elements.rb +0 -47
- data/lib/active_admin/arbre/html/tag.rb +0 -145
- data/lib/active_admin/arbre/html/text_node.rb +0 -35
- data/lib/active_admin/filter_form_builder.rb +0 -53
- data/lib/active_admin/renderer.rb +0 -87
- data/lib/active_admin/resource_controller/filters.rb +0 -58
- data/lib/active_admin/stylesheets/active_admin/mixins/_utilities.scss +0 -0
- data/lib/active_admin/view_helpers/filter_form_helper.rb +0 -36
- data/lib/active_admin/view_helpers/renderer_helper.rb +0 -29
- data/lib/active_admin/views/header_renderer.rb +0 -82
- data/lib/generators/active_admin/assets/templates/dashboards.rb +0 -36
- data/lib/generators/active_admin/install/templates/dashboards.rb +0 -44
- data/spec/unit/arbre/context_spec.rb +0 -35
- data/spec/unit/arbre/html/element_finder_methods_spec.rb +0 -110
- data/spec/unit/arbre/html/element_spec.rb +0 -236
- data/spec/unit/arbre/html/tag_attributes_spec.rb +0 -61
- data/spec/unit/arbre/html/tag_spec.rb +0 -63
- data/spec/unit/arbre/html_spec.rb +0 -228
- data/spec/unit/renderer_spec.rb +0 -126
@@ -16,13 +16,16 @@ ActiveAdmin::Resource.send :include, ActiveAdmin::Comments::ResourceHelper
|
|
16
16
|
# Add the module to the show page
|
17
17
|
ActiveAdmin.application.view_factory.show_page.send :include, ActiveAdmin::Comments::ShowPageHelper
|
18
18
|
|
19
|
-
#
|
20
|
-
ActiveAdmin
|
19
|
+
# Walk through all the loaded resources after they are loaded
|
20
|
+
ActiveAdmin.after_load do |app|
|
21
21
|
app.namespaces.values.each do |namespace|
|
22
22
|
if namespace.comments?
|
23
23
|
namespace.register ActiveAdmin::Comment, :as => "Comment" do
|
24
24
|
actions :index, :show, :create
|
25
25
|
|
26
|
+
# Ensure filters are turned on
|
27
|
+
config.filters = true
|
28
|
+
|
26
29
|
# Don't display in the menu
|
27
30
|
menu false
|
28
31
|
|
@@ -11,6 +11,8 @@ module ActiveAdmin
|
|
11
11
|
belongs_to :resource, :polymorphic => true
|
12
12
|
belongs_to :author, :polymorphic => true
|
13
13
|
|
14
|
+
attr_accessible :resource, :resource_id, :resource_type, :body, :namespace
|
15
|
+
|
14
16
|
validates_presence_of :resource
|
15
17
|
validates_presence_of :body
|
16
18
|
validates_presence_of :namespace
|
@@ -19,7 +21,7 @@ module ActiveAdmin
|
|
19
21
|
def self.resource_type(record)
|
20
22
|
record.class.base_class.name.to_s
|
21
23
|
end
|
22
|
-
|
24
|
+
|
23
25
|
def self.resource_id_cast(record)
|
24
26
|
# Postgres adapters won't compare strings to numbers (issue 34)
|
25
27
|
if resource_id_type == :string
|
@@ -31,11 +33,10 @@ module ActiveAdmin
|
|
31
33
|
|
32
34
|
def self.find_for_resource_in_namespace(resource, namespace)
|
33
35
|
where(:resource_type => resource_type(resource),
|
34
|
-
:resource_id => resource_id_cast(resource),
|
36
|
+
:resource_id => resource_id_cast(resource),
|
35
37
|
:namespace => namespace.to_s)
|
36
38
|
end
|
37
39
|
|
38
|
-
|
39
40
|
def self.resource_id_type
|
40
41
|
columns.select { |i| i.name == "resource_id" }.first.type
|
41
42
|
end
|
@@ -66,12 +66,12 @@ module ActiveAdmin
|
|
66
66
|
def build_comment_form
|
67
67
|
self << active_admin_form_for(ActiveAdmin::Comment.new, :url => comment_form_url, :html => {:class => "inline_form"}) do |form|
|
68
68
|
form.inputs do
|
69
|
-
form.input :resource_type, :value => ActiveAdmin::Comment.resource_type(@record), :as => :hidden
|
70
|
-
form.input :resource_id, :value => @record.id, :as => :hidden
|
71
|
-
form.input :body, :input_html => {:size => "80x8"}, :label => false
|
69
|
+
form.input :resource_type, :input_html => { :value => ActiveAdmin::Comment.resource_type(@record) }, :as => :hidden
|
70
|
+
form.input :resource_id, :input_html => { :value => @record.id }, :as => :hidden
|
71
|
+
form.input :body, :input_html => { :size => "80x8" }, :label => false
|
72
72
|
end
|
73
|
-
form.
|
74
|
-
form.
|
73
|
+
form.actions do
|
74
|
+
form.action :submit, :label => I18n.t('active_admin.comments.add'), :button_html => { :value => I18n.t('active_admin.comments.add') }
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -1,22 +1,5 @@
|
|
1
1
|
module ActiveAdmin
|
2
|
-
class Component < Arbre::
|
3
|
-
|
4
|
-
# By default components render a div
|
5
|
-
def tag_name
|
6
|
-
'div'
|
7
|
-
end
|
8
|
-
|
9
|
-
def initialize(*)
|
10
|
-
super
|
11
|
-
add_class default_class_name
|
12
|
-
end
|
13
|
-
|
14
|
-
protected
|
15
|
-
|
16
|
-
# By default, add a css class named after the ruby class
|
17
|
-
def default_class_name
|
18
|
-
self.class.name.demodulize.underscore
|
19
|
-
end
|
2
|
+
class Component < Arbre::Component
|
20
3
|
|
21
4
|
end
|
22
5
|
end
|
@@ -7,6 +7,10 @@ module ActiveAdmin
|
|
7
7
|
# csv_builder.column :id
|
8
8
|
# csv_builder.column("Name") { |resource| resource.full_name }
|
9
9
|
#
|
10
|
+
# csv_builder = CSVBuilder.new :separator => ";"
|
11
|
+
# csv_builder.column :id
|
12
|
+
#
|
13
|
+
#
|
10
14
|
class CSVBuilder
|
11
15
|
|
12
16
|
# Return a default CSVBuilder for a resource
|
@@ -21,10 +25,11 @@ module ActiveAdmin
|
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
24
|
-
attr_reader :columns
|
28
|
+
attr_reader :columns, :column_separator
|
25
29
|
|
26
|
-
def initialize(&block)
|
27
|
-
@columns
|
30
|
+
def initialize(options={}, &block)
|
31
|
+
@columns = []
|
32
|
+
@column_separator = options.delete(:separator)
|
28
33
|
instance_eval &block if block_given?
|
29
34
|
end
|
30
35
|
|
@@ -1,9 +1,9 @@
|
|
1
|
+
require 'active_admin/dashboards/dashboard_controller'
|
2
|
+
require 'active_admin/dashboards/section'
|
3
|
+
|
1
4
|
module ActiveAdmin
|
2
5
|
module Dashboards
|
3
6
|
|
4
|
-
autoload :DashboardController, 'active_admin/dashboards/dashboard_controller'
|
5
|
-
autoload :Section, 'active_admin/dashboards/section'
|
6
|
-
|
7
7
|
@@sections = {}
|
8
8
|
mattr_accessor :sections
|
9
9
|
|
@@ -21,9 +21,15 @@ module ActiveAdmin
|
|
21
21
|
# end
|
22
22
|
#
|
23
23
|
def build(&block)
|
24
|
+
warn "DEPRECATION WARNING: ActiveAdmin::Dashboard is deprecated and will be removed in the next version"
|
25
|
+
@built = true
|
24
26
|
module_eval(&block)
|
25
27
|
end
|
26
28
|
|
29
|
+
def built?
|
30
|
+
!!@built
|
31
|
+
end
|
32
|
+
|
27
33
|
# Add a new dashboard section to a namespace. If no namespace is given
|
28
34
|
# it will be added to the default namespace.
|
29
35
|
#
|
@@ -46,7 +52,18 @@ module ActiveAdmin
|
|
46
52
|
@@sections = {}
|
47
53
|
end
|
48
54
|
|
49
|
-
|
55
|
+
# Called from MenuBuilder to register dashboard to menu.
|
56
|
+
def add_to_menu(namespace, menu)
|
57
|
+
return unless ActiveAdmin::Dashboards.built?
|
58
|
+
|
59
|
+
dashboard_path = namespace.root? ? :dashboard_path : "#{namespace.name}_dashboard_path".to_sym
|
50
60
|
|
61
|
+
item = MenuItem.new :id => "dashboard",
|
62
|
+
:label => proc{ I18n.t("active_admin.dashboard") },
|
63
|
+
:url => dashboard_path,
|
64
|
+
:priority => 1
|
65
|
+
menu.add item
|
66
|
+
end
|
67
|
+
end
|
51
68
|
end
|
52
69
|
end
|
@@ -1,9 +1,6 @@
|
|
1
1
|
module ActiveAdmin
|
2
2
|
module Dashboards
|
3
|
-
|
4
|
-
|
5
|
-
actions :index
|
6
|
-
|
3
|
+
module DashboardController
|
7
4
|
def index
|
8
5
|
@dashboard_sections = find_sections
|
9
6
|
render 'active_admin/dashboard/index'
|
@@ -48,7 +45,6 @@ module ActiveAdmin
|
|
48
45
|
def active_admin_namespace
|
49
46
|
ActiveAdmin.application.namespace(namespace)
|
50
47
|
end
|
51
|
-
|
52
48
|
end
|
53
49
|
end
|
54
50
|
end
|
data/lib/active_admin/dsl.rb
CHANGED
@@ -7,13 +7,14 @@ module ActiveAdmin
|
|
7
7
|
#
|
8
8
|
class DSL
|
9
9
|
|
10
|
-
|
11
|
-
def run_registration_block(config, &block)
|
10
|
+
def initialize(config)
|
12
11
|
@config = config
|
13
|
-
instance_eval &block
|
14
12
|
end
|
15
13
|
|
16
|
-
|
14
|
+
# Runs the registration block inside this object
|
15
|
+
def run_registration_block(&block)
|
16
|
+
instance_eval &block if block_given?
|
17
|
+
end
|
17
18
|
|
18
19
|
# The instance of ActiveAdmin::Config that's being registered
|
19
20
|
# currently. You can use this within your registration blocks to
|
@@ -29,6 +30,32 @@ module ActiveAdmin
|
|
29
30
|
@config
|
30
31
|
end
|
31
32
|
|
33
|
+
# Include a module with this resource. The modules's `included` method
|
34
|
+
# is called with the instance of the `ActiveAdmin::DSL` passed into it.
|
35
|
+
#
|
36
|
+
# eg:
|
37
|
+
#
|
38
|
+
# module HelpSidebar
|
39
|
+
#
|
40
|
+
# def self.included(dsl)
|
41
|
+
# dsl.sidebar "Help" do
|
42
|
+
# "Call us for Help"
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# ActiveAdmin.register Post do
|
49
|
+
# include HelpSidebar
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# @param [Module] mod A module to include
|
53
|
+
#
|
54
|
+
# @returns [Nil]
|
55
|
+
def include(mod)
|
56
|
+
mod.included(self)
|
57
|
+
end
|
58
|
+
|
32
59
|
# Returns the controller for this resource. If you pass a
|
33
60
|
# block, it will be eval'd in the controller
|
34
61
|
#
|
@@ -59,6 +86,36 @@ module ActiveAdmin
|
|
59
86
|
def action_item(options = {}, &block)
|
60
87
|
config.add_action_item(options, &block)
|
61
88
|
end
|
89
|
+
|
90
|
+
# Add a new batch action item to the resource
|
91
|
+
# Provide a symbol/string to register the action, options, & block to execute on request
|
92
|
+
#
|
93
|
+
# To unregister an existing action, just provide the symbol & pass false as the second param
|
94
|
+
#
|
95
|
+
# @param [Symbol or String] title
|
96
|
+
# @param [Hash] options valid keys include:
|
97
|
+
# => :if is a proc that will be called to determine if the BatchAction should be displayed
|
98
|
+
# => :sort_order is used to sort the batch actions ascending
|
99
|
+
# => :confirm is a string which the user will have to accept in order to process the action
|
100
|
+
#
|
101
|
+
def batch_action(title, options = {}, &block)
|
102
|
+
|
103
|
+
# Create symbol & title information
|
104
|
+
if title.is_a?( String )
|
105
|
+
sym = title.titleize.gsub(' ', '').underscore.to_sym
|
106
|
+
else
|
107
|
+
sym = title
|
108
|
+
title = sym.to_s.titleize
|
109
|
+
end
|
110
|
+
|
111
|
+
# Either add/remove the batch action
|
112
|
+
unless options == false
|
113
|
+
config.add_batch_action( sym, title, options, &block )
|
114
|
+
else
|
115
|
+
config.remove_batch_action sym
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
62
119
|
|
63
120
|
def menu(options = {})
|
64
121
|
config.menu(options)
|
data/lib/active_admin/engine.rb
CHANGED
@@ -2,7 +2,7 @@ module ActiveAdmin
|
|
2
2
|
class Engine < Rails::Engine
|
3
3
|
if Rails.version > "3.1"
|
4
4
|
initializer "ActiveAdmin precompile hook" do |app|
|
5
|
-
app.config.assets.precompile +=
|
5
|
+
app.config.assets.precompile += %w(active_admin.js active_admin.css active_admin/print.css)
|
6
6
|
end
|
7
7
|
end
|
8
8
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'active_admin/filters/dsl'
|
2
|
+
require "active_admin/filters/resource_extension"
|
3
|
+
require 'active_admin/filters/forms'
|
4
|
+
|
5
|
+
# Add our Extensions
|
6
|
+
ActiveAdmin::ResourceDSL.send :include, ActiveAdmin::Filters::DSL
|
7
|
+
ActiveAdmin::Resource.send :include, ActiveAdmin::Filters::ResourceExtension
|
8
|
+
ActiveAdmin::ViewHelpers.send :include, ActiveAdmin::Filters::ViewHelper
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Filters
|
3
|
+
|
4
|
+
# This form builder defines methods to build filter forms such
|
5
|
+
# as the one found in the sidebar of the index page of a standard resource.
|
6
|
+
class FormBuilder < ::ActiveAdmin::FormBuilder
|
7
|
+
|
8
|
+
def filter(method, options = {})
|
9
|
+
return "" if method.blank?
|
10
|
+
options[:as] ||= default_input_type(method)
|
11
|
+
return "" unless options[:as]
|
12
|
+
content = input(method, options)
|
13
|
+
form_buffers.last << content.html_safe if content
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
# Returns the default filter type for a given attribute
|
19
|
+
def default_input_type(method, options = {})
|
20
|
+
if (column = column_for(method))
|
21
|
+
case column.type
|
22
|
+
when :date, :datetime
|
23
|
+
return :date_range
|
24
|
+
when :string, :text
|
25
|
+
return :string
|
26
|
+
when :integer
|
27
|
+
return :select if reflection_for(method.to_s.gsub('_id','').to_sym)
|
28
|
+
return :numeric
|
29
|
+
when :float, :decimal
|
30
|
+
return :numeric
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
if (reflection = reflection_for(method))
|
35
|
+
return :select if reflection.macro == :belongs_to && !reflection.options[:polymorphic]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def custom_input_class_name(as)
|
40
|
+
"Filter#{as.to_s.camelize}Input"
|
41
|
+
end
|
42
|
+
|
43
|
+
def active_admin_input_class_name(as)
|
44
|
+
"ActiveAdmin::Inputs::Filter#{as.to_s.camelize}Input"
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns the column for an attribute on the object being searched
|
48
|
+
# if it exists. Otherwise returns nil
|
49
|
+
def column_for(method)
|
50
|
+
@object.base.columns_hash[method.to_s] if @object.base.respond_to?(:columns_hash)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Returns the association reflection for the method if it exists
|
54
|
+
def reflection_for(method)
|
55
|
+
@object.base.reflect_on_association(method) if @object.base.respond_to?(:reflect_on_association)
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
# This module is included into the view
|
62
|
+
module ViewHelper
|
63
|
+
|
64
|
+
# Helper method to render a filter form
|
65
|
+
def active_admin_filters_form_for(search, filters, options = {})
|
66
|
+
options[:builder] ||= ActiveAdmin::Filters::FormBuilder
|
67
|
+
options[:url] ||= collection_path
|
68
|
+
options[:html] ||= {}
|
69
|
+
options[:html][:method] = :get
|
70
|
+
options[:html][:class] ||= "filter_form"
|
71
|
+
options[:as] = :q
|
72
|
+
clear_link = link_to(I18n.t('active_admin.clear_filters'), "#", :class => "clear_filters_btn")
|
73
|
+
form_for search, options do |f|
|
74
|
+
filters.each do |filter_options|
|
75
|
+
filter_options = filter_options.dup
|
76
|
+
attribute = filter_options.delete(:attribute)
|
77
|
+
f.filter attribute, filter_options
|
78
|
+
end
|
79
|
+
|
80
|
+
buttons = content_tag :div, :class => "buttons" do
|
81
|
+
f.submit(I18n.t('active_admin.filter')) +
|
82
|
+
clear_link +
|
83
|
+
hidden_field_tags_for(params, :except => [:q, :page])
|
84
|
+
end
|
85
|
+
|
86
|
+
f.form_buffers.last + buttons
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Filters
|
3
|
+
|
4
|
+
module ResourceExtension
|
5
|
+
|
6
|
+
def initialize(*)
|
7
|
+
super
|
8
|
+
add_filters_sidebar_section
|
9
|
+
end
|
10
|
+
|
11
|
+
# Returns the filters for this resource. If filters are not enabled,
|
12
|
+
# it will always return an empty array.
|
13
|
+
#
|
14
|
+
# @return [Array] Filters that apply for this resource
|
15
|
+
def filters
|
16
|
+
return [] unless filters_enabled?
|
17
|
+
|
18
|
+
@filters || default_filters
|
19
|
+
end
|
20
|
+
|
21
|
+
# Setter to enable / disable filters on this resource.
|
22
|
+
#
|
23
|
+
# Set to `nil` to inherit the setting from the namespace
|
24
|
+
def filters=(bool)
|
25
|
+
@filters_enabled = bool
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [Boolean] If filters are enabled for this resource
|
29
|
+
def filters_enabled?
|
30
|
+
@filters_enabled.nil? ? namespace.filters : @filters_enabled
|
31
|
+
end
|
32
|
+
|
33
|
+
# Add a filter for this resource. If filters are not enabled, this method
|
34
|
+
# will raise a RuntimeError
|
35
|
+
#
|
36
|
+
# @param [Symbol] attribute The attribute to filter on
|
37
|
+
# @param [Hash] options The set of options that are passed through to
|
38
|
+
# metasearch for the field definition.
|
39
|
+
def add_filter(attribute, options = {})
|
40
|
+
unless filters_enabled?
|
41
|
+
raise RuntimeError, "Can't add a filter when filters are disabled. Enable filters with 'config.filters = true'"
|
42
|
+
end
|
43
|
+
|
44
|
+
@filters ||= []
|
45
|
+
|
46
|
+
@filters << options.merge({ :attribute => attribute })
|
47
|
+
end
|
48
|
+
|
49
|
+
# Reset the filters to use defaults
|
50
|
+
def reset_filters!
|
51
|
+
@filters = nil
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
# @return [Array] The array of default for filters for this resource
|
57
|
+
def default_filters
|
58
|
+
default_association_filters + default_content_filters
|
59
|
+
end
|
60
|
+
|
61
|
+
# Returns a default set of filters for the associations
|
62
|
+
def default_association_filters
|
63
|
+
if resource_class.respond_to?(:reflections)
|
64
|
+
resource_class.reflections.collect{|name, r| { :attribute => name }}
|
65
|
+
else
|
66
|
+
[]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Returns a default set of filters for the content columns
|
71
|
+
def default_content_filters
|
72
|
+
if resource_class.respond_to?(:content_columns)
|
73
|
+
resource_class.content_columns.collect{|c| { :attribute => c.name.to_sym } }
|
74
|
+
else
|
75
|
+
[]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def add_filters_sidebar_section
|
80
|
+
self.sidebar_sections << filters_sidebar_section
|
81
|
+
end
|
82
|
+
|
83
|
+
def filters_sidebar_section
|
84
|
+
ActiveAdmin::SidebarSection.new(:filters, :only => :index, :if => proc{ active_admin_config.filters.any? } ) do
|
85
|
+
active_admin_filters_form_for assigns[:search], active_admin_config.filters
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|