rails_admin 0.8.1 → 1.0.0.rc
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.
- checksums.yaml +4 -4
- data/Gemfile +3 -15
- data/LICENSE.md +1 -1
- data/README.md +21 -8
- data/app/assets/images/rails_admin/aristo/images/bg_fallback.png +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/bootstrap/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/rails_admin/bootstrap/glyphicons-halflings.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_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_submit.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/select.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/slider.png +0 -0
- data/app/assets/images/rails_admin/magnifier.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-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/ra.filter-box.js +1 -1
- data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.coffee +4 -1
- data/app/assets/javascripts/rails_admin/ra.remote-form.js +4 -1
- data/app/assets/javascripts/rails_admin/rails_admin.js +1 -1
- data/app/assets/stylesheets/rails_admin/aristo/images/bg_fallback.png +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.scss +5 -5
- data/app/assets/stylesheets/rails_admin/ra.widgets.scss +5 -1
- data/app/controllers/rails_admin/application_controller.rb +3 -3
- data/app/controllers/rails_admin/main_controller.rb +6 -6
- data/app/helpers/rails_admin/application_helper.rb +5 -5
- data/app/helpers/rails_admin/form_builder.rb +1 -1
- data/app/helpers/rails_admin/main_helper.rb +1 -1
- data/app/views/kaminari/{twitter-bootstrap → ra-twitter-bootstrap}/_gap.html.haml +0 -0
- data/app/views/kaminari/{twitter-bootstrap → ra-twitter-bootstrap}/_next_page.html.haml +0 -0
- data/app/views/kaminari/{twitter-bootstrap → ra-twitter-bootstrap}/_page.html.haml +0 -0
- data/app/views/kaminari/{twitter-bootstrap → ra-twitter-bootstrap}/_paginator.html.haml +0 -0
- data/app/views/kaminari/{twitter-bootstrap → ra-twitter-bootstrap}/_prev_page.html.haml +0 -0
- data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +1 -1
- data/app/views/rails_admin/main/_form_colorpicker.html.haml +1 -1
- data/app/views/rails_admin/main/dashboard.html.haml +5 -5
- data/app/views/rails_admin/main/export.html.haml +45 -36
- data/app/views/rails_admin/main/history.html.haml +2 -2
- data/app/views/rails_admin/main/index.html.haml +1 -1
- data/config/locales/rails_admin.en.yml +1 -1
- data/lib/generators/rails_admin/templates/initializer.erb +4 -0
- data/lib/rails_admin.rb +23 -0
- data/lib/rails_admin/adapters/active_record.rb +8 -3
- data/lib/rails_admin/adapters/mongoid.rb +10 -13
- data/lib/rails_admin/adapters/mongoid/abstract_object.rb +1 -0
- data/lib/rails_admin/adapters/mongoid/association.rb +1 -0
- data/lib/rails_admin/adapters/mongoid/bson.rb +29 -0
- data/lib/rails_admin/config.rb +12 -6
- data/lib/rails_admin/config/actions/bulk_delete.rb +2 -2
- data/lib/rails_admin/config/actions/dashboard.rb +3 -3
- data/lib/rails_admin/config/actions/export.rb +1 -1
- data/lib/rails_admin/config/actions/index.rb +6 -2
- data/lib/rails_admin/config/actions/new.rb +2 -1
- data/lib/rails_admin/config/fields/association.rb +5 -1
- data/lib/rails_admin/config/fields/types/active_record_enum.rb +4 -0
- data/lib/rails_admin/config/fields/types/bson_object_id.rb +1 -15
- data/lib/rails_admin/config/fields/types/datetime.rb +5 -2
- data/lib/rails_admin/config/fields/types/file_upload.rb +1 -1
- data/lib/rails_admin/config/fields/types/serialized.rb +2 -2
- data/lib/rails_admin/config/fields/types/wysihtml5.rb +2 -2
- data/lib/rails_admin/config/lazy_model.rb +44 -4
- data/lib/rails_admin/config/model.rb +1 -1
- data/lib/rails_admin/engine.rb +0 -1
- data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +2 -1
- data/lib/rails_admin/support/csv_converter.rb +9 -13
- data/lib/rails_admin/support/datetime.rb +6 -5
- data/lib/rails_admin/support/i18n.rb +7 -5
- data/lib/rails_admin/version.rb +4 -4
- metadata +22 -30
- data/app/assets/javascripts/rails_admin/jquery.remotipart.fixed.js +0 -72
|
@@ -16,7 +16,7 @@ module RailsAdmin
|
|
|
16
16
|
proc do
|
|
17
17
|
if format = params[:json] && :json || params[:csv] && :csv || params[:xml] && :xml
|
|
18
18
|
request.format = format
|
|
19
|
-
@schema = HashHelper.symbolize(params[:schema]) if params[:schema] # to_json and to_xml expect symbols for keys AND values.
|
|
19
|
+
@schema = HashHelper.symbolize(params[:schema].slice(:except, :include, :methods, :only).permit!.to_h) if params[:schema] # to_json and to_xml expect symbols for keys AND values.
|
|
20
20
|
@objects = list_entries(@model_config, :export)
|
|
21
21
|
index
|
|
22
22
|
else
|
|
@@ -71,13 +71,17 @@ module RailsAdmin
|
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
format.csv do
|
|
74
|
-
header, encoding, output = CSVConverter.new(@objects, @schema).to_csv(params[:csv_options])
|
|
74
|
+
header, encoding, output = CSVConverter.new(@objects, @schema).to_csv(params[:csv_options].permit!.to_h)
|
|
75
75
|
if params[:send_data]
|
|
76
76
|
send_data output,
|
|
77
77
|
type: "text/csv; charset=#{encoding}; #{'header=present' if header}",
|
|
78
78
|
disposition: "attachment; filename=#{params[:model_name]}_#{DateTime.now.strftime('%Y-%m-%d_%Hh%Mm%S')}.csv"
|
|
79
79
|
else
|
|
80
|
-
|
|
80
|
+
if Rails.version.to_s >= '5'
|
|
81
|
+
render plain: output
|
|
82
|
+
else
|
|
83
|
+
render text: output
|
|
84
|
+
end
|
|
81
85
|
end
|
|
82
86
|
end
|
|
83
87
|
end
|
|
@@ -21,7 +21,8 @@ module RailsAdmin
|
|
|
21
21
|
@object.send("#{name}=", value)
|
|
22
22
|
end
|
|
23
23
|
if object_params = params[@abstract_model.to_param]
|
|
24
|
-
|
|
24
|
+
sanitize_params_for!(request.xhr? ? :modal : :create)
|
|
25
|
+
@object.set_attributes(@object.attributes.merge(object_params.to_h))
|
|
25
26
|
end
|
|
26
27
|
respond_to do |format|
|
|
27
28
|
format.html { render @action.template_name }
|
|
@@ -54,7 +54,7 @@ module RailsAdmin
|
|
|
54
54
|
# preload entire associated collection (per associated_collection_scope) on load
|
|
55
55
|
# Be sure to set limit in associated_collection_scope if set is large
|
|
56
56
|
register_instance_option :associated_collection_cache_all do
|
|
57
|
-
@associated_collection_cache_all ||= (associated_model_config.abstract_model.count <
|
|
57
|
+
@associated_collection_cache_all ||= (associated_model_config.abstract_model.count < associated_model_limit)
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
# determines whether association's elements can be removed
|
|
@@ -105,6 +105,10 @@ module RailsAdmin
|
|
|
105
105
|
def virtual?
|
|
106
106
|
true
|
|
107
107
|
end
|
|
108
|
+
|
|
109
|
+
def associated_model_limit
|
|
110
|
+
RailsAdmin.config.default_associated_collection_limit
|
|
111
|
+
end
|
|
108
112
|
end
|
|
109
113
|
end
|
|
110
114
|
end
|
|
@@ -8,14 +8,6 @@ module RailsAdmin
|
|
|
8
8
|
# Register field type for the type loader
|
|
9
9
|
RailsAdmin::Config::Fields::Types.register(self)
|
|
10
10
|
|
|
11
|
-
OBJECT_ID ||= begin
|
|
12
|
-
if defined?(Moped::BSON)
|
|
13
|
-
Moped::BSON::ObjectId
|
|
14
|
-
elsif defined?(BSON::ObjectId)
|
|
15
|
-
BSON::ObjectId
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
11
|
register_instance_option :label do
|
|
20
12
|
label = ((@label ||= {})[::I18n.locale] ||= abstract_model.model.human_attribute_name name)
|
|
21
13
|
label = 'Id' if label == ''
|
|
@@ -35,13 +27,7 @@ module RailsAdmin
|
|
|
35
27
|
end
|
|
36
28
|
|
|
37
29
|
def parse_value(value)
|
|
38
|
-
value.present? ?
|
|
39
|
-
rescue BSON::ObjectId::Invalid
|
|
40
|
-
nil
|
|
41
|
-
rescue => e
|
|
42
|
-
unless ['BSON::InvalidObjectId', 'Moped::Errors::InvalidObjectId'].include? e.class.to_s
|
|
43
|
-
raise e
|
|
44
|
-
end
|
|
30
|
+
value.present? ? abstract_model.parse_object_id(value) : nil
|
|
45
31
|
end
|
|
46
32
|
|
|
47
33
|
def parse_input(params)
|
|
@@ -38,8 +38,11 @@ module RailsAdmin
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
register_instance_option :strftime_format do
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
begin
|
|
42
|
+
::I18n.t(date_format, scope: i18n_scope, raise: true)
|
|
43
|
+
rescue ::I18n::ArgumentError
|
|
44
|
+
"%B %d, %Y %H:%M"
|
|
45
|
+
end
|
|
43
46
|
end
|
|
44
47
|
|
|
45
48
|
register_instance_option :datepicker_options do
|
|
@@ -42,7 +42,7 @@ module RailsAdmin
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
register_instance_option :image? do
|
|
45
|
-
(url = resource_url.to_s) && url.split('.').last =~ /jpg|jpeg|png|gif/i
|
|
45
|
+
(url = resource_url.to_s) && url.split('.').last =~ /jpg|jpeg|png|gif|svg/i
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
register_instance_option :allowed_methods do
|
|
@@ -9,11 +9,11 @@ module RailsAdmin
|
|
|
9
9
|
RailsAdmin::Config::Fields::Types.register(self)
|
|
10
10
|
|
|
11
11
|
register_instance_option :formatted_value do
|
|
12
|
-
|
|
12
|
+
RailsAdmin.yaml_dump(value) unless value.nil?
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def parse_value(value)
|
|
16
|
-
value.present? ? (
|
|
16
|
+
value.present? ? (RailsAdmin.yaml_load(value) || nil) : nil
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def parse_input(params)
|
|
@@ -16,11 +16,11 @@ module RailsAdmin
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
register_instance_option :css_location do
|
|
19
|
-
ActionController::Base.helpers.asset_path('bootstrap-wysihtml5.css')
|
|
19
|
+
ActionController::Base.helpers.asset_path('bootstrap-wysihtml5/index.css')
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
register_instance_option :js_location do
|
|
23
|
-
ActionController::Base.helpers.asset_path('bootstrap-wysihtml5.js')
|
|
23
|
+
ActionController::Base.helpers.asset_path('bootstrap-wysihtml5/index.js')
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
register_instance_option :partial do
|
|
@@ -5,13 +5,53 @@ module RailsAdmin
|
|
|
5
5
|
class LazyModel < BasicObject
|
|
6
6
|
def initialize(entity, &block)
|
|
7
7
|
@entity = entity
|
|
8
|
-
@
|
|
8
|
+
@deferred_blocks = [*block]
|
|
9
|
+
@existing_blocks = []
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def add_deferred_block(&block)
|
|
13
|
+
@deferred_blocks << block
|
|
9
14
|
end
|
|
10
15
|
|
|
11
16
|
def target
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
@model ||= ::RailsAdmin::Config::Model.new(@entity)
|
|
18
|
+
# When evaluating multiple configuration blocks, the order of
|
|
19
|
+
# execution is important. As one would expect (in my opinion),
|
|
20
|
+
# options defined within a resource should take precedence over
|
|
21
|
+
# more general options defined in an initializer. This way,
|
|
22
|
+
# general settings for a number of resources could be specified
|
|
23
|
+
# in the initializer, while models could override these settings
|
|
24
|
+
# later, if required.
|
|
25
|
+
#
|
|
26
|
+
# CAVEAT: It cannot be guaranteed that blocks defined in an initializer
|
|
27
|
+
# will be loaded (and adde to @deferred_blocks) first. For instance, if
|
|
28
|
+
# the initializer references a model class before defining
|
|
29
|
+
# a RailsAdmin configuration block, the configuration from the
|
|
30
|
+
# resource will get added to @deferred_blocks first:
|
|
31
|
+
#
|
|
32
|
+
# # app/models/some_model.rb
|
|
33
|
+
# class SomeModel
|
|
34
|
+
# rails_admin do
|
|
35
|
+
# :
|
|
36
|
+
# end
|
|
37
|
+
# end
|
|
38
|
+
#
|
|
39
|
+
# # config/initializers/rails_admin.rb
|
|
40
|
+
# model = 'SomeModel'.constantize # blocks from SomeModel get loaded
|
|
41
|
+
# model.config model do # blocks from initializer gets loaded
|
|
42
|
+
# :
|
|
43
|
+
# end
|
|
44
|
+
#
|
|
45
|
+
# Thus, sort all blocks to excute for a resource by Proc.source_path,
|
|
46
|
+
# to guarantee that blocks from 'config/initializers' evaluate before
|
|
47
|
+
# blocks defined within a model class.
|
|
48
|
+
unless @deferred_blocks.empty?
|
|
49
|
+
@existing_blocks += @deferred_blocks
|
|
50
|
+
@existing_blocks.
|
|
51
|
+
partition { |block| block.source_location.first =~ %r{config\/initializers} }.
|
|
52
|
+
flatten.
|
|
53
|
+
each { |block| @model.instance_eval(&block) }
|
|
54
|
+
@deferred_blocks = []
|
|
15
55
|
end
|
|
16
56
|
@model
|
|
17
57
|
end
|
|
@@ -61,7 +61,7 @@ module RailsAdmin
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
register_instance_option :label_plural do
|
|
64
|
-
(@label_plural ||= {})[::I18n.locale] ||= abstract_model.model.model_name.human(count: Float::INFINITY, default: label.pluralize)
|
|
64
|
+
(@label_plural ||= {})[::I18n.locale] ||= abstract_model.model.model_name.human(count: Float::INFINITY, default: label.pluralize(::I18n.locale))
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
def pluralize(count)
|
data/lib/rails_admin/engine.rb
CHANGED
|
@@ -41,6 +41,7 @@ module RailsAdmin
|
|
|
41
41
|
def initialize(controller, user_class = 'User', version_class = '::Version')
|
|
42
42
|
fail('PaperTrail not found') unless defined?(PaperTrail)
|
|
43
43
|
@controller = controller
|
|
44
|
+
@controller.send(:set_paper_trail_whodunnit) if @controller
|
|
44
45
|
begin
|
|
45
46
|
@user_class = user_class.to_s.constantize
|
|
46
47
|
rescue NameError
|
|
@@ -97,7 +98,7 @@ module RailsAdmin
|
|
|
97
98
|
versions = versions.where('event LIKE ?', "%#{query}%") if query.present?
|
|
98
99
|
versions = versions.order(sort_reverse == 'true' ? "#{sort} DESC" : sort)
|
|
99
100
|
versions = all ? versions : versions.send(Kaminari.config.page_method_name, current_page).per(per_page)
|
|
100
|
-
paginated_proxies = Kaminari.paginate_array([], total_count: versions.total_count)
|
|
101
|
+
paginated_proxies = Kaminari.paginate_array([], total_count: versions.try(:total_count) || versions.count)
|
|
101
102
|
paginated_proxies = paginated_proxies.page(current_page).per(per_page)
|
|
102
103
|
versions.each do |version|
|
|
103
104
|
paginated_proxies << VersionProxy.new(version, @user_class)
|
|
@@ -3,8 +3,6 @@ require 'csv'
|
|
|
3
3
|
|
|
4
4
|
module RailsAdmin
|
|
5
5
|
class CSVConverter
|
|
6
|
-
UTF8_ENCODINGS = [nil, '', 'utf8', 'utf-8', 'unicode', 'UTF8', 'UTF-8', 'UNICODE', 'utf8mb4']
|
|
7
|
-
TARGET_ENCODINGS = %w(UTF-8 UTF-16LE UTF-16BE UTF-32LE UTF-32BE UTF-7 ISO-8859-1 ISO-8859-15 IBM850 MacRoman Windows-1252 ISO-8859-3 IBM852 ISO-8859-2 Windows-1250 IBM855 ISO-8859-5 KOI8-R MacCyrillic Windows-1251 IBM866 GB2312 GBK GB18030 Big5 Big5-HKSCS EUC-TW EUC-JP ISO-2022-JP Shift_JIS EUC-KR)
|
|
8
6
|
def initialize(objects = [], schema = {})
|
|
9
7
|
return self if (@objects = objects).blank?
|
|
10
8
|
|
|
@@ -34,24 +32,21 @@ module RailsAdmin
|
|
|
34
32
|
end
|
|
35
33
|
|
|
36
34
|
def to_csv(options = {})
|
|
37
|
-
|
|
38
|
-
@encoding_from = Encoding.find(UTF8_ENCODINGS.include?(@abstract_model.encoding) ? 'UTF-8' : @abstract_model.encoding)
|
|
39
|
-
@encoding_to = Encoding.find(options[:encoding_to].presence || @encoding_from)
|
|
35
|
+
encoding_to = Encoding.find(options[:encoding_to]) if options[:encoding_to].present?
|
|
40
36
|
|
|
41
37
|
csv_string = generate_csv_string(options)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
csv_string = csv_string.encode(@encoding_to, @encoding_from, invalid: :replace, undef: :replace, replace: '?')
|
|
38
|
+
if encoding_to
|
|
39
|
+
csv_string = csv_string.encode(encoding_to, invalid: :replace, undef: :replace, replace: '?')
|
|
45
40
|
end
|
|
41
|
+
|
|
46
42
|
# Add a BOM for utf8 encodings, helps with utf8 auto-detect for some versions of Excel.
|
|
47
43
|
# Don't add if utf8 but user don't want to touch input encoding:
|
|
48
44
|
# If user chooses utf8, they will open it in utf8 and BOM will disappear at reading.
|
|
49
45
|
# But that way "English" users who don't bother and chooses to let utf8 by default won't get BOM added
|
|
50
46
|
# and will not see it if Excel opens the file with a different encoding.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
[!options[:skip_header], @encoding_to.to_s, csv_string]
|
|
47
|
+
csv_string = "\xEF\xBB\xBF#{csv_string}" if encoding_to == Encoding::UTF_8
|
|
48
|
+
|
|
49
|
+
[!options[:skip_header], (encoding_to || csv_string.encoding).to_s, csv_string]
|
|
55
50
|
end
|
|
56
51
|
|
|
57
52
|
private
|
|
@@ -66,10 +61,11 @@ module RailsAdmin
|
|
|
66
61
|
|
|
67
62
|
def generate_csv_string(options)
|
|
68
63
|
generator_options = (options[:generator] || {}).symbolize_keys.delete_if { |_, value| value.blank? }
|
|
64
|
+
method = @objects.respond_to?(:find_each) ? :find_each : :each
|
|
65
|
+
|
|
69
66
|
CSV.generate(generator_options) do |csv|
|
|
70
67
|
csv << generate_csv_header unless options[:skip_header]
|
|
71
68
|
|
|
72
|
-
method = @objects.respond_to?(:find_each) ? :find_each : :each
|
|
73
69
|
@objects.send(method) do |object|
|
|
74
70
|
csv << generate_csv_row(object)
|
|
75
71
|
end
|
|
@@ -10,6 +10,7 @@ module RailsAdmin
|
|
|
10
10
|
'%b' => 'MMM', # The abbreviated month name ("Jan")
|
|
11
11
|
'%B' => 'MMMM', # The full month name ("January")
|
|
12
12
|
'%d' => 'DD', # Day of the month (01..31)
|
|
13
|
+
'%-d' => 'D', # Day of the month (1..31)
|
|
13
14
|
'%D' => 'MM/DD/YY', # American date format mm/dd/yy
|
|
14
15
|
'%e' => 'D', # Day of the month (1..31)
|
|
15
16
|
'%F' => 'YY-MM-DD', # ISO 8601 date format
|
|
@@ -32,16 +33,16 @@ module RailsAdmin
|
|
|
32
33
|
format.to_s.scan(/%[AaBbp]/) do |match|
|
|
33
34
|
case match
|
|
34
35
|
when '%A'
|
|
35
|
-
english =
|
|
36
|
+
english = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
|
|
36
37
|
day_names.each_with_index { |d, i| date_string = date_string.gsub(/#{d}/, english[i]) }
|
|
37
38
|
when '%a'
|
|
38
|
-
english =
|
|
39
|
+
english = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
|
|
39
40
|
abbr_day_names.each_with_index { |d, i| date_string = date_string.gsub(/#{d}/, english[i]) }
|
|
40
41
|
when '%B'
|
|
41
|
-
english =
|
|
42
|
+
english = [nil, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][1..-1]
|
|
42
43
|
month_names.each_with_index { |m, i| date_string = date_string.gsub(/#{m}/, english[i]) }
|
|
43
44
|
when '%b'
|
|
44
|
-
english =
|
|
45
|
+
english = [nil, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][1..-1]
|
|
45
46
|
abbr_month_names.each_with_index { |m, i| date_string = date_string.gsub(/#{m}/, english[i]) }
|
|
46
47
|
when '%p'
|
|
47
48
|
date_string = date_string.gsub(/#{::I18n.t('date.time.am', default: "am")}/, 'am')
|
|
@@ -88,7 +89,7 @@ module RailsAdmin
|
|
|
88
89
|
|
|
89
90
|
begin
|
|
90
91
|
# Adjust with the correct timezone and daylight savint time
|
|
91
|
-
datetime_with_wrong_tz = ::DateTime.strptime(delocalized_value, strftime_format)
|
|
92
|
+
datetime_with_wrong_tz = ::DateTime.strptime(delocalized_value, strftime_format.gsub('%-d', '%d'))
|
|
92
93
|
Time.zone.parse(datetime_with_wrong_tz.strftime('%Y-%m-%d %H:%M:%S'))
|
|
93
94
|
rescue ArgumentError
|
|
94
95
|
nil
|
|
@@ -6,33 +6,35 @@ module RailsAdmin
|
|
|
6
6
|
def abbr_day_names
|
|
7
7
|
::I18n.t('date.abbr_day_names', raise: true)
|
|
8
8
|
rescue ::I18n::ArgumentError
|
|
9
|
-
|
|
9
|
+
["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def abbr_month_names
|
|
13
13
|
begin
|
|
14
14
|
names = ::I18n.t('date.abbr_month_names', raise: true)
|
|
15
15
|
rescue ::I18n::ArgumentError
|
|
16
|
-
names =
|
|
16
|
+
names = [nil, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
|
17
17
|
end
|
|
18
18
|
names[1..-1]
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def date_format
|
|
22
|
-
::I18n.t('date.formats.default',
|
|
22
|
+
::I18n.t('date.formats.default', raise: true)
|
|
23
|
+
rescue
|
|
24
|
+
"%Y-%m-%d"
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
def day_names
|
|
26
28
|
::I18n.t('date.day_names', raise: true)
|
|
27
29
|
rescue ::I18n::ArgumentError
|
|
28
|
-
|
|
30
|
+
["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
def month_names
|
|
32
34
|
begin
|
|
33
35
|
names = ::I18n.t('date.month_names', raise: true)
|
|
34
36
|
rescue ::I18n::ArgumentError
|
|
35
|
-
names =
|
|
37
|
+
names = [nil, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
|
|
36
38
|
end
|
|
37
39
|
names[1..-1]
|
|
38
40
|
end
|
data/lib/rails_admin/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails_admin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0.rc
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Erik Michaels-Ober
|
|
@@ -12,7 +12,7 @@ authors:
|
|
|
12
12
|
autorequire:
|
|
13
13
|
bindir: bin
|
|
14
14
|
cert_chain: []
|
|
15
|
-
date:
|
|
15
|
+
date: 2016-07-18 00:00:00.000000000 Z
|
|
16
16
|
dependencies:
|
|
17
17
|
- !ruby/object:Gem::Dependency
|
|
18
18
|
name: builder
|
|
@@ -142,46 +142,38 @@ dependencies:
|
|
|
142
142
|
name: rack-pjax
|
|
143
143
|
requirement: !ruby/object:Gem::Requirement
|
|
144
144
|
requirements:
|
|
145
|
-
- - "
|
|
145
|
+
- - ">="
|
|
146
146
|
- !ruby/object:Gem::Version
|
|
147
147
|
version: '0.7'
|
|
148
148
|
type: :runtime
|
|
149
149
|
prerelease: false
|
|
150
150
|
version_requirements: !ruby/object:Gem::Requirement
|
|
151
151
|
requirements:
|
|
152
|
-
- - "
|
|
152
|
+
- - ">="
|
|
153
153
|
- !ruby/object:Gem::Version
|
|
154
154
|
version: '0.7'
|
|
155
155
|
- !ruby/object:Gem::Dependency
|
|
156
156
|
name: rails
|
|
157
157
|
requirement: !ruby/object:Gem::Requirement
|
|
158
158
|
requirements:
|
|
159
|
-
- - "
|
|
159
|
+
- - ">="
|
|
160
160
|
- !ruby/object:Gem::Version
|
|
161
161
|
version: '4.0'
|
|
162
|
+
- - "<"
|
|
163
|
+
- !ruby/object:Gem::Version
|
|
164
|
+
version: '6'
|
|
162
165
|
type: :runtime
|
|
163
166
|
prerelease: false
|
|
164
167
|
version_requirements: !ruby/object:Gem::Requirement
|
|
165
168
|
requirements:
|
|
166
|
-
- - "
|
|
169
|
+
- - ">="
|
|
167
170
|
- !ruby/object:Gem::Version
|
|
168
171
|
version: '4.0'
|
|
169
|
-
-
|
|
170
|
-
name: remotipart
|
|
171
|
-
requirement: !ruby/object:Gem::Requirement
|
|
172
|
-
requirements:
|
|
173
|
-
- - "~>"
|
|
174
|
-
- !ruby/object:Gem::Version
|
|
175
|
-
version: '1.0'
|
|
176
|
-
type: :runtime
|
|
177
|
-
prerelease: false
|
|
178
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
179
|
-
requirements:
|
|
180
|
-
- - "~>"
|
|
172
|
+
- - "<"
|
|
181
173
|
- !ruby/object:Gem::Version
|
|
182
|
-
version: '
|
|
174
|
+
version: '6'
|
|
183
175
|
- !ruby/object:Gem::Dependency
|
|
184
|
-
name:
|
|
176
|
+
name: remotipart
|
|
185
177
|
requirement: !ruby/object:Gem::Requirement
|
|
186
178
|
requirements:
|
|
187
179
|
- - "~>"
|
|
@@ -303,7 +295,6 @@ files:
|
|
|
303
295
|
- app/assets/javascripts/rails_admin/custom/ui.coffee
|
|
304
296
|
- app/assets/javascripts/rails_admin/jquery.colorpicker.js
|
|
305
297
|
- app/assets/javascripts/rails_admin/jquery.pjax.js
|
|
306
|
-
- app/assets/javascripts/rails_admin/jquery.remotipart.fixed.js
|
|
307
298
|
- app/assets/javascripts/rails_admin/ra.filter-box.js
|
|
308
299
|
- app/assets/javascripts/rails_admin/ra.filtering-multiselect.js
|
|
309
300
|
- app/assets/javascripts/rails_admin/ra.filtering-select.js
|
|
@@ -413,11 +404,11 @@ files:
|
|
|
413
404
|
- app/helpers/rails_admin/application_helper.rb
|
|
414
405
|
- app/helpers/rails_admin/form_builder.rb
|
|
415
406
|
- app/helpers/rails_admin/main_helper.rb
|
|
416
|
-
- app/views/kaminari/twitter-bootstrap/_gap.html.haml
|
|
417
|
-
- app/views/kaminari/twitter-bootstrap/_next_page.html.haml
|
|
418
|
-
- app/views/kaminari/twitter-bootstrap/_page.html.haml
|
|
419
|
-
- app/views/kaminari/twitter-bootstrap/_paginator.html.haml
|
|
420
|
-
- app/views/kaminari/twitter-bootstrap/_prev_page.html.haml
|
|
407
|
+
- app/views/kaminari/ra-twitter-bootstrap/_gap.html.haml
|
|
408
|
+
- app/views/kaminari/ra-twitter-bootstrap/_next_page.html.haml
|
|
409
|
+
- app/views/kaminari/ra-twitter-bootstrap/_page.html.haml
|
|
410
|
+
- app/views/kaminari/ra-twitter-bootstrap/_paginator.html.haml
|
|
411
|
+
- app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.haml
|
|
421
412
|
- app/views/layouts/rails_admin/_navigation.html.haml
|
|
422
413
|
- app/views/layouts/rails_admin/_secondary_navigation.html.haml
|
|
423
414
|
- app/views/layouts/rails_admin/_sidebar_navigation.html.haml
|
|
@@ -469,6 +460,7 @@ files:
|
|
|
469
460
|
- lib/rails_admin/adapters/mongoid.rb
|
|
470
461
|
- lib/rails_admin/adapters/mongoid/abstract_object.rb
|
|
471
462
|
- lib/rails_admin/adapters/mongoid/association.rb
|
|
463
|
+
- lib/rails_admin/adapters/mongoid/bson.rb
|
|
472
464
|
- lib/rails_admin/adapters/mongoid/extension.rb
|
|
473
465
|
- lib/rails_admin/adapters/mongoid/property.rb
|
|
474
466
|
- lib/rails_admin/bootstrap-sass.rb
|
|
@@ -591,15 +583,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
591
583
|
requirements:
|
|
592
584
|
- - ">="
|
|
593
585
|
- !ruby/object:Gem::Version
|
|
594
|
-
version: 1.
|
|
586
|
+
version: 2.1.0
|
|
595
587
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
596
588
|
requirements:
|
|
597
|
-
- - "
|
|
589
|
+
- - ">"
|
|
598
590
|
- !ruby/object:Gem::Version
|
|
599
|
-
version: 1.
|
|
591
|
+
version: 1.3.1
|
|
600
592
|
requirements: []
|
|
601
593
|
rubyforge_project:
|
|
602
|
-
rubygems_version: 2.
|
|
594
|
+
rubygems_version: 2.5.1
|
|
603
595
|
signing_key:
|
|
604
596
|
specification_version: 4
|
|
605
597
|
summary: Admin for Rails
|