drewda_rails_admin 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +53 -0
- data/LICENSE.md +20 -0
- data/README.md +160 -0
- data/Rakefile +19 -0
- data/app/assets/images/rails_admin/aristo/images/bg_fallback.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/icon_sprite.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/progress_bar.gif +0 -0
- data/app/assets/images/rails_admin/aristo/images/slider_handles.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/images/rails_admin/bullet_black.png +0 -0
- data/app/assets/images/rails_admin/bullet_white.png +0 -0
- data/app/assets/images/rails_admin/calendar.png +0 -0
- data/app/assets/images/rails_admin/clock.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_background.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_hex.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_hsb_b.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_hsb_h.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_hsb_s.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_indic.gif +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_overlay.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_rgb_b.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_rgb_g.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_rgb_r.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_select.gif +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_submit.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_background.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_hex.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_hsb_b.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_hsb_h.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_hsb_s.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_indic.gif +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_rgb_b.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_rgb_g.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_rgb_r.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_submit.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/select.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/select2.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/slider.png +0 -0
- data/app/assets/images/rails_admin/logo.png +0 -0
- data/app/assets/images/rails_admin/magnifier.png +0 -0
- data/app/assets/images/rails_admin/multiselect/icon_sprite.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-n-dark.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-n-light.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-s-dark.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-s-light.png +0 -0
- data/app/assets/javascripts/rails_admin/custom/ui.js +12 -0
- data/app/assets/javascripts/rails_admin/jquery.colorpicker.js +484 -0
- data/app/assets/javascripts/rails_admin/jquery.pjax.js +431 -0
- data/app/assets/javascripts/rails_admin/jquery.ui.timepicker.js +1371 -0
- data/app/assets/javascripts/rails_admin/ra.datetimepicker.js +67 -0
- data/app/assets/javascripts/rails_admin/ra.filter-box.js +129 -0
- data/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js +280 -0
- data/app/assets/javascripts/rails_admin/ra.filtering-select.js +181 -0
- data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.coffee +40 -0
- data/app/assets/javascripts/rails_admin/ra.remote-form.js +150 -0
- data/app/assets/javascripts/rails_admin/rails_admin.js.erb +25 -0
- data/app/assets/javascripts/rails_admin/themes/default/ui.js +12 -0
- data/app/assets/javascripts/rails_admin/ui.js.coffee +61 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/bg_fallback.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/icon_sprite.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/progress_bar.gif +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/slider_handles.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/jquery-ui-1.8.7.custom.css.scss +733 -0
- data/app/assets/stylesheets/rails_admin/base/README +2 -0
- data/app/assets/stylesheets/rails_admin/base/mixins.css.scss +1 -0
- data/app/assets/stylesheets/rails_admin/base/theming.css.scss +263 -0
- data/app/assets/stylesheets/rails_admin/base/variables.css.scss +1 -0
- data/app/assets/stylesheets/rails_admin/custom/mixins.css.scss +12 -0
- data/app/assets/stylesheets/rails_admin/custom/theming.css.scss +13 -0
- data/app/assets/stylesheets/rails_admin/custom/variables.css.scss +15 -0
- data/app/assets/stylesheets/rails_admin/imports.css.scss.erb +76 -0
- data/app/assets/stylesheets/rails_admin/jquery.colorpicker.css.scss +180 -0
- data/app/assets/stylesheets/rails_admin/jquery.ui.timepicker.css.scss +69 -0
- data/app/assets/stylesheets/rails_admin/ra.calendar-additions.css.scss +25 -0
- data/app/assets/stylesheets/rails_admin/ra.filtering-multiselect.css.scss +85 -0
- data/app/assets/stylesheets/rails_admin/rails_admin.css +4 -0
- data/app/assets/stylesheets/rails_admin/themes/default/mixins.css.scss +8 -0
- data/app/assets/stylesheets/rails_admin/themes/default/theming.css.scss +11 -0
- data/app/assets/stylesheets/rails_admin/themes/default/variables.css.scss +12 -0
- data/app/controllers/rails_admin/application_controller.rb +82 -0
- data/app/controllers/rails_admin/main_controller.rb +151 -0
- data/app/helpers/rails_admin/application_helper.rb +123 -0
- data/app/helpers/rails_admin/form_builder.rb +104 -0
- data/app/helpers/rails_admin/main_helper.rb +36 -0
- data/app/views/kaminari/twitter-bootstrap/_gap.html.haml +2 -0
- data/app/views/kaminari/twitter-bootstrap/_next_page.html.haml +4 -0
- data/app/views/kaminari/twitter-bootstrap/_page.html.haml +4 -0
- data/app/views/kaminari/twitter-bootstrap/_paginator.html.haml +10 -0
- data/app/views/kaminari/twitter-bootstrap/_prev_page.html.haml +4 -0
- data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +12 -0
- data/app/views/layouts/rails_admin/application.html.haml +39 -0
- data/app/views/rails_admin/main/_dashboard_history.html.haml +10 -0
- data/app/views/rails_admin/main/_delete_notice.html.haml +18 -0
- data/app/views/rails_admin/main/_form_colorpicker.html.haml +24 -0
- data/app/views/rails_admin/main/_form_datetime.html.haml +4 -0
- data/app/views/rails_admin/main/_form_enumeration.html.haml +4 -0
- data/app/views/rails_admin/main/_form_field.html.haml +1 -0
- data/app/views/rails_admin/main/_form_file_upload.html.haml +18 -0
- data/app/views/rails_admin/main/_form_filtering_multiselect.html.haml +59 -0
- data/app/views/rails_admin/main/_form_filtering_select.html.haml +47 -0
- data/app/views/rails_admin/main/_form_nested_many.html.haml +41 -0
- data/app/views/rails_admin/main/_form_nested_one.html.haml +35 -0
- data/app/views/rails_admin/main/_form_polymorphic_association.html.haml +34 -0
- data/app/views/rails_admin/main/_form_text.html.haml +9 -0
- data/app/views/rails_admin/main/_submit_buttons.html.haml +15 -0
- data/app/views/rails_admin/main/bulk_delete.html.haml +11 -0
- data/app/views/rails_admin/main/dashboard.html.haml +31 -0
- data/app/views/rails_admin/main/delete.html.haml +18 -0
- data/app/views/rails_admin/main/edit.html.haml +2 -0
- data/app/views/rails_admin/main/export.html.haml +75 -0
- data/app/views/rails_admin/main/history.html.haml +42 -0
- data/app/views/rails_admin/main/index.html.haml +140 -0
- data/app/views/rails_admin/main/new.html.haml +2 -0
- data/app/views/rails_admin/main/show.html.haml +14 -0
- data/config/initializers/active_record_extensions.rb +19 -0
- data/config/initializers/devise_patch.rb +9 -0
- data/config/initializers/haml.rb +2 -0
- data/config/initializers/mongoid_extensions.rb +4 -0
- data/config/locales/fr.yml +24 -0
- data/config/locales/rails_admin.en.yml +130 -0
- data/config/routes.rb +12 -0
- data/lib/generators/rails_admin/install_generator.rb +84 -0
- data/lib/generators/rails_admin/templates/drop.rb +18 -0
- data/lib/generators/rails_admin/templates/initializer.erb +101 -0
- data/lib/generators/rails_admin/templates/migration.rb +18 -0
- data/lib/generators/rails_admin/uninstall_generator.rb +22 -0
- data/lib/generators/rails_admin/utils.rb +30 -0
- data/lib/rails_admin.rb +34 -0
- data/lib/rails_admin/abstract_model.rb +110 -0
- data/lib/rails_admin/adapters/active_record.rb +247 -0
- data/lib/rails_admin/adapters/active_record/abstract_object.rb +32 -0
- data/lib/rails_admin/adapters/mongoid.rb +333 -0
- data/lib/rails_admin/adapters/mongoid/abstract_object.rb +32 -0
- data/lib/rails_admin/adapters/mongoid/extension.rb +27 -0
- data/lib/rails_admin/config.rb +322 -0
- data/lib/rails_admin/config/actions.rb +121 -0
- data/lib/rails_admin/config/actions/base.rb +117 -0
- data/lib/rails_admin/config/actions/bulk_delete.rb +55 -0
- data/lib/rails_admin/config/actions/dashboard.rb +44 -0
- data/lib/rails_admin/config/actions/delete.rb +53 -0
- data/lib/rails_admin/config/actions/edit.rb +60 -0
- data/lib/rails_admin/config/actions/export.rb +40 -0
- data/lib/rails_admin/config/actions/history_index.rb +38 -0
- data/lib/rails_admin/config/actions/history_show.rb +38 -0
- data/lib/rails_admin/config/actions/index.rb +85 -0
- data/lib/rails_admin/config/actions/new.rb +64 -0
- data/lib/rails_admin/config/actions/show.rb +32 -0
- data/lib/rails_admin/config/actions/show_in_app.rb +28 -0
- data/lib/rails_admin/config/configurable.rb +92 -0
- data/lib/rails_admin/config/fields.rb +88 -0
- data/lib/rails_admin/config/fields/association.rb +108 -0
- data/lib/rails_admin/config/fields/base.rb +281 -0
- data/lib/rails_admin/config/fields/factories/belongs_to_association.rb +29 -0
- data/lib/rails_admin/config/fields/factories/carrierwave.rb +31 -0
- data/lib/rails_admin/config/fields/factories/devise.rb +27 -0
- data/lib/rails_admin/config/fields/factories/dragonfly.rb +27 -0
- data/lib/rails_admin/config/fields/factories/enum.rb +11 -0
- data/lib/rails_admin/config/fields/factories/paperclip.rb +26 -0
- data/lib/rails_admin/config/fields/factories/password.rb +17 -0
- data/lib/rails_admin/config/fields/factories/serialized.rb +17 -0
- data/lib/rails_admin/config/fields/group.rb +78 -0
- data/lib/rails_admin/config/fields/types.rb +27 -0
- data/lib/rails_admin/config/fields/types/all.rb +26 -0
- data/lib/rails_admin/config/fields/types/belongs_to_association.rb +41 -0
- data/lib/rails_admin/config/fields/types/boolean.rb +31 -0
- data/lib/rails_admin/config/fields/types/bson_object_id.rb +42 -0
- data/lib/rails_admin/config/fields/types/carrierwave.rb +31 -0
- data/lib/rails_admin/config/fields/types/color.rb +37 -0
- data/lib/rails_admin/config/fields/types/date.rb +24 -0
- data/lib/rails_admin/config/fields/types/datetime.rb +165 -0
- data/lib/rails_admin/config/fields/types/decimal.rb +14 -0
- data/lib/rails_admin/config/fields/types/dragonfly.rb +41 -0
- data/lib/rails_admin/config/fields/types/enum.rb +35 -0
- data/lib/rails_admin/config/fields/types/file_upload.rb +61 -0
- data/lib/rails_admin/config/fields/types/float.rb +14 -0
- data/lib/rails_admin/config/fields/types/has_and_belongs_to_many_association.rb +14 -0
- data/lib/rails_admin/config/fields/types/has_many_association.rb +32 -0
- data/lib/rails_admin/config/fields/types/has_one_association.rb +39 -0
- data/lib/rails_admin/config/fields/types/hidden.rb +21 -0
- data/lib/rails_admin/config/fields/types/integer.rb +22 -0
- data/lib/rails_admin/config/fields/types/mongoid_type.rb +25 -0
- data/lib/rails_admin/config/fields/types/paperclip.rb +28 -0
- data/lib/rails_admin/config/fields/types/password.rb +39 -0
- data/lib/rails_admin/config/fields/types/polymorphic_association.rb +76 -0
- data/lib/rails_admin/config/fields/types/serialized.rb +22 -0
- data/lib/rails_admin/config/fields/types/string.rb +41 -0
- data/lib/rails_admin/config/fields/types/text.rb +36 -0
- data/lib/rails_admin/config/fields/types/time.rb +36 -0
- data/lib/rails_admin/config/fields/types/timestamp.rb +18 -0
- data/lib/rails_admin/config/groupable.rb +18 -0
- data/lib/rails_admin/config/has_fields.rb +135 -0
- data/lib/rails_admin/config/has_groups.rb +23 -0
- data/lib/rails_admin/config/hideable.rb +28 -0
- data/lib/rails_admin/config/model.rb +88 -0
- data/lib/rails_admin/config/proxyable.rb +12 -0
- data/lib/rails_admin/config/proxyable/proxy.rb +43 -0
- data/lib/rails_admin/config/sections.rb +38 -0
- data/lib/rails_admin/config/sections/base.rb +29 -0
- data/lib/rails_admin/config/sections/create.rb +11 -0
- data/lib/rails_admin/config/sections/edit.rb +11 -0
- data/lib/rails_admin/config/sections/export.rb +11 -0
- data/lib/rails_admin/config/sections/list.rb +27 -0
- data/lib/rails_admin/config/sections/nested.rb +10 -0
- data/lib/rails_admin/config/sections/show.rb +10 -0
- data/lib/rails_admin/config/sections/update.rb +10 -0
- data/lib/rails_admin/engine.rb +22 -0
- data/lib/rails_admin/extension.rb +29 -0
- data/lib/rails_admin/extensions/cancan.rb +5 -0
- data/lib/rails_admin/extensions/cancan/authorization_adapter.rb +59 -0
- data/lib/rails_admin/extensions/history.rb +5 -0
- data/lib/rails_admin/extensions/history/auditing_adapter.rb +37 -0
- data/lib/rails_admin/extensions/history/history.rb +69 -0
- data/lib/rails_admin/extensions/paper_trail.rb +5 -0
- data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +92 -0
- data/lib/rails_admin/i18n_support.rb +43 -0
- data/lib/rails_admin/support/core_extensions.rb +44 -0
- data/lib/rails_admin/support/csv_converter.rb +109 -0
- data/lib/rails_admin/version.rb +6 -0
- data/lib/tasks/prepare_ci_env.rake +27 -0
- data/lib/tasks/rails_admin.rake +18 -0
- data/spec/ci.sh +2 -0
- data/spec/controllers/application_controller_spec.rb +30 -0
- data/spec/controllers/main_controller_spec.rb +180 -0
- data/spec/database_helpers.rb +15 -0
- data/spec/dummy_app/Gemfile +58 -0
- data/spec/dummy_app/Rakefile +7 -0
- 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/application_controller.rb +3 -0
- data/spec/dummy_app/app/controllers/players_controller.rb +5 -0
- data/spec/dummy_app/app/helpers/application_helper.rb +2 -0
- data/spec/dummy_app/app/locales/models.en.yml +16 -0
- data/spec/dummy_app/app/models/abstract.rb +5 -0
- data/spec/dummy_app/app/models/article.rb +9 -0
- data/spec/dummy_app/app/models/author.rb +6 -0
- data/spec/dummy_app/app/models/ball.rb +8 -0
- data/spec/dummy_app/app/models/category.rb +3 -0
- data/spec/dummy_app/app/models/cms.rb +5 -0
- data/spec/dummy_app/app/models/cms/basic_page.rb +7 -0
- data/spec/dummy_app/app/models/cms/unscoped_page.rb +3 -0
- data/spec/dummy_app/app/models/comment.rb +3 -0
- data/spec/dummy_app/app/models/division.rb +12 -0
- data/spec/dummy_app/app/models/draft.rb +11 -0
- data/spec/dummy_app/app/models/fan.rb +5 -0
- data/spec/dummy_app/app/models/field_test.rb +20 -0
- data/spec/dummy_app/app/models/hardball.rb +2 -0
- data/spec/dummy_app/app/models/league.rb +10 -0
- data/spec/dummy_app/app/models/mongoid_field_test.rb +22 -0
- data/spec/dummy_app/app/models/nested_field_test.rb +6 -0
- data/spec/dummy_app/app/models/player.rb +23 -0
- data/spec/dummy_app/app/models/rel_test.rb +6 -0
- data/spec/dummy_app/app/models/tag.rb +7 -0
- data/spec/dummy_app/app/models/team.rb +25 -0
- data/spec/dummy_app/app/models/user.rb +21 -0
- data/spec/dummy_app/app/uploaders/carrierwave_uploader.rb +53 -0
- data/spec/dummy_app/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy_app/app/views/players/show.html.haml +1 -0
- data/spec/dummy_app/config.ru +4 -0
- data/spec/dummy_app/config/application.rb +62 -0
- data/spec/dummy_app/config/boot.rb +6 -0
- data/spec/dummy_app/config/database.yml +25 -0
- data/spec/dummy_app/config/environment.rb +5 -0
- data/spec/dummy_app/config/environments/development.rb +37 -0
- data/spec/dummy_app/config/environments/production.rb +67 -0
- data/spec/dummy_app/config/environments/test.rb +37 -0
- data/spec/dummy_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy_app/config/initializers/devise.rb +148 -0
- data/spec/dummy_app/config/initializers/inflections.rb +15 -0
- data/spec/dummy_app/config/initializers/mime_types.rb +5 -0
- data/spec/dummy_app/config/initializers/rails_admin.rb +11 -0
- data/spec/dummy_app/config/initializers/secret_token.rb +7 -0
- data/spec/dummy_app/config/initializers/session_store.rb +8 -0
- data/spec/dummy_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy_app/config/mongoid.yml +17 -0
- data/spec/dummy_app/config/routes.rb +10 -0
- data/spec/dummy_app/db/migrate/00000000000001_create_divisions_migration.rb +13 -0
- data/spec/dummy_app/db/migrate/00000000000002_create_drafts_migration.rb +19 -0
- data/spec/dummy_app/db/migrate/00000000000003_create_leagues_migration.rb +12 -0
- data/spec/dummy_app/db/migrate/00000000000004_create_players_migration.rb +20 -0
- data/spec/dummy_app/db/migrate/00000000000005_create_teams_migration.rb +22 -0
- data/spec/dummy_app/db/migrate/00000000000006_devise_create_users.rb +49 -0
- data/spec/dummy_app/db/migrate/00000000000007_create_histories_table.rb +16 -0
- data/spec/dummy_app/db/migrate/00000000000008_create_fans_migration.rb +12 -0
- data/spec/dummy_app/db/migrate/00000000000009_create_fans_teams_migration.rb +11 -0
- data/spec/dummy_app/db/migrate/00000000000010_add_revenue_to_team_migration.rb +9 -0
- data/spec/dummy_app/db/migrate/00000000000011_add_suspended_to_player_migration.rb +9 -0
- data/spec/dummy_app/db/migrate/00000000000012_add_avatar_columns_to_user.rb +16 -0
- data/spec/dummy_app/db/migrate/00000000000013_add_roles_to_user.rb +9 -0
- data/spec/dummy_app/db/migrate/00000000000014_add_color_to_team_migration.rb +9 -0
- data/spec/dummy_app/db/migrate/20101223222233_create_rel_tests.rb +15 -0
- data/spec/dummy_app/db/migrate/20110103205808_create_comments.rb +15 -0
- data/spec/dummy_app/db/migrate/20110123042530_rename_histories_to_rails_admin_histories.rb +9 -0
- data/spec/dummy_app/db/migrate/20110224184303_create_field_tests.rb +22 -0
- data/spec/dummy_app/db/migrate/20110328193014_create_cms_basic_pages.rb +14 -0
- data/spec/dummy_app/db/migrate/20110329183136_remove_league_id_from_teams.rb +9 -0
- data/spec/dummy_app/db/migrate/20110607152842_add_format_to_field_test.rb +9 -0
- data/spec/dummy_app/db/migrate/20110714095433_create_balls.rb +12 -0
- data/spec/dummy_app/db/migrate/20110831090841_add_protected_field_and_restricted_field_to_field_tests.rb +6 -0
- data/spec/dummy_app/db/migrate/20110901131551_change_division_primary_key.rb +19 -0
- data/spec/dummy_app/db/migrate/20110901142530_rename_league_id_foreign_key_on_divisions.rb +5 -0
- data/spec/dummy_app/db/migrate/20110901150912_set_primary_key_not_null_for_divisions.rb +21 -0
- data/spec/dummy_app/db/migrate/20110901154834_change_length_for_rails_admin_histories.rb +9 -0
- data/spec/dummy_app/db/migrate/20111103174459_create_unscoped_pages.rb +9 -0
- data/spec/dummy_app/db/migrate/20111108143642_add_dragonfly_and_carrierwave_to_field_tests.rb +7 -0
- data/spec/dummy_app/db/migrate/20111115041025_add_type_to_balls.rb +5 -0
- data/spec/dummy_app/db/migrate/20111123092549_create_nested_field_tests.rb +10 -0
- data/spec/dummy_app/db/migrate/20111130075338_add_dragonfly_asset_name_to_field_tests.rb +5 -0
- data/spec/dummy_app/db/migrate/20111215083258_create_foo_bars.rb +8 -0
- data/spec/dummy_app/db/migrate/20120117151733_add_custom_field_to_teams.rb +5 -0
- data/spec/dummy_app/db/migrate/20120118122004_add_categories.rb +7 -0
- data/spec/dummy_app/db/seeds.rb +18 -0
- data/spec/dummy_app/doc/README_FOR_APP +2 -0
- data/spec/dummy_app/public/404.html +26 -0
- data/spec/dummy_app/public/422.html +26 -0
- data/spec/dummy_app/public/500.html +25 -0
- data/spec/dummy_app/public/favicon.ico +0 -0
- data/spec/dummy_app/public/robots.txt +5 -0
- data/spec/dummy_app/public/system/dragonfly/development/2011/11/24/10_36_27_888_Pensive_Parakeet.jpg +0 -0
- data/spec/dummy_app/public/system/dragonfly/development/2011/11/24/10_36_27_888_Pensive_Parakeet.jpg.meta +1 -0
- data/spec/dummy_app/public/system/dragonfly/development/2011/11/30/08_54_39_906_Costa_Rican_Frog.jpg +0 -0
- data/spec/dummy_app/public/system/dragonfly/development/2011/11/30/08_54_39_906_Costa_Rican_Frog.jpg.meta +1 -0
- data/spec/dummy_app/public/system/paperclip_assets/1/original/Boston City Flow.jpg +0 -0
- data/spec/dummy_app/public/system/paperclip_assets/1/thumb/Boston City Flow.jpg +0 -0
- data/spec/dummy_app/public/system/paperclip_assets/3/original/Costa Rican Frog.jpg +0 -0
- data/spec/dummy_app/public/system/paperclip_assets/3/thumb/Costa Rican Frog.jpg +0 -0
- data/spec/dummy_app/public/system/paperclip_assets/6/original/liste-electorale.pdf +0 -0
- data/spec/dummy_app/public/system/paperclip_assets/6/thumb/liste-electorale.pdf +148 -0
- data/spec/dummy_app/public/uploads/field_test/carrierwave_asset/3/Boston_City_Flow.jpg +0 -0
- data/spec/dummy_app/public/uploads/field_test/carrierwave_asset/3/thumb_Boston_City_Flow.jpg +0 -0
- data/spec/dummy_app/public/uploads/field_test/carrierwave_asset/4/Costa_Rican_Frog.jpg +0 -0
- data/spec/dummy_app/public/uploads/field_test/carrierwave_asset/4/thumb_Costa_Rican_Frog.jpg +0 -0
- data/spec/dummy_app/public/uploads/field_test/carrierwave_asset/6/Pensive_Parakeet.jpg +0 -0
- data/spec/dummy_app/public/uploads/field_test/carrierwave_asset/6/thumb_Pensive_Parakeet.jpg +0 -0
- data/spec/dummy_app/script/rails +6 -0
- data/spec/factories.rb +89 -0
- data/spec/helpers/application_helper_spec.rb +277 -0
- data/spec/integration/authorization/cancan_spec.rb +349 -0
- data/spec/integration/basic/bulk_action/rails_admin_basic_bulk_action_spec.rb +25 -0
- data/spec/integration/basic/bulk_destroy/rails_admin_basic_bulk_destroy_spec.rb +44 -0
- data/spec/integration/basic/create/rails_admin_basic_create_spec.rb +154 -0
- data/spec/integration/basic/create/rails_admin_namespaced_model_create_spec.rb +23 -0
- data/spec/integration/basic/delete/rails_admin_basic_delete_spec.rb +27 -0
- data/spec/integration/basic/destroy/rails_admin_basic_destroy_spec.rb +56 -0
- data/spec/integration/basic/edit/rails_admin_basic_edit_spec.rb +109 -0
- data/spec/integration/basic/export/rails_admin_basic_export_spec.rb +87 -0
- data/spec/integration/basic/list/rails_admin_basic_list_spec.rb +392 -0
- data/spec/integration/basic/new/rails_admin_basic_new_spec.rb +74 -0
- data/spec/integration/basic/new/rails_admin_namespaced_model_new_spec.rb +31 -0
- data/spec/integration/basic/show/rails_admin_basic_show_spec.rb +91 -0
- data/spec/integration/basic/update/rails_admin_basic_update_spec.rb +219 -0
- data/spec/integration/config/edit/rails_admin_config_edit_spec.rb +954 -0
- data/spec/integration/config/list/rails_admin_config_list_spec.rb +509 -0
- data/spec/integration/config/show/rails_admin_config_show_spec.rb +302 -0
- data/spec/integration/history/rails_admin_history_spec.rb +66 -0
- data/spec/integration/rails_admin_spec.rb +113 -0
- data/spec/integration/relation_spec.rb +26 -0
- data/spec/spec_helper.rb +86 -0
- data/spec/support/tableless.rb +27 -0
- data/spec/unit/adapters/active_record/abstract_object_spec.rb +131 -0
- data/spec/unit/adapters/active_record_spec.rb +373 -0
- data/spec/unit/adapters/mongoid/abstract_object_spec.rb +30 -0
- data/spec/unit/adapters/mongoid_spec.rb +581 -0
- data/spec/unit/config/actions_spec.rb +181 -0
- data/spec/unit/config/fields/base_spec.rb +300 -0
- data/spec/unit/config/model_spec.rb +75 -0
- data/spec/unit/config/sections_spec.rb +123 -0
- data/spec/unit/config_spec.rb +273 -0
- metadata +823 -0
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'rails_admin/i18n_support'
|
2
|
+
|
3
|
+
module RailsAdmin
|
4
|
+
module ApplicationHelper
|
5
|
+
|
6
|
+
include RailsAdmin::I18nSupport
|
7
|
+
|
8
|
+
def authorized?(*args)
|
9
|
+
@authorization_adapter.nil? || @authorization_adapter.authorized?(*args)
|
10
|
+
end
|
11
|
+
|
12
|
+
def current_action?(action, abstract_model = @abstract_model, object = @object)
|
13
|
+
@action.custom_key == action.custom_key && abstract_model.try(:to_param) == @abstract_model.try(:to_param) && @object.try(:id) == object.try(:id)
|
14
|
+
end
|
15
|
+
|
16
|
+
def action(key, abstract_model = nil, object = nil)
|
17
|
+
RailsAdmin::Config::Actions.find(key, { :controller => self.controller, :abstract_model => abstract_model, :object => object })
|
18
|
+
end
|
19
|
+
|
20
|
+
def actions(scope = :all, abstract_model = nil, object = nil)
|
21
|
+
RailsAdmin::Config::Actions.all(scope, { :controller => self.controller, :abstract_model => abstract_model, :object => object })
|
22
|
+
end
|
23
|
+
|
24
|
+
def edit_user_link
|
25
|
+
return nil unless authorized?(:edit, _current_user.class, _current_user) && _current_user.respond_to?(:email)
|
26
|
+
return nil unless abstract_model = RailsAdmin.config(_current_user.class).abstract_model
|
27
|
+
return nil unless edit_action = RailsAdmin::Config::Actions.find(:edit, {:controller => self.controller, :abstract_model => abstract_model, :object => _current_user })
|
28
|
+
link_to _current_user.email, url_for(:action => edit_action.action_name, :model_name => abstract_model.to_param, :id => _current_user.id, :controller => 'rails_admin/main')
|
29
|
+
end
|
30
|
+
|
31
|
+
def wording_for(label, action = @action, abstract_model = @abstract_model, object = @object)
|
32
|
+
model_config = abstract_model.try(:config)
|
33
|
+
object = abstract_model && object.is_a?(abstract_model.model) ? object : nil
|
34
|
+
action = RailsAdmin::Config::Actions.find(action.to_sym) if (action.is_a?(Symbol) || action.is_a?(String))
|
35
|
+
|
36
|
+
I18n.t("admin.actions.#{action.i18n_key}.#{label}",
|
37
|
+
:model_label => model_config.try(:label),
|
38
|
+
:model_label_plural => model_config.try(:label_plural),
|
39
|
+
:object_label => model_config && object.try(model_config.object_label_method)
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def main_navigation
|
44
|
+
nodes_stack = RailsAdmin::Config.visible_models(:controller => self.controller)
|
45
|
+
nodes_stack.group_by(&:navigation_label).map do |navigation_label, nodes|
|
46
|
+
|
47
|
+
%{<li class='nav-header'>#{navigation_label || t('admin.misc.navigation')}</li>}.html_safe +
|
48
|
+
nodes.select{|n| n.parent.nil? || !n.parent.to_s.in?(nodes_stack.map{|c| c.abstract_model.model_name }) }.map do |node|
|
49
|
+
%{
|
50
|
+
<li#{' class="active"' if node == @model_config }>
|
51
|
+
<a href="#{url_for(:action => :index, :controller => 'rails_admin/main', :model_name => node.abstract_model.to_param)}">#{node.label_plural}</a>
|
52
|
+
</li>
|
53
|
+
#{navigation(nodes_stack, nodes_stack.select{|n| n.parent.to_s == node.abstract_model.model_name}, 1)}
|
54
|
+
}.html_safe
|
55
|
+
end.join.html_safe
|
56
|
+
end.join.html_safe
|
57
|
+
end
|
58
|
+
|
59
|
+
def navigation nodes_stack, nodes, level
|
60
|
+
nodes.map do |node|
|
61
|
+
%{
|
62
|
+
<li#{' class="active"' if node == @model_config }>
|
63
|
+
<a class="nav-level-#{level}" href="#{url_for(:action => :index, :controller => 'rails_admin/main', :model_name => node.abstract_model.to_param)}">#{node.label_plural}</a>
|
64
|
+
</li>
|
65
|
+
#{navigation(nodes_stack, nodes_stack.select{ |n| n.parent.to_s == node.abstract_model.model_name}, level + 1)}
|
66
|
+
}.html_safe
|
67
|
+
end.join
|
68
|
+
end
|
69
|
+
|
70
|
+
def breadcrumb action = @action, acc = []
|
71
|
+
begin
|
72
|
+
(parent_actions ||= []) << action
|
73
|
+
end while action.breadcrumb_parent && (action = action(*action.breadcrumb_parent))
|
74
|
+
parent_actions << action(:dashboard) if parent_actions.last.key != :dashboard # in case chain is interrupted
|
75
|
+
|
76
|
+
content_tag(:ul, :class => "breadcrumb") do
|
77
|
+
parent_actions.map do |a|
|
78
|
+
am = a.send(:eval, 'bindings[:abstract_model]')
|
79
|
+
o = a.send(:eval, 'bindings[:object]')
|
80
|
+
content_tag(:li, :class => "#{"active" if current_action?(a, am, o)}") do
|
81
|
+
if a.http_methods.include?(:get)
|
82
|
+
link_to wording_for(:breadcrumb, a, am, o), { :action => a.action_name, :controller => 'rails_admin/main', :model_name => am.try(:to_param), :id => o.try(:id) }
|
83
|
+
else
|
84
|
+
content_tag(:span, wording_for(:breadcrumb, a, am, o))
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end.reverse.join('<span class="divider">/</span>').html_safe
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# parent => :root, :collection, :member
|
92
|
+
def menu_for(parent, abstract_model = nil, object = nil, only_icon = false) # perf matters here (no action view trickery)
|
93
|
+
actions = actions(parent, abstract_model, object).select{ |a| a.http_methods.include?(:get) }
|
94
|
+
actions.map do |action|
|
95
|
+
wording = wording_for(:menu, action)
|
96
|
+
%{
|
97
|
+
<li data-original-title="#{wording}" rel="#{'tooltip' if only_icon}" class="icon #{action.key}_#{parent}_link #{'active' if current_action?(action)}">
|
98
|
+
<a href="#{url_for({ :action => action.action_name, :controller => 'rails_admin/main', :model_name => abstract_model.try(:to_param), :id => object.try(:id) })}">
|
99
|
+
<i class="#{action.link_icon}"></i>
|
100
|
+
<span#{only_icon ? " style='display:none'" : ""}>#{wording}</span>
|
101
|
+
</a>
|
102
|
+
</li>
|
103
|
+
}
|
104
|
+
end.join.html_safe
|
105
|
+
end
|
106
|
+
|
107
|
+
def bulk_menu abstract_model = @abstract_model
|
108
|
+
actions = actions(:bulkable, abstract_model)
|
109
|
+
return '' if actions.empty?
|
110
|
+
content_tag :li, { :class => 'dropdown', :style => 'float:right' } do
|
111
|
+
content_tag(:a, { :class => 'dropdown-toggle', :'data-toggle' => "dropdown", :href => '#' }) { t('admin.misc.bulk_menu_title').html_safe + '<b class="caret"></b>'.html_safe } +
|
112
|
+
content_tag(:ul, :class => 'dropdown-menu', :style => 'left:auto; right:0;') do
|
113
|
+
actions.map do |action|
|
114
|
+
content_tag :li do
|
115
|
+
link_to_function wording_for(:bulk_link, action), "jQuery('#bulk_action').val('#{action.action_name}'); jQuery('#bulk_form').submit()"
|
116
|
+
end
|
117
|
+
end.join.html_safe
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
@@ -0,0 +1,104 @@
|
|
1
|
+
ActionView::Base.field_error_proc = Proc.new { |html_tag, instance| html_tag }
|
2
|
+
|
3
|
+
module RailsAdmin
|
4
|
+
class FormBuilder < ::ActionView::Helpers::FormBuilder
|
5
|
+
include ::NestedForm::BuilderMixin
|
6
|
+
|
7
|
+
def generate(options = {})
|
8
|
+
options.reverse_merge!({
|
9
|
+
:action => @template.controller.params[:action],
|
10
|
+
:model_config => @template.instance_variable_get(:@model_config),
|
11
|
+
:nested_in => false
|
12
|
+
})
|
13
|
+
groups = options[:model_config].send(options[:nested_in] ? :nested : options[:action]).with(:form => self, :object => @object, :view => @template).visible_groups
|
14
|
+
|
15
|
+
object_infos +
|
16
|
+
groups.map do |fieldset|
|
17
|
+
fieldset_for fieldset, options[:nested_in]
|
18
|
+
end.join.html_safe +
|
19
|
+
(options[:nested_in] ? '' : @template.render(:partial => 'submit_buttons'))
|
20
|
+
end
|
21
|
+
|
22
|
+
def fieldset_for fieldset, nested_in
|
23
|
+
if (fields = fieldset.with(:form => self, :object => @object, :view => @template).visible_fields).length > 0
|
24
|
+
@template.content_tag :fieldset do
|
25
|
+
contents = []
|
26
|
+
contents << @template.content_tag(:legend, %{<i class="icon-chevron-#{(fieldset.active? ? 'down' : 'right')}"></i> #{fieldset.label}}.html_safe, :style => "#{fieldset.label == I18n.translate("admin.form.basic_info") ? 'display:none' : ''}")
|
27
|
+
contents << @template.content_tag(:p, fieldset.help) if fieldset.help.present?
|
28
|
+
contents << fields.map{ |field| field_wrapper_for(field, nested_in) }.join
|
29
|
+
contents.join.html_safe
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def field_wrapper_for field, nested_in
|
35
|
+
# do not show nested field if the target is the origin
|
36
|
+
unless field.inverse_of.presence && field.inverse_of == nested_in
|
37
|
+
@template.content_tag(:div, :class => "control-group #{field.type_css_class} #{field.css_class} #{'error' if field.errors.present?}", :id => "#{dom_id(field)}_field") do
|
38
|
+
label(field.method_name, field.label, :class => 'control-label') +
|
39
|
+
(field.nested_form ? field_for(field) : input_for(field))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def input_for field
|
45
|
+
@template.content_tag(:div, :class => 'controls') do
|
46
|
+
field_for(field) +
|
47
|
+
errors_for(field) +
|
48
|
+
help_for(field)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def errors_for field
|
53
|
+
field.errors.present? ? @template.content_tag(:span, "#{field.label} #{field.errors.to_sentence}", :class => 'help-inline') : ''.html_safe
|
54
|
+
end
|
55
|
+
|
56
|
+
def help_for field
|
57
|
+
field.help.present? ? @template.content_tag(:p, field.help, :class => 'help-block') : ''.html_safe
|
58
|
+
end
|
59
|
+
|
60
|
+
def field_for field
|
61
|
+
if field.read_only?
|
62
|
+
field.pretty_value.to_s.html_safe
|
63
|
+
else
|
64
|
+
field.render
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def object_infos
|
69
|
+
model_config = RailsAdmin.config(object)
|
70
|
+
model_label = model_config.label
|
71
|
+
object_label = (object.new_record? ? I18n.t('admin.form.new_model', :name => model_label) : object.send(model_config.object_label_method).presence || "#{model_config.label} ##{object.id}")
|
72
|
+
%{<span style="display:none" class="object-infos" data-model-label="#{model_label}" data-object-label="#{object_label}"></span>}.html_safe
|
73
|
+
end
|
74
|
+
|
75
|
+
def javascript_for(field, options = {}, &block)
|
76
|
+
%{<script type="text/javascript">
|
77
|
+
jQuery(function($) {
|
78
|
+
if(!$("#{jquery_namespace(field)}").parents(".fields_blueprint").length) {
|
79
|
+
if(#{options[:modal] == false ? '!$("#modal").length' : 'true'}) {
|
80
|
+
#{@template.capture(&block)}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
});
|
84
|
+
</script>}.html_safe
|
85
|
+
end
|
86
|
+
|
87
|
+
def jquery_namespace field
|
88
|
+
%{#{(@template.controller.params[:modal] ? '#modal ' : '')}##{dom_id(field)}_field}
|
89
|
+
end
|
90
|
+
|
91
|
+
def dom_id field
|
92
|
+
(@dom_id ||= {})[field.name] ||=
|
93
|
+
[
|
94
|
+
@object_name.to_s.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, ""),
|
95
|
+
options[:index],
|
96
|
+
field.method_name
|
97
|
+
].reject(&:blank?).join('_')
|
98
|
+
end
|
99
|
+
|
100
|
+
def dom_name field
|
101
|
+
(@dom_name ||= {})[field.name] ||= %{#{@object_name}#{options[:index] && "[#{options[:index]}]"}[#{field.method_name}]#{field.is_a?(Config::Fields::Association) && field.multiple? ? '[]' : ''}}
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'builder'
|
2
|
+
|
3
|
+
module RailsAdmin
|
4
|
+
module MainHelper
|
5
|
+
def rails_admin_form_for(*args, &block)
|
6
|
+
options = args.extract_options!.reverse_merge(:builder => RailsAdmin::FormBuilder)
|
7
|
+
form_for(*(args << options), &block) << after_nested_form_callbacks
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_indicator(percent)
|
11
|
+
return "" if percent < 0 # none
|
12
|
+
return "info" if percent < 34 # < 1/100 of max
|
13
|
+
return "success" if percent < 67 # < 1/10 of max
|
14
|
+
return "warning" if percent < 84 # < 1/3 of max
|
15
|
+
return "important" # > 1/3 of max
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_column_sets(properties)
|
19
|
+
sets = []
|
20
|
+
property_index = 0
|
21
|
+
set_index = 0
|
22
|
+
|
23
|
+
while (property_index < properties.length)
|
24
|
+
current_set_width = 0
|
25
|
+
begin
|
26
|
+
sets[set_index] ||= []
|
27
|
+
sets[set_index] << properties[property_index]
|
28
|
+
current_set_width += (properties[property_index].column_width || 120)
|
29
|
+
property_index += 1
|
30
|
+
end while (current_set_width < RailsAdmin::Config.total_columns_width) && (property_index < properties.length)
|
31
|
+
set_index += 1
|
32
|
+
end
|
33
|
+
sets
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
%ul.nav.pull-right
|
2
|
+
- actions(:root).each do |action|
|
3
|
+
%li= link_to wording_for(:menu, action), { :action => action.action_name, :controller => 'rails_admin/main' }
|
4
|
+
- if main_app_root_path = (main_app.root_path rescue false)
|
5
|
+
%li= link_to t('home.name').capitalize, main_app_root_path
|
6
|
+
- if _current_user
|
7
|
+
- if user_link = edit_user_link
|
8
|
+
%li= user_link
|
9
|
+
- if defined?(Devise) && (devise_scope = request.env["warden"].config[:default_scope] rescue false) && (logout_path = main_app.send("destroy_#{devise_scope}_session_path") rescue false)
|
10
|
+
%li= link_to content_tag('span', t('admin.misc.log_out'), :class => 'label label-important'), logout_path, :method => Devise.sign_out_via
|
11
|
+
- if _current_user.respond_to?(:email)
|
12
|
+
%li= image_tag "#{(request.ssl? ? 'https://secure' : 'http://www')}.gravatar.com/avatar/#{Digest::MD5.hexdigest _current_user.email}?s=30", :style => 'padding-top:5px'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
!!! 5
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%title= "#{@abstract_model.try(:pretty_name) || @page_name} | #{[_get_plugin_name[0] || 'Rails', _get_plugin_name[1] || 'Admin'].join(' ')}"
|
5
|
+
%meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
|
6
|
+
%meta{:content => "NONE,NOARCHIVE", :name => "robots"}
|
7
|
+
= csrf_meta_tag
|
8
|
+
= stylesheet_link_tag "rails_admin/rails_admin.css", :media => :all
|
9
|
+
= javascript_include_tag "rails_admin/rails_admin.js"
|
10
|
+
%body.rails_admin
|
11
|
+
.navbar.navbar-fixed-top
|
12
|
+
.navbar-inner
|
13
|
+
.container-fluid
|
14
|
+
%a.brand{:href => dashboard_path}
|
15
|
+
= _get_plugin_name[0] || 'Rails'
|
16
|
+
%small= _get_plugin_name[1] || 'Admin'
|
17
|
+
.nav-collapse
|
18
|
+
= render :partial => 'layouts/rails_admin/secondary_navigation'
|
19
|
+
.container-fluid
|
20
|
+
.row-fluid
|
21
|
+
.span3
|
22
|
+
.well.sidebar-nav
|
23
|
+
%ul.nav.nav-list= main_navigation
|
24
|
+
.span9
|
25
|
+
.row-fluid
|
26
|
+
.content
|
27
|
+
.page-header
|
28
|
+
%h1= @page_name
|
29
|
+
- flash && flash.each do |key, value|
|
30
|
+
.alert{:class => "alert-#{key}"}
|
31
|
+
%a.close{:href => '#', :'data-dismiss' => "alert"}×
|
32
|
+
= value
|
33
|
+
= breadcrumb
|
34
|
+
%ul.nav.nav-tabs
|
35
|
+
= menu_for((@abstract_model ? (@object.try(:id) ? :member : :collection) : :root), @abstract_model, @object)
|
36
|
+
= content_for :contextual_tabs
|
37
|
+
= yield
|
38
|
+
%footer
|
39
|
+
%p © RailsAdmin 2012
|
@@ -0,0 +1,10 @@
|
|
1
|
+
%table.table.table-condensed.table-striped
|
2
|
+
%thead
|
3
|
+
%tr
|
4
|
+
%th.shrink.user= t("admin.table_headers.username")
|
5
|
+
%th.changes= t("admin.table_headers.changes")
|
6
|
+
%tbody
|
7
|
+
- @history.each do |t|
|
8
|
+
%tr
|
9
|
+
%td= t.try :username
|
10
|
+
%td= "#{m = t.message.try(:downcase)} #{m.to_s.rindex("changed") ? "for #{t.table.capitalize} ##{t.item}" : ''}"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
- object = delete_notice
|
2
|
+
|
3
|
+
%li{:style => 'display:block; margin-top:10px'}
|
4
|
+
%span.label= @abstract_model.pretty_name
|
5
|
+
= link_to @model_config.with(:object => object).object_label, show_path(:model_name => @abstract_model.to_param, :id => object.id)
|
6
|
+
%ul
|
7
|
+
- @abstract_model.associations.select{|a| a[:type] == :has_many }.each do |association|
|
8
|
+
- object.send(association[:name]).each do |child|
|
9
|
+
%li
|
10
|
+
- child_config = RailsAdmin.config(child)
|
11
|
+
= association[:pretty_name]
|
12
|
+
= link_to(child_config.with(:object => child).object_label, show_path(:model_name => child_config.abstract_model.to_param, :id => child.id))
|
13
|
+
- @abstract_model.associations.select{|a| a[:type] == :has_one }.each do |association|
|
14
|
+
- if child = object.send(association[:name])
|
15
|
+
%li
|
16
|
+
- child_config = RailsAdmin.config(child)
|
17
|
+
= association[:pretty_name]
|
18
|
+
= link_to(child_config.with(:object => child).object_label, show_path(:model_name => child_config.abstract_model.to_param, :id => child.id))
|
@@ -0,0 +1,24 @@
|
|
1
|
+
- html_attributes = field.html_attributes.reverse_merge({:style => "background-color: #{field.color}"}).reverse_merge((hdv = field.html_default_value).nil? ? {} : { :value => hdv })
|
2
|
+
= form.send field.view_helper, field.method_name, html_attributes
|
3
|
+
|
4
|
+
= javascript_include_tag asset_path 'rails_admin/jquery.colorpicker.js'
|
5
|
+
= stylesheet_link_tag asset_path 'rails_admin/jquery.colorpicker.css'
|
6
|
+
= form.javascript_for(field) do
|
7
|
+
:plain
|
8
|
+
var input = $('#{ form.jquery_namespace(field) } input')
|
9
|
+
input.css('backgroundColor', '#' + input.val());
|
10
|
+
input.ColorPicker({
|
11
|
+
color: input.val(),
|
12
|
+
onShow: function (el) {
|
13
|
+
$(el).fadeIn(500);
|
14
|
+
return false;
|
15
|
+
},
|
16
|
+
onHide: function (el) {
|
17
|
+
$(el).fadeOut(500);
|
18
|
+
return false;
|
19
|
+
},
|
20
|
+
onChange: function (hsb, hex, rgb) {
|
21
|
+
input.val(hex);
|
22
|
+
input.css('backgroundColor', '#' + hex);
|
23
|
+
}
|
24
|
+
});
|
@@ -0,0 +1,4 @@
|
|
1
|
+
= form.send field.view_helper, field.method_name, field.html_attributes.reverse_merge((hdv = field.html_default_value).nil? ? {} : { :value => hdv })
|
2
|
+
= form.javascript_for(field) do
|
3
|
+
:plain
|
4
|
+
$("#{form.jquery_namespace(field)} input").datetimepicker(#{field.js_plugin_options.html_safe});
|
@@ -0,0 +1,4 @@
|
|
1
|
+
= form.select field.method_name, field.enum, { :include_blank => true }.merge((hdv = field.html_default_value).nil? ? {} : { :selected => hdv }), field.html_attributes.reverse_merge({ :placeholder => t('admin.misc.search') })
|
2
|
+
= form.javascript_for(field) do
|
3
|
+
:plain
|
4
|
+
$("#{form.jquery_namespace(field)} select").filteringSelect({});
|
@@ -0,0 +1 @@
|
|
1
|
+
= form.send field.view_helper, field.method_name, field.html_attributes.reverse_merge((hdv = field.html_default_value).nil? ? {} : { :value => hdv, :checked => hdv })
|
@@ -0,0 +1,18 @@
|
|
1
|
+
- file = form.object.send(field.method_name).presence
|
2
|
+
|
3
|
+
.toggle{:style => ('display:none;' if file && field.delete_method && form.object.send(field.delete_method) == '1')}
|
4
|
+
- if value = field.pretty_value
|
5
|
+
= value
|
6
|
+
= form.file_field(field.name, field.html_attributes)
|
7
|
+
- if field.optional? && field.errors.blank? && file && field.delete_method
|
8
|
+
%a.btn.btn-info{:href => '#', :'data-toggle' => 'button', :onclick => "$(this).siblings('[type=checkbox]').click(); $(this).siblings('.toggle').toggle('slow'); jQuery(this).toggleClass('btn-danger btn-info'); return false"}
|
9
|
+
%i.icon-white.icon-trash
|
10
|
+
= I18n.t('admin.actions.delete.menu').capitalize + " #{field.method_name}"
|
11
|
+
= form.check_box(field.delete_method, :style => 'display:none;' )
|
12
|
+
- if field.cache_method
|
13
|
+
= form.hidden_field(field.cache_method)
|
14
|
+
= form.javascript_for(field) do
|
15
|
+
:plain
|
16
|
+
$("#{form.jquery_namespace(field)} .delete input[type='checkbox']").live('click', function() {
|
17
|
+
$(this).parents('.input').first().children('.toggle').toggle('slow');
|
18
|
+
});
|
@@ -0,0 +1,59 @@
|
|
1
|
+
:ruby
|
2
|
+
related_id = params[:associations] && params[:associations][field.name.to_s]
|
3
|
+
config = field.associated_model_config
|
4
|
+
source_abstract_model = RailsAdmin.config(form.object.class).abstract_model
|
5
|
+
|
6
|
+
if form.object.new_record? && related_id.present? && related_id != 'new'
|
7
|
+
selected = [config.abstract_model.get(related_id)]
|
8
|
+
else
|
9
|
+
selected = form.object.send(field.name)
|
10
|
+
end
|
11
|
+
selected_ids = selected.map{|s| s.send(field.associated_primary_key)}
|
12
|
+
|
13
|
+
|
14
|
+
current_action = params[:action].in?(['create', 'new']) ? 'create' : 'update'
|
15
|
+
|
16
|
+
edit_url = authorized?(:edit, config.abstract_model) ? edit_path(:model_name => config.abstract_model.to_param, :id => '__ID__') : ''
|
17
|
+
|
18
|
+
xhr = !field.associated_collection_cache_all
|
19
|
+
|
20
|
+
collection = if xhr
|
21
|
+
selected.map { |o| [o.send(field.associated_object_label_method), o.send(field.associated_primary_key)] }
|
22
|
+
else
|
23
|
+
i = 0
|
24
|
+
controller.list_entries(config, :index, field.associated_collection_scope, false).map { |o| [o.send(field.associated_object_label_method), o.send(field.associated_primary_key)] }.sort_by {|a| [selected_ids.index(a[1]) || selected_ids.size, i+=1] }
|
25
|
+
end
|
26
|
+
|
27
|
+
%input{:name => form.dom_name(field), :type => "hidden", :value => ""}
|
28
|
+
|
29
|
+
- selected_ids = (hdv = field.html_default_value).nil? ? selected_ids : hdv
|
30
|
+
= form.select field.method_name, collection, { :selected => selected_ids, :object => form.object }, field.html_attributes.merge({:'data-edit-url' => edit_url, :multiple => true})
|
31
|
+
- if authorized? :new, config.abstract_model
|
32
|
+
- path_hash = { :model_name => config.abstract_model.to_param, :modal => true }
|
33
|
+
- path_hash.merge!({ :associations => { field.inverse_of => (form.object.id || 'new') } }) if field.inverse_of
|
34
|
+
= link_to "<i class=\"icon-plus icon-white\"></i> ".html_safe + wording_for(:link, :new, config.abstract_model), '#', :data => { :link => new_path(path_hash) }, :class => "create btn btn-info", :style => 'margin-left:10px'
|
35
|
+
|
36
|
+
= form.javascript_for(field) do
|
37
|
+
:plain
|
38
|
+
$("#{form.jquery_namespace(field)} select").filteringMultiselect({
|
39
|
+
xhr: #{xhr},
|
40
|
+
createQuery: function(query) {
|
41
|
+
return { query: query }
|
42
|
+
},
|
43
|
+
remote_source: "#{index_path(config.abstract_model, :source_object_id => form.object.id, :source_abstract_model => source_abstract_model.to_param, :associated_collection => field.name, :current_action => current_action, :compact => true).html_safe}",
|
44
|
+
sortable: #{field.orderable ? 'true' : 'false'},
|
45
|
+
cacheAll: #{field.associated_collection_cache_all ? 'true' : 'false'},
|
46
|
+
regional: {
|
47
|
+
chooseAll: "#{t("admin.misc.chose_all")}",
|
48
|
+
chosen: "#{t("admin.misc.chosen", :name => config.label_plural)}",
|
49
|
+
clearAll: "#{t("admin.misc.clear_all")}",
|
50
|
+
search: "#{t("admin.misc.search")}",
|
51
|
+
up: "#{t("admin.misc.up")}",
|
52
|
+
down: "#{t("admin.misc.down")}"
|
53
|
+
}
|
54
|
+
});
|
55
|
+
if($("#modal").length) { // hide link if we already are inside a dialog (endless issues on nested dialogs with JS)
|
56
|
+
$("#{form.jquery_namespace(field)} .btn").remove();
|
57
|
+
} else {
|
58
|
+
$("#{form.jquery_namespace(field)}").remoteForm();
|
59
|
+
}
|