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
@@ -1,58 +0,0 @@
|
|
1
|
-
jQuery(function($) {
|
2
|
-
window.NestedFormEvents = function() {
|
3
|
-
this.addFields = $.proxy(this.addFields, this);
|
4
|
-
this.removeFields = $.proxy(this.removeFields, this);
|
5
|
-
};
|
6
|
-
|
7
|
-
NestedFormEvents.prototype = {
|
8
|
-
addFields: function(e) {
|
9
|
-
var link = e.currentTarget;
|
10
|
-
var assoc = $(link).attr('data-association'); // Name of child
|
11
|
-
var content = $('#' + assoc + '_fields_blueprint').html(); // Fields template
|
12
|
-
var context = ($(link).closest('.fields').find('input:first').attr('name') || '').replace(new RegExp('\[[a-z]+\]$'), '');
|
13
|
-
|
14
|
-
// Make a unique ID for the new child
|
15
|
-
// moved before parent interpolation in case a parent would mungle <object_name>_new_<assoc> to <object_name>_<(new_<parent_timestamp>|<parent_index>)>_<assoc>
|
16
|
-
// It happens if object_name.ends_with?(parent_name)
|
17
|
-
var regexp = new RegExp('new_' + assoc, 'g');
|
18
|
-
var new_id = new Date().getTime();
|
19
|
-
content = content.replace(regexp, "new_" + new_id);
|
20
|
-
|
21
|
-
if (context) {
|
22
|
-
var parentNames = context.match(/[a-z_]+_attributes/g) || [];
|
23
|
-
var parentIds = context.match(/(new_)?[0-9]+/g) || [];
|
24
|
-
for(var i = 0; i < parentNames.length; i++) {
|
25
|
-
if(parentIds[i]) {
|
26
|
-
content = content.replace(
|
27
|
-
new RegExp('(_' + parentNames[i] + ')_.+?_', 'g'),
|
28
|
-
'$1_' + parentIds[i] + '_');
|
29
|
-
content = content.replace(
|
30
|
-
new RegExp('(\\[' + parentNames[i] + '\\])\\[.+?\\]', 'g'),
|
31
|
-
'$1[' + parentIds[i] + ']');
|
32
|
-
}
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
var field = this.insertFields(content, assoc, link);
|
37
|
-
$(link).closest("form")
|
38
|
-
.trigger({ type: 'nested:fieldAdded', field: field })
|
39
|
-
.trigger({ type: 'nested:fieldAdded:' + assoc, field: field });
|
40
|
-
return false;
|
41
|
-
},
|
42
|
-
insertFields: function(content, assoc, link) {
|
43
|
-
return $(content).insertBefore(link).hide().show('slow');
|
44
|
-
},
|
45
|
-
removeFields: function(e) {
|
46
|
-
var link = e.currentTarget;
|
47
|
-
$(link).toggleClass('important').toggleClass('notice');
|
48
|
-
var hiddenField = $(link).prev('input[type=hidden]');
|
49
|
-
hiddenField.val(hiddenField.val() === '1' ? '0' : '1');
|
50
|
-
$(link).siblings('fieldset').toggle();
|
51
|
-
return false;
|
52
|
-
}
|
53
|
-
};
|
54
|
-
|
55
|
-
window.nestedFormEvents = new NestedFormEvents();
|
56
|
-
$('form a.add_nested_fields').live('click', nestedFormEvents.addFields);
|
57
|
-
$('form a.remove_nested_fields').live('click', nestedFormEvents.removeFields);
|
58
|
-
});
|
@@ -1,17 +0,0 @@
|
|
1
|
-
- models = RailsAdmin::Config.visible_models.select { |model| authorized?(:index, model.abstract_model) }
|
2
|
-
- root_models = models.select { |model| model.parent == :root }
|
3
|
-
|
4
|
-
%ul#nav.navigation
|
5
|
-
- root_models.each do |model|
|
6
|
-
- children = [model] + models.select { |m| m.parent.to_s == model.abstract_model.model.to_s }
|
7
|
-
- tab_titles = children.map { |child| child.abstract_model.pretty_name.downcase }
|
8
|
-
- active = tab_titles.include? @page_type
|
9
|
-
%li{:class => "#{"active" if active} #{"more" unless children.empty?}"}
|
10
|
-
- if children.size == 1
|
11
|
-
= link_to(model.label_plural, index_path(:model_name => model.abstract_model.to_param))
|
12
|
-
- else
|
13
|
-
= model.navigation_label ? t(model.navigation_label, :default => model.navigation_label) : model.label_plural
|
14
|
-
%ul
|
15
|
-
- children.each_with_index do |child, index|
|
16
|
-
%li{:class => ("active" if @page_type == tab_titles[index])}
|
17
|
-
= link_to(child.label_plural, index_path(:model_name => child.abstract_model.to_param))
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module RailsAdmin
|
2
|
-
class AbstractObject
|
3
|
-
# undef almost all of this class's methods so it will pass almost
|
4
|
-
# everything through to its delegate using method_missing (below).
|
5
|
-
instance_methods.each { |m| undef_method m unless m.to_s =~ /(^__|^send$|^object_id$)/ }
|
6
|
-
# ^^^^^
|
7
|
-
# the unnecessary "to_s" above is a workaround for meta_where, see
|
8
|
-
# https://github.com/sferik/rails_admin/issues/374
|
9
|
-
|
10
|
-
attr_accessor :object
|
11
|
-
|
12
|
-
def initialize(object)
|
13
|
-
self.object = object
|
14
|
-
end
|
15
|
-
|
16
|
-
def set_attributes(attributes, role = nil)
|
17
|
-
object.assign_attributes(attributes, :as => role)
|
18
|
-
end
|
19
|
-
|
20
|
-
def method_missing(name, *args, &block)
|
21
|
-
self.object.send(name, *args, &block)
|
22
|
-
end
|
23
|
-
|
24
|
-
def save(options = { :validate => true })
|
25
|
-
object.save(options)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,111 +0,0 @@
|
|
1
|
-
require 'rails_admin/config/proxy'
|
2
|
-
|
3
|
-
module RailsAdmin
|
4
|
-
module Config
|
5
|
-
# A base class for all configurables.
|
6
|
-
#
|
7
|
-
# Each configurable has a parent object. This parent object must provide
|
8
|
-
# the configurable with abstract_model and bindings.
|
9
|
-
#
|
10
|
-
# Bindings is a hash of variables bound by the querying context. For
|
11
|
-
# example the list view's template will bind an object to key
|
12
|
-
# :object for each row it outputs. This object is the actual row object
|
13
|
-
# which is then used as the receiver of queries for property values.
|
14
|
-
#
|
15
|
-
# @see RailsAdmin::AbstractModel
|
16
|
-
# @see RailsAdmin::Config::Model#abstract_model
|
17
|
-
class Base
|
18
|
-
attr_reader :abstract_model, :bindings, :parent, :root
|
19
|
-
|
20
|
-
def initialize(parent = nil)
|
21
|
-
@abstract_model = parent && parent.abstract_model
|
22
|
-
@bindings = {}
|
23
|
-
@parent = parent
|
24
|
-
@root = parent && parent.root
|
25
|
-
end
|
26
|
-
|
27
|
-
def has_option?(name)
|
28
|
-
options = self.class.instance_variable_get("@config_options")
|
29
|
-
options && options.has_key?(name)
|
30
|
-
end
|
31
|
-
|
32
|
-
# Register an instance option for this object only
|
33
|
-
def register_instance_option(option_name, &default)
|
34
|
-
scope = class << self; self; end;
|
35
|
-
self.class.register_instance_option(option_name, scope, &default)
|
36
|
-
end
|
37
|
-
|
38
|
-
def register_deprecated_instance_option(option_name, replacement_option_name)
|
39
|
-
scope = class << self; self; end;
|
40
|
-
self.class.register_deprecated_instance_option(option_name, replacement_option_name, scope)
|
41
|
-
end
|
42
|
-
|
43
|
-
def with(bindings = {})
|
44
|
-
RailsAdmin::Config::Proxy.new(self, bindings)
|
45
|
-
end
|
46
|
-
|
47
|
-
# Register an instance option. Instance option is a configuration
|
48
|
-
# option that stores its value within an instance variable and is
|
49
|
-
# accessed by an instance method. Both go by the name of the option.
|
50
|
-
def self.register_instance_option(option_name, scope = self, &default)
|
51
|
-
unless options = scope.instance_variable_get("@config_options")
|
52
|
-
options = scope.instance_variable_set("@config_options", {})
|
53
|
-
end
|
54
|
-
|
55
|
-
option_name = option_name.to_s
|
56
|
-
|
57
|
-
options[option_name] = nil
|
58
|
-
|
59
|
-
# If it's a boolean create an alias for it and remove question mark
|
60
|
-
if "?" == option_name[-1, 1]
|
61
|
-
scope.send(:define_method, "#{option_name.chop!}?") do
|
62
|
-
send(option_name)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# Define getter/setter by the option name
|
67
|
-
scope.send(:define_method, option_name) do |*args, &block|
|
68
|
-
if !args[0].nil? || block
|
69
|
-
# Invocation with args --> This is the declaration of the option, i.e. setter
|
70
|
-
instance_variable_set("@#{option_name}_registered", args[0].nil? ? block : args[0])
|
71
|
-
else
|
72
|
-
# Invocation without args nor block --> It's the use of the option, i.e. getter
|
73
|
-
value = instance_variable_get("@#{option_name}_registered")
|
74
|
-
case value
|
75
|
-
when Proc
|
76
|
-
# Track recursive invocation with an instance variable. This prevents run-away recursion
|
77
|
-
# and allows configurations such as
|
78
|
-
# label { "#{label}".upcase }
|
79
|
-
# This will use the default definition when called recursively.
|
80
|
-
if instance_variable_get("@#{option_name}_recurring")
|
81
|
-
value = instance_eval &default
|
82
|
-
else
|
83
|
-
instance_variable_set("@#{option_name}_recurring", true)
|
84
|
-
value = instance_eval &value
|
85
|
-
instance_variable_set("@#{option_name}_recurring", false)
|
86
|
-
end
|
87
|
-
when nil
|
88
|
-
value = instance_eval &default
|
89
|
-
end
|
90
|
-
value
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def self.register_deprecated_instance_option(option_name, replacement_option_name, scope = self)
|
96
|
-
scope.send(:define_method, option_name) do |*args, &block|
|
97
|
-
ActiveSupport::Deprecation.warn("The #{option_name} configuration option is deprecated, please use #{replacement_option_name}.")
|
98
|
-
send(replacement_option_name, *args, &block)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
# Register a class option. Class option is a configuration
|
103
|
-
# option that stores it's value within a class object's instance variable
|
104
|
-
# and is accessed by a class method. Both go by the name of the option.
|
105
|
-
def self.register_class_option(option_name, &default)
|
106
|
-
scope = class << self; self; end;
|
107
|
-
self.register_instance_option(option_name, scope, &default)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module RailsAdmin
|
2
|
-
module Config
|
3
|
-
class Proxy
|
4
|
-
|
5
|
-
instance_methods.each {|m| undef_method m unless m =~ /^(__|instance_eval|object_id)/ }
|
6
|
-
|
7
|
-
attr_reader :bindings
|
8
|
-
|
9
|
-
def initialize(object, bindings = {})
|
10
|
-
@object = object
|
11
|
-
@bindings = bindings
|
12
|
-
end
|
13
|
-
|
14
|
-
# Bind variables to be used by the configuration options
|
15
|
-
def bind(key, value = nil)
|
16
|
-
if key.kind_of?(Hash)
|
17
|
-
@bindings = key
|
18
|
-
else
|
19
|
-
@bindings[key] = value
|
20
|
-
end
|
21
|
-
self
|
22
|
-
end
|
23
|
-
|
24
|
-
def method_missing(name, *args, &block)
|
25
|
-
if @object.respond_to?(name)
|
26
|
-
reset = @object.instance_variable_get("@bindings")
|
27
|
-
begin
|
28
|
-
@object.instance_variable_set("@bindings", @bindings)
|
29
|
-
response = @object.__send__(name, *args, &block)
|
30
|
-
ensure
|
31
|
-
@object.instance_variable_set("@bindings", @reset)
|
32
|
-
end
|
33
|
-
response
|
34
|
-
else
|
35
|
-
super(name, *args, &block)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/string/inflections'
|
2
|
-
module RailsAdmin
|
3
|
-
class AbstractModel
|
4
|
-
module GenericSupport
|
5
|
-
def to_param
|
6
|
-
model.to_s.split("::").map(&:underscore).join("~")
|
7
|
-
end
|
8
|
-
|
9
|
-
def param_key
|
10
|
-
model.to_s.split("::").map(&:underscore).join("_")
|
11
|
-
end
|
12
|
-
|
13
|
-
def pretty_name
|
14
|
-
model.model_name.human
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# https://github.com/rails/rails/issues/3164
|
2
|
-
# http://stackoverflow.com/questions/6312448/how-to-disable-logging-of-asset-pipeline-sprockets-messages-in-rails-3-1
|
3
|
-
|
4
|
-
Rails.application.assets.logger = Logger.new('/dev/null')
|
5
|
-
Rails::Rack::Logger.class_eval do
|
6
|
-
def before_dispatch_with_quiet_assets(env)
|
7
|
-
before_dispatch_without_quiet_assets(env) unless env['PATH_INFO'].index("/assets/") == 0
|
8
|
-
end
|
9
|
-
alias_method_chain :before_dispatch, :quiet_assets
|
10
|
-
end
|
data/spec/dummy_app/foo/Gemfile
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
# Declare your gem's dependencies in foo.gemspec.
|
4
|
-
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
-
# development dependencies will be added by default to the :development group.
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
# jquery-rails is used by the dummy application
|
9
|
-
gem "jquery-rails"
|
10
|
-
|
11
|
-
# Declare any dependencies that are still in development here instead of in
|
12
|
-
# your gemspec. These might include edge Rails or gems from your path or
|
13
|
-
# Git. Remember to move these dependencies to your gemspec before releasing
|
14
|
-
# your gem to rubygems.org.
|
15
|
-
|
16
|
-
# To use debugger
|
17
|
-
# gem 'ruby-debug19', :require => 'ruby-debug'
|
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright 2011 YOURNAME
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/spec/dummy_app/foo/Rakefile
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
begin
|
3
|
-
require 'bundler/setup'
|
4
|
-
rescue LoadError
|
5
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
-
end
|
7
|
-
begin
|
8
|
-
require 'rdoc/task'
|
9
|
-
rescue LoadError
|
10
|
-
require 'rdoc/rdoc'
|
11
|
-
require 'rake/rdoctask'
|
12
|
-
RDoc::Task = Rake::RDocTask
|
13
|
-
end
|
14
|
-
|
15
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
-
rdoc.rdoc_dir = 'rdoc'
|
17
|
-
rdoc.title = 'Foo'
|
18
|
-
rdoc.options << '--line-numbers'
|
19
|
-
rdoc.rdoc_files.include('README.rdoc')
|
20
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
-
end
|
22
|
-
|
23
|
-
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
24
|
-
load 'rails/tasks/engine.rake'
|
25
|
-
|
26
|
-
|
27
|
-
Bundler::GemHelper.install_tasks
|
28
|
-
|
29
|
-
require 'rake/testtask'
|
30
|
-
|
31
|
-
Rake::TestTask.new(:test) do |t|
|
32
|
-
t.libs << 'lib'
|
33
|
-
t.libs << 'test'
|
34
|
-
t.pattern = 'test/**/*_test.rb'
|
35
|
-
t.verbose = false
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
task :default => :test
|
@@ -1,9 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
-
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
-
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
-
// the compiled file.
|
6
|
-
//
|
7
|
-
//= require jquery
|
8
|
-
//= require jquery_ujs
|
9
|
-
//= require_tree .
|
@@ -1,7 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
-
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
-
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
-
*= require_self
|
6
|
-
*= require_tree .
|
7
|
-
*/
|
@@ -1,23 +0,0 @@
|
|
1
|
-
$:.push File.expand_path("../lib", __FILE__)
|
2
|
-
|
3
|
-
# Maintain your gem's version:
|
4
|
-
require "foo/version"
|
5
|
-
|
6
|
-
# Describe your gem and declare its dependencies:
|
7
|
-
Gem::Specification.new do |s|
|
8
|
-
s.name = "foo"
|
9
|
-
s.version = Foo::VERSION
|
10
|
-
s.authors = ["TODO: Your name"]
|
11
|
-
s.email = ["TODO: Your email"]
|
12
|
-
s.homepage = "TODO"
|
13
|
-
s.summary = "TODO: Summary of Foo."
|
14
|
-
s.description = "TODO: Description of Foo."
|
15
|
-
|
16
|
-
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
|
17
|
-
s.test_files = Dir["test/**/*"]
|
18
|
-
|
19
|
-
s.add_dependency "rails", "~> 3.1.3"
|
20
|
-
# s.add_dependency "jquery-rails"
|
21
|
-
|
22
|
-
s.add_development_dependency "sqlite3"
|
23
|
-
end
|
@@ -1,6 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#!/usr/bin/env ruby
|
3
|
-
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
4
|
-
|
5
|
-
ENGINE_PATH = File.expand_path('../..', __FILE__)
|
6
|
-
load File.expand_path('../../test/dummy/script/rails', __FILE__)
|
@@ -1,7 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
-
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
-
|
5
|
-
require File.expand_path('../config/application', __FILE__)
|
6
|
-
|
7
|
-
Dummy::Application.load_tasks
|
@@ -1,9 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
-
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
-
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
-
// the compiled file.
|
6
|
-
//
|
7
|
-
//= require jquery
|
8
|
-
//= require jquery_ujs
|
9
|
-
//= require_tree .
|
@@ -1,7 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
-
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
-
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
-
*= require_self
|
6
|
-
*= require_tree .
|
7
|
-
*/
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require File.expand_path('../boot', __FILE__)
|
2
|
-
|
3
|
-
require 'rails/all'
|
4
|
-
|
5
|
-
Bundler.require
|
6
|
-
require "foo"
|
7
|
-
|
8
|
-
module Dummy
|
9
|
-
class Application < Rails::Application
|
10
|
-
# Settings in config/environments/* take precedence over those specified here.
|
11
|
-
# Application configuration should go into files in config/initializers
|
12
|
-
# -- all .rb files in that directory are automatically loaded.
|
13
|
-
|
14
|
-
# Custom directories with classes and modules you want to be autoloadable.
|
15
|
-
# config.autoload_paths += %W(#{config.root}/extras)
|
16
|
-
|
17
|
-
# Only load the plugins named here, in the order given (default is alphabetical).
|
18
|
-
# :all can be used as a placeholder for all plugins not explicitly named.
|
19
|
-
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
20
|
-
|
21
|
-
# Activate observers that should always be running.
|
22
|
-
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
23
|
-
|
24
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
25
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
26
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
27
|
-
|
28
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
29
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
30
|
-
# config.i18n.default_locale = :de
|
31
|
-
|
32
|
-
# Configure the default encoding used in templates for Ruby 1.9.
|
33
|
-
config.encoding = "utf-8"
|
34
|
-
|
35
|
-
# Configure sensitive parameters which will be filtered from the log file.
|
36
|
-
config.filter_parameters += [:password]
|
37
|
-
|
38
|
-
# Enable the asset pipeline
|
39
|
-
config.assets.enabled = true
|
40
|
-
|
41
|
-
# Version of your assets, change this if you want to expire all your assets
|
42
|
-
config.assets.version = '1.0'
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# SQLite version 3.x
|
2
|
-
# gem install sqlite3
|
3
|
-
#
|
4
|
-
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
-
# gem 'sqlite3'
|
6
|
-
development:
|
7
|
-
adapter: sqlite3
|
8
|
-
database: db/development.sqlite3
|
9
|
-
pool: 5
|
10
|
-
timeout: 5000
|
11
|
-
|
12
|
-
# Warning: The database defined as "test" will be erased and
|
13
|
-
# re-generated from your development database when you run "rake".
|
14
|
-
# Do not set this db to the same as development or production.
|
15
|
-
test:
|
16
|
-
adapter: sqlite3
|
17
|
-
database: db/test.sqlite3
|
18
|
-
pool: 5
|
19
|
-
timeout: 5000
|
20
|
-
|
21
|
-
production:
|
22
|
-
adapter: sqlite3
|
23
|
-
database: db/production.sqlite3
|
24
|
-
pool: 5
|
25
|
-
timeout: 5000
|