rails_admin 3.1.4 → 3.3.0
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 +19 -14
- data/README.md +2 -2
- data/app/assets/javascripts/rails_admin/application.js.erb +3 -2
- data/app/assets/stylesheets/rails_admin/application.scss.erb +1 -1
- data/app/controllers/rails_admin/main_controller.rb +5 -1
- data/app/helpers/rails_admin/application_helper.rb +4 -0
- data/app/helpers/rails_admin/form_builder.rb +2 -2
- data/app/helpers/rails_admin/main_helper.rb +1 -1
- data/app/views/layouts/rails_admin/_head.html.erb +8 -5
- data/app/views/rails_admin/main/_form_boolean.html.erb +2 -2
- data/app/views/rails_admin/main/_form_filtering_multiselect.html.erb +5 -35
- data/app/views/rails_admin/main/_form_filtering_select.html.erb +6 -18
- data/app/views/rails_admin/main/_form_nested_many.html.erb +1 -1
- data/app/views/rails_admin/main/_form_nested_one.html.erb +1 -1
- data/app/views/rails_admin/main/_form_polymorphic_association.html.erb +12 -21
- data/app/views/rails_admin/main/delete.html.erb +1 -1
- data/config/initializers/active_record_extensions.rb +0 -23
- data/lib/generators/rails_admin/importmap_formatter.rb +1 -1
- data/lib/generators/rails_admin/install_generator.rb +13 -1
- data/lib/generators/rails_admin/templates/rails_admin.vite.js +2 -0
- data/lib/rails_admin/abstract_model.rb +18 -7
- data/lib/rails_admin/adapters/active_record/association.rb +25 -8
- data/lib/rails_admin/adapters/active_record/object_extension.rb +0 -18
- data/lib/rails_admin/adapters/active_record.rb +51 -5
- data/lib/rails_admin/adapters/mongoid/association.rb +1 -1
- data/lib/rails_admin/adapters/mongoid/object_extension.rb +0 -5
- data/lib/rails_admin/adapters/mongoid.rb +6 -3
- data/lib/rails_admin/config/actions/index.rb +5 -3
- data/lib/rails_admin/config/fields/association.rb +41 -2
- data/lib/rails_admin/config/fields/base.rb +4 -4
- data/lib/rails_admin/config/fields/collection_association.rb +90 -0
- data/lib/rails_admin/config/fields/singular_association.rb +59 -0
- data/lib/rails_admin/config/fields/types/active_storage.rb +12 -7
- data/lib/rails_admin/config/fields/types/all.rb +0 -1
- data/lib/rails_admin/config/fields/types/belongs_to_association.rb +17 -20
- data/lib/rails_admin/config/fields/types/dragonfly.rb +0 -1
- data/lib/rails_admin/config/fields/types/file_upload.rb +7 -1
- data/lib/rails_admin/config/fields/types/has_and_belongs_to_many_association.rb +2 -2
- data/lib/rails_admin/config/fields/types/has_many_association.rb +2 -24
- data/lib/rails_admin/config/fields/types/has_one_association.rb +12 -22
- data/lib/rails_admin/config/fields/types/multiple_active_storage.rb +13 -8
- data/lib/rails_admin/config/fields/types/multiple_file_upload.rb +7 -1
- data/lib/rails_admin/config/fields/types/polymorphic_association.rb +32 -9
- data/lib/rails_admin/config.rb +5 -0
- data/lib/rails_admin/engine.rb +5 -0
- data/lib/rails_admin/extensions/url_for_extension.rb +15 -0
- data/lib/rails_admin/support/composite_keys_serializer.rb +15 -0
- data/lib/rails_admin/support/datetime.rb +1 -0
- data/lib/rails_admin/version.rb +2 -2
- data/package.json +2 -2
- data/src/rails_admin/abstract-select.js +30 -0
- data/src/rails_admin/base.js +4 -1
- data/src/rails_admin/filtering-multiselect.js +2 -4
- data/src/rails_admin/filtering-select.js +2 -4
- metadata +39 -15
- data/lib/rails_admin/adapters/composite_primary_keys/association.rb +0 -45
- data/lib/rails_admin/adapters/composite_primary_keys.rb +0 -40
- data/lib/rails_admin/config/fields/types/composite_keys_belongs_to_association.rb +0 -31
@@ -23,19 +23,16 @@ module RailsAdmin
|
|
23
23
|
end
|
24
24
|
|
25
25
|
register_instance_option :image? do
|
26
|
-
|
27
|
-
mime_type = Mime::Type.lookup_by_extension(value.filename.extension_without_delimiter)
|
28
|
-
mime_type.to_s.match?(/^image/)
|
29
|
-
end
|
26
|
+
value && (value.representable? || value.content_type.match?(/^image/))
|
30
27
|
end
|
31
28
|
|
32
29
|
def resource_url(thumb = false)
|
33
30
|
return nil unless value
|
34
31
|
|
35
|
-
if thumb && value.
|
36
|
-
|
32
|
+
if thumb && value.representable?
|
33
|
+
representation = value.representation(thumb_method)
|
37
34
|
Rails.application.routes.url_helpers.rails_blob_representation_path(
|
38
|
-
|
35
|
+
representation.blob.signed_id, representation.variation.key, representation.blob.filename, only_path: true
|
39
36
|
)
|
40
37
|
else
|
41
38
|
Rails.application.routes.url_helpers.rails_blob_path(value, only_path: true)
|
@@ -48,7 +45,7 @@ module RailsAdmin
|
|
48
45
|
end
|
49
46
|
|
50
47
|
register_instance_option :keep_method do
|
51
|
-
method_name if ::ActiveStorage.replace_on_assign_to_many
|
48
|
+
method_name if ::ActiveStorage.gem_version >= Gem::Version.new('7.1') || ::ActiveStorage.replace_on_assign_to_many
|
52
49
|
end
|
53
50
|
|
54
51
|
register_instance_option :delete_method do
|
@@ -70,6 +67,14 @@ module RailsAdmin
|
|
70
67
|
direct? && {data: {direct_upload_url: bindings[:view].main_app.rails_direct_uploads_url}} || {},
|
71
68
|
)
|
72
69
|
end
|
70
|
+
|
71
|
+
register_instance_option :searchable do
|
72
|
+
false
|
73
|
+
end
|
74
|
+
|
75
|
+
register_instance_option :sortable do
|
76
|
+
false
|
77
|
+
end
|
73
78
|
end
|
74
79
|
end
|
75
80
|
end
|
@@ -47,13 +47,19 @@ module RailsAdmin
|
|
47
47
|
end
|
48
48
|
|
49
49
|
register_instance_option :image? do
|
50
|
-
mime_type = Mime::Type.lookup_by_extension(
|
50
|
+
mime_type = Mime::Type.lookup_by_extension(extension)
|
51
51
|
mime_type.to_s.match?(/^image/)
|
52
52
|
end
|
53
53
|
|
54
54
|
def resource_url(_thumb = false)
|
55
55
|
raise 'not implemented'
|
56
56
|
end
|
57
|
+
|
58
|
+
def extension
|
59
|
+
URI.parse(resource_url).path.split('.').last
|
60
|
+
rescue URI::InvalidURIError
|
61
|
+
nil
|
62
|
+
end
|
57
63
|
end
|
58
64
|
|
59
65
|
def initialize(*args)
|
@@ -51,26 +51,29 @@ module RailsAdmin
|
|
51
51
|
false
|
52
52
|
end
|
53
53
|
|
54
|
-
def
|
55
|
-
|
54
|
+
def associated_model_config
|
55
|
+
@associated_model_config ||= association.klass.collect { |type| RailsAdmin.config(type) }.reject(&:excluded?)
|
56
|
+
end
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
[
|
58
|
+
def collection(_scope = nil)
|
59
|
+
if value
|
60
|
+
[[formatted_value, selected_id]]
|
61
|
+
else
|
62
|
+
[[]]
|
60
63
|
end
|
61
64
|
end
|
62
65
|
|
63
|
-
def
|
64
|
-
|
66
|
+
def type_column
|
67
|
+
association.foreign_type.to_s
|
65
68
|
end
|
66
69
|
|
67
|
-
def
|
70
|
+
def type_collection
|
68
71
|
associated_model_config.collect do |config|
|
69
72
|
[config.label, config.abstract_model.model.name]
|
70
73
|
end
|
71
74
|
end
|
72
75
|
|
73
|
-
def
|
76
|
+
def type_urls
|
74
77
|
types = associated_model_config.collect do |config|
|
75
78
|
[config.abstract_model.model.name, config.abstract_model.to_param]
|
76
79
|
end
|
@@ -82,6 +85,26 @@ module RailsAdmin
|
|
82
85
|
bindings[:object].send(association.name)
|
83
86
|
end
|
84
87
|
|
88
|
+
def widget_options_for_types
|
89
|
+
type_collection.inject({}) do |options, model|
|
90
|
+
options.merge(
|
91
|
+
model.second.downcase.gsub('::', '-') => {
|
92
|
+
xhr: true,
|
93
|
+
remote_source: bindings[:view].index_path(model.second.underscore, source_object_id: bindings[:object].id, source_abstract_model: abstract_model.to_param, current_action: bindings[:view].current_action, compact: true),
|
94
|
+
float_left: false,
|
95
|
+
},
|
96
|
+
)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def widget_options
|
101
|
+
widget_options_for_types[selected_type.try(:downcase)] || {float_left: false}
|
102
|
+
end
|
103
|
+
|
104
|
+
def selected_type
|
105
|
+
bindings[:object].send(type_column)
|
106
|
+
end
|
107
|
+
|
85
108
|
def parse_input(params)
|
86
109
|
if (type_value = params[association.foreign_type.to_sym]).present?
|
87
110
|
config = associated_model_config.find { |c| type_value == c.abstract_model.model.name }
|
data/lib/rails_admin/config.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'rails_admin/config/lazy_model'
|
4
4
|
require 'rails_admin/config/sections/list'
|
5
|
+
require 'rails_admin/support/composite_keys_serializer'
|
5
6
|
require 'active_support/core_ext/module/attribute_accessors'
|
6
7
|
|
7
8
|
module RailsAdmin
|
@@ -84,6 +85,9 @@ module RailsAdmin
|
|
84
85
|
# Set where RailsAdmin fetches JS/CSS from, defaults to :sprockets
|
85
86
|
attr_writer :asset_source
|
86
87
|
|
88
|
+
# For customization of composite keys representation
|
89
|
+
attr_accessor :composite_keys_serializer
|
90
|
+
|
87
91
|
# Setup authentication to be run as a before filter
|
88
92
|
# This is run inside the controller instance so you can setup any authentication you need to
|
89
93
|
#
|
@@ -329,6 +333,7 @@ module RailsAdmin
|
|
329
333
|
@navigation_static_links = {}
|
330
334
|
@navigation_static_label = nil
|
331
335
|
@asset_source = nil
|
336
|
+
@composite_keys_serializer = RailsAdmin::Support::CompositeKeysSerializer
|
332
337
|
@parent_controller = '::ActionController::Base'
|
333
338
|
@forgery_protection_settings = {with: :exception}
|
334
339
|
RailsAdmin::Config::Actions.reset
|
data/lib/rails_admin/engine.rb
CHANGED
@@ -4,6 +4,7 @@ require 'kaminari'
|
|
4
4
|
require 'nested_form'
|
5
5
|
require 'rails'
|
6
6
|
require 'rails_admin'
|
7
|
+
require 'rails_admin/extensions/url_for_extension'
|
7
8
|
require 'rails_admin/version'
|
8
9
|
require 'turbo-rails'
|
9
10
|
|
@@ -15,6 +16,10 @@ module RailsAdmin
|
|
15
16
|
|
16
17
|
config.action_dispatch.rescue_responses['RailsAdmin::ActionNotAllowed'] = :forbidden
|
17
18
|
|
19
|
+
initializer 'RailsAdmin load UrlForExtension' do
|
20
|
+
RailsAdmin::Engine.routes.singleton_class.prepend(RailsAdmin::Extensions::UrlForExtension)
|
21
|
+
end
|
22
|
+
|
18
23
|
initializer 'RailsAdmin reload config in development' do |app|
|
19
24
|
config.initializer_path = app.root.join('config/initializers/rails_admin.rb')
|
20
25
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAdmin
|
4
|
+
module Extensions
|
5
|
+
module UrlForExtension
|
6
|
+
def url_for(options, *args)
|
7
|
+
case options[:id]
|
8
|
+
when Array
|
9
|
+
options[:id] = RailsAdmin.config.composite_keys_serializer.serialize(options[:id])
|
10
|
+
end
|
11
|
+
super options, *args
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAdmin
|
4
|
+
module Support
|
5
|
+
module CompositeKeysSerializer
|
6
|
+
def self.serialize(keys)
|
7
|
+
keys.map { |key| key&.to_s&.gsub('_', '__') }.join('_')
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.deserialize(string)
|
11
|
+
string.split('_').map { |key| key&.gsub('__', '_') }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -21,6 +21,7 @@ module RailsAdmin
|
|
21
21
|
'%-I' => 'h', # Hour of the day, 12-hour clock (1..12)
|
22
22
|
'%k' => 'H', # Hour of the day, 24-hour clock (0..23)
|
23
23
|
'%l' => 'h', # Hour of the day, 12-hour clock (1..12)
|
24
|
+
'%-l' => 'h', # Hour of the day, 12-hour clock (1..12)
|
24
25
|
'%M' => 'i', # Minute of the hour (00..59)
|
25
26
|
'%-M' => 'i', # Minute of the hour (00..59)
|
26
27
|
'%m' => 'm', # Month of the year (01..12)
|
data/lib/rails_admin/version.rb
CHANGED
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "rails_admin",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.3.0",
|
4
4
|
"description": "RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data.",
|
5
5
|
"homepage": "https://github.com/railsadminteam/rails_admin",
|
6
6
|
"license": "MIT",
|
@@ -22,7 +22,7 @@
|
|
22
22
|
"bootstrap": "^5.1.3",
|
23
23
|
"flatpickr": "^4.6.9",
|
24
24
|
"jquery": "^3.6.0",
|
25
|
-
"jquery-ui": "^1.12.1"
|
25
|
+
"jquery-ui": "^1.12.1 <1.14.0"
|
26
26
|
},
|
27
27
|
"devDependencies": {
|
28
28
|
"prettier": "^2.4.1"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import jQuery from "jquery";
|
2
|
+
import "jquery-ui/ui/widget.js";
|
3
|
+
|
4
|
+
(function ($) {
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
$.widget("ra.abstractSelect", {
|
8
|
+
options: {
|
9
|
+
createQuery: function (query) {
|
10
|
+
if ($.isEmptyObject(this.scopeBy)) {
|
11
|
+
return { query: query };
|
12
|
+
} else {
|
13
|
+
const filterQuery = {};
|
14
|
+
for (var field in this.scopeBy) {
|
15
|
+
const targetField = this.scopeBy[field];
|
16
|
+
const targetValue = $(`[name$="[${field}]"]`).val();
|
17
|
+
if (!filterQuery[targetField]) {
|
18
|
+
filterQuery[targetField] = [];
|
19
|
+
}
|
20
|
+
filterQuery[targetField].push(
|
21
|
+
targetValue ? { o: "is", v: targetValue } : { o: "_blank" }
|
22
|
+
);
|
23
|
+
}
|
24
|
+
return { query: query, f: filterQuery };
|
25
|
+
}
|
26
|
+
},
|
27
|
+
scopeBy: {},
|
28
|
+
},
|
29
|
+
});
|
30
|
+
})(jQuery);
|
data/src/rails_admin/base.js
CHANGED
@@ -17,6 +17,7 @@ import "jquery-ui/ui/widget.js";
|
|
17
17
|
import "jquery-ui/ui/widgets/menu.js";
|
18
18
|
import "jquery-ui/ui/widgets/mouse.js";
|
19
19
|
|
20
|
+
import "./abstract-select";
|
20
21
|
import "./filter-box";
|
21
22
|
import "./filtering-multiselect";
|
22
23
|
import "./filtering-select";
|
@@ -26,4 +27,6 @@ import "./sidescroll";
|
|
26
27
|
import "./ui";
|
27
28
|
import "./widgets";
|
28
29
|
|
29
|
-
|
30
|
+
if (!window._rails_loaded) {
|
31
|
+
Rails.start();
|
32
|
+
}
|
@@ -1,13 +1,11 @@
|
|
1
1
|
import jQuery from "jquery";
|
2
2
|
import "jquery-ui/ui/widget.js";
|
3
3
|
import I18n from "./i18n";
|
4
|
+
|
4
5
|
(function ($) {
|
5
|
-
$.widget("ra.filteringMultiselect", {
|
6
|
+
$.widget("ra.filteringMultiselect", $.ra.abstractSelect, {
|
6
7
|
_cache: {},
|
7
8
|
options: {
|
8
|
-
createQuery: function (query) {
|
9
|
-
return { query: query };
|
10
|
-
},
|
11
9
|
sortable: false,
|
12
10
|
removable: true,
|
13
11
|
regional: {
|
@@ -6,11 +6,8 @@ import I18n from "./i18n";
|
|
6
6
|
(function ($) {
|
7
7
|
"use strict";
|
8
8
|
|
9
|
-
$.widget("ra.filteringSelect", {
|
9
|
+
$.widget("ra.filteringSelect", $.ra.abstractSelect, {
|
10
10
|
options: {
|
11
|
-
createQuery: function (query) {
|
12
|
-
return { query: query };
|
13
|
-
},
|
14
11
|
minLength: 0,
|
15
12
|
searchDelay: 200,
|
16
13
|
remote_source: null,
|
@@ -300,6 +297,7 @@ import I18n from "./i18n";
|
|
300
297
|
destroy: function () {
|
301
298
|
this.input.remove();
|
302
299
|
this.button.remove();
|
300
|
+
this.element.html($('<option value="" selected="selected"></option>'));
|
303
301
|
this.element.show();
|
304
302
|
this.filtering_select.remove();
|
305
303
|
$.Widget.prototype.destroy.call(this);
|
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: 3.
|
4
|
+
version: 3.3.0
|
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: 2024-
|
15
|
+
date: 2024-12-08 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activemodel-serializers-xml
|
@@ -28,6 +28,20 @@ dependencies:
|
|
28
28
|
- - ">="
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: '1.0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: csv
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
31
45
|
- !ruby/object:Gem::Dependency
|
32
46
|
name: kaminari
|
33
47
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,7 +85,7 @@ dependencies:
|
|
71
85
|
version: '6.0'
|
72
86
|
- - "<"
|
73
87
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
88
|
+
version: '9'
|
75
89
|
type: :runtime
|
76
90
|
prerelease: false
|
77
91
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -81,21 +95,27 @@ dependencies:
|
|
81
95
|
version: '6.0'
|
82
96
|
- - "<"
|
83
97
|
- !ruby/object:Gem::Version
|
84
|
-
version: '
|
98
|
+
version: '9'
|
85
99
|
- !ruby/object:Gem::Dependency
|
86
100
|
name: turbo-rails
|
87
101
|
requirement: !ruby/object:Gem::Requirement
|
88
102
|
requirements:
|
89
|
-
- - "
|
103
|
+
- - ">="
|
90
104
|
- !ruby/object:Gem::Version
|
91
105
|
version: '1.0'
|
106
|
+
- - "<"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '3'
|
92
109
|
type: :runtime
|
93
110
|
prerelease: false
|
94
111
|
version_requirements: !ruby/object:Gem::Requirement
|
95
112
|
requirements:
|
96
|
-
- - "
|
113
|
+
- - ">="
|
97
114
|
- !ruby/object:Gem::Version
|
98
115
|
version: '1.0'
|
116
|
+
- - "<"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '3'
|
99
119
|
- !ruby/object:Gem::Dependency
|
100
120
|
name: bundler
|
101
121
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,6 +210,7 @@ files:
|
|
190
210
|
- lib/generators/rails_admin/templates/initializer.erb
|
191
211
|
- lib/generators/rails_admin/templates/rails_admin.js
|
192
212
|
- lib/generators/rails_admin/templates/rails_admin.scss.erb
|
213
|
+
- lib/generators/rails_admin/templates/rails_admin.vite.js
|
193
214
|
- lib/generators/rails_admin/templates/rails_admin.webpacker.js
|
194
215
|
- lib/generators/rails_admin/utils.rb
|
195
216
|
- lib/rails_admin.rb
|
@@ -199,8 +220,6 @@ files:
|
|
199
220
|
- lib/rails_admin/adapters/active_record/association.rb
|
200
221
|
- lib/rails_admin/adapters/active_record/object_extension.rb
|
201
222
|
- lib/rails_admin/adapters/active_record/property.rb
|
202
|
-
- lib/rails_admin/adapters/composite_primary_keys.rb
|
203
|
-
- lib/rails_admin/adapters/composite_primary_keys/association.rb
|
204
223
|
- lib/rails_admin/adapters/mongoid.rb
|
205
224
|
- lib/rails_admin/adapters/mongoid/association.rb
|
206
225
|
- lib/rails_admin/adapters/mongoid/bson.rb
|
@@ -226,6 +245,7 @@ files:
|
|
226
245
|
- lib/rails_admin/config/fields.rb
|
227
246
|
- lib/rails_admin/config/fields/association.rb
|
228
247
|
- lib/rails_admin/config/fields/base.rb
|
248
|
+
- lib/rails_admin/config/fields/collection_association.rb
|
229
249
|
- lib/rails_admin/config/fields/factories/action_text.rb
|
230
250
|
- lib/rails_admin/config/fields/factories/active_storage.rb
|
231
251
|
- lib/rails_admin/config/fields/factories/association.rb
|
@@ -237,6 +257,7 @@ files:
|
|
237
257
|
- lib/rails_admin/config/fields/factories/password.rb
|
238
258
|
- lib/rails_admin/config/fields/factories/shrine.rb
|
239
259
|
- lib/rails_admin/config/fields/group.rb
|
260
|
+
- lib/rails_admin/config/fields/singular_association.rb
|
240
261
|
- lib/rails_admin/config/fields/types.rb
|
241
262
|
- lib/rails_admin/config/fields/types/action_text.rb
|
242
263
|
- lib/rails_admin/config/fields/types/active_record_enum.rb
|
@@ -250,7 +271,6 @@ files:
|
|
250
271
|
- lib/rails_admin/config/fields/types/ck_editor.rb
|
251
272
|
- lib/rails_admin/config/fields/types/code_mirror.rb
|
252
273
|
- lib/rails_admin/config/fields/types/color.rb
|
253
|
-
- lib/rails_admin/config/fields/types/composite_keys_belongs_to_association.rb
|
254
274
|
- lib/rails_admin/config/fields/types/date.rb
|
255
275
|
- lib/rails_admin/config/fields/types/datetime.rb
|
256
276
|
- lib/rails_admin/config/fields/types/decimal.rb
|
@@ -312,6 +332,8 @@ files:
|
|
312
332
|
- lib/rails_admin/extensions/paper_trail/auditing_adapter.rb
|
313
333
|
- lib/rails_admin/extensions/pundit.rb
|
314
334
|
- lib/rails_admin/extensions/pundit/authorization_adapter.rb
|
335
|
+
- lib/rails_admin/extensions/url_for_extension.rb
|
336
|
+
- lib/rails_admin/support/composite_keys_serializer.rb
|
315
337
|
- lib/rails_admin/support/csv_converter.rb
|
316
338
|
- lib/rails_admin/support/datetime.rb
|
317
339
|
- lib/rails_admin/support/es_module_processor.rb
|
@@ -319,6 +341,7 @@ files:
|
|
319
341
|
- lib/rails_admin/version.rb
|
320
342
|
- lib/tasks/rails_admin.rake
|
321
343
|
- package.json
|
344
|
+
- src/rails_admin/abstract-select.js
|
322
345
|
- src/rails_admin/base.js
|
323
346
|
- src/rails_admin/filter-box.js
|
324
347
|
- src/rails_admin/filtering-multiselect.js
|
@@ -447,12 +470,13 @@ homepage: https://github.com/railsadminteam/rails_admin
|
|
447
470
|
licenses:
|
448
471
|
- MIT
|
449
472
|
metadata: {}
|
450
|
-
post_install_message:
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
473
|
+
post_install_message: |
|
474
|
+
### Upgrading RailsAdmin from 2.x.x to 3.x.x ###
|
475
|
+
|
476
|
+
Due to introduction of Webpack/Webpacker support, some additional dependencies and configuration will be needed.
|
477
|
+
Running `bin/rails g rails_admin:install` will suggest required changes, based on the current setup of your app.
|
478
|
+
|
479
|
+
For a complete list of changes, see https://github.com/railsadminteam/rails_admin/blob/master/CHANGELOG.md
|
456
480
|
rdoc_options: []
|
457
481
|
require_paths:
|
458
482
|
- lib
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RailsAdmin
|
4
|
-
module Adapters
|
5
|
-
module CompositePrimaryKeys
|
6
|
-
class Association < RailsAdmin::Adapters::ActiveRecord::Association
|
7
|
-
def field_type
|
8
|
-
if type == :belongs_to && association.foreign_key.is_a?(Array)
|
9
|
-
:composite_keys_belongs_to_association
|
10
|
-
else
|
11
|
-
super
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def primary_key
|
16
|
-
return nil if polymorphic?
|
17
|
-
|
18
|
-
value = association.association_primary_key
|
19
|
-
|
20
|
-
if value.is_a? Array
|
21
|
-
:id
|
22
|
-
else
|
23
|
-
value.to_sym
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def foreign_key
|
28
|
-
if association.foreign_key.is_a? Array
|
29
|
-
association.foreign_key.map(&:to_sym)
|
30
|
-
else
|
31
|
-
super
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def key_accessor
|
36
|
-
if type == :belongs_to && foreign_key.is_a?(Array)
|
37
|
-
:"#{name}_id"
|
38
|
-
else
|
39
|
-
super
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rails_admin/adapters/active_record'
|
4
|
-
require 'rails_admin/adapters/composite_primary_keys/association'
|
5
|
-
|
6
|
-
module RailsAdmin
|
7
|
-
module Adapters
|
8
|
-
module CompositePrimaryKeys
|
9
|
-
include RailsAdmin::Adapters::ActiveRecord
|
10
|
-
|
11
|
-
def get(id, scope = scoped)
|
12
|
-
begin
|
13
|
-
object = scope.find(id)
|
14
|
-
rescue ::ActiveRecord::RecordNotFound
|
15
|
-
return nil
|
16
|
-
end
|
17
|
-
|
18
|
-
object.extend(RailsAdmin::Adapters::ActiveRecord::ObjectExtension)
|
19
|
-
end
|
20
|
-
|
21
|
-
def associations
|
22
|
-
model.reflect_on_all_associations.collect do |association|
|
23
|
-
RailsAdmin::Adapters::CompositePrimaryKeys::Association.new(association, model)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def bulk_scope(scope, options)
|
30
|
-
if primary_key.is_a? Array
|
31
|
-
options[:bulk_ids].map do |id|
|
32
|
-
scope.where(primary_key.zip(::CompositePrimaryKeys::CompositeKeys.parse(id)).to_h)
|
33
|
-
end.reduce(&:or)
|
34
|
-
else
|
35
|
-
super
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rails_admin/config/fields/types/belongs_to_association'
|
4
|
-
|
5
|
-
module RailsAdmin
|
6
|
-
module Config
|
7
|
-
module Fields
|
8
|
-
module Types
|
9
|
-
class CompositeKeysBelongsToAssociation < RailsAdmin::Config::Fields::Types::BelongsToAssociation
|
10
|
-
RailsAdmin::Config::Fields::Types.register(self)
|
11
|
-
|
12
|
-
register_instance_option :allowed_methods do
|
13
|
-
nested_form ? [method_name] : Array(association.foreign_key)
|
14
|
-
end
|
15
|
-
|
16
|
-
def selected_id
|
17
|
-
association.foreign_key.map { |attribute| bindings[:object].safe_send(attribute) }.to_composite_keys.to_s
|
18
|
-
end
|
19
|
-
|
20
|
-
def parse_input(params)
|
21
|
-
return unless params[method_name].present? && association.foreign_key.is_a?(Array) && !nested_form
|
22
|
-
|
23
|
-
association.foreign_key.zip(CompositePrimaryKeys::CompositeKeys.parse(params.delete(method_name))).each do |key, value|
|
24
|
-
params[key] = value
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|