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,67 @@
|
|
1
|
+
/*
|
2
|
+
* RailsAdmin date/time picker @VERSION
|
3
|
+
*
|
4
|
+
* License
|
5
|
+
*
|
6
|
+
* http://www.railsadmin.org
|
7
|
+
*
|
8
|
+
* Depends:
|
9
|
+
* jquery.ui.core.js
|
10
|
+
* jquery.ui.widget.js
|
11
|
+
* jquery.ui.datepicker.js
|
12
|
+
* jquery.ui.timepicker.js (http://plugins.jquery.com/project/timepicker-by-fgelinas)
|
13
|
+
*/
|
14
|
+
(function($) {
|
15
|
+
|
16
|
+
$.widget("ra.datetimepicker", {
|
17
|
+
options: {
|
18
|
+
showDate: true,
|
19
|
+
showTime: true,
|
20
|
+
datepicker: {},
|
21
|
+
timepicker: {}
|
22
|
+
},
|
23
|
+
|
24
|
+
_create: function() {
|
25
|
+
var widget = this;
|
26
|
+
this.element.hide();
|
27
|
+
|
28
|
+
if (this.options.showTime) {
|
29
|
+
this.timepicker = $('<input class="TIMEPICKER" type="text" value="' + this.options.timepicker.value + '" />');
|
30
|
+
|
31
|
+
this.timepicker.css("width", "60px");
|
32
|
+
|
33
|
+
this.timepicker.insertAfter(this.element);
|
34
|
+
|
35
|
+
this.timepicker.bind("change", function() { widget._onChange(); });
|
36
|
+
|
37
|
+
this.timepicker.timepicker(this.options.timepicker);
|
38
|
+
}
|
39
|
+
|
40
|
+
if (this.options.showDate) {
|
41
|
+
this.datepicker = $('<input type="text" value="' + this.options.datepicker.value + '" />');
|
42
|
+
|
43
|
+
this.datepicker.css("margin-right", "10px");
|
44
|
+
|
45
|
+
this.datepicker.insertAfter(this.element);
|
46
|
+
|
47
|
+
this.datepicker.bind("change", function() { widget._onChange(); });
|
48
|
+
|
49
|
+
this.datepicker.datepicker(this.options.datepicker);
|
50
|
+
}
|
51
|
+
},
|
52
|
+
|
53
|
+
_onChange: function() {
|
54
|
+
var value = [];
|
55
|
+
|
56
|
+
if (this.options.showDate) {
|
57
|
+
value.push(this.datepicker.val());
|
58
|
+
}
|
59
|
+
|
60
|
+
if (this.options.showTime) {
|
61
|
+
value.push(this.timepicker.val());
|
62
|
+
}
|
63
|
+
|
64
|
+
this.element.val(value.join(" "));
|
65
|
+
}
|
66
|
+
});
|
67
|
+
})(jQuery);
|
@@ -0,0 +1,129 @@
|
|
1
|
+
(function($) {
|
2
|
+
|
3
|
+
var filters;
|
4
|
+
|
5
|
+
$.filters = filters = {
|
6
|
+
options: {
|
7
|
+
regional: {
|
8
|
+
datePicker: {
|
9
|
+
dateFormat: 'mm/dd/yy'
|
10
|
+
}
|
11
|
+
}
|
12
|
+
},
|
13
|
+
|
14
|
+
append: function(field_label, field_name, field_type, field_value, field_operator, field_options, index) {
|
15
|
+
var value_name = 'f[' + field_name + '][' + index + '][v]';
|
16
|
+
var operator_name = 'f[' + field_name + '][' + index + '][o]';
|
17
|
+
switch(field_type) {
|
18
|
+
case 'boolean':
|
19
|
+
var control = '<select class="input-small" name="' + value_name + '">' +
|
20
|
+
'<option value="_discard">...</option>' +
|
21
|
+
'<option value="true"' + (field_value == "true" ? 'selected="selected"' : '') + '>True</option>' +
|
22
|
+
'<option value="false"' + (field_value == "false" ? 'selected="selected"' : '') + '>False</option>' +
|
23
|
+
'<option disabled="disabled">---------</option>' +
|
24
|
+
'<option ' + (field_value == "_present" ? 'selected="selected"' : '') + ' value="_present">Is present</option>' +
|
25
|
+
'<option ' + (field_value == "_blank" ? 'selected="selected"' : '') + ' value="_blank" >Is blank</option>' +
|
26
|
+
'</select>';
|
27
|
+
break;
|
28
|
+
case 'date':
|
29
|
+
case 'datetime':
|
30
|
+
case 'timestamp':
|
31
|
+
var control = '<select class="switch-additionnal-fieldsets input-small" name="' + operator_name + '">' +
|
32
|
+
'<option ' + (field_operator == "default" ? 'selected="selected"' : '') + ' data-additional-fieldset="default" value="default">Date ...</option>' +
|
33
|
+
'<option ' + (field_operator == "between" ? 'selected="selected"' : '') + ' data-additional-fieldset="between" value="between">Between ... and ...</option>' +
|
34
|
+
'<option ' + (field_operator == "today" ? 'selected="selected"' : '') + ' value="today">Today</option>' +
|
35
|
+
'<option ' + (field_operator == "yesterday" ? 'selected="selected"' : '') + ' value="yesterday">Yesterday</option>' +
|
36
|
+
'<option ' + (field_operator == "this_week" ? 'selected="selected"' : '') + ' value="this_week">This week</option>' +
|
37
|
+
'<option ' + (field_operator == "last_week" ? 'selected="selected"' : '') + ' value="last_week">Last week</option>' +
|
38
|
+
'<option disabled="disabled">---------</option>' +
|
39
|
+
'<option ' + (field_operator == "_not_null" ? 'selected="selected"' : '') + ' value="_not_null">Is present</option>' +
|
40
|
+
'<option ' + (field_operator == "_null" ? 'selected="selected"' : '') + ' value="_null" >Is blank</option>' +
|
41
|
+
'</select>'
|
42
|
+
var additional_control =
|
43
|
+
'<input class="date additional-fieldset default input-small" style="display:' + ((!field_operator || field_operator == "default") ? 'inline-block' : 'none') + ';" type="text" name="' + value_name + '[]" value="' + (field_value[0] || '') + '" /> ' +
|
44
|
+
'<input placeholder="-∞" class="date additional-fieldset between input-small" style="display:' + ((field_operator == "between") ? 'inline-block' : 'none') + ';" type="text" name="' + value_name + '[]" value="' + (field_value[1] || '') + '" /> ' +
|
45
|
+
'<input placeholder="∞" class="date additional-fieldset between input-small" style="display:' + ((field_operator == "between") ? 'inline-block' : 'none') + ';" type="text" name="' + value_name + '[]" value="' + (field_value[2] || '') + '" />';
|
46
|
+
break;
|
47
|
+
case 'enum':
|
48
|
+
var multiple_values = ((field_value instanceof Array) ? true : false)
|
49
|
+
var control = '<select style="display:' + (multiple_values ? 'none' : 'inline-block') + '" ' + (multiple_values ? '' : 'name="' + value_name + '"') + ' data-name="' + value_name + '" class="select-single input-small">' +
|
50
|
+
'<option value="_discard">...</option>' +
|
51
|
+
'<option ' + (field_value == "_present" ? 'selected="selected"' : '') + ' value="_present">Is present</option>' +
|
52
|
+
'<option ' + (field_value == "_blank" ? 'selected="selected"' : '') + ' value="_blank">Is blank</option>' +
|
53
|
+
'<option disabled="disabled">---------</option>' +
|
54
|
+
field_options +
|
55
|
+
'</select>' +
|
56
|
+
'<select multiple="multiple" style="display:' + (multiple_values ? 'inline-block' : 'none') + '" ' + (multiple_values ? 'name="' + value_name + '[]"' : '') + ' data-name="' + value_name + '[]" class="select-multiple input-small">' +
|
57
|
+
field_options +
|
58
|
+
'</select> ' +
|
59
|
+
'<a href="#" class="switch-select"><i class="icon-' + (multiple_values ? 'minus' : 'plus') + '"></i></a>';
|
60
|
+
break;
|
61
|
+
case 'string':
|
62
|
+
case 'text':
|
63
|
+
case 'belongs_to_association':
|
64
|
+
var control = '<select class="switch-additionnal-fieldsets input-small" value="' + field_operator + '" name="' + operator_name + '">' +
|
65
|
+
'<option data-additional-fieldset="additional-fieldset"' + (field_operator == "like" ? 'selected="selected"' : '') + ' value="like">Contains</option>' +
|
66
|
+
'<option data-additional-fieldset="additional-fieldset"' + (field_operator == "is" ? 'selected="selected"' : '') + ' value="is">Is exactly</option>' +
|
67
|
+
'<option data-additional-fieldset="additional-fieldset"' + (field_operator == "starts_with" ? 'selected="selected"' : '') + ' value="starts_with">Starts with</option>' +
|
68
|
+
'<option data-additional-fieldset="additional-fieldset"' + (field_operator == "ends_with" ? 'selected="selected"' : '') + ' value="ends_with">Ends with</option>' +
|
69
|
+
'<option disabled="disabled">---------</option>' +
|
70
|
+
'<option ' + (field_operator == "_present" ? 'selected="selected"' : '') + ' value="_present">Is present</option>' +
|
71
|
+
'<option ' + (field_operator == "_blank" ? 'selected="selected"' : '') + ' value="_blank">Is blank</option>' +
|
72
|
+
'</select>'
|
73
|
+
var additional_control = '<input class="additional-fieldset input-small" style="display:' + (field_operator == "_blank" || field_operator == "_present" ? 'none' : 'inline-block') + ';" type="text" name="' + value_name + '" value="' + field_value + '" /> ';
|
74
|
+
break;
|
75
|
+
default:
|
76
|
+
var control = '<input type="text" class="input-small" name="' + value_name + '" value="' + field_value + '"/> ';
|
77
|
+
break;
|
78
|
+
}
|
79
|
+
|
80
|
+
var content = '<p class="filter form-search">' +
|
81
|
+
'<span class="label label-info form-label"><a href="#" class="delete"><i class="icon-trash icon-white"></i></a> ' + field_label + '</span> ' +
|
82
|
+
control + " " +
|
83
|
+
(additional_control || '') +
|
84
|
+
'</div> ';
|
85
|
+
$('#filters_box').append(content);
|
86
|
+
$('#filters_box .date').datepicker(this.options.regional.datePicker);
|
87
|
+
$("hr.filters_box:hidden").show('slow');
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
$("#filters a").live('click', function(e) {
|
92
|
+
e.preventDefault();
|
93
|
+
$.filters.append(
|
94
|
+
$(this).data('field-label'),
|
95
|
+
$(this).data('field-name'),
|
96
|
+
$(this).data('field-type'),
|
97
|
+
$(this).data('field-value'),
|
98
|
+
$(this).data('field-operator'),
|
99
|
+
$(this).data('field-options'),
|
100
|
+
$.now().toString().slice(6,11)
|
101
|
+
);
|
102
|
+
});
|
103
|
+
|
104
|
+
$('#filters_box .delete').live('click', function(e) {
|
105
|
+
e.preventDefault();
|
106
|
+
form = $(this).parents('form');
|
107
|
+
$(this).parents('.filter').remove();
|
108
|
+
!$("#filters_box").children().length && $("hr.filters_box:visible").hide('slow');
|
109
|
+
});
|
110
|
+
|
111
|
+
$('#filters_box .switch-select').live('click', function(e) {
|
112
|
+
e.preventDefault();
|
113
|
+
var selected_select = $(this).siblings('select:visible');
|
114
|
+
var not_selected_select = $(this).siblings('select:hidden');
|
115
|
+
not_selected_select.attr('name', not_selected_select.data('name')).show('slow');
|
116
|
+
selected_select.attr('name', null).hide('slow');
|
117
|
+
$(this).find('i').toggleClass("icon-plus icon-minus")
|
118
|
+
});
|
119
|
+
|
120
|
+
$('#filters_box .switch-additionnal-fieldsets').live('change', function() {
|
121
|
+
var selected_option = $(this).find('option:selected');
|
122
|
+
if(klass = $(selected_option).data('additional-fieldset')) {
|
123
|
+
$(this).siblings('.additional-fieldset:not(.' + klass + ')').hide('slow');
|
124
|
+
$(this).siblings('.' + klass).show('slow');
|
125
|
+
} else {
|
126
|
+
$(this).siblings('.additional-fieldset').hide('slow');
|
127
|
+
}
|
128
|
+
});
|
129
|
+
})( jQuery );
|
@@ -0,0 +1,280 @@
|
|
1
|
+
/*
|
2
|
+
* RailsAdmin filtering multiselect @VERSION
|
3
|
+
*
|
4
|
+
* License
|
5
|
+
*
|
6
|
+
* http://www.railsadmin.org
|
7
|
+
*
|
8
|
+
* Depends:
|
9
|
+
* jquery.ui.core.js
|
10
|
+
* jquery.ui.widget.js
|
11
|
+
*/
|
12
|
+
(function($) {
|
13
|
+
$.widget("ra.filteringMultiselect", {
|
14
|
+
_cache: {},
|
15
|
+
options: {
|
16
|
+
createQuery: function(query) {
|
17
|
+
return { query: query };
|
18
|
+
},
|
19
|
+
sortable: false,
|
20
|
+
regional: {
|
21
|
+
up: "Up",
|
22
|
+
down: "Down",
|
23
|
+
add: "Add",
|
24
|
+
chooseAll: "Choose all",
|
25
|
+
chosen: "Chosen records",
|
26
|
+
clearAll: "Clear all",
|
27
|
+
remove: "Remove",
|
28
|
+
selectChoice: "Select your choice(s) and click"
|
29
|
+
},
|
30
|
+
searchDelay: 400,
|
31
|
+
remote_source: null,
|
32
|
+
xhr: false
|
33
|
+
},
|
34
|
+
|
35
|
+
_create: function() {
|
36
|
+
this._cache = {};
|
37
|
+
this._build();
|
38
|
+
this._buildCache();
|
39
|
+
this._bindEvents();
|
40
|
+
},
|
41
|
+
|
42
|
+
_build: function() {
|
43
|
+
var i;
|
44
|
+
|
45
|
+
this.wrapper = $('<div class="ra-multiselect">');
|
46
|
+
|
47
|
+
this.wrapper.insertAfter(this.element);
|
48
|
+
|
49
|
+
this.header = $('<div class="ra-multiselect-header ui-helper-clearfix">');
|
50
|
+
|
51
|
+
this.filter = $('<input type="search" placeholder="' + this.options.regional.search + '" class="ra-multiselect-search"/>');
|
52
|
+
|
53
|
+
this.header.append(this.filter);
|
54
|
+
|
55
|
+
this.wrapper.append(this.header);
|
56
|
+
|
57
|
+
this.columns = {
|
58
|
+
left: $('<div class="ra-multiselect-column ra-multiselect-left">'),
|
59
|
+
center: $('<div class="ra-multiselect-column ra-multiselect-center">'),
|
60
|
+
right: $('<div class="ra-multiselect-column ra-multiselect-right">')
|
61
|
+
};
|
62
|
+
|
63
|
+
for (i in this.columns) {
|
64
|
+
if (this.columns.hasOwnProperty(i)) {
|
65
|
+
this.wrapper.append(this.columns[i]);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
this.collection = $('<select multiple="multiple"></select>');
|
70
|
+
|
71
|
+
this.collection.addClass("ra-multiselect-collection");
|
72
|
+
|
73
|
+
this.addAll = $('<a href="#" class="ra-multiselect-item-add-all"><span class="ui-icon ui-icon-circle-triangle-e"></span>' + this.options.regional.chooseAll + '</a>');
|
74
|
+
|
75
|
+
this.columns.left.append(this.collection)
|
76
|
+
.append(this.addAll);
|
77
|
+
|
78
|
+
this.add = $('<a href="#" class="ui-icon ui-icon-circle-triangle-e ra-multiselect-item-add">' + this.options.regional.add + '</a>');
|
79
|
+
|
80
|
+
this.remove = $('<a href="#" class="ui-icon ui-icon-circle-triangle-w ra-multiselect-item-remove">' + this.options.regional.remove + '</a>');
|
81
|
+
|
82
|
+
this.columns.center.append(this.add).append(this.remove)
|
83
|
+
if (this.options.sortable) {
|
84
|
+
this.up = $('<a href="#" class="ui-icon ui-icon-circle-triangle-n ra-multiselect-item-up">' + this.options.regional.up + '</a>');
|
85
|
+
this.down = $('<a href="#" class="ui-icon ui-icon-circle-triangle-s ra-multiselect-item-down">' + this.options.regional.down + '</a>');
|
86
|
+
this.columns.center.append(this.up).append(this.down);
|
87
|
+
}
|
88
|
+
|
89
|
+
this.selection = $('<select class="ra-multiselect-selection" multiple="multiple"></select>');
|
90
|
+
|
91
|
+
this.removeAll = $('<a href="#" class="ra-multiselect-item-remove-all"><span class="ui-icon ui-icon-circle-triangle-w"></span>' + this.options.regional.clearAll + '</a>');
|
92
|
+
|
93
|
+
this.columns.right.append(this.selection)
|
94
|
+
.append(this.removeAll);
|
95
|
+
|
96
|
+
this.element.css({display: "none"});
|
97
|
+
},
|
98
|
+
|
99
|
+
_bindEvents: function() {
|
100
|
+
var widget = this;
|
101
|
+
|
102
|
+
/* Add all to selection */
|
103
|
+
this.addAll.click(function(e){
|
104
|
+
widget._select($('option', widget.collection));
|
105
|
+
e.preventDefault();
|
106
|
+
});
|
107
|
+
|
108
|
+
/* Add to selection */
|
109
|
+
this.add.click(function(e){
|
110
|
+
widget._select($(':selected', widget.collection));
|
111
|
+
e.preventDefault();
|
112
|
+
});
|
113
|
+
|
114
|
+
/* Remove all from selection */
|
115
|
+
this.removeAll.click(function(e){
|
116
|
+
widget._deSelect($('option', widget.selection));
|
117
|
+
e.preventDefault();
|
118
|
+
});
|
119
|
+
|
120
|
+
/* Remove from selection */
|
121
|
+
this.remove.click(function(e){
|
122
|
+
widget._deSelect($(':selected', widget.selection));
|
123
|
+
e.preventDefault();
|
124
|
+
});
|
125
|
+
|
126
|
+
var timeout = null;
|
127
|
+
if(this.options.sortable) {
|
128
|
+
/* Move selection up */
|
129
|
+
this.up.click(function(e){
|
130
|
+
widget._move('up', $(':selected', widget.selection));
|
131
|
+
e.preventDefault();
|
132
|
+
});
|
133
|
+
|
134
|
+
/* Move selection down */
|
135
|
+
this.down.click(function(e){
|
136
|
+
widget._move('down', $(':selected', widget.selection));
|
137
|
+
e.preventDefault();
|
138
|
+
});
|
139
|
+
}
|
140
|
+
|
141
|
+
/* Typing to the filter */
|
142
|
+
this.filter.bind('keyup click', function(e){
|
143
|
+
if (timeout) { clearTimeout(timeout); }
|
144
|
+
timeout = setTimeout(function() {
|
145
|
+
widget._queryFilter(widget.filter.val());
|
146
|
+
}, widget.options.searchDelay
|
147
|
+
);
|
148
|
+
});
|
149
|
+
},
|
150
|
+
|
151
|
+
_queryFilter: function(val) {
|
152
|
+
var widget = this;
|
153
|
+
widget._query(val, function(matches) {
|
154
|
+
var i, html = "";
|
155
|
+
for (i in matches) {
|
156
|
+
if (matches.hasOwnProperty(i) && !widget.selected(matches[i].id)) {
|
157
|
+
html += '<option value="' + matches[i].id + '">' + matches[i].label + '</option>';
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
widget.collection.html(html);
|
162
|
+
});
|
163
|
+
},
|
164
|
+
|
165
|
+
_buildCache: function(options) {
|
166
|
+
var widget = this;
|
167
|
+
|
168
|
+
this.element.find("option").each(function(i, option) {
|
169
|
+
if (option.selected) {
|
170
|
+
widget._cache[option.value] = option.innerHTML;
|
171
|
+
$(option).clone().appendTo(widget.selection).attr("selected", false);
|
172
|
+
} else {
|
173
|
+
widget._cache[option.value] = option.innerHTML;
|
174
|
+
$(option).clone().appendTo(widget.collection).attr("selected", false);
|
175
|
+
}
|
176
|
+
});
|
177
|
+
},
|
178
|
+
|
179
|
+
_deSelect: function(options) {
|
180
|
+
var widget = this;
|
181
|
+
options.each(function(i, option) {
|
182
|
+
widget.element.find("option[value=" + option.value + "]").removeAttr("selected");
|
183
|
+
});
|
184
|
+
$(options).appendTo(this.collection).attr('selected', false);
|
185
|
+
},
|
186
|
+
|
187
|
+
_query: function(query, success) {
|
188
|
+
|
189
|
+
var i, matches = [];
|
190
|
+
|
191
|
+
if (query === "") {
|
192
|
+
|
193
|
+
if (!this.options.xhr) {
|
194
|
+
for (i in this._cache) {
|
195
|
+
if (this._cache.hasOwnProperty(i)) {
|
196
|
+
matches.push({id: i, label: this._cache[i]});
|
197
|
+
}
|
198
|
+
}
|
199
|
+
}
|
200
|
+
|
201
|
+
success.apply(this, [matches]);
|
202
|
+
|
203
|
+
} else {
|
204
|
+
|
205
|
+
if (this.options.xhr) {
|
206
|
+
|
207
|
+
$.ajax({
|
208
|
+
beforeSend: function(xhr) {
|
209
|
+
xhr.setRequestHeader("Accept", "application/json");
|
210
|
+
},
|
211
|
+
url: this.options.remote_source,
|
212
|
+
data: this.options.createQuery(query),
|
213
|
+
success: success
|
214
|
+
});
|
215
|
+
|
216
|
+
} else {
|
217
|
+
|
218
|
+
query = new RegExp(query + '.*', 'i');
|
219
|
+
|
220
|
+
for (i in this._cache) {
|
221
|
+
if (this._cache.hasOwnProperty(i) && query.test(this._cache[i])) {
|
222
|
+
matches.push({id: i, label: this._cache[i]});
|
223
|
+
}
|
224
|
+
}
|
225
|
+
|
226
|
+
success.apply(this, [matches]);
|
227
|
+
}
|
228
|
+
}
|
229
|
+
},
|
230
|
+
|
231
|
+
_select: function(options) {
|
232
|
+
var widget = this;
|
233
|
+
options.each(function(i, option) {
|
234
|
+
var el = widget.element.find("option[value=" + option.value + "]");
|
235
|
+
if (el.length) {
|
236
|
+
el.attr("selected", "selected");
|
237
|
+
} else {
|
238
|
+
widget.element.append($('<option value="' + option.value + '" selected="selected"></option>'));
|
239
|
+
}
|
240
|
+
});
|
241
|
+
$(options).appendTo(this.selection).attr('selected', false);
|
242
|
+
},
|
243
|
+
|
244
|
+
_move: function(direction, options) {
|
245
|
+
var widget = this;
|
246
|
+
if(direction == 'up') {
|
247
|
+
options.each(function(i, option) {
|
248
|
+
var prev = $(option).prev();
|
249
|
+
if (prev.length > 0) {
|
250
|
+
var el = widget.element.find("option[value=" + option.value + "]");
|
251
|
+
var el_prev = widget.element.find("option[value=" + prev[0].value + "]");
|
252
|
+
el_prev.before(el);
|
253
|
+
prev.before($(option));
|
254
|
+
}
|
255
|
+
});
|
256
|
+
} else {
|
257
|
+
$.fn.reverse = [].reverse; // needed to lower last items first
|
258
|
+
options.reverse().each(function(i, option) {
|
259
|
+
var next = $(option).next();
|
260
|
+
if (next.length > 0) {
|
261
|
+
var el = widget.element.find("option[value=" + option.value + "]");
|
262
|
+
var el_next = widget.element.find("option[value=" + next[0].value + "]");
|
263
|
+
el_next.after(el);
|
264
|
+
next.after($(option));
|
265
|
+
}
|
266
|
+
});
|
267
|
+
}
|
268
|
+
},
|
269
|
+
|
270
|
+
selected: function(value) {
|
271
|
+
return this.element.find("option[value=" + value + "]").attr("selected");
|
272
|
+
},
|
273
|
+
|
274
|
+
destroy: function() {
|
275
|
+
this.wrapper.remove();
|
276
|
+
this.element.css({display: "inline"});
|
277
|
+
$.Widget.prototype.destroy.apply(this, arguments);
|
278
|
+
}
|
279
|
+
});
|
280
|
+
})(jQuery);
|