rails_admin 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rails_admin might be problematic. Click here for more details.

Files changed (87) hide show
  1. data/Gemfile +5 -30
  2. data/README.md +20 -2
  3. data/app/assets/javascripts/rails_admin/ra.filtering-select.js +2 -2
  4. data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.coffee +1 -1
  5. data/app/assets/javascripts/rails_admin/ra.remote-form.js +1 -1
  6. data/app/assets/javascripts/rails_admin/ra.widgets.coffee +43 -3
  7. data/app/assets/javascripts/rails_admin/ui.js.coffee +2 -0
  8. data/app/assets/stylesheets/rails_admin/imports.css.scss.erb +3 -0
  9. data/app/assets/stylesheets/rails_admin/ra.widgets.css.scss +8 -0
  10. data/app/controllers/rails_admin/main_controller.rb +3 -3
  11. data/app/helpers/rails_admin/application_helper.rb +15 -4
  12. data/app/helpers/rails_admin/form_builder.rb +35 -35
  13. data/app/views/layouts/rails_admin/application.html.haml +2 -1
  14. data/app/views/rails_admin/main/_delete_notice.html.haml +9 -8
  15. data/app/views/rails_admin/main/_form_datetime.html.haml +1 -1
  16. data/app/views/rails_admin/main/_form_enumeration.html.haml +18 -1
  17. data/app/views/rails_admin/main/_form_file_upload.html.haml +2 -2
  18. data/app/views/rails_admin/main/_form_text.html.haml +7 -1
  19. data/app/views/rails_admin/main/dashboard.html.haml +26 -25
  20. data/app/views/rails_admin/main/index.html.haml +1 -1
  21. data/config/initializers/active_record_extensions.rb +2 -2
  22. data/config/locales/rails_admin.en.yml +1 -0
  23. data/lib/generators/rails_admin/install_generator.rb +1 -1
  24. data/lib/generators/rails_admin/templates/initializer.erb +66 -67
  25. data/lib/rails_admin/abstract_model.rb +7 -7
  26. data/lib/rails_admin/adapters/active_record.rb +17 -8
  27. data/lib/rails_admin/adapters/mongoid.rb +38 -42
  28. data/lib/rails_admin/adapters/mongoid/extension.rb +1 -1
  29. data/lib/rails_admin/config.rb +15 -1
  30. data/lib/rails_admin/config/actions/base.rb +16 -2
  31. data/lib/rails_admin/config/actions/dashboard.rb +17 -11
  32. data/lib/rails_admin/config/fields.rb +0 -1
  33. data/lib/rails_admin/config/fields/association.rb +2 -3
  34. data/lib/rails_admin/config/fields/base.rb +18 -6
  35. data/lib/rails_admin/config/fields/types/enum.rb +4 -0
  36. data/lib/rails_admin/config/fields/types/string.rb +6 -4
  37. data/lib/rails_admin/config/fields/types/text.rb +19 -2
  38. data/lib/rails_admin/config/model.rb +17 -0
  39. data/lib/rails_admin/config/sections/base.rb +17 -0
  40. data/lib/rails_admin/engine.rb +4 -0
  41. data/lib/rails_admin/extensions/history/auditing_adapter.rb +1 -1
  42. data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +4 -4
  43. data/lib/rails_admin/support/csv_converter.rb +3 -3
  44. data/lib/rails_admin/version.rb +2 -2
  45. data/lib/tasks/rails_admin.rake +36 -6
  46. data/spec/controllers/main_controller_spec.rb +52 -9
  47. data/spec/dummy_app/Gemfile +7 -16
  48. data/spec/dummy_app/app/active_record/another_field_test.rb +4 -0
  49. data/spec/dummy_app/app/active_record/ball.rb +1 -1
  50. data/spec/dummy_app/app/active_record/nested_field_test.rb +2 -1
  51. data/spec/dummy_app/app/active_record/team.rb +3 -2
  52. data/spec/dummy_app/app/active_record/user.rb +6 -2
  53. data/spec/dummy_app/app/mongoid/another_field_test.rb +6 -0
  54. data/spec/dummy_app/app/mongoid/ball.rb +1 -1
  55. data/spec/dummy_app/app/mongoid/nested_field_test.rb +2 -1
  56. data/spec/dummy_app/app/mongoid/team.rb +1 -1
  57. data/spec/dummy_app/config/environments/development.rb +2 -2
  58. data/spec/dummy_app/db/migrate/20120720075608_create_another_field_tests.rb +8 -0
  59. data/spec/dummy_app/db/seeds.rb +3 -3
  60. data/spec/dummy_app/db/test.sqlite3 +0 -0
  61. data/spec/dummy_app/log/test.log +53792 -0
  62. data/spec/helpers/application_helper_spec.rb +37 -0
  63. data/spec/helpers/form_builder_spec.rb +17 -0
  64. data/spec/integration/authorization/cancan_spec.rb +21 -13
  65. data/spec/integration/basic/create/rails_admin_namespaced_model_create_spec.rb +1 -8
  66. data/spec/integration/basic/delete/rails_admin_basic_delete_spec.rb +15 -4
  67. data/spec/integration/basic/list/rails_admin_basic_list_spec.rb +9 -12
  68. data/spec/integration/basic/show/rails_admin_basic_show_spec.rb +2 -10
  69. data/spec/integration/basic/update/rails_admin_basic_update_spec.rb +6 -0
  70. data/spec/integration/config/edit/rails_admin_config_edit_spec.rb +241 -300
  71. data/spec/integration/config/list/rails_admin_config_list_spec.rb +3 -81
  72. data/spec/integration/config/show/rails_admin_config_show_spec.rb +2 -2
  73. data/spec/spec_helper.rb +1 -0
  74. data/spec/unit/active_record_extension_spec.rb +16 -0
  75. data/spec/unit/adapters/active_record_spec.rb +11 -9
  76. data/spec/unit/adapters/mongoid_spec.rb +4 -4
  77. data/spec/unit/config/actions/base_spec.rb +32 -0
  78. data/spec/unit/config/fields/base_spec.rb +56 -0
  79. data/spec/unit/config/fields/date_spec.rb +53 -0
  80. data/spec/unit/config/fields/datetime_spec.rb +55 -0
  81. data/spec/unit/config/fields/time_spec.rb +39 -0
  82. data/spec/unit/config/fields/timestamp_spec.rb +20 -0
  83. data/spec/unit/config_spec.rb +1 -1
  84. data/spec/unit/support/csv_converter_spec.rb +16 -0
  85. metadata +44 -35
  86. data/lib/rails_admin/config/fields/factories/serialized.rb +0 -17
  87. data/lib/tasks/prepare_ci_env.rake +0 -27
@@ -36,7 +36,7 @@ module RailsAdmin
36
36
 
37
37
  def all(options = {},scope=nil)
38
38
  scope ||= self.scoped
39
- scope = scope.includes(options[:include]) if options[:include]
39
+ scope = scope.includes(*options[:include]) if options[:include]
40
40
  scope = scope.limit(options[:limit]) if options[:limit]
41
41
  scope = scope.any_in(:_id => options[:bulk_ids]) if options[:bulk_ids]
42
42
  scope = scope.where(query_conditions(options[:query])) if options[:query]
@@ -83,44 +83,13 @@ module RailsAdmin
83
83
  def properties
84
84
  fields = model.fields.reject{|name, field| DISABLED_COLUMN_TYPES.include?(field.type.to_s) }
85
85
  fields.map do |name,field|
86
- ar_type = {
87
- "Array" => { :type => :serialized },
88
- "BigDecimal" => { :type => :decimal },
89
- "Boolean" => { :type => :boolean },
90
- "BSON::ObjectId" => { :type => :bson_object_id, :serial? => (name == primary_key) },
91
- "Moped::BSON::ObjectId" => { :type => :bson_object_id, :serial? => (name == primary_key) },
92
- "Date" => { :type => :date },
93
- "DateTime" => { :type => :datetime },
94
- "Float" => { :type => :float },
95
- "Hash" => { :type => :serialized },
96
- "Integer" => { :type => :integer },
97
- "Object" => (
98
- if associations.find{|a| a[:type] == :belongs_to && a[:foreign_key] == name.to_sym}
99
- { :type => :bson_object_id }
100
- else
101
- { :type => :string, :length => 255 }
102
- end
103
- ),
104
- "String" => (
105
- if (length = length_validation_lookup(name)) && length < 256
106
- { :type => :string, :length => length }
107
- elsif STRING_TYPE_COLUMN_NAMES.include?(name.to_sym)
108
- { :type => :string, :length => 255 }
109
- else
110
- { :type => :text }
111
- end
112
- ),
113
- "Symbol" => { :type => :string, :length => 255 },
114
- "Time" => { :type => :datetime },
115
- }[field.type.to_s] or raise "Need to map field #{field.type.to_s} for field name #{name} in #{model.inspect}"
116
-
117
86
  {
118
87
  :name => field.name.to_sym,
119
88
  :length => nil,
120
89
  :pretty_name => field.name.to_s.gsub('_', ' ').strip.capitalize,
121
90
  :nullable? => true,
122
91
  :serial? => false,
123
- }.merge(ar_type)
92
+ }.merge(type_lookup(name, field))
124
93
  end
125
94
  end
126
95
 
@@ -128,12 +97,6 @@ module RailsAdmin
128
97
  model.collection_name.to_s
129
98
  end
130
99
 
131
- def serialized_attributes
132
- # Mongoid Array and Hash type columns are mapped to RA serialized type
133
- # through type detection in self#properties.
134
- []
135
- end
136
-
137
100
  def encoding
138
101
  'UTF-8'
139
102
  end
@@ -237,11 +200,11 @@ module RailsAdmin
237
200
  return if value.blank?
238
201
  value = case operator
239
202
  when 'default', 'like'
240
- Regexp.compile(Regexp.escape(value))
203
+ Regexp.compile(Regexp.escape(value), Regexp::IGNORECASE)
241
204
  when 'starts_with'
242
- Regexp.compile("^#{Regexp.escape(value)}")
205
+ Regexp.compile("^#{Regexp.escape(value)}", Regexp::IGNORECASE)
243
206
  when 'ends_with'
244
- Regexp.compile("#{Regexp.escape(value)}$")
207
+ Regexp.compile("#{Regexp.escape(value)}$", Regexp::IGNORECASE)
245
208
  when 'is', '='
246
209
  value.to_s
247
210
  else
@@ -277,6 +240,39 @@ module RailsAdmin
277
240
  end
278
241
  end
279
242
 
243
+ def type_lookup(name, field)
244
+ {
245
+ "Array" => { :type => :serialized },
246
+ "BigDecimal" => { :type => :decimal },
247
+ "Boolean" => { :type => :boolean },
248
+ "BSON::ObjectId" => { :type => :bson_object_id, :serial? => (name == primary_key) },
249
+ "Moped::BSON::ObjectId" => { :type => :bson_object_id, :serial? => (name == primary_key) },
250
+ "Date" => { :type => :date },
251
+ "DateTime" => { :type => :datetime },
252
+ "Float" => { :type => :float },
253
+ "Hash" => { :type => :serialized },
254
+ "Integer" => { :type => :integer },
255
+ "Object" => (
256
+ if associations.find{|a| a[:type] == :belongs_to && a[:foreign_key] == name.to_sym}
257
+ { :type => :bson_object_id }
258
+ else
259
+ { :type => :string, :length => 255 }
260
+ end
261
+ ),
262
+ "String" => (
263
+ if (length = length_validation_lookup(name)) && length < 256
264
+ { :type => :string, :length => length }
265
+ elsif STRING_TYPE_COLUMN_NAMES.include?(name.to_sym)
266
+ { :type => :string, :length => 255 }
267
+ else
268
+ { :type => :text }
269
+ end
270
+ ),
271
+ "Symbol" => { :type => :string, :length => 255 },
272
+ "Time" => { :type => :datetime },
273
+ }[field.type.to_s] or raise "Need to map field #{field.type.to_s} for field name #{name} in #{model.inspect}"
274
+ end
275
+
280
276
  def association_model_proc_lookup(association)
281
277
  if association.polymorphic? && [:referenced_in, :belongs_to].include?(association.macro)
282
278
  RailsAdmin::AbstractModel.polymorphic_parents(:mongoid, association.name) || []
@@ -9,7 +9,7 @@ module RailsAdmin
9
9
  self.nested_attributes_options = {}
10
10
  class << self
11
11
  def rails_admin(&block)
12
- RailsAdmin::Config.model(self, &block)
12
+ RailsAdmin.config(self, &block)
13
13
  end
14
14
  alias_method_chain :accepts_nested_attributes_for, :rails_admin
15
15
  end
@@ -63,9 +63,16 @@ module RailsAdmin
63
63
  # Stores model configuration objects in a hash identified by model's class
64
64
  # name.
65
65
  #
66
- # @see RailsAdmin::Config.model
66
+ # @see RailsAdmin.config
67
67
  attr_reader :registry
68
68
 
69
+ # accepts a hash of static links to be shown below the main navigation
70
+ attr_accessor :navigation_static_links
71
+ attr_accessor :navigation_static_label
72
+
73
+ # yell about fields that are not marked as accessible
74
+ attr_accessor :yell_for_non_accessible_fields
75
+
69
76
  # Setup authentication to be run as a before filter
70
77
  # This is run inside the controller instance so you can setup any authentication you need to
71
78
  #
@@ -264,6 +271,10 @@ module RailsAdmin
264
271
  #
265
272
  # @see RailsAdmin::Config.registry
266
273
  def models(&block)
274
+ if block
275
+ raise 'coucou'
276
+ ActiveSupport::Deprecation.warn("'config.models do ... end' is deprecated for performance reasons and will be removed in next major release, please duplicate to every concerned model instead.")
277
+ end
267
278
  RailsAdmin::AbstractModel.all.map{|m| model(m, &block)}
268
279
  end
269
280
 
@@ -272,6 +283,7 @@ module RailsAdmin
272
283
  # @see RailsAdmin::Config.registry
273
284
  def reset
274
285
  @compact_show_view = true
286
+ @yell_for_non_accessible_fields = true
275
287
  @authenticate = nil
276
288
  @authorize = nil
277
289
  @audit = nil
@@ -289,6 +301,8 @@ module RailsAdmin
289
301
  @label_methods = [:name, :title]
290
302
  @main_app_name = Proc.new { [Rails.application.engine_name.titleize.chomp(' Application'), 'Admin'] }
291
303
  @registry = {}
304
+ @navigation_static_links = {}
305
+ @navigation_static_label = nil
292
306
  RailsAdmin::Config::Actions.reset
293
307
  end
294
308
 
@@ -9,6 +9,14 @@ module RailsAdmin
9
9
  include RailsAdmin::Config::Proxyable
10
10
  include RailsAdmin::Config::Configurable
11
11
  include RailsAdmin::Config::Hideable
12
+
13
+ register_instance_option :only do
14
+ nil
15
+ end
16
+
17
+ register_instance_option :except do
18
+ []
19
+ end
12
20
 
13
21
  # http://twitter.github.com/bootstrap/base-css.html#icons
14
22
  register_instance_option :link_icon do
@@ -17,11 +25,17 @@ module RailsAdmin
17
25
 
18
26
  # Should the action be visible
19
27
  register_instance_option :visible? do
20
- authorized? && (bindings[:abstract_model] ? bindings[:abstract_model].config.with(bindings).try(:visible?) : true)
28
+ authorized?
21
29
  end
22
30
 
23
31
  register_instance_option :authorized? do
24
- bindings[:controller] ? bindings[:controller].authorized?(self.authorization_key, bindings[:abstract_model], bindings[:object]) : true
32
+ (
33
+ bindings[:controller].nil? or bindings[:controller].authorized?(self.authorization_key, bindings[:abstract_model], bindings[:object])) and (
34
+ bindings[:abstract_model].nil? or (
35
+ (only.nil? or [only].flatten.map(&:to_s).include?(bindings[:abstract_model].model.to_s)) and
36
+ ![except].flatten.map(&:to_s).include?(bindings[:abstract_model].model.to_s) and
37
+ bindings[:abstract_model].config.with(bindings).visible?
38
+ ))
25
39
  end
26
40
 
27
41
  # Is the action acting on the root level (Example: /admin/contact)
@@ -15,18 +15,20 @@ module RailsAdmin
15
15
  register_instance_option :controller do
16
16
  Proc.new do
17
17
  @history = @auditing_adapter && @auditing_adapter.latest || []
18
- @abstract_models = RailsAdmin::Config.visible_models(:controller => self).map(&:abstract_model)
18
+ if @action.statistics?
19
+ @abstract_models = RailsAdmin::Config.visible_models(:controller => self).map(&:abstract_model)
19
20
 
20
- @most_recent_changes = {}
21
- @count = {}
22
- @max = 0
23
- @abstract_models.each do |t|
24
- scope = @authorization_adapter && @authorization_adapter.query(:index, t)
25
- current_count = t.count({}, scope)
26
- @max = current_count > @max ? current_count : @max
27
- @count[t.pretty_name] = current_count
28
- if t.properties.find{|c| c[:name] == :updated_at }
29
- @most_recent_changes[t.pretty_name] = t.first(:sort => :updated_at).try(:updated_at)
21
+ @most_recent_changes = {}
22
+ @count = {}
23
+ @max = 0
24
+ @abstract_models.each do |t|
25
+ scope = @authorization_adapter && @authorization_adapter.query(:index, t)
26
+ current_count = t.count({}, scope)
27
+ @max = current_count > @max ? current_count : @max
28
+ @count[t.pretty_name] = current_count
29
+ if t.properties.find{|c| c[:name] == :updated_at }
30
+ @most_recent_changes[t.pretty_name] = t.first(:sort => :updated_at).try(:updated_at)
31
+ end
30
32
  end
31
33
  end
32
34
  render @action.template_name, :status => (flash[:error].present? ? :not_found : 200)
@@ -40,6 +42,10 @@ module RailsAdmin
40
42
  register_instance_option :link_icon do
41
43
  'icon-home'
42
44
  end
45
+
46
+ register_instance_option :statistics? do
47
+ true
48
+ end
43
49
  end
44
50
  end
45
51
  end
@@ -85,4 +85,3 @@ require 'rails_admin/config/fields/factories/paperclip'
85
85
  require 'rails_admin/config/fields/factories/dragonfly'
86
86
  require 'rails_admin/config/fields/factories/carrierwave'
87
87
  require 'rails_admin/config/fields/factories/association'
88
- require 'rails_admin/config/fields/factories/serialized'
@@ -18,11 +18,10 @@ module RailsAdmin
18
18
  register_instance_option(:pretty_value) do
19
19
  v = bindings[:view]
20
20
  [value].flatten.select(&:present?).map do |associated|
21
- amc = polymorphic? ? RailsAdmin::Config.model(associated) : associated_model_config # perf optimization for non-polymorphic associations
21
+ amc = polymorphic? ? RailsAdmin.config(associated) : associated_model_config # perf optimization for non-polymorphic associations
22
22
  am = amc.abstract_model
23
23
  wording = associated.send(amc.object_label_method)
24
- can_see = v.authorized?(:show, am, associated) && !am.embedded?
25
- can_see = can_see && (show_action = RailsAdmin::Config::Actions.find(:show, { :controller => v.controller, :abstract_model => am, :object => associated }))
24
+ can_see = !am.embedded? && (show_action = v.action(:show, am, associated))
26
25
  can_see ? v.link_to(wording, v.url_for(:action => show_action.action_name, :model_name => am.to_param, :id => associated.id), :class => 'pjax') : wording
27
26
  end.to_sentence.html_safe
28
27
  end
@@ -138,6 +138,10 @@ module RailsAdmin
138
138
  (@label ||= {})[::I18n.locale] ||= abstract_model.model.human_attribute_name name
139
139
  end
140
140
 
141
+ register_instance_option :hint do
142
+ (@hint ||= "")
143
+ end
144
+
141
145
  # Accessor for field's maximum length per database.
142
146
  #
143
147
  # @see RailsAdmin::AbstractModel.properties
@@ -160,10 +164,12 @@ module RailsAdmin
160
164
  #
161
165
  # @see RailsAdmin::AbstractModel.properties
162
166
  register_instance_option :required? do
163
- @required ||= !!([name] + children_fields).uniq.find do |column_name|
167
+ context = (bindings && bindings[:object] ? (bindings[:object].persisted? ? :update : :create) : :nil)
168
+ (@required ||= {})[context] ||= !!([name] + children_fields).uniq.find do |column_name|
164
169
  !!abstract_model.model.validators_on(column_name).find do |v|
165
- v.kind == :presence && !v.options[:allow_nil] ||
166
- v.kind == :numericality && !v.options[:allow_nil]
170
+ !v.options[:allow_nil] and
171
+ [:presence, :numericality].include?(v.kind) and
172
+ (v.options[:on] == context or v.options[:on].blank?)
167
173
  end
168
174
  end
169
175
  end
@@ -204,12 +210,17 @@ module RailsAdmin
204
210
  end
205
211
 
206
212
  register_instance_option :render do
207
- bindings[:view].render :partial => partial.to_s, :locals => {:field => self, :form => bindings[:form] }
213
+ bindings[:view].render :partial => "rails_admin/main/#{partial}", :locals => {:field => self, :form => bindings[:form] }
208
214
  end
209
215
 
210
216
  def editable?
211
217
  return false if @properties && @properties[:read_only]
212
- !bindings[:object].class.active_authorizer[bindings[:view].controller.send(:_attr_accessible_role)].deny?(self.method_name)
218
+ active_model_attr_accessible = !bindings[:object].class.active_authorizer[bindings[:view].controller.send(:_attr_accessible_role)].deny?(self.method_name)
219
+ return true if active_model_attr_accessible
220
+ if RailsAdmin::Config.yell_for_non_accessible_fields
221
+ Rails.logger.debug "\n\n[RailsAdmin] Please add 'attr_accessible :#{self.method_name}' in your '#{bindings[:object].class}' model definition if you want to make it editable.\nYou can also explicitely mark this field as read-only: \n\nconfig.model #{bindings[:object].class} do\n field :#{self.name} do\n read_only true\n end\nend\n\nAdd 'config.yell_for_non_accessible_fields = false' in your 'rails_admin.rb' initializer if you do not want to see these warnings\n\n"
222
+ end
223
+ false
213
224
  end
214
225
 
215
226
  # Is this an association
@@ -280,7 +291,8 @@ module RailsAdmin
280
291
  "#<#{self.class.name}[#{name}] #{
281
292
  instance_variables.map do |v|
282
293
  value = instance_variable_get(v)
283
- if [:@parent, :@root, :@section].include? v
294
+ if [:@parent, :@root, :@section, :@children_fields_registered,
295
+ :@associated_model_config, :@group, :@bindings].include? v
284
296
  if value.respond_to? :name
285
297
  "#{v}=#{value.name.inspect}"
286
298
  else
@@ -28,6 +28,10 @@ module RailsAdmin
28
28
  value.presence || ' - '
29
29
  end
30
30
  end
31
+
32
+ register_instance_option(:multiple?) do
33
+ properties && [:serialized].include?(properties[:type])
34
+ end
31
35
  end
32
36
  end
33
37
  end
@@ -22,10 +22,12 @@ module RailsAdmin
22
22
  else
23
23
  max_length = [length, valid_length[:maximum] || nil].compact.min
24
24
  min_length = [0, valid_length[:minimum] || nil].compact.max
25
- if min_length == 0
26
- text += "#{I18n.translate("admin.form.char_length_up_to").capitalize} #{max_length}."
27
- else
28
- text += "#{I18n.translate("admin.form.char_length_of").capitalize} #{min_length}-#{max_length}."
25
+ if max_length
26
+ if min_length == 0
27
+ text += "#{I18n.translate("admin.form.char_length_up_to").capitalize} #{max_length}."
28
+ else
29
+ text += "#{I18n.translate("admin.form.char_length_of").capitalize} #{min_length}-#{max_length}."
30
+ end
29
31
  end
30
32
  end
31
33
  text
@@ -7,7 +7,7 @@ module RailsAdmin
7
7
  class Text < RailsAdmin::Config::Fields::Base
8
8
  # Register field type for the type loader
9
9
  RailsAdmin::Config::Fields::Types::register(self)
10
-
10
+
11
11
  # CKEditor is disabled by default
12
12
  register_instance_option(:ckeditor) do
13
13
  false
@@ -45,7 +45,7 @@ module RailsAdmin
45
45
  #Pass the location of the theme and mode for Codemirror
46
46
  register_instance_option(:codemirror_assets) do
47
47
  {
48
- :mode => '/assets/codemirror/modes/css.js',
48
+ :mode => '/assets/codemirror/modes/css.js',
49
49
  :theme => '/assets/codemirror/themes/night.css'
50
50
  }
51
51
  end
@@ -60,6 +60,19 @@ module RailsAdmin
60
60
  '/assets/codemirror.css'
61
61
  end
62
62
 
63
+ # bootstrap_wysihtml5
64
+ register_instance_option(:bootstrap_wysihtml5) do
65
+ false
66
+ end
67
+
68
+ register_instance_option(:bootstrap_wysihtml5_css_location) do
69
+ '/assets/bootstrap-wysihtml5.css'
70
+ end
71
+
72
+ register_instance_option(:bootstrap_wysihtml5_js_location) do
73
+ '/assets/bootstrap-wysihtml5-all.js'
74
+ end
75
+
63
76
  register_instance_option(:html_attributes) do
64
77
  {
65
78
  :cols => '48',
@@ -70,6 +83,10 @@ module RailsAdmin
70
83
  register_instance_option(:partial) do
71
84
  :form_text
72
85
  end
86
+
87
+ register_instance_option :formatted_value do
88
+ value.to_s.html_safe
89
+ end
73
90
  end
74
91
  end
75
92
  end
@@ -83,6 +83,23 @@ module RailsAdmin
83
83
  def method_missing(m, *args, &block)
84
84
  self.send(:base).send(m, *args, &block)
85
85
  end
86
+
87
+ def inspect
88
+ "#<#{self.class.name}[#{abstract_model.model.name}] #{
89
+ instance_variables.map do |v|
90
+ value = instance_variable_get(v)
91
+ if [:@parent, :@root].include? v
92
+ if value.respond_to? :name
93
+ "#{v}=#{value.name.inspect}"
94
+ else
95
+ "#{v}=#{value.class.name}"
96
+ end
97
+ else
98
+ "#{v}=#{value.inspect}"
99
+ end
100
+ end.join(", ")
101
+ }>"
102
+ end
86
103
  end
87
104
  end
88
105
  end
@@ -23,6 +23,23 @@ module RailsAdmin
23
23
 
24
24
  @abstract_model = root.abstract_model
25
25
  end
26
+
27
+ def inspect
28
+ "#<#{self.class.name} #{
29
+ instance_variables.map do |v|
30
+ value = instance_variable_get(v)
31
+ if [:@parent, :@root, :@abstract_model].include? v
32
+ if value.respond_to? :name
33
+ "#{v}=#{value.name.inspect}"
34
+ else
35
+ "#{v}=#{value.class.name}"
36
+ end
37
+ else
38
+ "#{v}=#{value.inspect}"
39
+ end
40
+ end.join(", ")
41
+ }>"
42
+ end
26
43
  end
27
44
  end
28
45
  end