obitum-rails_admin 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -8
- data/README.md +6 -2
- data/app/assets/javascripts/rails_admin/custom/ui.js +5 -5
- data/app/assets/javascripts/rails_admin/jquery-ui-1.8.16.custom.js +4727 -4727
- data/app/assets/javascripts/rails_admin/jquery.colorpicker.js +484 -484
- data/app/assets/javascripts/rails_admin/jquery.pjax.js +250 -85
- data/app/assets/javascripts/rails_admin/jquery.ui.timepicker.js +1371 -1219
- data/app/assets/javascripts/rails_admin/ra.filter-box.js +30 -30
- data/app/assets/javascripts/rails_admin/ra.filtering-select.js +11 -11
- data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.coffee +40 -0
- data/app/assets/javascripts/rails_admin/ra.remote-form.js +41 -39
- data/app/assets/javascripts/rails_admin/rails_admin.js.erb +4 -3
- data/app/assets/javascripts/rails_admin/themes/default/ui.js +6 -6
- data/app/assets/javascripts/rails_admin/ui.js.coffee +44 -16
- data/app/assets/stylesheets/rails_admin/base/README +2 -2
- data/app/assets/stylesheets/rails_admin/base/theming.css.scss +226 -113
- data/app/assets/stylesheets/rails_admin/custom/mixins.css.scss +1 -1
- data/app/assets/stylesheets/rails_admin/custom/theming.css.scss +2 -2
- data/app/assets/stylesheets/rails_admin/custom/variables.css.scss +3 -3
- data/app/assets/stylesheets/rails_admin/imports.css.scss.erb +36 -1
- data/app/assets/stylesheets/rails_admin/jquery.ui.timepicker.css.scss +16 -0
- data/app/assets/stylesheets/rails_admin/ra.filtering-multiselect.css.scss +2 -2
- data/app/assets/stylesheets/rails_admin/themes/default/mixins.css.scss +1 -1
- data/app/assets/stylesheets/rails_admin/themes/default/theming.css.scss +2 -2
- data/app/assets/stylesheets/rails_admin/themes/default/variables.css.scss +3 -3
- data/app/controllers/rails_admin/application_controller.rb +13 -18
- data/app/controllers/rails_admin/main_controller.rb +15 -16
- data/app/helpers/rails_admin/application_helper.rb +67 -41
- data/app/helpers/rails_admin/form_builder.rb +31 -29
- data/app/helpers/rails_admin/main_helper.rb +4 -4
- data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +12 -11
- data/app/views/layouts/rails_admin/application.html.haml +29 -29
- data/app/views/rails_admin/main/_dashboard_history.html.haml +1 -1
- data/app/views/rails_admin/main/_delete_notice.html.haml +4 -5
- data/app/views/rails_admin/main/_form_colorpicker.html.haml +2 -1
- data/app/views/rails_admin/main/_form_datetime.html.haml +1 -1
- data/app/views/rails_admin/main/_form_enumeration.html.haml +1 -1
- data/app/views/rails_admin/main/_form_field.html.haml +1 -1
- data/app/views/rails_admin/main/_form_file_upload.html.haml +3 -2
- data/app/views/rails_admin/main/_form_filtering_multiselect.html.haml +6 -4
- data/app/views/rails_admin/main/_form_filtering_select.html.haml +6 -5
- data/app/views/rails_admin/main/_form_nested_many.html.haml +41 -6
- data/app/views/rails_admin/main/_form_nested_one.html.haml +34 -5
- data/app/views/rails_admin/main/_form_text.html.haml +3 -3
- data/app/views/rails_admin/main/_submit_buttons.html.haml +6 -4
- data/app/views/rails_admin/main/bulk_delete.html.haml +7 -3
- data/app/views/rails_admin/main/dashboard.html.haml +4 -4
- data/app/views/rails_admin/main/delete.html.haml +7 -3
- data/app/views/rails_admin/main/edit.html.haml +1 -1
- data/app/views/rails_admin/main/export.html.haml +57 -53
- data/app/views/rails_admin/main/history.html.haml +8 -8
- data/app/views/rails_admin/main/index.html.haml +22 -21
- data/app/views/rails_admin/main/new.html.haml +1 -1
- data/app/views/rails_admin/main/show.html.haml +2 -2
- data/config/initializers/active_record_extensions.rb +2 -2
- data/config/initializers/haml.rb +0 -1
- data/config/locales/rails_admin.en.yml +5 -5
- data/lib/generators/rails_admin/templates/initializer.erb +7 -7
- data/lib/rails_admin/abstract_model.rb +36 -53
- data/lib/rails_admin/adapters/active_record/abstract_object.rb +32 -0
- data/lib/rails_admin/adapters/active_record.rb +56 -137
- data/lib/rails_admin/config/actions/base.rb +40 -28
- data/lib/rails_admin/config/actions/bulk_delete.rb +10 -11
- data/lib/rails_admin/config/actions/dashboard.rb +9 -5
- data/lib/rails_admin/config/actions/delete.rb +12 -9
- data/lib/rails_admin/config/actions/edit.rb +13 -9
- data/lib/rails_admin/config/actions/export.rb +9 -6
- data/lib/rails_admin/config/actions/history_index.rb +9 -5
- data/lib/rails_admin/config/actions/history_show.rb +9 -5
- data/lib/rails_admin/config/actions/index.rb +23 -13
- data/lib/rails_admin/config/actions/new.rb +14 -10
- data/lib/rails_admin/config/actions/show.rb +10 -5
- data/lib/rails_admin/config/actions/show_in_app.rb +9 -4
- data/lib/rails_admin/config/actions.rb +16 -16
- data/lib/rails_admin/config/configurable.rb +92 -0
- data/lib/rails_admin/config/fields/association.rb +6 -23
- data/lib/rails_admin/config/fields/base.rb +58 -40
- data/lib/rails_admin/config/fields/factories/belongs_to_association.rb +26 -0
- data/lib/rails_admin/config/fields/factories/carrierwave.rb +21 -2
- data/lib/rails_admin/config/fields/factories/devise.rb +9 -12
- data/lib/rails_admin/config/fields/factories/dragonfly.rb +13 -7
- data/lib/rails_admin/config/fields/factories/paperclip.rb +14 -15
- data/lib/rails_admin/config/fields/group.rb +16 -3
- data/lib/rails_admin/config/fields/types/belongs_to_association.rb +2 -2
- data/lib/rails_admin/config/fields/types/carrierwave.rb +0 -9
- data/lib/rails_admin/config/fields/types/color.rb +3 -3
- data/lib/rails_admin/config/fields/types/dragonfly.rb +1 -19
- data/lib/rails_admin/config/fields/types/file_upload.rb +7 -11
- data/lib/rails_admin/config/fields/types/has_many_association.rb +1 -6
- data/lib/rails_admin/config/fields/types/has_one_association.rb +4 -4
- data/lib/rails_admin/config/fields/types/paperclip.rb +0 -18
- data/lib/rails_admin/config/fields/types/password.rb +2 -2
- data/lib/rails_admin/config/fields/types/polymorphic_association.rb +2 -2
- data/lib/rails_admin/config/fields/types/text.rb +2 -2
- data/lib/rails_admin/config/fields.rb +7 -17
- data/lib/rails_admin/config/has_fields.rb +9 -9
- data/lib/rails_admin/config/has_groups.rb +2 -2
- data/lib/rails_admin/config/hideable.rb +2 -2
- data/lib/rails_admin/config/model.rb +23 -17
- data/lib/rails_admin/config/proxyable/proxy.rb +43 -0
- data/lib/rails_admin/config/proxyable.rb +12 -0
- data/lib/rails_admin/config/sections/base.rb +14 -4
- data/lib/rails_admin/config.rb +38 -9
- data/lib/rails_admin/extension.rb +1 -1
- data/lib/rails_admin/extensions/history/auditing_adapter.rb +6 -6
- data/lib/rails_admin/extensions/history/history.rb +2 -1
- data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +13 -13
- data/lib/rails_admin/support/csv_converter.rb +6 -6
- data/lib/rails_admin/version.rb +1 -1
- data/lib/rails_admin.rb +0 -5
- data/spec/controllers/main_controller_spec.rb +7 -7
- data/spec/dummy_app/Gemfile +10 -7
- data/spec/dummy_app/Rakefile +1 -1
- data/spec/dummy_app/app/assets/images/rails.png +0 -0
- data/spec/dummy_app/app/assets/javascripts/application.js +15 -0
- data/spec/dummy_app/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy_app/app/controllers/players_controller.rb +1 -1
- data/spec/dummy_app/app/models/cms/basic_page.rb +1 -1
- data/spec/dummy_app/app/models/division.rb +5 -1
- data/spec/dummy_app/app/models/field_test.rb +4 -4
- data/spec/dummy_app/app/models/nested_field_test.rb +3 -0
- data/spec/dummy_app/app/models/player.rb +3 -3
- data/spec/dummy_app/app/views/layouts/application.html.erb +3 -2
- data/spec/dummy_app/app/views/players/show.html.haml +1 -1
- data/spec/dummy_app/config/application.rb +20 -5
- data/spec/dummy_app/config/database.yml +5 -2
- data/spec/dummy_app/config/environments/development.rb +11 -1
- data/spec/dummy_app/config/environments/production.rb +19 -3
- data/spec/dummy_app/config/environments/test.rb +5 -7
- data/spec/dummy_app/config/initializers/devise.rb +6 -0
- data/spec/dummy_app/config/initializers/inflections.rb +5 -0
- data/spec/dummy_app/config/initializers/secret_token.rb +1 -1
- data/spec/dummy_app/{foo/test/dummy/config → config}/initializers/wrap_parameters.rb +1 -1
- data/spec/dummy_app/config/routes.rb +1 -1
- data/spec/dummy_app/db/migrate/00000000000006_devise_create_users.rb +35 -5
- data/spec/dummy_app/db/migrate/20120118122004_add_categories.rb +1 -1
- data/spec/dummy_app/doc/README_FOR_APP +2 -0
- data/spec/dummy_app/public/404.html +26 -0
- data/spec/dummy_app/{foo/test/dummy/public → public}/422.html +0 -0
- data/spec/dummy_app/{foo/test/dummy/public → public}/500.html +0 -1
- data/spec/dummy_app/public/favicon.ico +0 -0
- data/spec/dummy_app/public/robots.txt +5 -0
- data/spec/helpers/application_helper_spec.rb +107 -42
- data/spec/{requests → integration}/authorization/cancan_spec.rb +4 -5
- data/spec/{requests → integration}/basic/bulk_action/rails_admin_basic_bulk_action_spec.rb +0 -0
- data/spec/{requests → integration}/basic/bulk_destroy/rails_admin_basic_bulk_destroy_spec.rb +3 -16
- data/spec/{requests → integration}/basic/create/rails_admin_basic_create_spec.rb +0 -2
- data/spec/{requests → integration}/basic/create/rails_admin_namespaced_model_create_spec.rb +0 -16
- data/spec/{requests → integration}/basic/delete/rails_admin_basic_delete_spec.rb +0 -0
- data/spec/{requests → integration}/basic/destroy/rails_admin_basic_destroy_spec.rb +0 -0
- data/spec/{requests → integration}/basic/edit/rails_admin_basic_edit_spec.rb +2 -2
- data/spec/{requests → integration}/basic/export/rails_admin_basic_export_spec.rb +1 -1
- data/spec/{requests → integration}/basic/list/rails_admin_basic_list_spec.rb +12 -38
- data/spec/{requests → integration}/basic/new/rails_admin_basic_new_spec.rb +0 -0
- data/spec/{requests → integration}/basic/new/rails_admin_namespaced_model_new_spec.rb +0 -0
- data/spec/{requests → integration}/basic/show/rails_admin_basic_show_spec.rb +1 -2
- data/spec/{requests → integration}/basic/update/rails_admin_basic_update_spec.rb +2 -2
- data/spec/{requests → integration}/config/edit/rails_admin_config_edit_spec.rb +65 -24
- data/spec/{requests → integration}/config/list/rails_admin_config_list_spec.rb +2 -2
- data/spec/{requests → integration}/config/show/rails_admin_config_show_spec.rb +20 -0
- data/spec/{requests → integration}/history/rails_admin_history_spec.rb +3 -3
- data/spec/{requests → integration}/rails_admin_spec.rb +8 -41
- data/spec/{requests → integration}/relation_spec.rb +0 -0
- data/spec/spec_helper.rb +13 -31
- data/spec/{lib → unit/adapters/active_record}/abstract_object_spec.rb +17 -5
- data/spec/unit/adapters/active_record_spec.rb +53 -0
- data/spec/{requests/actions.rb → unit/config/actions_spec.rb} +47 -31
- data/spec/unit/config/fields/base_spec.rb +291 -0
- data/spec/unit/config/model_spec.rb +75 -0
- data/spec/unit/config/sections_spec.rb +123 -0
- data/spec/{lib/rails_admin_spec.rb → unit/config_spec.rb} +65 -93
- metadata +127 -223
- data/app/assets/javascripts/rails_admin/jquery_nested_form.js +0 -58
- data/app/views/layouts/rails_admin/_navigation.html.haml +0 -17
- data/lib/rails_admin/abstract_object.rb +0 -28
- data/lib/rails_admin/config/base.rb +0 -111
- data/lib/rails_admin/config/proxy.rb +0 -40
- data/lib/rails_admin/generic_support.rb +0 -18
- data/spec/dummy_app/config/initializers/quiet_assets.rb +0 -10
- data/spec/dummy_app/foo/Gemfile +0 -17
- data/spec/dummy_app/foo/MIT-LICENSE +0 -20
- data/spec/dummy_app/foo/README.rdoc +0 -3
- data/spec/dummy_app/foo/Rakefile +0 -39
- data/spec/dummy_app/foo/app/assets/javascripts/foo/application.js +0 -9
- data/spec/dummy_app/foo/app/assets/stylesheets/foo/application.css +0 -7
- data/spec/dummy_app/foo/app/controllers/foo/application_controller.rb +0 -4
- data/spec/dummy_app/foo/app/helpers/foo/application_helper.rb +0 -4
- data/spec/dummy_app/foo/app/models/foo/bar.rb +0 -4
- data/spec/dummy_app/foo/app/views/layouts/foo/application.html.erb +0 -14
- data/spec/dummy_app/foo/config/routes.rb +0 -2
- data/spec/dummy_app/foo/foo.gemspec +0 -23
- data/spec/dummy_app/foo/lib/foo/engine.rb +0 -5
- data/spec/dummy_app/foo/lib/foo/version.rb +0 -3
- data/spec/dummy_app/foo/lib/foo.rb +0 -4
- data/spec/dummy_app/foo/lib/tasks/foo_tasks.rake +0 -4
- data/spec/dummy_app/foo/script/rails +0 -6
- data/spec/dummy_app/foo/test/dummy/Rakefile +0 -7
- data/spec/dummy_app/foo/test/dummy/app/assets/javascripts/application.js +0 -9
- data/spec/dummy_app/foo/test/dummy/app/assets/stylesheets/application.css +0 -7
- data/spec/dummy_app/foo/test/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy_app/foo/test/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy_app/foo/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy_app/foo/test/dummy/config/application.rb +0 -45
- data/spec/dummy_app/foo/test/dummy/config/boot.rb +0 -10
- data/spec/dummy_app/foo/test/dummy/config/database.yml +0 -25
- data/spec/dummy_app/foo/test/dummy/config/environment.rb +0 -5
- data/spec/dummy_app/foo/test/dummy/config/environments/development.rb +0 -30
- data/spec/dummy_app/foo/test/dummy/config/environments/production.rb +0 -60
- data/spec/dummy_app/foo/test/dummy/config/environments/test.rb +0 -39
- data/spec/dummy_app/foo/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy_app/foo/test/dummy/config/initializers/inflections.rb +0 -10
- data/spec/dummy_app/foo/test/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy_app/foo/test/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy_app/foo/test/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy_app/foo/test/dummy/config/locales/en.yml +0 -5
- data/spec/dummy_app/foo/test/dummy/config/routes.rb +0 -4
- data/spec/dummy_app/foo/test/dummy/config.ru +0 -4
- data/spec/dummy_app/foo/test/dummy/db/schema.rb +0 -21
- data/spec/dummy_app/foo/test/dummy/public/404.html +0 -26
- data/spec/dummy_app/foo/test/dummy/public/favicon.ico +0 -0
- data/spec/dummy_app/foo/test/dummy/script/rails +0 -6
- data/spec/dummy_app/foo/test/fixtures/foo/bars.yml +0 -11
- data/spec/dummy_app/foo/test/foo_test.rb +0 -7
- data/spec/dummy_app/foo/test/integration/navigation_test.rb +0 -10
- data/spec/dummy_app/foo/test/test_helper.rb +0 -10
- data/spec/dummy_app/foo/test/unit/foo/bar_test.rb +0 -9
- data/spec/generator_helpers.rb +0 -30
- data/spec/generators/install_generator_spec.rb +0 -85
- data/spec/generators/uninstall_generator_spec.rb +0 -35
- data/spec/lib/custom_field.rb +0 -7
- data/spec/requests/config/navigation/rails_admin_config_navigation_spec.rb +0 -107
- data/spec/requests/config/rails_admin_config_spec.rb +0 -227
@@ -3,15 +3,15 @@ module RailsAdmin
|
|
3
3
|
module Actions
|
4
4
|
class Delete < RailsAdmin::Config::Actions::Base
|
5
5
|
RailsAdmin::Config::Actions.register(self)
|
6
|
-
|
6
|
+
|
7
7
|
register_instance_option :member do
|
8
8
|
true
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
register_instance_option :route_fragment do
|
12
12
|
'delete'
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
register_instance_option :http_methods do
|
16
16
|
[:get, :delete]
|
17
17
|
end
|
@@ -19,18 +19,18 @@ module RailsAdmin
|
|
19
19
|
register_instance_option :authorization_key do
|
20
20
|
:destroy
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
register_instance_option :controller do
|
24
24
|
Proc.new do
|
25
25
|
if request.get? # DELETE
|
26
|
-
|
26
|
+
|
27
27
|
respond_to do |format|
|
28
28
|
format.html { render @action.template_name }
|
29
29
|
format.js { render @action.template_name, :layout => false }
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
elsif request.delete? # DESTROY
|
33
|
-
|
33
|
+
|
34
34
|
@auditing_adapter && @auditing_adapter.delete_object("Destroyed #{@model_config.with(:object => @object).object_label}", @object, @abstract_model, _current_user)
|
35
35
|
if @abstract_model.destroy(@object)
|
36
36
|
flash[:success] = t("admin.flash.successful", :name => @model_config.label, :action => t("admin.actions.delete.done"))
|
@@ -39,11 +39,14 @@ module RailsAdmin
|
|
39
39
|
end
|
40
40
|
|
41
41
|
redirect_to back_or_index
|
42
|
-
|
42
|
+
|
43
43
|
end
|
44
|
-
|
45
44
|
end
|
46
45
|
end
|
46
|
+
|
47
|
+
register_instance_option :link_icon do
|
48
|
+
'icon-remove'
|
49
|
+
end
|
47
50
|
end
|
48
51
|
end
|
49
52
|
end
|
@@ -2,32 +2,32 @@ module RailsAdmin
|
|
2
2
|
module Config
|
3
3
|
module Actions
|
4
4
|
class Edit < RailsAdmin::Config::Actions::Base
|
5
|
-
RailsAdmin::Config::Actions.register(self)
|
6
|
-
|
5
|
+
RailsAdmin::Config::Actions.register(self)
|
6
|
+
|
7
7
|
register_instance_option :member do
|
8
8
|
true
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
register_instance_option :http_methods do
|
12
12
|
[:get, :put]
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
register_instance_option :controller do
|
16
16
|
Proc.new do
|
17
|
-
|
17
|
+
|
18
18
|
if request.get? # EDIT
|
19
19
|
|
20
20
|
respond_to do |format|
|
21
21
|
format.html { render @action.template_name }
|
22
22
|
format.js { render @action.template_name, :layout => false }
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
elsif request.put? # UPDATE
|
26
|
-
|
26
|
+
|
27
27
|
@cached_assocations_hash = associations_hash
|
28
28
|
@attributes = get_attributes
|
29
29
|
@modified_assoc = []
|
30
|
-
|
30
|
+
|
31
31
|
@old_object = @object.dup
|
32
32
|
@model_config.update.fields.map { |f| f.parse_input(@attributes) if f.respond_to?(:parse_input) }
|
33
33
|
@object.set_attributes(@attributes, _attr_accessible_role)
|
@@ -41,11 +41,15 @@ module RailsAdmin
|
|
41
41
|
else
|
42
42
|
handle_save_error :edit
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
end
|
46
46
|
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
register_instance_option :link_icon do
|
51
|
+
'icon-pencil'
|
52
|
+
end
|
49
53
|
end
|
50
54
|
end
|
51
55
|
end
|
@@ -3,15 +3,15 @@ module RailsAdmin
|
|
3
3
|
module Actions
|
4
4
|
class Export < RailsAdmin::Config::Actions::Base
|
5
5
|
RailsAdmin::Config::Actions.register(self)
|
6
|
-
|
6
|
+
|
7
7
|
register_instance_option :collection do
|
8
8
|
true
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
register_instance_option :http_methods do
|
12
12
|
[:get, :post]
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
register_instance_option :controller do
|
16
16
|
Proc.new do
|
17
17
|
|
@@ -23,14 +23,17 @@ module RailsAdmin
|
|
23
23
|
else
|
24
24
|
render @action.template_name
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
register_instance_option :bulkable? do
|
31
31
|
true
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
|
+
register_instance_option :link_icon do
|
35
|
+
'icon-share'
|
36
|
+
end
|
34
37
|
end
|
35
38
|
end
|
36
39
|
end
|
@@ -3,19 +3,19 @@ module RailsAdmin
|
|
3
3
|
module Actions
|
4
4
|
class HistoryIndex < RailsAdmin::Config::Actions::Base
|
5
5
|
RailsAdmin::Config::Actions.register(self)
|
6
|
-
|
6
|
+
|
7
7
|
register_instance_option :authorization_key do
|
8
8
|
:history
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
register_instance_option :collection do
|
12
12
|
true
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
register_instance_option :route_fragment do
|
16
16
|
'history'
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
register_instance_option :controller do
|
20
20
|
Proc.new do
|
21
21
|
@general = true
|
@@ -24,10 +24,14 @@ module RailsAdmin
|
|
24
24
|
render @action.template_name, :layout => request.xhr? ? false : 'rails_admin/application'
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
register_instance_option :template_name do
|
29
29
|
:history
|
30
30
|
end
|
31
|
+
|
32
|
+
register_instance_option :link_icon do
|
33
|
+
'icon-book'
|
34
|
+
end
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
@@ -3,19 +3,19 @@ module RailsAdmin
|
|
3
3
|
module Actions
|
4
4
|
class HistoryShow < RailsAdmin::Config::Actions::Base
|
5
5
|
RailsAdmin::Config::Actions.register(self)
|
6
|
-
|
6
|
+
|
7
7
|
register_instance_option :authorization_key do
|
8
8
|
:history
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
register_instance_option :member do
|
12
12
|
true
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
register_instance_option :route_fragment do
|
16
16
|
'history'
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
register_instance_option :controller do
|
20
20
|
Proc.new do
|
21
21
|
@general = false
|
@@ -24,10 +24,14 @@ module RailsAdmin
|
|
24
24
|
render @action.template_name, :layout => request.xhr? ? false : 'rails_admin/application'
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
register_instance_option :template_name do
|
29
29
|
:history
|
30
30
|
end
|
31
|
+
|
32
|
+
register_instance_option :link_icon do
|
33
|
+
'icon-book'
|
34
|
+
end
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
@@ -3,33 +3,38 @@ module RailsAdmin
|
|
3
3
|
module Actions
|
4
4
|
class Index < RailsAdmin::Config::Actions::Base
|
5
5
|
RailsAdmin::Config::Actions.register(self)
|
6
|
-
|
6
|
+
|
7
7
|
register_instance_option :collection do
|
8
8
|
true
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
register_instance_option :http_methods do
|
12
12
|
[:get, :post]
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
register_instance_option :route_fragment do
|
16
16
|
''
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
register_instance_option :breadcrumb_parent do
|
20
|
-
:
|
20
|
+
parent_model = bindings[:abstract_model].try(:config).try(:parent)
|
21
|
+
if am = parent_model && RailsAdmin.config(parent_model).try(:abstract_model)
|
22
|
+
[:index, am]
|
23
|
+
else
|
24
|
+
[:dashboard]
|
25
|
+
end
|
21
26
|
end
|
22
|
-
|
27
|
+
|
23
28
|
register_instance_option :controller do
|
24
29
|
Proc.new do
|
25
30
|
@objects ||= list_entries
|
26
31
|
|
27
32
|
respond_to do |format|
|
28
|
-
|
29
|
-
format.html do
|
33
|
+
|
34
|
+
format.html do
|
30
35
|
render @action.template_name, :layout => !request.xhr?, :status => (flash[:error].present? ? :not_found : 200)
|
31
36
|
end
|
32
|
-
|
37
|
+
|
33
38
|
format.json do
|
34
39
|
output = if params[:compact]
|
35
40
|
@objects.map{ |o| { :id => o.id, :label => o.send(@model_config.object_label_method) } }
|
@@ -42,7 +47,7 @@ module RailsAdmin
|
|
42
47
|
render :json => output
|
43
48
|
end
|
44
49
|
end
|
45
|
-
|
50
|
+
|
46
51
|
format.xml do
|
47
52
|
output = @objects.to_xml(@schema)
|
48
53
|
if params[:send_data]
|
@@ -51,7 +56,7 @@ module RailsAdmin
|
|
51
56
|
render :xml => output
|
52
57
|
end
|
53
58
|
end
|
54
|
-
|
59
|
+
|
55
60
|
format.csv do
|
56
61
|
header, encoding, output = CSVConverter.new(@objects, @schema).to_csv(params[:csv_options])
|
57
62
|
if params[:send_data]
|
@@ -62,11 +67,16 @@ module RailsAdmin
|
|
62
67
|
render :text => output
|
63
68
|
end
|
64
69
|
end
|
65
|
-
|
70
|
+
|
66
71
|
end
|
67
|
-
|
72
|
+
|
68
73
|
end
|
69
74
|
end
|
75
|
+
|
76
|
+
|
77
|
+
register_instance_option :link_icon do
|
78
|
+
'icon-th-list'
|
79
|
+
end
|
70
80
|
end
|
71
81
|
end
|
72
82
|
end
|
@@ -3,21 +3,21 @@ module RailsAdmin
|
|
3
3
|
module Actions
|
4
4
|
class New < RailsAdmin::Config::Actions::Base
|
5
5
|
RailsAdmin::Config::Actions.register(self)
|
6
|
-
|
6
|
+
|
7
7
|
register_instance_option :collection do
|
8
8
|
true
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
register_instance_option :http_methods do
|
12
12
|
[:get, :post] # NEW / CREATE
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
register_instance_option :controller do
|
16
|
-
|
16
|
+
|
17
17
|
Proc.new do
|
18
|
-
|
18
|
+
|
19
19
|
if request.get? # NEW
|
20
|
-
|
20
|
+
|
21
21
|
@object = @abstract_model.new
|
22
22
|
@authorization_adapter && @authorization_adapter.attributes_for(:new, @abstract_model).each do |name, value|
|
23
23
|
@object.send("#{name}=", value)
|
@@ -29,12 +29,12 @@ module RailsAdmin
|
|
29
29
|
format.html { render @action.template_name }
|
30
30
|
format.js { render @action.template_name, :layout => false }
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
elsif request.post? # CREATE
|
34
|
-
|
34
|
+
|
35
35
|
@modified_assoc = []
|
36
36
|
@object = @abstract_model.new
|
37
|
-
@attributes = get_attributes
|
37
|
+
@attributes = get_attributes
|
38
38
|
@model_config.create.fields.each {|f| f.parse_input(@attributes) if f.respond_to?(:parse_input) }
|
39
39
|
@authorization_adapter && @authorization_adapter.attributes_for(:create, @abstract_model).each do |name, value|
|
40
40
|
@object.send("#{name}=", value)
|
@@ -50,10 +50,14 @@ module RailsAdmin
|
|
50
50
|
else
|
51
51
|
handle_save_error
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
57
|
+
|
58
|
+
register_instance_option :link_icon do
|
59
|
+
'icon-plus'
|
60
|
+
end
|
57
61
|
end
|
58
62
|
end
|
59
63
|
end
|
@@ -3,24 +3,29 @@ module RailsAdmin
|
|
3
3
|
module Actions
|
4
4
|
class Show < RailsAdmin::Config::Actions::Base
|
5
5
|
RailsAdmin::Config::Actions.register(self)
|
6
|
-
|
6
|
+
|
7
7
|
register_instance_option :member do
|
8
8
|
true
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
register_instance_option :route_fragment do
|
12
12
|
''
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
register_instance_option :breadcrumb_parent do
|
16
|
-
:index
|
16
|
+
[:index, bindings[:abstract_model]]
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
register_instance_option :controller do
|
20
20
|
Proc.new do
|
21
21
|
render @action.template_name
|
22
22
|
end
|
23
23
|
end
|
24
|
+
|
25
|
+
|
26
|
+
register_instance_option :link_icon do
|
27
|
+
'icon-info-sign'
|
28
|
+
end
|
24
29
|
end
|
25
30
|
end
|
26
31
|
end
|
@@ -3,20 +3,25 @@ module RailsAdmin
|
|
3
3
|
module Actions
|
4
4
|
class ShowInApp < RailsAdmin::Config::Actions::Base
|
5
5
|
RailsAdmin::Config::Actions.register(self)
|
6
|
-
|
6
|
+
|
7
7
|
register_instance_option :member do
|
8
8
|
true
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
register_instance_option :visible? do
|
12
|
-
bindings[:controller].main_app.url_for(bindings[:object]) rescue false
|
12
|
+
authorized? && (bindings[:controller].main_app.url_for(bindings[:object]) rescue false)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
register_instance_option :controller do
|
16
16
|
Proc.new do
|
17
17
|
redirect_to main_app.url_for(@object)
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
21
|
+
|
22
|
+
register_instance_option :link_icon do
|
23
|
+
'icon-eye-open'
|
24
|
+
end
|
20
25
|
end
|
21
26
|
end
|
22
27
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module RailsAdmin
|
2
2
|
module Config
|
3
3
|
module Actions
|
4
|
-
|
4
|
+
|
5
5
|
class << self
|
6
6
|
def all(scope = nil, bindings = {})
|
7
7
|
if scope.is_a?(Hash)
|
@@ -22,28 +22,28 @@ module RailsAdmin
|
|
22
22
|
when :member
|
23
23
|
@@actions.select(&:member?)
|
24
24
|
end
|
25
|
-
|
26
|
-
bindings[:controller] ? actions.
|
25
|
+
actions = actions.map{ |action| action.with(bindings) }
|
26
|
+
bindings[:controller] ? actions.select(&:visible?) : actions
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def find custom_key, bindings = {}
|
30
30
|
init_actions!
|
31
|
-
action = @@actions.find{ |a| a.custom_key == custom_key }
|
32
|
-
bindings[:controller] ? (action
|
31
|
+
action = @@actions.find{ |a| a.custom_key == custom_key }.with(bindings)
|
32
|
+
bindings[:controller] ? (action.try(:visible?) && action || nil) : action
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
def collection key, parent_class = :base, &block
|
36
36
|
add_action key, parent_class, :collection, &block
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
def member key, parent_class = :base, &block
|
40
40
|
add_action key, parent_class, :member, &block
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
def root key, parent_class = :base, &block
|
44
44
|
add_action key, parent_class, :root, &block
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
def add_action key, parent_class, parent, &block
|
48
48
|
a = "RailsAdmin::Config::Actions::#{parent_class.to_s.camelize}".constantize.new
|
49
49
|
a.instance_eval(%{
|
@@ -59,17 +59,17 @@ module RailsAdmin
|
|
59
59
|
raise "Action #{a.custom_key} already exist. Please change its custom key"
|
60
60
|
end
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
def reset
|
64
64
|
@@actions = nil
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
def register(name, klass = nil)
|
68
68
|
if klass == nil && name.kind_of?(Class)
|
69
69
|
klass = name
|
70
70
|
name = klass.to_s.demodulize.underscore.to_sym
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
instance_eval %{
|
74
74
|
def #{name}(&block)
|
75
75
|
action = #{klass}.new
|
@@ -82,9 +82,9 @@ module RailsAdmin
|
|
82
82
|
end
|
83
83
|
}
|
84
84
|
end
|
85
|
-
|
86
|
-
private
|
87
|
-
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
88
|
def init_actions!
|
89
89
|
@@actions ||= [
|
90
90
|
Dashboard.new,
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module RailsAdmin
|
2
|
+
module Config
|
3
|
+
# A module for all configurables.
|
4
|
+
|
5
|
+
module Configurable
|
6
|
+
def self.included(base)
|
7
|
+
base.send :extend, ClassMethods
|
8
|
+
end
|
9
|
+
|
10
|
+
def has_option?(name)
|
11
|
+
options = self.class.instance_variable_get("@config_options")
|
12
|
+
options && options.has_key?(name)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Register an instance option for this object only
|
16
|
+
def register_instance_option(option_name, &default)
|
17
|
+
scope = class << self; self; end;
|
18
|
+
self.class.register_instance_option(option_name, scope, &default)
|
19
|
+
end
|
20
|
+
|
21
|
+
def register_deprecated_instance_option(option_name, replacement_option_name)
|
22
|
+
scope = class << self; self; end;
|
23
|
+
self.class.register_deprecated_instance_option(option_name, replacement_option_name, scope)
|
24
|
+
end
|
25
|
+
|
26
|
+
module ClassMethods
|
27
|
+
# Register an instance option. Instance option is a configuration
|
28
|
+
# option that stores its value within an instance variable and is
|
29
|
+
# accessed by an instance method. Both go by the name of the option.
|
30
|
+
def register_instance_option(option_name, scope = self, &default)
|
31
|
+
unless options = scope.instance_variable_get("@config_options")
|
32
|
+
options = scope.instance_variable_set("@config_options", {})
|
33
|
+
end
|
34
|
+
|
35
|
+
option_name = option_name.to_s
|
36
|
+
|
37
|
+
options[option_name] = nil
|
38
|
+
|
39
|
+
# If it's a boolean create an alias for it and remove question mark
|
40
|
+
if "?" == option_name[-1, 1]
|
41
|
+
scope.send(:define_method, "#{option_name.chop!}?") do
|
42
|
+
send(option_name)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Define getter/setter by the option name
|
47
|
+
scope.send(:define_method, option_name) do |*args, &block|
|
48
|
+
if !args[0].nil? || block
|
49
|
+
# Invocation with args --> This is the declaration of the option, i.e. setter
|
50
|
+
instance_variable_set("@#{option_name}_registered", args[0].nil? ? block : args[0])
|
51
|
+
else
|
52
|
+
# Invocation without args nor block --> It's the use of the option, i.e. getter
|
53
|
+
value = instance_variable_get("@#{option_name}_registered")
|
54
|
+
case value
|
55
|
+
when Proc
|
56
|
+
# Track recursive invocation with an instance variable. This prevents run-away recursion
|
57
|
+
# and allows configurations such as
|
58
|
+
# label { "#{label}".upcase }
|
59
|
+
# This will use the default definition when called recursively.
|
60
|
+
if instance_variable_get("@#{option_name}_recurring")
|
61
|
+
value = instance_eval &default
|
62
|
+
else
|
63
|
+
instance_variable_set("@#{option_name}_recurring", true)
|
64
|
+
value = instance_eval &value
|
65
|
+
instance_variable_set("@#{option_name}_recurring", false)
|
66
|
+
end
|
67
|
+
when nil
|
68
|
+
value = instance_eval &default
|
69
|
+
end
|
70
|
+
value
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def register_deprecated_instance_option(option_name, replacement_option_name, scope = self)
|
76
|
+
scope.send(:define_method, option_name) do |*args, &block|
|
77
|
+
ActiveSupport::Deprecation.warn("The #{option_name} configuration option is deprecated, please use #{replacement_option_name}.")
|
78
|
+
send(replacement_option_name, *args, &block)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Register a class option. Class option is a configuration
|
83
|
+
# option that stores it's value within a class object's instance variable
|
84
|
+
# and is accessed by a class method. Both go by the name of the option.
|
85
|
+
def register_class_option(option_name, &default)
|
86
|
+
scope = class << self; self; end;
|
87
|
+
self.register_instance_option(option_name, scope, &default)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -27,14 +27,6 @@ module RailsAdmin
|
|
27
27
|
end.to_sentence.html_safe
|
28
28
|
end
|
29
29
|
|
30
|
-
register_instance_option(:sortable) do
|
31
|
-
false
|
32
|
-
end
|
33
|
-
|
34
|
-
register_instance_option(:searchable) do
|
35
|
-
false
|
36
|
-
end
|
37
|
-
|
38
30
|
# Accessor whether association is visible or not. By default
|
39
31
|
# association checks whether the child model is excluded in
|
40
32
|
# configuration or not.
|
@@ -64,7 +56,7 @@ module RailsAdmin
|
|
64
56
|
|
65
57
|
# Reader for the association's child model's configuration
|
66
58
|
def associated_model_config
|
67
|
-
@associated_model_config ||= RailsAdmin.config(association[:
|
59
|
+
@associated_model_config ||= RailsAdmin.config(association[:child_model_proc].call)
|
68
60
|
end
|
69
61
|
|
70
62
|
# Reader for the association's child model object's label method
|
@@ -82,24 +74,11 @@ module RailsAdmin
|
|
82
74
|
association[:inverse_of]
|
83
75
|
end
|
84
76
|
|
85
|
-
# we need to check for validation on method and on association
|
86
|
-
register_instance_option :required? do
|
87
|
-
@required ||= !!(abstract_model.model.validators_on(name) + abstract_model.model.validators_on(method_name)).find do |v|
|
88
|
-
v.is_a?(ActiveModel::Validations::PresenceValidator) && !v.options[:allow_nil] ||
|
89
|
-
v.is_a?(ActiveModel::Validations::NumericalityValidator) && !v.options[:allow_nil]
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
# Reader for validation errors of the bound object
|
94
|
-
def errors
|
95
|
-
bindings[:object].errors[association[:name]] + bindings[:object].errors[child_key]
|
96
|
-
end
|
97
|
-
|
98
77
|
# Reader whether this is a polymorphic association
|
99
78
|
def polymorphic?
|
100
79
|
association[:polymorphic]
|
101
80
|
end
|
102
|
-
|
81
|
+
|
103
82
|
# Reader for nested attributes
|
104
83
|
register_instance_option :nested_form do
|
105
84
|
association[:nested_form]
|
@@ -109,6 +88,10 @@ module RailsAdmin
|
|
109
88
|
def value
|
110
89
|
bindings[:object].send(association[:name])
|
111
90
|
end
|
91
|
+
|
92
|
+
def virtual?
|
93
|
+
true
|
94
|
+
end
|
112
95
|
end
|
113
96
|
end
|
114
97
|
end
|