rails_admin 3.0.0.rc → 3.0.0.rc4
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.
- checksums.yaml +4 -4
- data/README.md +6 -8
- data/app/assets/javascripts/{rails_admin.js → rails_admin/application.js} +0 -0
- data/app/assets/stylesheets/{rails_admin.scss → rails_admin/application.scss} +0 -0
- data/app/controllers/rails_admin/main_controller.rb +2 -3
- data/app/helpers/rails_admin/application_helper.rb +33 -11
- data/app/views/layouts/rails_admin/_head.html.erb +8 -5
- data/app/views/layouts/rails_admin/_secondary_navigation.html.erb +2 -2
- data/app/views/layouts/rails_admin/application.html.erb +1 -1
- data/app/views/rails_admin/main/export.html.erb +1 -1
- data/app/views/rails_admin/main/index.html.erb +2 -2
- data/app/views/rails_admin/main/show.html.erb +11 -9
- data/lib/generators/rails_admin/install_generator.rb +8 -6
- data/lib/rails_admin/abstract_model.rb +3 -4
- data/lib/rails_admin/adapters/active_record.rb +2 -1
- data/lib/rails_admin/adapters/mongoid.rb +2 -2
- data/lib/rails_admin/config/actions/base.rb +5 -0
- data/lib/rails_admin/config/actions/export.rb +2 -1
- data/lib/rails_admin/config/actions/index.rb +2 -1
- data/lib/rails_admin/config/actions/new.rb +2 -1
- data/lib/rails_admin/config/actions/show_in_app.rb +4 -0
- data/lib/rails_admin/config/fields/base.rb +2 -2
- data/lib/rails_admin/config/fields/factories/active_storage.rb +2 -1
- data/lib/rails_admin/config/fields/factories/association.rb +4 -4
- data/lib/rails_admin/config/fields/factories/carrierwave.rb +2 -1
- data/lib/rails_admin/config/fields/factories/devise.rb +2 -1
- data/lib/rails_admin/config/fields/factories/dragonfly.rb +2 -1
- data/lib/rails_admin/config/fields/factories/paperclip.rb +2 -1
- data/lib/rails_admin/config/fields/types/datetime.rb +2 -1
- data/lib/rails_admin/config.rb +14 -3
- data/lib/rails_admin/engine.rb +8 -9
- data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +2 -2
- data/lib/rails_admin/extensions/pundit/authorization_adapter.rb +1 -1
- data/lib/rails_admin/version.rb +34 -1
- data/package.json +1 -1
- data/src/rails_admin/ui.js +19 -3
- data/vendor/assets/javascripts/rails_admin/flatpickr-with-locales.js +958 -395
- metadata +11 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9316454f8142d78f5723f035c4dae4d4c1e43b1a4f67b9fe3382a46fac7a3a7
|
4
|
+
data.tar.gz: 42019837af600e34a153786615addcc21c1709bdffb78f96dddfd322ad54d5d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57095a84c563d2b37d54a03ec88a412b32438c7ff0653075380fe86669c9d19206219b896d3827f931f1a1f98434e98b9209ec2fb2a5735f98410fff758cf6a8
|
7
|
+
data.tar.gz: 2d3f9afaaef4ebe8a69793ba8e4da469ee5ea91e1821aa2d82f91884165354a79d0b8b5b08d0988f04584eef4f0aebff985006043ace64e8814c434789f65ffb
|
data/README.md
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
# RailsAdmin
|
2
2
|
|
3
3
|
[![Gem Version](https://img.shields.io/gem/v/rails_admin.svg)][gem]
|
4
|
-
[![Build Status](https://img.shields.io/github/workflow/status/
|
5
|
-
[![Coverage Status](https://img.shields.io/coveralls/
|
6
|
-
[![
|
7
|
-
[![Code Climate](https://codeclimate.com/github/sferik/rails_admin.svg)][codeclimate]
|
4
|
+
[![Build Status](https://img.shields.io/github/workflow/status/railsadminteam/rails_admin/Test)][ghactions]
|
5
|
+
[![Coverage Status](https://img.shields.io/coveralls/railsadminteam/rails_admin.svg)][coveralls]
|
6
|
+
[![Code Climate](https://codeclimate.com/github/railsadminteam/rails_admin.svg)][codeclimate]
|
8
7
|
[![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=rails_admin&package-manager=bundler&version-scheme=semver)][semver]
|
9
8
|
|
10
9
|
[gem]: https://rubygems.org/gems/rails_admin
|
11
10
|
[ghactions]: https://github.com/railsadminteam/rails_admin/actions
|
12
|
-
[coveralls]: https://coveralls.io/r/
|
13
|
-
[
|
14
|
-
[codeclimate]: https://codeclimate.com/github/sferik/rails_admin
|
11
|
+
[coveralls]: https://coveralls.io/r/railsadminteam/rails_admin
|
12
|
+
[codeclimate]: https://codeclimate.com/github/railsadminteam/rails_admin
|
15
13
|
[semver]: https://dependabot.com/compatibility-score.html?dependency-name=rails_admin&package-manager=bundler&version-scheme=semver
|
16
14
|
|
17
15
|
RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data.
|
@@ -47,7 +45,7 @@ RailsAdmin is a Rails engine that provides an easy-to-use interface for managing
|
|
47
45
|
|
48
46
|
## Installation
|
49
47
|
|
50
|
-
1. On your gemfile: `gem 'rails_admin', ['>= 3.0.0.
|
48
|
+
1. On your gemfile: `gem 'rails_admin', ['>= 3.0.0.rc4', '< 4']`
|
51
49
|
2. Run `bundle install`
|
52
50
|
3. Run `rails g rails_admin:install`
|
53
51
|
4. Provide a namespace for the routes when asked
|
File without changes
|
File without changes
|
@@ -13,9 +13,8 @@ module RailsAdmin
|
|
13
13
|
|
14
14
|
def list_entries(model_config = @model_config, auth_scope_key = :index, additional_scope = get_association_scope_from_params, pagination = !(params[:associated_collection] || params[:all] || params[:bulk_ids]))
|
15
15
|
scope = model_config.scope
|
16
|
-
|
17
|
-
|
18
|
-
end
|
16
|
+
auth_scope = @authorization_adapter&.query(auth_scope_key, model_config.abstract_model)
|
17
|
+
scope = scope.merge(auth_scope) if auth_scope
|
19
18
|
scope = scope.instance_eval(&additional_scope) if additional_scope
|
20
19
|
get_collection(model_config, scope, pagination)
|
21
20
|
end
|
@@ -20,17 +20,24 @@ module RailsAdmin
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def edit_user_link
|
23
|
-
return nil unless _current_user.
|
24
|
-
return nil unless abstract_model = RailsAdmin.config(_current_user.class).abstract_model
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
if
|
31
|
-
|
23
|
+
return nil unless _current_user.try(:email).present?
|
24
|
+
return nil unless (abstract_model = RailsAdmin.config(_current_user.class).abstract_model)
|
25
|
+
|
26
|
+
edit_action = action(:edit, abstract_model, _current_user)
|
27
|
+
authorized = edit_action.try(:authorized?)
|
28
|
+
content = edit_user_link_label
|
29
|
+
|
30
|
+
if authorized
|
31
|
+
edit_url = rails_admin.url_for(
|
32
|
+
action_name: edit_action.action_name,
|
33
|
+
model_name: abstract_model.to_param,
|
34
|
+
controller: 'rails_admin/main',
|
35
|
+
id: _current_user.id,
|
36
|
+
)
|
37
|
+
|
38
|
+
link_to content, edit_url, class: 'nav-link'
|
32
39
|
else
|
33
|
-
content_tag :span, content
|
40
|
+
content_tag :span, content, class: 'nav-link'
|
34
41
|
end
|
35
42
|
end
|
36
43
|
|
@@ -162,7 +169,7 @@ module RailsAdmin
|
|
162
169
|
else
|
163
170
|
'javascript:void(0)'
|
164
171
|
end
|
165
|
-
content_tag(:a, label, {href: href, target: action.link_target, class: ['nav-link', current_action?(action) && 'active', !action.enabled? && 'disabled'].compact})
|
172
|
+
content_tag(:a, label, {href: href, target: action.link_target, class: ['nav-link', current_action?(action) && 'active', !action.enabled? && 'disabled'].compact}.merge(action.turbo? ? {} : {data: {turbo: 'false'}}))
|
166
173
|
else
|
167
174
|
content_tag(:span, label)
|
168
175
|
end
|
@@ -206,5 +213,20 @@ module RailsAdmin
|
|
206
213
|
end
|
207
214
|
raise e
|
208
215
|
end
|
216
|
+
|
217
|
+
private
|
218
|
+
|
219
|
+
def edit_user_link_label
|
220
|
+
[
|
221
|
+
RailsAdmin::Config.show_gravatar &&
|
222
|
+
image_tag(gravatar_url(_current_user.email), alt: ''),
|
223
|
+
|
224
|
+
content_tag(:span, _current_user.email),
|
225
|
+
].filter(&:present?).join.html_safe
|
226
|
+
end
|
227
|
+
|
228
|
+
def gravatar_url(email)
|
229
|
+
"https://secure.gravatar.com/avatar/#{Digest::MD5.hexdigest email}?s=30"
|
230
|
+
end
|
209
231
|
end
|
210
232
|
end
|
@@ -5,13 +5,16 @@
|
|
5
5
|
<%= csrf_meta_tag %>
|
6
6
|
<% case RailsAdmin::config.asset_source
|
7
7
|
when :webpacker %>
|
8
|
-
<%= stylesheet_pack_tag "rails_admin" %>
|
9
|
-
<%= javascript_pack_tag "rails_admin", async: true %>
|
10
|
-
<% when :
|
8
|
+
<%= stylesheet_pack_tag "rails_admin", data: {'turbo-track': 'reload'} %>
|
9
|
+
<%= javascript_pack_tag "rails_admin", async: true, data: {'turbo-track': 'reload'} %>
|
10
|
+
<% when :sprockets %>
|
11
11
|
<% handle_asset_dependency_error do %>
|
12
|
-
<%= stylesheet_link_tag "rails_admin.css", media: :all %>
|
13
|
-
<%= javascript_include_tag "rails_admin.js", async: true %>
|
12
|
+
<%= stylesheet_link_tag "rails_admin/application.css", media: :all, data: {'turbo-track': 'reload'} %>
|
13
|
+
<%= javascript_include_tag "rails_admin/application.js", async: true, data: {'turbo-track': 'reload'} %>
|
14
14
|
<% end %>
|
15
|
+
<% when :webpack %>
|
16
|
+
<%= stylesheet_link_tag "rails_admin.css", media: :all, data: {'turbo-track': 'reload'} %>
|
17
|
+
<%= javascript_include_tag "rails_admin.js", async: true, data: {'turbo-track': 'reload'} %>
|
15
18
|
<% else
|
16
19
|
raise "Unknown asset_source: #{RailsAdmin::config.asset_source}"
|
17
20
|
end %>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<ul class="navbar-nav ms-auto root_links">
|
2
2
|
<% actions(:root).select(&:show_in_navigation).each do |action| %>
|
3
3
|
<li class="nav-item <%= action.action_name %>_root_link">
|
4
|
-
<%= link_to wording_for(:menu, action), { action: action.action_name, controller: 'rails_admin/main' }, class: ['nav-link'] %>
|
4
|
+
<%= link_to wording_for(:menu, action), { action: action.action_name, controller: 'rails_admin/main' }, {class: ['nav-link']}.merge(action.turbo? ? {} : {data: {turbo: 'false'}}) %>
|
5
5
|
</li>
|
6
6
|
<% end %>
|
7
7
|
<% if main_app_root_path = (main_app.root_path rescue false) %>
|
@@ -17,7 +17,7 @@
|
|
17
17
|
<% end %>
|
18
18
|
<% if logout_path.present? %>
|
19
19
|
<li class="nav-item">
|
20
|
-
<%= link_to t('admin.misc.log_out'), logout_path, method: logout_method, class: 'nav-link label label-danger' %>
|
20
|
+
<%= link_to t('admin.misc.log_out'), logout_path, method: logout_method, class: 'nav-link label label-danger', data: {turbo: 'false'} %>
|
21
21
|
</li>
|
22
22
|
<% end %>
|
23
23
|
<% end %>
|
@@ -14,7 +14,7 @@
|
|
14
14
|
<%= render "layouts/rails_admin/sidebar_navigation" %>
|
15
15
|
</div>
|
16
16
|
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2">
|
17
|
-
<div class="container">
|
17
|
+
<div class="container-fluid">
|
18
18
|
<%= render template: 'layouts/rails_admin/content' %>
|
19
19
|
</div>
|
20
20
|
</div>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% params = request.params.except(:action, :controller, :utf8, :page, :per_page, :format, :authenticity_token) %>
|
2
2
|
<% visible_fields = @model_config.export.with(view: self, object: @abstract_model.model.new, controller: self.controller).visible_fields %>
|
3
|
-
<%= form_tag export_path(params.merge(all: true)), method: 'post', class: "main" do %>
|
3
|
+
<%= form_tag export_path(params.merge(all: true)), method: 'post', class: "main", data: {turbo: false} do %>
|
4
4
|
<input name="send_data" type="hidden" value="true" />
|
5
5
|
<fieldset id="fields_to_export" class="mb-3">
|
6
6
|
<legend>
|
@@ -96,8 +96,8 @@
|
|
96
96
|
<ul class="nav nav-tabs" id="scope_selector">
|
97
97
|
<% @model_config.list.scopes.each_with_index do |scope, index| %>
|
98
98
|
<% scope = '_all' if scope.nil? %>
|
99
|
-
<li class="
|
100
|
-
<a href="<%= index_path(params.merge(scope: scope, page: nil)) %>">
|
99
|
+
<li class="nav-item">
|
100
|
+
<a href="<%= index_path(params.merge(scope: scope, page: nil)) %>" class="nav-link <%= 'active' if scope.to_s == params[:scope] || (params[:scope].blank? && index == 0) %>">
|
101
101
|
<%= I18n.t("admin.scopes.#{@abstract_model.to_param}.#{scope}", default: I18n.t("admin.scopes.#{scope}", default: scope.to_s.titleize)) %>
|
102
102
|
</a>
|
103
103
|
</li>
|
@@ -10,16 +10,18 @@
|
|
10
10
|
<%= fieldset.help %>
|
11
11
|
</p>
|
12
12
|
<% end %>
|
13
|
-
<
|
13
|
+
<div class="list-group">
|
14
14
|
<% fields.each_with_index do |field, index| %>
|
15
|
-
<
|
16
|
-
<
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
<div class="list-group-item border-0 <%= field.type_css_class %> <%= field.css_class %>">
|
16
|
+
<div class="card">
|
17
|
+
<h5 class="card-header bg-light">
|
18
|
+
<%= field.label %>
|
19
|
+
</h5>
|
20
|
+
<div class="card-body">
|
21
|
+
<%= field.pretty_value %>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
</div>
|
23
25
|
<% end %>
|
24
26
|
</dl>
|
25
27
|
</div>
|
@@ -8,12 +8,16 @@ module RailsAdmin
|
|
8
8
|
include Generators::Utils::InstanceMethods
|
9
9
|
|
10
10
|
argument :_namespace, type: :string, required: false, desc: 'RailsAdmin url namespace'
|
11
|
-
class_option :asset, type: :string, required: false, default: nil, desc: 'Asset delivery method [options:
|
11
|
+
class_option :asset, type: :string, required: false, default: nil, desc: 'Asset delivery method [options: webpacker, sprockets]'
|
12
12
|
desc 'RailsAdmin installation generator'
|
13
13
|
|
14
14
|
def install
|
15
|
-
|
16
|
-
|
15
|
+
if File.read(File.join(destination_root, 'config/routes.rb')).include?('mount RailsAdmin::Engine')
|
16
|
+
display "Skipped route addition, since it's already there"
|
17
|
+
else
|
18
|
+
namespace = ask_for('Where do you want to mount rails_admin?', 'admin', _namespace)
|
19
|
+
route("mount RailsAdmin::Engine => '/#{namespace}', as: 'rails_admin'")
|
20
|
+
end
|
17
21
|
if File.exist? File.join(destination_root, 'config/initializers/rails_admin.rb')
|
18
22
|
insert_into_file 'config/initializers/rails_admin.rb', " config.asset_source = :#{asset}\n", after: "RailsAdmin.config do |config|\n"
|
19
23
|
else
|
@@ -35,9 +39,7 @@ module RailsAdmin
|
|
35
39
|
def asset
|
36
40
|
return options['asset'] if options['asset']
|
37
41
|
|
38
|
-
if
|
39
|
-
'webpack'
|
40
|
-
elsif defined?(Webpacker)
|
42
|
+
if defined?(Webpacker)
|
41
43
|
'webpacker'
|
42
44
|
else
|
43
45
|
'sprockets'
|
@@ -19,7 +19,7 @@ module RailsAdmin
|
|
19
19
|
def new(m)
|
20
20
|
m = m.constantize unless m.is_a?(Class)
|
21
21
|
(am = old_new(m)).model && am.adapter ? am : nil
|
22
|
-
rescue *([LoadError, NameError] + (defined?(ActiveRecord) ? ['ActiveRecord::NoDatabaseError'.constantize] : []))
|
22
|
+
rescue *([LoadError, NameError] + (defined?(ActiveRecord) ? ['ActiveRecord::NoDatabaseError'.constantize, 'ActiveRecord::ConnectionNotEstablished'.constantize] : []))
|
23
23
|
puts "[RailsAdmin] Could not load model #{m}, assuming model is non existing. (#{$ERROR_INFO})" unless Rails.env.test?
|
24
24
|
nil
|
25
25
|
end
|
@@ -86,9 +86,8 @@ module RailsAdmin
|
|
86
86
|
associations.each do |association|
|
87
87
|
case association.type
|
88
88
|
when :has_one
|
89
|
-
|
90
|
-
|
91
|
-
end
|
89
|
+
child = object.send(association.name)
|
90
|
+
yield(association, [child]) if child
|
92
91
|
when :has_many
|
93
92
|
children = object.send(association.name)
|
94
93
|
yield(association, Array.new(children))
|
@@ -52,10 +52,10 @@ module RailsAdmin
|
|
52
52
|
scope
|
53
53
|
rescue NoMethodError => e
|
54
54
|
if /page/.match?(e.message)
|
55
|
-
e = e.exception <<-
|
55
|
+
e = e.exception <<-ERROR.gsub(/^\s{12}/, '')
|
56
56
|
#{e.message}
|
57
57
|
If you don't have kaminari-mongoid installed, add `gem 'kaminari-mongoid'` to your Gemfile.
|
58
|
-
|
58
|
+
ERROR
|
59
59
|
end
|
60
60
|
raise e
|
61
61
|
end
|
@@ -78,6 +78,11 @@ module RailsAdmin
|
|
78
78
|
nil
|
79
79
|
end
|
80
80
|
|
81
|
+
# Determines whether to navigate via Turbo Drive or not
|
82
|
+
register_instance_option :turbo? do
|
83
|
+
true
|
84
|
+
end
|
85
|
+
|
81
86
|
# This block is evaluated in the context of the controller when action is called
|
82
87
|
# You can access:
|
83
88
|
# - @objects if you're on a model scope
|
@@ -14,7 +14,8 @@ module RailsAdmin
|
|
14
14
|
|
15
15
|
register_instance_option :controller do
|
16
16
|
proc do
|
17
|
-
|
17
|
+
format = params[:json] && :json || params[:csv] && :csv || params[:xml] && :xml
|
18
|
+
if format
|
18
19
|
request.format = format
|
19
20
|
@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
21
|
@objects = list_entries(@model_config, :export)
|
@@ -20,7 +20,8 @@ module RailsAdmin
|
|
20
20
|
|
21
21
|
register_instance_option :breadcrumb_parent do
|
22
22
|
parent_model = bindings[:abstract_model].try(:config).try(:parent)
|
23
|
-
|
23
|
+
am = parent_model && RailsAdmin.config(parent_model).try(:abstract_model)
|
24
|
+
if am
|
24
25
|
[:index, am]
|
25
26
|
else
|
26
27
|
[:dashboard]
|
@@ -21,7 +21,8 @@ module RailsAdmin
|
|
21
21
|
@authorization_adapter&.attributes_for(:new, @abstract_model)&.each do |name, value|
|
22
22
|
@object.send("#{name}=", value)
|
23
23
|
end
|
24
|
-
|
24
|
+
object_params = params[@abstract_model.param_key]
|
25
|
+
if object_params
|
25
26
|
sanitize_params_for!(request.xhr? ? :modal : :create)
|
26
27
|
@object.assign_attributes(@object.attributes.merge(object_params.to_h))
|
27
28
|
end
|
@@ -301,14 +301,14 @@ module RailsAdmin
|
|
301
301
|
def value
|
302
302
|
bindings[:object].safe_send(name)
|
303
303
|
rescue NoMethodError => e
|
304
|
-
raise e.exception <<-
|
304
|
+
raise e.exception <<-ERROR.gsub(/^\s{10}/, '')
|
305
305
|
#{e.message}
|
306
306
|
If you want to use a RailsAdmin virtual field(= a field without corresponding instance method),
|
307
307
|
you should declare 'formatted_value' in the field definition.
|
308
308
|
field :#{name} do
|
309
309
|
formatted_value{ bindings[:object].call_some_method }
|
310
310
|
end
|
311
|
-
|
311
|
+
ERROR
|
312
312
|
end
|
313
313
|
|
314
314
|
# Reader for nested attributes
|
@@ -16,7 +16,8 @@ RailsAdmin::Config::Fields.register_factory do |parent, properties, fields|
|
|
16
16
|
["#{name}_attachment".to_sym, "#{name}_blob".to_sym]
|
17
17
|
end
|
18
18
|
children_fields = associations.map do |child_name|
|
19
|
-
|
19
|
+
child_association = parent.abstract_model.associations.detect { |p| p.name.to_sym == child_name }
|
20
|
+
next unless child_association
|
20
21
|
|
21
22
|
child_field = fields.detect { |f| f.name == child_name } || RailsAdmin::Config::Fields.default_factory.call(parent, child_association, fields)
|
22
23
|
child_field.hide unless field == child_field
|
@@ -3,7 +3,8 @@ require 'rails_admin/config/fields/types'
|
|
3
3
|
require 'rails_admin/config/fields/types/belongs_to_association'
|
4
4
|
|
5
5
|
RailsAdmin::Config::Fields.register_factory do |parent, properties, fields|
|
6
|
-
|
6
|
+
association = parent.abstract_model.associations.detect { |a| a.foreign_key == properties.name && %i[belongs_to has_and_belongs_to_many].include?(a.type) }
|
7
|
+
if association
|
7
8
|
field = RailsAdmin::Config::Fields::Types.load("#{association.polymorphic? ? :polymorphic : association.type}_association").new(parent, association.name, association)
|
8
9
|
fields << field
|
9
10
|
|
@@ -15,9 +16,8 @@ RailsAdmin::Config::Fields.register_factory do |parent, properties, fields|
|
|
15
16
|
end.collect { |k| association.send(k) }.compact
|
16
17
|
|
17
18
|
parent.abstract_model.properties.select { |p| possible_field_names.include? p.name }.each do |column|
|
18
|
-
|
19
|
-
|
20
|
-
end
|
19
|
+
child_field = fields.detect { |f| f.name.to_s == column.name.to_s }
|
20
|
+
child_field ||= RailsAdmin::Config::Fields.default_factory.call(parent, column, fields)
|
21
21
|
child_columns << child_field
|
22
22
|
end
|
23
23
|
|
@@ -12,7 +12,8 @@ RailsAdmin::Config::Fields.register_factory do |parent, properties, fields|
|
|
12
12
|
fields << field
|
13
13
|
children_fields = []
|
14
14
|
columns.each do |children_column_name|
|
15
|
-
|
15
|
+
child_properties = parent.abstract_model.properties.detect { |p| p.name.to_s == children_column_name.to_s }
|
16
|
+
next unless child_properties
|
16
17
|
|
17
18
|
children_field = fields.detect { |f| f.name == children_column_name } || RailsAdmin::Config::Fields.default_factory.call(parent, child_properties, fields)
|
18
19
|
children_field.hide unless field == children_field
|
@@ -12,7 +12,8 @@ RailsAdmin::Config::Fields.register_factory do |parent, properties, fields|
|
|
12
12
|
properties = parent.abstract_model.properties.detect { |p| ext == p.name }
|
13
13
|
next unless properties
|
14
14
|
|
15
|
-
|
15
|
+
field = fields.detect { |f| f.name == ext }
|
16
|
+
unless field
|
16
17
|
RailsAdmin::Config::Fields.default_factory.call(parent, properties, fields)
|
17
18
|
field = fields.last
|
18
19
|
end
|
@@ -9,7 +9,8 @@ RailsAdmin::Config::Fields.register_factory do |parent, properties, fields|
|
|
9
9
|
children_fields = []
|
10
10
|
extensions.each do |ext|
|
11
11
|
children_column_name = "#{attachment_name}_#{ext}".to_sym
|
12
|
-
|
12
|
+
child_properties = parent.abstract_model.properties.detect { |p| p.name.to_s == children_column_name.to_s }
|
13
|
+
next unless child_properties
|
13
14
|
|
14
15
|
children_field = fields.detect { |f| f.name == children_column_name } || RailsAdmin::Config::Fields.default_factory.call(parent, child_properties, fields)
|
15
16
|
children_field.hide
|
@@ -10,7 +10,8 @@ RailsAdmin::Config::Fields.register_factory do |parent, properties, fields|
|
|
10
10
|
children_fields = []
|
11
11
|
extensions.each do |ext|
|
12
12
|
children_column_name = "#{attachment_name}_#{ext}".to_sym
|
13
|
-
|
13
|
+
child_properties = parent.abstract_model.properties.detect { |p| p.name.to_s == children_column_name.to_s }
|
14
|
+
next unless child_properties
|
14
15
|
|
15
16
|
children_field = fields.detect { |f| f.name == children_column_name } || RailsAdmin::Config::Fields.default_factory.call(parent, child_properties, fields)
|
16
17
|
children_field.hide
|
data/lib/rails_admin/config.rb
CHANGED
@@ -39,7 +39,7 @@ module RailsAdmin
|
|
39
39
|
attr_accessor :included_models
|
40
40
|
|
41
41
|
# Fields to be hidden in show, create and update views
|
42
|
-
|
42
|
+
attr_reader :default_hidden_fields
|
43
43
|
|
44
44
|
# Default items per page value used if a model level option has not
|
45
45
|
# been configured
|
@@ -81,7 +81,7 @@ module RailsAdmin
|
|
81
81
|
attr_accessor :navigation_static_label
|
82
82
|
|
83
83
|
# Set where RailsAdmin fetches JS/CSS from, defaults to :sprockets
|
84
|
-
|
84
|
+
attr_writer :asset_source
|
85
85
|
|
86
86
|
# Finish initialization by executing deferred configuration blocks
|
87
87
|
def initialize!
|
@@ -257,6 +257,17 @@ module RailsAdmin
|
|
257
257
|
@registry[key]
|
258
258
|
end
|
259
259
|
|
260
|
+
def asset_source
|
261
|
+
@asset_source ||=
|
262
|
+
begin
|
263
|
+
warn <<-MSG.gsub(/^ +/, '').freeze
|
264
|
+
[Warning] After upgrading RailsAdmin to 3.x you haven't set asset_source yet, using :sprockets as the default.
|
265
|
+
To suppress this message, run 'rails rails_admin:install' to setup the asset delivery method suitable to you.
|
266
|
+
MSG
|
267
|
+
:sprockets
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
260
271
|
def default_hidden_fields=(fields)
|
261
272
|
if fields.is_a?(Array)
|
262
273
|
@default_hidden_fields = {}
|
@@ -326,7 +337,7 @@ module RailsAdmin
|
|
326
337
|
@show_gravatar = true
|
327
338
|
@navigation_static_links = {}
|
328
339
|
@navigation_static_label = nil
|
329
|
-
@asset_source =
|
340
|
+
@asset_source = nil
|
330
341
|
@parent_controller = '::ActionController::Base'
|
331
342
|
@forgery_protection_settings = {with: :exception}
|
332
343
|
RailsAdmin::Config::Actions.reset
|
data/lib/rails_admin/engine.rb
CHANGED
@@ -2,6 +2,7 @@ require 'kaminari'
|
|
2
2
|
require 'nested_form'
|
3
3
|
require 'rails'
|
4
4
|
require 'rails_admin'
|
5
|
+
require 'rails_admin/version'
|
5
6
|
require 'turbo-rails'
|
6
7
|
|
7
8
|
module RailsAdmin
|
@@ -11,10 +12,10 @@ module RailsAdmin
|
|
11
12
|
config.action_dispatch.rescue_responses['RailsAdmin::ActionNotAllowed'] = :forbidden
|
12
13
|
|
13
14
|
initializer 'RailsAdmin precompile hook', group: :all do |app|
|
14
|
-
if
|
15
|
+
if defined?(Sprockets)
|
15
16
|
app.config.assets.precompile += %w[
|
16
|
-
rails_admin.js
|
17
|
-
rails_admin.css
|
17
|
+
rails_admin/application.js
|
18
|
+
rails_admin/application.css
|
18
19
|
]
|
19
20
|
app.config.assets.paths << RailsAdmin::Engine.root.join('src')
|
20
21
|
require 'rails_admin/support/esmodule_preprocessor'
|
@@ -42,10 +43,6 @@ module RailsAdmin
|
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
45
|
-
rake_tasks do
|
46
|
-
Dir[File.join(File.dirname(__FILE__), '../tasks/*.rake')].each { |f| load f }
|
47
|
-
end
|
48
|
-
|
49
46
|
# Check for required middlewares, users may forget to use them in Rails API mode
|
50
47
|
config.after_initialize do |app|
|
51
48
|
has_session_store = app.config.middleware.to_a.any? do |m|
|
@@ -59,20 +56,22 @@ module RailsAdmin
|
|
59
56
|
unless missing.empty? && has_session_store
|
60
57
|
configs = missing.map { |m| "config.middleware.use #{m}" }
|
61
58
|
configs << "config.middleware.use #{app.config.session_store.try(:name) || 'ActionDispatch::Session::CookieStore'}, #{app.config.session_options}" unless has_session_store
|
62
|
-
raise <<~
|
59
|
+
raise <<~ERROR
|
63
60
|
Required middlewares for RailsAdmin are not added
|
64
61
|
To fix this, add
|
65
62
|
|
66
63
|
#{configs.join("\n ")}
|
67
64
|
|
68
65
|
to config/application.rb.
|
69
|
-
|
66
|
+
ERROR
|
70
67
|
end
|
71
68
|
|
72
69
|
RailsAdmin::Config.initialize!
|
73
70
|
|
74
71
|
# Force route reload, since it doesn't reflect RailsAdmin action configuration yet
|
75
72
|
app.reload_routes!
|
73
|
+
|
74
|
+
RailsAdmin::Version.warn_with_js_version
|
76
75
|
end
|
77
76
|
end
|
78
77
|
end
|
@@ -49,7 +49,7 @@ module RailsAdmin
|
|
49
49
|
created_at: :created_at,
|
50
50
|
message: :event,
|
51
51
|
}.freeze
|
52
|
-
E_VERSION_MODEL_NOT_SET = <<-
|
52
|
+
E_VERSION_MODEL_NOT_SET = <<-ERROR.strip_heredoc.freeze
|
53
53
|
Please set up PaperTrail's version model explicitly.
|
54
54
|
|
55
55
|
config.audit_with :paper_trail, 'User', 'PaperTrail::Version'
|
@@ -58,7 +58,7 @@ module RailsAdmin
|
|
58
58
|
(https://github.com/paper-trail-gem/paper_trail#6a-custom-version-classes)
|
59
59
|
that configuration will take precedence over what you specify in
|
60
60
|
`audit_with`.
|
61
|
-
|
61
|
+
ERROR
|
62
62
|
|
63
63
|
def self.setup
|
64
64
|
raise 'PaperTrail not found' unless defined?(::PaperTrail)
|
@@ -7,7 +7,7 @@ module RailsAdmin
|
|
7
7
|
class AuthorizationAdapter
|
8
8
|
# This method is called first time only and used for setup
|
9
9
|
def self.setup
|
10
|
-
RailsAdmin::Extensions::ControllerExtension.include ::Pundit
|
10
|
+
RailsAdmin::Extensions::ControllerExtension.include defined?(::Pundit::Authorization) ? ::Pundit::Authorization : ::Pundit
|
11
11
|
end
|
12
12
|
|
13
13
|
# See the +authorize_with+ config method for where the initialization happens.
|