rails_admin 0.3.0 → 0.4.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.
- data/Gemfile +2 -2
- data/README.md +13 -6
- 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_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_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_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/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/jquery.colorpicker.css.scss +1 -0
- data/app/controllers/rails_admin/main_controller.rb +1 -1
- data/app/helpers/rails_admin/application_helper.rb +3 -2
- data/app/views/rails_admin/main/index.html.haml +1 -1
- data/lib/generators/rails_admin/install_generator.rb +1 -1
- data/lib/rails_admin/abstract_model.rb +4 -0
- data/lib/rails_admin/adapters/active_record.rb +4 -0
- data/lib/rails_admin/adapters/mongoid.rb +6 -0
- data/lib/rails_admin/adapters/mongoid/abstract_object.rb +3 -3
- data/lib/rails_admin/config.rb +9 -12
- data/lib/rails_admin/config/actions/base.rb +4 -3
- data/lib/rails_admin/config/fields/association.rb +1 -1
- data/lib/rails_admin/config/fields/base.rb +1 -1
- data/lib/rails_admin/config/fields/factories/association.rb +1 -1
- data/lib/rails_admin/config/fields/types/belongs_to_association.rb +1 -1
- data/lib/rails_admin/config/fields/types/boolean.rb +2 -2
- data/lib/rails_admin/config/fields/types/datetime.rb +1 -1
- data/lib/rails_admin/config/has_fields.rb +3 -2
- data/lib/rails_admin/config/lazy_model.rb +21 -0
- data/lib/rails_admin/extensions/history/history.rb +5 -5
- data/lib/rails_admin/support/csv_converter.rb +2 -6
- data/lib/rails_admin/version.rb +1 -1
- data/spec/controllers/{application_controller_spec.rb → rails_admin/application_controller_spec.rb} +0 -0
- data/spec/controllers/{main_controller_spec.rb → rails_admin/main_controller_spec.rb} +36 -4
- data/spec/dummy_app/Gemfile +2 -2
- data/spec/dummy_app/app/active_record/comment.rb +1 -1
- data/spec/dummy_app/app/active_record/team.rb +1 -1
- data/spec/dummy_app/app/mongoid/field_test.rb +2 -1
- data/spec/dummy_app/app/mongoid/team.rb +1 -1
- data/spec/dummy_app/db/seeds.rb +4 -4
- data/spec/dummy_app/db/test.sqlite3 +0 -0
- data/spec/dummy_app/log/test.log +156160 -0
- data/spec/helpers/rails_admin/application_helper_spec.rb +353 -0
- data/spec/helpers/{form_builder_spec.rb → rails_admin/form_builder_spec.rb} +0 -0
- data/spec/integration/authorization/cancan_spec.rb +13 -13
- data/spec/integration/basic/bulk_action/rails_admin_basic_bulk_action_spec.rb +2 -2
- data/spec/integration/basic/bulk_destroy/rails_admin_basic_bulk_destroy_spec.rb +13 -2
- data/spec/integration/basic/create/rails_admin_basic_create_spec.rb +8 -9
- data/spec/integration/basic/create/rails_admin_namespaced_model_create_spec.rb +1 -1
- data/spec/integration/basic/destroy/rails_admin_basic_destroy_spec.rb +4 -4
- data/spec/integration/basic/edit/rails_admin_basic_edit_spec.rb +2 -2
- data/spec/integration/basic/export/rails_admin_basic_export_spec.rb +2 -2
- data/spec/integration/basic/list/rails_admin_basic_list_spec.rb +51 -21
- data/spec/integration/basic/update/rails_admin_basic_update_spec.rb +15 -15
- data/spec/integration/config/edit/rails_admin_config_edit_spec.rb +13 -14
- data/spec/integration/config/list/rails_admin_config_list_spec.rb +7 -6
- data/spec/integration/config/show/rails_admin_config_show_spec.rb +1 -1
- data/spec/integration/rails_admin_spec.rb +2 -0
- data/spec/{unit → rails_admin}/abstract_model_spec.rb +7 -0
- data/spec/{unit → rails_admin}/active_record_extension_spec.rb +0 -0
- data/spec/{unit → rails_admin}/adapters/active_record/abstract_object_spec.rb +0 -0
- data/spec/{unit → rails_admin}/adapters/active_record_spec.rb +0 -0
- data/spec/{unit → rails_admin}/adapters/mongoid/abstract_object_spec.rb +0 -0
- data/spec/{unit → rails_admin}/adapters/mongoid_spec.rb +7 -1
- data/spec/{unit → rails_admin}/config/actions/base_spec.rb +0 -0
- data/spec/{unit → rails_admin}/config/actions_spec.rb +0 -0
- data/spec/{unit → rails_admin}/config/fields/base_spec.rb +0 -0
- data/spec/{unit → rails_admin}/config/fields/date_spec.rb +0 -0
- data/spec/{unit → rails_admin}/config/fields/datetime_spec.rb +0 -0
- data/spec/{unit → rails_admin}/config/fields/file_upload_spec.rb +0 -0
- data/spec/{unit → rails_admin}/config/fields/time_spec.rb +0 -0
- data/spec/{unit → rails_admin}/config/fields/timestamp_spec.rb +0 -0
- data/spec/rails_admin/config/fields/types/datetime_spec.rb +18 -0
- data/spec/{unit → rails_admin}/config/fields_spec.rb +0 -0
- data/spec/rails_admin/config/has_fields_spec.rb +30 -0
- data/spec/rails_admin/config/lazy_model_spec.rb +29 -0
- data/spec/{unit → rails_admin}/config/model_spec.rb +0 -0
- data/spec/{unit → rails_admin}/config/sections_spec.rb +0 -0
- data/spec/{unit → rails_admin}/config_spec.rb +0 -0
- data/spec/{unit → rails_admin}/support/csv_converter_spec.rb +0 -0
- data/spec/spec_helper.rb +2 -0
- metadata +65 -60
- data/spec/helpers/application_helper_spec.rb +0 -328
data/Gemfile
CHANGED
@@ -9,7 +9,7 @@ group :active_record do
|
|
9
9
|
platforms :ruby, :mswin, :mingw do
|
10
10
|
case ENV['CI_DB_ADAPTER']
|
11
11
|
when 'mysql'
|
12
|
-
gem 'mysql', '
|
12
|
+
gem 'mysql', '2.8.1'
|
13
13
|
when 'postgresql'
|
14
14
|
gem 'pg', '~> 0.13'
|
15
15
|
else
|
@@ -21,7 +21,7 @@ end
|
|
21
21
|
group :mongoid do
|
22
22
|
gem 'mongoid', '~> 3.0'
|
23
23
|
gem 'mongoid-paperclip', '~> 0.0.8', :require => 'mongoid_paperclip'
|
24
|
-
gem 'carrierwave-mongoid',
|
24
|
+
gem 'carrierwave-mongoid', '~> 0.3', :require => 'carrierwave/mongoid'
|
25
25
|
end
|
26
26
|
|
27
27
|
group :debug do
|
data/README.md
CHANGED
@@ -28,18 +28,25 @@ Hoeven][plukevdh], and [Rein Henrichs][reinh].
|
|
28
28
|
|
29
29
|
## Announcements
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
* `config.models do ... end` is deprecated (note the 's' to models, `config.model(MyModel) do .. end` is fine), for performance reasons (forces early loading of all application's models). Duplicate to each model instead, before next release. If you really need the old behavior:
|
31
|
+
RailsAdmin model configuration is now lazy loaded.
|
34
32
|
|
35
33
|
```ruby
|
36
|
-
config.
|
37
|
-
|
38
|
-
|
34
|
+
config.model 'Team' do
|
35
|
+
...
|
36
|
+
end
|
37
|
+
|
38
|
+
# or
|
39
|
+
class Team
|
40
|
+
rails_admin do
|
41
|
+
...
|
39
42
|
end
|
40
43
|
end
|
41
44
|
```
|
42
45
|
|
46
|
+
won't load the Team model.
|
47
|
+
|
48
|
+
Incidentally, you are only allowed one configuration block per model.
|
49
|
+
|
43
50
|
## Features
|
44
51
|
|
45
52
|
* Display database tables
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -130,7 +130,7 @@ module RailsAdmin
|
|
130
130
|
def get_collection(model_config, scope, pagination)
|
131
131
|
associations = model_config.list.fields.select {|f| f.type == :belongs_to_association && !f.polymorphic? }.map {|f| f.association[:name] }
|
132
132
|
options = {}
|
133
|
-
options = options.merge(:page => (params[
|
133
|
+
options = options.merge(:page => (params[Kaminari.config.param_name] || 1).to_i, :per => (params[:per] || model_config.list.items_per_page)) if pagination
|
134
134
|
options = options.merge(:include => associations) unless associations.blank?
|
135
135
|
options = options.merge(get_sort_hash(model_config))
|
136
136
|
options = options.merge(:query => params[:query]) if params[:query].present?
|
@@ -5,8 +5,9 @@ module RailsAdmin
|
|
5
5
|
|
6
6
|
include RailsAdmin::I18nSupport
|
7
7
|
|
8
|
-
def authorized?(
|
9
|
-
|
8
|
+
def authorized?(action, abstract_model = nil, object = nil)
|
9
|
+
object = nil if object.try :new_record?
|
10
|
+
@authorization_adapter.nil? || @authorization_adapter.authorized?(action, abstract_model, object)
|
10
11
|
end
|
11
12
|
|
12
13
|
def current_action?(action, abstract_model = @abstract_model, object = @object)
|
@@ -21,7 +21,7 @@
|
|
21
21
|
@index = 0
|
22
22
|
@ordered_filters = (params[:f] || @model_config.list.filters).inject({}) { |memo, filter|
|
23
23
|
field_name = filter.is_a?(Array) ? filter.first : filter
|
24
|
-
(filter.is_a?(Array) ? filter.last : { (@index += 1) => { "
|
24
|
+
(filter.is_a?(Array) ? filter.last : { (@index += 1) => { "v" => '' } }) .each do |index, filter_hash|
|
25
25
|
unless filter_hash['disabled']
|
26
26
|
memo[index] = { field_name => filter_hash }
|
27
27
|
else
|
@@ -20,7 +20,7 @@ module RailsAdmin
|
|
20
20
|
routes = File.open(Rails.root.join("config/routes.rb")).try :read
|
21
21
|
initializer = (File.open(Rails.root.join("config/initializers/rails_admin.rb")) rescue nil).try :read
|
22
22
|
|
23
|
-
display "Hello, RailsAdmin installer will help you
|
23
|
+
display "Hello, RailsAdmin installer will help you set things up!", :blue
|
24
24
|
display "I need to work with Devise, let's look at a few things first:"
|
25
25
|
display "Checking for a current installation of devise..."
|
26
26
|
unless defined?(Devise)
|
@@ -109,6 +109,10 @@ module RailsAdmin
|
|
109
109
|
ObjectId.from_string(str)
|
110
110
|
end
|
111
111
|
|
112
|
+
def adapter_supports_joins?
|
113
|
+
false
|
114
|
+
end
|
115
|
+
|
112
116
|
private
|
113
117
|
|
114
118
|
def query_conditions(query, fields = config.list.fields.select(&:queryable?))
|
@@ -263,6 +267,7 @@ module RailsAdmin
|
|
263
267
|
"Moped::BSON::ObjectId" => { :type => :bson_object_id, :serial? => (name == primary_key) },
|
264
268
|
"Date" => { :type => :date },
|
265
269
|
"DateTime" => { :type => :datetime },
|
270
|
+
"ActiveSupport::TimeWithZone" => { :type => :datetime },
|
266
271
|
"Float" => { :type => :float },
|
267
272
|
"Hash" => { :type => :serialized },
|
268
273
|
"Money" => { :type => :serialized },
|
@@ -408,6 +413,7 @@ module RailsAdmin
|
|
408
413
|
|
409
414
|
def sort_by(options, scope)
|
410
415
|
return scope unless options[:sort]
|
416
|
+
|
411
417
|
field_name, collection_name = options[:sort].to_s.split('.').reverse
|
412
418
|
if collection_name && collection_name != table_name
|
413
419
|
# sorting by associated model column is not supported, so just ignore
|
@@ -13,11 +13,11 @@ module RailsAdmin
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def #{name.to_s.singularize}_ids=(item_ids)
|
16
|
-
|
16
|
+
__items__ = Array.wrap(item_ids).map{|item_id| #{name}.klass.find(item_id) rescue nil }.compact
|
17
17
|
if persisted?
|
18
|
-
#{name}.substitute
|
18
|
+
#{name}.substitute __items__
|
19
19
|
else
|
20
|
-
|
20
|
+
__items__.each do |item|
|
21
21
|
item.update_attribute('#{association.foreign_key}', id)
|
22
22
|
end
|
23
23
|
end
|
data/lib/rails_admin/config.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'rails_admin/config/
|
1
|
+
require 'rails_admin/config/lazy_model'
|
2
2
|
require 'rails_admin/config/sections/list'
|
3
3
|
require 'active_support/core_ext/class/attribute_accessors'
|
4
4
|
|
@@ -244,9 +244,12 @@ module RailsAdmin
|
|
244
244
|
entity.class.name.to_sym
|
245
245
|
end
|
246
246
|
end
|
247
|
-
|
248
|
-
|
249
|
-
|
247
|
+
|
248
|
+
if block
|
249
|
+
@registry[key] = RailsAdmin::Config::LazyModel.new(entity, &block)
|
250
|
+
else
|
251
|
+
@registry[key] ||= RailsAdmin::Config::LazyModel.new(entity)
|
252
|
+
end
|
250
253
|
end
|
251
254
|
|
252
255
|
def default_hidden_fields=(fields)
|
@@ -266,15 +269,9 @@ module RailsAdmin
|
|
266
269
|
|
267
270
|
# Returns all model configurations
|
268
271
|
#
|
269
|
-
# If a block is given it is evaluated in the context of configuration
|
270
|
-
# instances.
|
271
|
-
#
|
272
272
|
# @see RailsAdmin::Config.registry
|
273
|
-
def models
|
274
|
-
|
275
|
-
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.")
|
276
|
-
end
|
277
|
-
RailsAdmin::AbstractModel.all.map{|m| model(m, &block)}
|
273
|
+
def models
|
274
|
+
RailsAdmin::AbstractModel.all.map{|m| model(m)}
|
278
275
|
end
|
279
276
|
|
280
277
|
# Reset all configurations to defaults.
|
@@ -30,10 +30,11 @@ module RailsAdmin
|
|
30
30
|
|
31
31
|
register_instance_option :authorized? do
|
32
32
|
(
|
33
|
-
bindings[:controller].nil? or bindings[:controller].authorized?(self.authorization_key, bindings[:abstract_model], bindings[:object])
|
33
|
+
bindings[:controller].nil? or bindings[:controller].authorized?(self.authorization_key, bindings[:abstract_model], bindings[:object])
|
34
|
+
) and (
|
34
35
|
bindings[:abstract_model].nil? or (
|
35
|
-
(only.nil? or [only].flatten.map(&:to_s).include?(bindings[:abstract_model].
|
36
|
-
![except].flatten.map(&:to_s).include?(bindings[:abstract_model].
|
36
|
+
(only.nil? or [only].flatten.map(&:to_s).include?(bindings[:abstract_model].to_s)) and
|
37
|
+
![except].flatten.map(&:to_s).include?(bindings[:abstract_model].to_s) and
|
37
38
|
bindings[:abstract_model].config.with(bindings).visible?
|
38
39
|
))
|
39
40
|
end
|
@@ -16,7 +16,7 @@ RailsAdmin::Config::Fields.register_factory do |parent, properties, fields|
|
|
16
16
|
end.map{|k| association[k] }.compact
|
17
17
|
|
18
18
|
parent.abstract_model.properties.select{|p| possible_field_names.include? p[:name] }.each do |column|
|
19
|
-
unless child_field = fields.find{|f| f.name.to_s == column[:name].to_s }
|
19
|
+
unless child_field = fields.find{|f| f.name.to_s == column[:name].to_s }
|
20
20
|
child_field = RailsAdmin::Config::Fields.default_factory.call(parent, column, fields)
|
21
21
|
end
|
22
22
|
child_columns << child_field
|
@@ -12,7 +12,7 @@ module RailsAdmin
|
|
12
12
|
end
|
13
13
|
|
14
14
|
register_instance_option :sortable do
|
15
|
-
@sortable ||= associated_model_config.abstract_model.properties.map{ |p| p[:name] }.include?(associated_model_config.object_label_method) ? associated_model_config.object_label_method : {self.abstract_model.table_name => self.method_name}
|
15
|
+
@sortable ||= abstract_model.adapter_supports_joins? && associated_model_config.abstract_model.properties.map{ |p| p[:name] }.include?(associated_model_config.object_label_method) ? associated_model_config.object_label_method : {self.abstract_model.table_name => self.method_name}
|
16
16
|
end
|
17
17
|
|
18
18
|
register_instance_option :searchable do
|
@@ -16,9 +16,9 @@ module RailsAdmin
|
|
16
16
|
case value
|
17
17
|
when nil
|
18
18
|
%{<span class="badge">-</span>}
|
19
|
-
when false
|
19
|
+
when false
|
20
20
|
%{<span class="badge badge-important">✘</span>}
|
21
|
-
when true
|
21
|
+
when true
|
22
22
|
%{<span class="badge badge-success">✓</span>}
|
23
23
|
end.html_safe
|
24
24
|
end
|
@@ -52,7 +52,7 @@ module RailsAdmin
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def formatted_date_value
|
55
|
-
value = bindings[:object].new_record? && self.value.nil? && !self.default_value.nil? ? self.default_value :
|
55
|
+
value = bindings[:object].new_record? && self.value.nil? && !self.default_value.nil? ? self.default_value : self.value
|
56
56
|
value.nil? ? "" : I18n.l(value, :format => localized_date_format).strip
|
57
57
|
end
|
58
58
|
|
@@ -8,8 +8,9 @@ module RailsAdmin
|
|
8
8
|
|
9
9
|
# some fields are hidden by default (belongs_to keys, has_many associations in list views.)
|
10
10
|
# unhide them if config specifically defines them
|
11
|
-
|
12
|
-
|
11
|
+
if field
|
12
|
+
field.show unless field.instance_variable_get("@#{field.name}_registered").is_a?(Proc)
|
13
|
+
end
|
13
14
|
# Specify field as virtual if type is not specifically set and field was not
|
14
15
|
# found in default stack
|
15
16
|
if field.nil? && type.nil?
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails_admin/config/model'
|
2
|
+
|
3
|
+
module RailsAdmin
|
4
|
+
module Config
|
5
|
+
class LazyModel
|
6
|
+
def initialize(entity, &block)
|
7
|
+
@entity = entity
|
8
|
+
@deferred_block = block
|
9
|
+
end
|
10
|
+
|
11
|
+
def method_missing(method, *args, &block)
|
12
|
+
if !@model
|
13
|
+
@model = RailsAdmin::Config::Model.new(@entity)
|
14
|
+
@model.instance_eval(&@deferred_block) if @deferred_block
|
15
|
+
end
|
16
|
+
|
17
|
+
@model.send(method, *args, &block)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -15,20 +15,20 @@ class RailsAdmin::History < ActiveRecord::Base
|
|
15
15
|
create(
|
16
16
|
:message => [message].flatten.join(', '),
|
17
17
|
:item => object.id,
|
18
|
-
:table => abstract_model.
|
18
|
+
:table => abstract_model.to_s,
|
19
19
|
:username => user.try(:email)
|
20
20
|
)
|
21
21
|
end
|
22
22
|
|
23
|
-
def self.history_for_model(
|
24
|
-
history = where(:table =>
|
23
|
+
def self.history_for_model(abstract_model, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20))
|
24
|
+
history = where(:table => abstract_model.to_s)
|
25
25
|
history = history.where("message LIKE ? OR username LIKE ?", "%#{query}%", "%#{query}%") if query
|
26
26
|
history = history.order(sort_reverse == "true" ? "#{sort} DESC" : sort) if sort
|
27
27
|
all ? history : history.send(Kaminari.config.page_method_name, page.presence || "1").per(per_page)
|
28
28
|
end
|
29
29
|
|
30
|
-
def self.history_for_object(
|
31
|
-
history = where(:table =>
|
30
|
+
def self.history_for_object(abstract_model, object, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20))
|
31
|
+
history = where(:table => abstract_model.to_s, :item => object.id)
|
32
32
|
history = history.where("message LIKE ? OR username LIKE ?", "%#{query}%", "%#{query}%") if query
|
33
33
|
history = history.order(sort_reverse == "true" ? "#{sort} DESC" : sort) if sort
|
34
34
|
all ? history : history.send(Kaminari.config.page_method_name, page.presence || "1").per(per_page)
|
@@ -5,6 +5,7 @@ module RailsAdmin
|
|
5
5
|
|
6
6
|
CSVClass = RUBY_VERSION < '1.9' ? ::FasterCSV : ::CSV
|
7
7
|
NON_ASCII_ENCODINGS = /(UTF\-16)|(UTF\-32)|(ISO\-2022\-JP)|(Big5\-HKSCS)|(UTF\-7)/
|
8
|
+
UTF8_ENCODINGS = [nil, '', 'utf8', 'utf-8', 'unicode', 'UTF8', 'UTF-8', 'UNICODE']
|
8
9
|
|
9
10
|
class CSVConverter
|
10
11
|
|
@@ -42,11 +43,7 @@ module RailsAdmin
|
|
42
43
|
return '' if @objects.blank?
|
43
44
|
|
44
45
|
# encoding shenanigans first
|
45
|
-
@encoding_from =
|
46
|
-
'UTF-8'
|
47
|
-
else
|
48
|
-
encoding
|
49
|
-
end
|
46
|
+
@encoding_from = UTF8_ENCODINGS.include?(@abstract_model.encoding) ? 'UTF-8' : @abstract_model.encoding
|
50
47
|
|
51
48
|
unless options[:encoding_to].blank?
|
52
49
|
@encoding_to = options[:encoding_to]
|
@@ -106,4 +103,3 @@ module RailsAdmin
|
|
106
103
|
end
|
107
104
|
end
|
108
105
|
end
|
109
|
-
|