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,4 +1,4 @@
|
|
1
|
-
|
1
|
+
"zh-CN":
|
2
2
|
active_admin:
|
3
3
|
dashboard: "控制面板"
|
4
4
|
dashboard_welcome:
|
@@ -9,7 +9,9 @@ zh_cn:
|
|
9
9
|
delete: "删除"
|
10
10
|
delete_confirmation: "确定删除?"
|
11
11
|
new_model: "新建%{model}"
|
12
|
+
create_model: "新建%{model}"
|
12
13
|
edit_model: "编辑%{model}"
|
14
|
+
update_model: "编辑%{model}"
|
13
15
|
delete_model: "删除%{model}"
|
14
16
|
details: "%{model}详情"
|
15
17
|
cancel: "取消"
|
@@ -34,7 +36,45 @@ zh_cn:
|
|
34
36
|
one: "显示 <b>1</b> %{model}"
|
35
37
|
one_page: "显示 <b>所有 %{n}</b> %{model}"
|
36
38
|
multiple: "显示所有 <b>%{total}</b> %{model}中的<b>%{from} - %{to}</b> 条"
|
39
|
+
entry:
|
40
|
+
one: "条目"
|
41
|
+
other: "条目"
|
37
42
|
any: "任何"
|
38
43
|
blank_slate:
|
39
44
|
content: "暂时还没有%{resource_name}."
|
40
|
-
link: "新建一个"
|
45
|
+
link: "新建一个"
|
46
|
+
batch_actions:
|
47
|
+
button_label: "批处理"
|
48
|
+
delete_confirmation: "你确定要删除所有%{plural_model}? 如果执行,将不可恢复."
|
49
|
+
succesfully_destroyed:
|
50
|
+
one: "成功删除 1 %{model}"
|
51
|
+
other: "成功删除 %{count} %{plural_model}"
|
52
|
+
selection_toggle_explanation: "(切换选择)"
|
53
|
+
link: "新建一个"
|
54
|
+
action_label: "%{title} 被选中"
|
55
|
+
labels:
|
56
|
+
destroy: "删除"
|
57
|
+
comments:
|
58
|
+
body: "内容"
|
59
|
+
author: "作者"
|
60
|
+
title: "评论"
|
61
|
+
add: "添加评论"
|
62
|
+
resource: "资源"
|
63
|
+
no_comments_yet: "暂时没有评论"
|
64
|
+
title_content: "(%{count})条评论"
|
65
|
+
errors:
|
66
|
+
empty_text: "评论保存失败,内空不能为空."
|
67
|
+
devise:
|
68
|
+
login:
|
69
|
+
title: "登录"
|
70
|
+
remember_me: "记住我"
|
71
|
+
submit: "登录"
|
72
|
+
reset_password:
|
73
|
+
title: "忘记密码?"
|
74
|
+
submit: "重置密码"
|
75
|
+
change_password:
|
76
|
+
title: "更改您的密码"
|
77
|
+
submit: "更改我的密码"
|
78
|
+
links:
|
79
|
+
sign_in: "登录"
|
80
|
+
forgot_your_password: "忘记密码?"
|
@@ -3,7 +3,7 @@
|
|
3
3
|
dashboard: 儀表板
|
4
4
|
dashboard_welcome:
|
5
5
|
welcome: "歡迎來到 Active Admin 這是預設的儀表板頁面。"
|
6
|
-
call_to_action: "
|
6
|
+
call_to_action: "要新增儀表板內容,請查看 'app/admin/dashboards.rb'"
|
7
7
|
view: "檢視"
|
8
8
|
edit: "編輯"
|
9
9
|
delete: "刪除"
|
@@ -43,3 +43,38 @@
|
|
43
43
|
blank_slate:
|
44
44
|
content: "尚無 %{resource_name}"
|
45
45
|
link: "建立一筆"
|
46
|
+
batch_actions:
|
47
|
+
button_label: "批次作業"
|
48
|
+
delete_confirmation: "您確定要刪除這些 %{plural_model} 嗎?此動作無法復原。"
|
49
|
+
succesfully_destroyed:
|
50
|
+
one: "成功刪除 1 %{model}"
|
51
|
+
other: "成功刪除 %{count} %{plural_model}"
|
52
|
+
selection_toggle_explanation: "(切換選取)"
|
53
|
+
link: "建立一個"
|
54
|
+
action_label: "%{title} 已選取"
|
55
|
+
labels:
|
56
|
+
destroy: "刪除"
|
57
|
+
comments:
|
58
|
+
body: "內文"
|
59
|
+
author: "作者"
|
60
|
+
title: "評論"
|
61
|
+
add: "新增評論"
|
62
|
+
resource: "資源"
|
63
|
+
no_comments_yet: "尚無評論"
|
64
|
+
title_content: "(%{count}) 則評論"
|
65
|
+
errors:
|
66
|
+
empty_text: "評論儲存失敗,不允許空白的內容。"
|
67
|
+
devise:
|
68
|
+
login:
|
69
|
+
title: "登錄"
|
70
|
+
remember_me: "記住我"
|
71
|
+
submit: "登錄"
|
72
|
+
reset_password:
|
73
|
+
title: "忘記密碼?"
|
74
|
+
submit: "重置密碼"
|
75
|
+
change_password:
|
76
|
+
title: "更改您的密碼"
|
77
|
+
submit: "更改我的密碼"
|
78
|
+
links:
|
79
|
+
sign_in: "登錄"
|
80
|
+
forgot_your_password: "忘記密碼?"
|
data/lib/active_admin/menu.rb
CHANGED
@@ -1,42 +1,67 @@
|
|
1
1
|
module ActiveAdmin
|
2
|
+
|
3
|
+
# Each Namespace builds up it's own menu as the global navigation
|
4
|
+
#
|
5
|
+
# To build a new menu:
|
6
|
+
#
|
7
|
+
# menu = Menu.new do |m|
|
8
|
+
# m.add MenuItem.new(:label => "Dashboard", :url => "/")
|
9
|
+
# m.add MenuItem.new(:label => "Admin", :url => "/admin")
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# If you're interested in configuring a menu item, take a look at the
|
13
|
+
# options available in `ActiveAdmin::MenuItem`
|
14
|
+
#
|
2
15
|
class Menu
|
3
|
-
|
16
|
+
|
17
|
+
attr_accessor :children
|
18
|
+
|
4
19
|
def initialize
|
5
|
-
@
|
20
|
+
@children = Menu::ItemCollection.new
|
21
|
+
|
6
22
|
yield(self) if block_given?
|
7
|
-
end
|
8
|
-
|
9
|
-
def add(*args, &block)
|
10
|
-
@items << MenuItem.new(*args, &block)
|
11
23
|
end
|
12
|
-
|
13
|
-
|
14
|
-
|
24
|
+
|
25
|
+
# Add a new MenuItem to the menu
|
26
|
+
#
|
27
|
+
# Example:
|
28
|
+
# menu = Menu.new
|
29
|
+
# dash = MenuItem.new :label => "Dashboard"
|
30
|
+
# menu.add dash
|
31
|
+
#
|
32
|
+
# Accepts as many menu items as you wish to add:
|
33
|
+
#
|
34
|
+
# menu = Menu.new
|
35
|
+
# dash = MenuItem.new :label => "Dashboard"
|
36
|
+
# admin = MenuItem.new :label => "Admin"
|
37
|
+
# menu.add dash, admin
|
38
|
+
#
|
39
|
+
# @param [MenuItem] menu_items Add as many menu items as you pass in
|
40
|
+
def add(*menu_items)
|
41
|
+
menu_items.each do |menu_item|
|
42
|
+
menu_item.parent = nil
|
43
|
+
@children << menu_item
|
44
|
+
end
|
15
45
|
end
|
16
|
-
|
17
|
-
def
|
18
|
-
@
|
46
|
+
|
47
|
+
def [](id)
|
48
|
+
@children.find_by_id(id)
|
19
49
|
end
|
20
|
-
|
21
|
-
|
22
|
-
|
50
|
+
|
51
|
+
# @return Sorted [Array] of [MenuItem]
|
52
|
+
def items
|
53
|
+
@children.sort
|
23
54
|
end
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
if item.url == url
|
31
|
-
found = item
|
32
|
-
break
|
33
|
-
else
|
34
|
-
found = recursive_find_by_url(item.children, url)
|
35
|
-
break if found
|
36
|
-
end
|
55
|
+
|
56
|
+
class ItemCollection < Array
|
57
|
+
|
58
|
+
def find_by_id(id)
|
59
|
+
id = MenuItem.generate_item_id(id)
|
60
|
+
find{ |i| i.id == id }
|
37
61
|
end
|
38
|
-
|
62
|
+
|
39
63
|
end
|
40
|
-
|
64
|
+
|
41
65
|
end
|
66
|
+
|
42
67
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
|
3
|
+
class MenuBuilder
|
4
|
+
|
5
|
+
def self.build_for_namespace(namespace)
|
6
|
+
new(namespace).menu
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :menu
|
10
|
+
|
11
|
+
def initialize(namespace)
|
12
|
+
@namespace = namespace
|
13
|
+
end
|
14
|
+
|
15
|
+
def menu
|
16
|
+
@menu ||= build_menu
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def namespace
|
22
|
+
@namespace
|
23
|
+
end
|
24
|
+
|
25
|
+
def build_menu
|
26
|
+
menu = Menu.new
|
27
|
+
|
28
|
+
Dashboards.add_to_menu(namespace, menu)
|
29
|
+
|
30
|
+
namespace.resources.each do |resource|
|
31
|
+
register_with_menu(menu, resource) if resource.include_in_menu?
|
32
|
+
end
|
33
|
+
|
34
|
+
menu
|
35
|
+
end
|
36
|
+
|
37
|
+
# Does all the work of registernig a config with the menu system
|
38
|
+
def register_with_menu(menu, resource)
|
39
|
+
# The menu we're going to add this resource to
|
40
|
+
add_to = menu
|
41
|
+
|
42
|
+
# Adding as a child
|
43
|
+
if resource.parent_menu_item_name
|
44
|
+
# Create the parent if it doesn't exist
|
45
|
+
unless menu[resource.parent_menu_item_name]
|
46
|
+
item = MenuItem.new(:label => resource.parent_menu_item_name, :url => "#", :id => resource.parent_menu_item_name)
|
47
|
+
add_to.add(item)
|
48
|
+
end
|
49
|
+
|
50
|
+
add_to = menu[resource.parent_menu_item_name]
|
51
|
+
end
|
52
|
+
|
53
|
+
if add_to[resource.menu_item.id]
|
54
|
+
existing = add_to[resource.menu_item.id]
|
55
|
+
add_to.children.delete(existing)
|
56
|
+
add_to.add(resource.menu_item)
|
57
|
+
resource.menu_item.add(*existing.children)
|
58
|
+
else
|
59
|
+
add_to.add resource.menu_item
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -1,22 +1,63 @@
|
|
1
1
|
module ActiveAdmin
|
2
|
+
|
2
3
|
class MenuItem
|
3
4
|
|
4
|
-
attr_accessor :
|
5
|
+
attr_accessor :id, :label, :url, :priority, :parent, :display_if_block, :children
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
# Build a new menu item
|
8
|
+
#
|
9
|
+
# @param [Hash] options The options for the menu
|
10
|
+
#
|
11
|
+
# @option options [String, Proc] :label
|
12
|
+
# The label to display for this menu item. It can either be a String or a
|
13
|
+
# Proc. If the option is Proc, it is called each time the label is requested.
|
14
|
+
#
|
15
|
+
# @option options [String] :id
|
16
|
+
# A custom id to reference this menu item with. If empty an id is automatically
|
17
|
+
# generated for you.
|
18
|
+
#
|
19
|
+
# @option options [String, Symbol] :url
|
20
|
+
# A string or symbol representing the url for this item. If it's a symbol, the
|
21
|
+
# view will automatically call the method for you.
|
22
|
+
#
|
23
|
+
# @option options [Integer] :priority
|
24
|
+
# MenuItems are sorted by priority then by label. The lower the priority, the
|
25
|
+
# earlier in the menu the item will be displayed.
|
26
|
+
# Default: 10
|
27
|
+
#
|
28
|
+
# @option options [Proc] :if
|
29
|
+
# A block for the view to call to decide if this menu item should be displayed.
|
30
|
+
# The block should return true of false
|
31
|
+
def initialize(options = {})
|
32
|
+
@label = options[:label]
|
33
|
+
@id = MenuItem.generate_item_id(options[:id] || label)
|
34
|
+
@url = options[:url]
|
35
|
+
@priority = options[:priority] || 10
|
36
|
+
@children = Menu::ItemCollection.new
|
10
37
|
|
11
|
-
@display_if_block = options
|
38
|
+
@display_if_block = options[:if]
|
12
39
|
|
13
40
|
yield(self) if block_given? # Builder style syntax
|
14
41
|
end
|
15
42
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
43
|
+
def self.generate_item_id(id)
|
44
|
+
id.to_s.downcase.gsub(" ", "_")
|
45
|
+
end
|
46
|
+
|
47
|
+
def label
|
48
|
+
case @label
|
49
|
+
when Proc
|
50
|
+
@label.call
|
51
|
+
else
|
52
|
+
@label.to_s
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def add(*menu_items)
|
57
|
+
menu_items.each do |menu_item|
|
58
|
+
menu_item.parent = self
|
59
|
+
@children << menu_item
|
60
|
+
end
|
20
61
|
end
|
21
62
|
|
22
63
|
def children
|
@@ -28,7 +69,7 @@ module ActiveAdmin
|
|
28
69
|
end
|
29
70
|
|
30
71
|
def dom_id
|
31
|
-
|
72
|
+
id.gsub( " ", '_' ).gsub( /[^a-z0-9_]/, '' )
|
32
73
|
end
|
33
74
|
|
34
75
|
# Returns an array of the ancestory of this menu item
|
@@ -40,13 +81,13 @@ module ActiveAdmin
|
|
40
81
|
|
41
82
|
# Returns the child item with the name passed in
|
42
83
|
# @blog_menu["Create New"] => <#MenuItem @name="Create New" >
|
43
|
-
def [](
|
44
|
-
@children.
|
84
|
+
def [](id)
|
85
|
+
@children.find_by_id(id)
|
45
86
|
end
|
46
87
|
|
47
88
|
def <=>(other)
|
48
89
|
result = priority <=> other.priority
|
49
|
-
result =
|
90
|
+
result = label <=> other.label if result == 0
|
50
91
|
result
|
51
92
|
end
|
52
93
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'active_admin/helpers/settings'
|
2
2
|
require 'active_admin/resource_collection'
|
3
|
+
require 'active_admin/menu_builder'
|
3
4
|
|
4
5
|
module ActiveAdmin
|
5
6
|
|
@@ -38,7 +39,6 @@ module ActiveAdmin
|
|
38
39
|
@application = application
|
39
40
|
@name = name.to_s.underscore.to_sym
|
40
41
|
@resources = ResourceCollection.new
|
41
|
-
@menu = Menu.new
|
42
42
|
register_module unless root?
|
43
43
|
generate_dashboard_controller
|
44
44
|
end
|
@@ -52,7 +52,7 @@ module ActiveAdmin
|
|
52
52
|
# Register the resource
|
53
53
|
register_resource_controller(config)
|
54
54
|
parse_registration_block(config, &block) if block_given?
|
55
|
-
|
55
|
+
reset_menu!
|
56
56
|
|
57
57
|
# Ensure that the dashboard is generated
|
58
58
|
generate_dashboard_controller
|
@@ -70,7 +70,7 @@ module ActiveAdmin
|
|
70
70
|
# Register the resource
|
71
71
|
register_page_controller(config)
|
72
72
|
parse_page_registration_block(config, &block) if block_given?
|
73
|
-
|
73
|
+
reset_menu!
|
74
74
|
|
75
75
|
config
|
76
76
|
end
|
@@ -100,16 +100,7 @@ module ActiveAdmin
|
|
100
100
|
def unload!
|
101
101
|
unload_resources!
|
102
102
|
unload_dashboard!
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
# The menu gets built by Active Admin once all the resources have been
|
107
|
-
# loaded. This method gets called to register each resource with the menu system.
|
108
|
-
def load_menu!
|
109
|
-
register_dashboard
|
110
|
-
resources.each do |resource|
|
111
|
-
register_with_menu(resource) if resource.include_in_menu?
|
112
|
-
end
|
103
|
+
reset_menu!
|
113
104
|
end
|
114
105
|
|
115
106
|
# Returns the first registered ActiveAdmin::Resource instance for a given class
|
@@ -123,6 +114,14 @@ module ActiveAdmin
|
|
123
114
|
application.send(name)
|
124
115
|
end
|
125
116
|
|
117
|
+
def menu
|
118
|
+
@menu ||= MenuBuilder.build_for_namespace(self)
|
119
|
+
end
|
120
|
+
|
121
|
+
def reset_menu!
|
122
|
+
@menu = nil
|
123
|
+
end
|
124
|
+
|
126
125
|
protected
|
127
126
|
|
128
127
|
# Either returns an existing Resource instance or builds a new
|
@@ -135,7 +134,6 @@ module ActiveAdmin
|
|
135
134
|
resources.add Page.new(self, name, options)
|
136
135
|
end
|
137
136
|
|
138
|
-
|
139
137
|
def register_page_controller(config)
|
140
138
|
eval "class ::#{config.controller_name} < ActiveAdmin::PageController; end"
|
141
139
|
config.controller.active_admin_config = config
|
@@ -147,6 +145,12 @@ module ActiveAdmin
|
|
147
145
|
const_name = resource.controller_name.split('::').last
|
148
146
|
# Remove the const if its been defined
|
149
147
|
parent.send(:remove_const, const_name) if parent.const_defined?(const_name)
|
148
|
+
|
149
|
+
# Remove circular references
|
150
|
+
resource.controller.active_admin_config = nil
|
151
|
+
if resource.is_a?(Resource) && resource.dsl
|
152
|
+
resource.dsl.run_registration_block { @config = nil }
|
153
|
+
end
|
150
154
|
end
|
151
155
|
@resources = ResourceCollection.new
|
152
156
|
end
|
@@ -156,10 +160,6 @@ module ActiveAdmin
|
|
156
160
|
Dashboards.clear_all_sections!
|
157
161
|
end
|
158
162
|
|
159
|
-
def unload_menu!
|
160
|
-
@menu = Menu.new
|
161
|
-
end
|
162
|
-
|
163
163
|
# Creates a ruby module to namespace all the classes in if required
|
164
164
|
def register_module
|
165
165
|
eval "module ::#{module_name}; end"
|
@@ -170,52 +170,22 @@ module ActiveAdmin
|
|
170
170
|
config.controller.active_admin_config = config
|
171
171
|
end
|
172
172
|
|
173
|
-
def resource_dsl
|
174
|
-
@resource_dsl ||= ResourceDSL.new
|
175
|
-
end
|
176
|
-
|
177
173
|
def parse_registration_block(config, &block)
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
def page_dsl
|
182
|
-
@page_dsl ||= PageDSL.new
|
174
|
+
config.dsl = ResourceDSL.new(config)
|
175
|
+
config.dsl.run_registration_block(&block)
|
183
176
|
end
|
184
177
|
|
185
178
|
def parse_page_registration_block(config, &block)
|
186
|
-
|
179
|
+
PageDSL.new(config).run_registration_block(&block)
|
187
180
|
end
|
188
181
|
|
189
182
|
# Creates a dashboard controller for this config
|
190
183
|
def generate_dashboard_controller
|
191
|
-
|
192
|
-
end
|
184
|
+
return unless ActiveAdmin::Dashboards.built?
|
193
185
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
menu.add(I18n.t("active_admin.dashboard"), dashboard_path, 1) unless menu[I18n.t("active_admin.dashboard")]
|
198
|
-
end
|
199
|
-
|
200
|
-
# Does all the work of registernig a config with the menu system
|
201
|
-
def register_with_menu(config)
|
202
|
-
# The menu we're going to add this resource to
|
203
|
-
add_to = menu
|
204
|
-
|
205
|
-
# Adding as a child
|
206
|
-
if config.parent_menu_item_name
|
207
|
-
# Create the parent if it doesn't exist
|
208
|
-
menu.add(config.parent_menu_item_name, '#') unless menu[config.parent_menu_item_name]
|
209
|
-
add_to = menu[config.parent_menu_item_name]
|
210
|
-
end
|
211
|
-
|
212
|
-
# Check if this menu item has already been created
|
213
|
-
if add_to[config.menu_item_name]
|
214
|
-
# Update the url if it's already been created
|
215
|
-
add_to[config.menu_item_name].url = config.route_collection_path
|
216
|
-
else
|
217
|
-
add_to.add(config.menu_item_name, config.route_collection_path, config.menu_item_priority, { :if => config.menu_item_display_if })
|
218
|
-
end
|
186
|
+
eval "class ::#{dashboard_controller_name} < ActiveAdmin::PageController
|
187
|
+
include ActiveAdmin::Dashboards::DashboardController
|
188
|
+
end"
|
219
189
|
end
|
220
190
|
end
|
221
191
|
end
|