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
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'active_admin/helpers/collection'
|
2
|
+
|
1
3
|
module ActiveAdmin
|
2
4
|
module Views
|
3
5
|
|
@@ -81,38 +83,35 @@ module ActiveAdmin
|
|
81
83
|
link_to format.to_s.upcase, { :format => format}.merge(request.query_parameters.except(:commit, :format))
|
82
84
|
end
|
83
85
|
div :class => "download_links" do
|
84
|
-
|
86
|
+
text_node [I18n.t('active_admin.download'), links].flatten.join(" ").html_safe
|
85
87
|
end
|
86
88
|
end
|
87
89
|
|
90
|
+
include ::ActiveAdmin::Helpers::Collection
|
91
|
+
|
88
92
|
# modified from will_paginate
|
89
93
|
def page_entries_info(options = {})
|
90
94
|
if options[:entry_name]
|
91
95
|
entry_name = options[:entry_name]
|
92
|
-
entries_name = options[:entries_name]
|
93
|
-
elsif
|
96
|
+
entries_name = options[:entries_name] || entry_name.pluralize
|
97
|
+
elsif collection_is_empty?
|
94
98
|
entry_name = I18n.translate("active_admin.pagination.entry", :count => 1, :default => 'entry')
|
95
99
|
entries_name = I18n.translate("active_admin.pagination.entry", :count => 2, :default => 'entries')
|
96
100
|
else
|
97
|
-
|
98
|
-
|
99
|
-
entries_name = I18n.translate!("activerecord.models.#{collection.first.class.model_name.i18n_key}", :count => collection.size)
|
100
|
-
rescue I18n::MissingTranslationData
|
101
|
-
entry_name = collection.first.class.name.underscore.sub('_', ' ')
|
102
|
-
end
|
101
|
+
entry_name = I18n.translate("activerecord.models.#{collection.first.class.model_name.i18n_key}", :count => 1, :default => collection.first.class.name.underscore.sub('_', ' '))
|
102
|
+
entries_name = I18n.translate("activerecord.models.#{collection.first.class.model_name.i18n_key}", :count => collection.size, :default => entry_name.pluralize)
|
103
103
|
end
|
104
|
-
entries_name = entry_name.pluralize unless entries_name
|
105
104
|
|
106
105
|
if collection.num_pages < 2
|
107
|
-
case
|
106
|
+
case collection_size
|
108
107
|
when 0; I18n.t('active_admin.pagination.empty', :model => entries_name)
|
109
108
|
when 1; I18n.t('active_admin.pagination.one', :model => entry_name)
|
110
109
|
else; I18n.t('active_admin.pagination.one_page', :model => entries_name, :n => collection.total_count)
|
111
110
|
end
|
112
111
|
else
|
113
|
-
offset = collection.current_page * collection.
|
114
|
-
total
|
115
|
-
I18n.t('active_admin.pagination.multiple', :model => entries_name, :from =>
|
112
|
+
offset = (collection.current_page - 1) * collection.limit_value
|
113
|
+
total = collection.total_count
|
114
|
+
I18n.t('active_admin.pagination.multiple', :model => entries_name, :from => offset + 1, :to => offset + collection_size, :total => total)
|
116
115
|
end
|
117
116
|
end
|
118
117
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Views
|
3
|
+
|
4
|
+
class Popover < ActiveAdmin::Component
|
5
|
+
builder_method :popover
|
6
|
+
|
7
|
+
def build(options = {}, &block)
|
8
|
+
options = options.dup
|
9
|
+
contents_root_tag = options.delete(:contents_root_tag) || :div
|
10
|
+
options[:style] = "display: none"
|
11
|
+
|
12
|
+
super(options)
|
13
|
+
|
14
|
+
@contents_root = send(contents_root_tag, :class => "popover_contents")
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_child(child)
|
18
|
+
if @contents_root
|
19
|
+
@contents_root << child
|
20
|
+
else
|
21
|
+
super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'active_admin/helpers/collection'
|
2
|
+
|
1
3
|
module ActiveAdmin
|
2
4
|
module Views
|
3
5
|
|
@@ -7,6 +9,8 @@ module ActiveAdmin
|
|
7
9
|
builder_method :scopes_renderer
|
8
10
|
|
9
11
|
include ActiveAdmin::ScopeChain
|
12
|
+
include ::ActiveAdmin::Helpers::Collection
|
13
|
+
|
10
14
|
|
11
15
|
def default_class_name
|
12
16
|
"scopes table_tools_segmented_control"
|
@@ -28,16 +32,12 @@ module ActiveAdmin
|
|
28
32
|
|
29
33
|
def build_scope(scope, options)
|
30
34
|
li :class => classes_for_scope(scope) do
|
31
|
-
|
32
|
-
scope_name = I18n.t!("active_admin.scopes.#{scope.id}")
|
33
|
-
rescue I18n::MissingTranslationData
|
34
|
-
scope_name = scope.name
|
35
|
-
end
|
35
|
+
scope_name = I18n.t("active_admin.scopes.#{scope.id}", :default => scope.name)
|
36
36
|
|
37
37
|
a :href => url_for(params.merge(:scope => scope.id, :page => 1)), :class => "table_tools_button" do
|
38
38
|
text_node scope_name
|
39
39
|
span :class => 'count' do
|
40
|
-
"(
|
40
|
+
"(#{get_scope_count(scope)})"
|
41
41
|
end if options[:scope_count] && scope.show_count
|
42
42
|
end
|
43
43
|
end
|
@@ -58,18 +58,13 @@ module ActiveAdmin
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def current_filter_search_empty?
|
61
|
-
|
61
|
+
params.include?(:q) && collection_is_empty?
|
62
62
|
end
|
63
63
|
|
64
64
|
# Return the count for the scope passed in.
|
65
65
|
def get_scope_count(scope)
|
66
|
-
scope_chain(scope,
|
66
|
+
collection_size(scope_chain(scope, collection_before_scope))
|
67
67
|
end
|
68
|
-
|
69
|
-
def scoping_class
|
70
|
-
assigns["before_scope_collection"] || active_admin_config.resource_class
|
71
|
-
end
|
72
|
-
|
73
68
|
end
|
74
69
|
end
|
75
70
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Views
|
3
|
+
|
4
|
+
class SiteTitle < Component
|
5
|
+
|
6
|
+
def tag_name
|
7
|
+
'h1'
|
8
|
+
end
|
9
|
+
|
10
|
+
def build(namespace)
|
11
|
+
super(:id => "site_title")
|
12
|
+
@namespace = namespace
|
13
|
+
|
14
|
+
if site_title_link?
|
15
|
+
text_node site_title_with_link
|
16
|
+
else
|
17
|
+
text_node site_title_content
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def site_title_link?
|
22
|
+
@namespace.site_title_link.present?
|
23
|
+
end
|
24
|
+
|
25
|
+
def site_title_image?
|
26
|
+
@namespace.site_title_image.present?
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def site_title_with_link
|
32
|
+
helpers.link_to(site_title_content, @namespace.site_title_link)
|
33
|
+
end
|
34
|
+
|
35
|
+
def site_title_content
|
36
|
+
if site_title_image?
|
37
|
+
title_image
|
38
|
+
else
|
39
|
+
title_text
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def title_text
|
44
|
+
helpers.render_or_call_method_or_proc_on(self, @namespace.site_title)
|
45
|
+
end
|
46
|
+
|
47
|
+
def title_image
|
48
|
+
path = helpers.render_or_call_method_or_proc_on(self, @namespace.site_title_image)
|
49
|
+
helpers.image_tag(path, :id => "site_title_image", :alt => @namespace.site_title)
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -9,7 +9,7 @@ module ActiveAdmin
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def default_class_name
|
12
|
-
'
|
12
|
+
'status_tag'
|
13
13
|
end
|
14
14
|
|
15
15
|
# @method status_tag(status, type = nil, options = {})
|
@@ -22,13 +22,13 @@ module ActiveAdmin
|
|
22
22
|
#
|
23
23
|
# Examples:
|
24
24
|
# status_tag('In Progress')
|
25
|
-
# # => <span class='
|
25
|
+
# # => <span class='status_tag in_progress'>In Progress</span>
|
26
26
|
#
|
27
27
|
# status_tag('active', :ok)
|
28
|
-
# # => <span class='
|
28
|
+
# # => <span class='status_tag active ok'>Active</span>
|
29
29
|
#
|
30
30
|
# status_tag('active', :ok, :class => 'important', :id => 'status_123', :label => 'on')
|
31
|
-
# # => <span class='
|
31
|
+
# # => <span class='status_tag active ok important' id='status_123'>on</span>
|
32
32
|
#
|
33
33
|
def build(*args)
|
34
34
|
options = args.extract_options!
|
@@ -17,11 +17,11 @@ module ActiveAdmin
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def column(*args, &block)
|
20
|
-
options = default_options.merge(args.
|
20
|
+
options = default_options.merge(args.extract_options!)
|
21
21
|
title = args[0]
|
22
22
|
data = args[1] || args[0]
|
23
23
|
|
24
|
-
col = Column.new(title, data, options, &block)
|
24
|
+
col = Column.new(title, data, @resource_class, options, &block)
|
25
25
|
@columns << col
|
26
26
|
|
27
27
|
# Build our header item
|
@@ -72,9 +72,9 @@ module ActiveAdmin
|
|
72
72
|
if current_sort[0] == sort_key
|
73
73
|
classes << "sorted-#{current_sort[1]}"
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
header_class = title.downcase.underscore
|
77
|
-
|
77
|
+
|
78
78
|
classes << header_class
|
79
79
|
|
80
80
|
th :class => classes do
|
@@ -131,17 +131,23 @@ module ActiveAdmin
|
|
131
131
|
attr_accessor :title, :data
|
132
132
|
|
133
133
|
def initialize(*args, &block)
|
134
|
-
@options =
|
134
|
+
@options = args.extract_options!
|
135
|
+
|
135
136
|
@title = pretty_title args[0]
|
136
137
|
@data = args[1] || args[0]
|
137
138
|
@data = block if block
|
139
|
+
@resource_class = args[2]
|
138
140
|
end
|
139
141
|
|
140
142
|
def sortable?
|
141
143
|
if @data.is_a?(Proc)
|
142
144
|
[String, Symbol].include?(@options[:sortable].class)
|
143
|
-
|
145
|
+
elsif @options.has_key?(:sortable)
|
144
146
|
@options[:sortable]
|
147
|
+
elsif @data.respond_to?(:to_sym) && @resource_class
|
148
|
+
!@resource_class.reflect_on_association(@data.to_sym)
|
149
|
+
else
|
150
|
+
true
|
145
151
|
end
|
146
152
|
end
|
147
153
|
|
@@ -164,7 +170,8 @@ module ActiveAdmin
|
|
164
170
|
# # => Sort key will be 'login'
|
165
171
|
#
|
166
172
|
def sort_key
|
167
|
-
|
173
|
+
# If boolean or nil, use the default sort key.
|
174
|
+
if @options[:sortable] == true || @options[:sortable] == false || @options[:sortable].nil?
|
168
175
|
@data.to_s
|
169
176
|
else
|
170
177
|
@options[:sortable].to_s
|
@@ -175,22 +182,15 @@ module ActiveAdmin
|
|
175
182
|
|
176
183
|
def pretty_title(raw)
|
177
184
|
if raw.is_a?(Symbol)
|
178
|
-
if @options[:i18n] && @options[:i18n].respond_to?(:human_attribute_name)
|
179
|
-
raw =
|
185
|
+
if @options[:i18n] && @options[:i18n].respond_to?(:human_attribute_name)
|
186
|
+
raw = @options[:i18n].human_attribute_name(raw, :default => raw.to_s.titleize)
|
187
|
+
else
|
188
|
+
raw.to_s.titleize
|
180
189
|
end
|
181
|
-
|
182
|
-
raw.to_s.titleize
|
183
190
|
else
|
184
191
|
raw
|
185
192
|
end
|
186
193
|
end
|
187
|
-
|
188
|
-
def default_options
|
189
|
-
{
|
190
|
-
:sortable => true
|
191
|
-
}
|
192
|
-
end
|
193
|
-
|
194
194
|
end
|
195
195
|
end
|
196
196
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Views
|
3
|
+
class Footer < Component
|
4
|
+
|
5
|
+
def build
|
6
|
+
super :id => "footer"
|
7
|
+
powered_by_message
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def powered_by_message
|
13
|
+
para "Powered by #{link_to("Active Admin", "http://www.activeadmin.info")} #{ActiveAdmin::VERSION}".html_safe
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Views
|
3
|
+
class Header < Component
|
4
|
+
|
5
|
+
def build(namespace, menu)
|
6
|
+
super(:id => "header")
|
7
|
+
|
8
|
+
@namespace = namespace
|
9
|
+
@menu = menu
|
10
|
+
|
11
|
+
build_site_title
|
12
|
+
build_global_navigation
|
13
|
+
build_utility_navigation
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
def build_site_title
|
18
|
+
insert_tag view_factory.site_title, @namespace
|
19
|
+
end
|
20
|
+
|
21
|
+
def build_global_navigation
|
22
|
+
insert_tag view_factory.global_navigation, @menu, :class => 'header-item'
|
23
|
+
end
|
24
|
+
|
25
|
+
def build_utility_navigation
|
26
|
+
insert_tag view_factory.utility_navigation, @namespace
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -9,6 +9,7 @@ module ActiveAdmin
|
|
9
9
|
#
|
10
10
|
# index :as => :block do |product|
|
11
11
|
# div :for => product do
|
12
|
+
# resource_selection_cell product
|
12
13
|
# h2 auto_link(product.title)
|
13
14
|
# div do
|
14
15
|
# simple_format product.description
|
@@ -19,6 +20,8 @@ module ActiveAdmin
|
|
19
20
|
class IndexAsBlock < ActiveAdmin::Component
|
20
21
|
|
21
22
|
def build(page_presenter, collection)
|
23
|
+
add_class "index"
|
24
|
+
resource_selection_toggle_panel
|
22
25
|
collection.each do |obj|
|
23
26
|
instance_exec(obj, &page_presenter.block)
|
24
27
|
end
|
@@ -71,6 +71,7 @@ module ActiveAdmin
|
|
71
71
|
# title and body methods
|
72
72
|
instance_eval &page_presenter.block if page_presenter.block
|
73
73
|
|
74
|
+
add_class "index"
|
74
75
|
build_posts
|
75
76
|
end
|
76
77
|
|
@@ -82,6 +83,7 @@ module ActiveAdmin
|
|
82
83
|
@title
|
83
84
|
end
|
84
85
|
|
86
|
+
|
85
87
|
# Setter method for the configuration of the body
|
86
88
|
#
|
87
89
|
def body(method = nil, &block)
|
@@ -94,6 +96,7 @@ module ActiveAdmin
|
|
94
96
|
private
|
95
97
|
|
96
98
|
def build_posts
|
99
|
+
resource_selection_toggle_panel if active_admin_config.batch_actions.any?
|
97
100
|
@collection.each do |post|
|
98
101
|
build_post(post)
|
99
102
|
end
|
@@ -101,6 +104,7 @@ module ActiveAdmin
|
|
101
104
|
|
102
105
|
def build_post(post)
|
103
106
|
div :for => post do
|
107
|
+
resource_selection_cell(post) if active_admin_config.batch_actions.any?
|
104
108
|
build_title(post)
|
105
109
|
build_body(post)
|
106
110
|
end
|
@@ -26,6 +26,7 @@ module ActiveAdmin
|
|
26
26
|
def build(page_presenter, collection)
|
27
27
|
@page_presenter = page_presenter
|
28
28
|
@collection = collection
|
29
|
+
add_class "index"
|
29
30
|
build_table
|
30
31
|
end
|
31
32
|
|
@@ -36,6 +37,7 @@ module ActiveAdmin
|
|
36
37
|
protected
|
37
38
|
|
38
39
|
def build_table
|
40
|
+
resource_selection_toggle_panel
|
39
41
|
table :class => "index_grid" do
|
40
42
|
collection.in_groups_of(number_of_columns).each do |group|
|
41
43
|
build_row(group)
|
@@ -13,12 +13,14 @@ module ActiveAdmin
|
|
13
13
|
# column method:
|
14
14
|
#
|
15
15
|
# index do
|
16
|
+
# selectable_column
|
16
17
|
# column :title
|
17
18
|
# end
|
18
19
|
#
|
19
20
|
# If the default title does not work for you, pass it as the first argument:
|
20
21
|
#
|
21
22
|
# index do
|
23
|
+
# selectable_column
|
22
24
|
# column "My Custom Title", :title
|
23
25
|
# end
|
24
26
|
#
|
@@ -30,6 +32,7 @@ module ActiveAdmin
|
|
30
32
|
# within the context of the view for each of the objects in the collection.
|
31
33
|
#
|
32
34
|
# index do
|
35
|
+
# selectable_column
|
33
36
|
# column "Title" do |post|
|
34
37
|
# link_to post.title, admin_post_path(post)
|
35
38
|
# end
|
@@ -41,6 +44,7 @@ module ActiveAdmin
|
|
41
44
|
# To setup links to View, Edit and Delete a resource, use the default_actions method:
|
42
45
|
#
|
43
46
|
# index do
|
47
|
+
# selectable_column
|
44
48
|
# column :title
|
45
49
|
# default_actions
|
46
50
|
# end
|
@@ -48,6 +52,7 @@ module ActiveAdmin
|
|
48
52
|
# Alternatively, you can create a column with custom links:
|
49
53
|
#
|
50
54
|
# index do
|
55
|
+
# selectable_column
|
51
56
|
# column :title
|
52
57
|
# column "Actions" do |post|
|
53
58
|
# link_to "View", admin_post_path(post)
|
@@ -94,9 +99,9 @@ module ActiveAdmin
|
|
94
99
|
|
95
100
|
def build(page_presenter, collection)
|
96
101
|
table_options = {
|
97
|
-
:id => active_admin_config.
|
102
|
+
:id => active_admin_config.resource_name.plural,
|
98
103
|
:sortable => true,
|
99
|
-
:class => "index_table",
|
104
|
+
:class => "index_table index",
|
100
105
|
:i18n => active_admin_config.resource_class,
|
101
106
|
:paginator => page_presenter[:paginator] != false
|
102
107
|
}
|
@@ -127,9 +132,17 @@ module ActiveAdmin
|
|
127
132
|
#
|
128
133
|
class IndexTableFor < ::ActiveAdmin::Views::TableFor
|
129
134
|
|
135
|
+
# Display a column for checkbox
|
136
|
+
def selectable_column
|
137
|
+
return unless active_admin_config.batch_actions.any?
|
138
|
+
column( resource_selection_toggle_cell, { :class => "selectable" } ) { |resource| resource_selection_cell( resource ) }
|
139
|
+
end
|
140
|
+
|
130
141
|
# Display a column for the id
|
131
142
|
def id_column
|
132
|
-
column(
|
143
|
+
column(resource_class.human_attribute_name(resource_class.primary_key), :sortable => resource_class.primary_key) do |resource|
|
144
|
+
link_to resource.id, resource_path(resource), :class => "resource_id_link"
|
145
|
+
end
|
133
146
|
end
|
134
147
|
|
135
148
|
# Adds links to View, Edit and Delete
|
@@ -140,13 +153,13 @@ module ActiveAdmin
|
|
140
153
|
column options[:name] do |resource|
|
141
154
|
links = ''.html_safe
|
142
155
|
if controller.action_methods.include?('show')
|
143
|
-
links
|
156
|
+
links << link_to(I18n.t('active_admin.view'), resource_path(resource), :class => "member_link view_link")
|
144
157
|
end
|
145
158
|
if controller.action_methods.include?('edit')
|
146
|
-
links
|
159
|
+
links << link_to(I18n.t('active_admin.edit'), edit_resource_path(resource), :class => "member_link edit_link")
|
147
160
|
end
|
148
161
|
if controller.action_methods.include?('destroy')
|
149
|
-
links
|
162
|
+
links << link_to(I18n.t('active_admin.delete'), resource_path(resource), :method => :delete, :data => {:confirm => I18n.t('active_admin.delete_confirmation')}, :class => "member_link delete_link")
|
150
163
|
end
|
151
164
|
links
|
152
165
|
end
|