avo 2.28.3.pre.pr1646 → 2.29.1.pre.pr1652
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of avo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/components/avo/fields/belongs_to_field/edit_component.rb +5 -1
- data/app/components/avo/fields/has_one_field/show_component.rb +6 -2
- data/app/components/avo/referrer_params_component.html.erb +2 -0
- data/app/controllers/avo/base_controller.rb +6 -1
- data/app/helpers/avo/application_helper.rb +5 -6
- data/app/javascript/js/controllers/fields/tags_field_controller.js +4 -0
- data/lib/avo/base_resource.rb +2 -1
- data/lib/avo/configuration.rb +4 -6
- data/lib/avo/fields/has_one_field.rb +2 -1
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/templates/initializer/avo.tt +2 -0
- data/public/avo-assets/avo.base.js +47 -47
- data/public/avo-assets/avo.base.js.map +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d2125434870241611526a666d97850dd666741c17ebe191c8496dfc0804faf0
|
4
|
+
data.tar.gz: f05693aeee46a349b98329592a9f4bc0ae1b35f6922e8fd83d7ef7dd120bbc3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70967faaf46f6552646994b4cf3d5d080b8059d2909826169ac63021b11699875d4c3d81282eb9f65e074b208711b2260d220656cde4aa422503569070176421
|
7
|
+
data.tar.gz: 300be7ff2c5c9d04ada4995820318ec3076c6a1ba5954c1ccc88792d35117e1db13d3e89f84d41c8db44f322cc1df19fe7625b3d86772813e96a58f11cb1379a
|
data/Gemfile.lock
CHANGED
@@ -31,6 +31,10 @@ class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
|
|
31
31
|
@resource.model["#{@field.foreign_key}_type"]
|
32
32
|
end
|
33
33
|
|
34
|
+
def polymorphic_resource
|
35
|
+
::Avo::App.get_resource_by_model_name(polymorphic_class)
|
36
|
+
end
|
37
|
+
|
34
38
|
# Get the polymorphic id
|
35
39
|
def polymorphic_id
|
36
40
|
@resource.model["#{@field.foreign_key}_id"]
|
@@ -44,7 +48,7 @@ class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
|
|
44
48
|
|
45
49
|
return @polymorphic_record if @polymorphic_record.present?
|
46
50
|
|
47
|
-
@polymorphic_record =
|
51
|
+
@polymorphic_record = polymorphic_resource.find_record polymorphic_id, query: polymorphic_class.safe_constantize, params: params
|
48
52
|
|
49
53
|
@polymorphic_record
|
50
54
|
end
|
@@ -36,11 +36,15 @@ class Avo::Fields::HasOneField::ShowComponent < Avo::Fields::ShowComponent
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def create_path
|
39
|
+
association_id = @field.resource.model_class._reflections[@field.id.to_s].inverse_of.name
|
40
|
+
|
39
41
|
args = {
|
40
|
-
via_relation:
|
42
|
+
via_relation: association_id,
|
41
43
|
via_relation_class: @resource.model_class.to_s,
|
42
|
-
via_resource_id: @resource.model.to_param
|
44
|
+
via_resource_id: @resource.model.to_param,
|
45
|
+
via_association_type: :has_one
|
43
46
|
}
|
47
|
+
|
44
48
|
helpers.new_resource_path(resource: @field.target_resource, **args)
|
45
49
|
end
|
46
50
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
<%# via_association_type is used in has_one create actions %>
|
2
|
+
<%= hidden_field_tag :via_association_type, params[:via_association_type] if params[:via_association_type] %>
|
1
3
|
<%= hidden_field_tag :via_resource_class, params[:via_resource_class] if params[:via_resource_class] %>
|
2
4
|
<%= hidden_field_tag :via_resource_id, params[:via_resource_id] if params[:via_resource_id] %>
|
3
5
|
<%= hidden_field_tag :via_relation, params[:via_relation] if params[:via_relation] %>
|
@@ -151,7 +151,12 @@ module Avo
|
|
151
151
|
@related_record = via_resource.find_record params[:via_resource_id], params: params
|
152
152
|
association_name = BaseResource.valid_association_name(@model, params[:via_relation])
|
153
153
|
|
154
|
-
|
154
|
+
if params[:via_association_type] == "has_one"
|
155
|
+
# On has_one scenarios we should switch the @record and @related_record
|
156
|
+
@related_record.send("#{@reflection.parent_reflection.inverse_of.name}=", @model)
|
157
|
+
else
|
158
|
+
@model.send(association_name) << @related_record
|
159
|
+
end
|
155
160
|
end
|
156
161
|
end
|
157
162
|
|
@@ -102,16 +102,15 @@ module Avo
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def root_path_without_url
|
105
|
-
Avo
|
106
|
-
.to_s
|
107
|
-
.delete_prefix(request.base_url.to_s)
|
108
|
-
.delete_suffix("/")
|
109
|
-
.gsub("/?", "?")
|
110
|
-
.query = ""
|
105
|
+
"#{Avo.configuration.prefix_path}#{mount_path}"
|
111
106
|
rescue
|
112
107
|
Avo.configuration.root_path
|
113
108
|
end
|
114
109
|
|
110
|
+
def mount_path
|
111
|
+
Avo::Engine.routes.find_script_name(params.permit!.to_h.symbolize_keys)
|
112
|
+
end
|
113
|
+
|
115
114
|
private
|
116
115
|
|
117
116
|
# Taken from the original library
|
@@ -60,6 +60,10 @@ export default class extends BaseController {
|
|
60
60
|
},
|
61
61
|
originalInputValueFormat: (valuesArr) => valuesArr.map((item) => item.value),
|
62
62
|
})
|
63
|
+
} else {
|
64
|
+
options = merge(options, {
|
65
|
+
originalInputValueFormat: (valuesArr) => valuesArr.map((item) => item.value).join(','),
|
66
|
+
})
|
63
67
|
}
|
64
68
|
|
65
69
|
return options
|
data/lib/avo/base_resource.rb
CHANGED
@@ -382,7 +382,8 @@ module Avo
|
|
382
382
|
|
383
383
|
if field.polymorphic_as.present? && field.types.map(&:to_s).include?(@params[:via_relation_class])
|
384
384
|
# set the value to the actual record
|
385
|
-
|
385
|
+
via_resource = ::Avo::App.get_resource_by_model_name(@params[:via_relation_class])
|
386
|
+
value = via_resource.find_record(@params[:via_resource_id])
|
386
387
|
elsif reflection.present? && reflection.foreign_key.present? && field.id.to_s == @params[:via_relation].to_s
|
387
388
|
resource = Avo::App.get_resource_by_model_name params[:via_relation_class]
|
388
389
|
model = resource.find_record @params[:via_resource_id], params: params
|
data/lib/avo/configuration.rb
CHANGED
@@ -42,6 +42,7 @@ module Avo
|
|
42
42
|
attr_accessor :field_wrapper_layout
|
43
43
|
attr_accessor :sign_out_path_name
|
44
44
|
attr_accessor :resources
|
45
|
+
attr_accessor :prefix_path
|
45
46
|
attr_writer :branding
|
46
47
|
|
47
48
|
def initialize
|
@@ -94,6 +95,7 @@ module Avo
|
|
94
95
|
@authorization_client = :pundit
|
95
96
|
@field_wrapper_layout = :inline
|
96
97
|
@resources = nil
|
98
|
+
@prefix_path = nil
|
97
99
|
end
|
98
100
|
|
99
101
|
def current_user_method(&block)
|
@@ -117,8 +119,8 @@ module Avo
|
|
117
119
|
end
|
118
120
|
|
119
121
|
def namespace
|
120
|
-
if
|
121
|
-
|
122
|
+
if Avo.configuration.root_path.present?
|
123
|
+
Avo.configuration.root_path.delete "/"
|
122
124
|
else
|
123
125
|
root_path.delete "/"
|
124
126
|
end
|
@@ -130,10 +132,6 @@ module Avo
|
|
130
132
|
@root_path
|
131
133
|
end
|
132
134
|
|
133
|
-
def computed_root_path
|
134
|
-
Avo.configuration.root_path
|
135
|
-
end
|
136
|
-
|
137
135
|
def feature_enabled?(feature)
|
138
136
|
!@disabled_features.map(&:to_sym).include?(feature.to_sym)
|
139
137
|
end
|
@@ -33,7 +33,8 @@ module Avo
|
|
33
33
|
related_model = nil
|
34
34
|
else
|
35
35
|
related_class = model.class.reflections[name.to_s.downcase].class_name
|
36
|
-
|
36
|
+
related_resource = ::Avo::App.get_resource_by_model_name(related_class)
|
37
|
+
related_model = related_resource.find_record value
|
37
38
|
end
|
38
39
|
|
39
40
|
model.public_send("#{key}=", related_model)
|
data/lib/avo/version.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
Avo.configure do |config|
|
3
3
|
## == Routing ==
|
4
4
|
config.root_path = '/<%= options[:path] %>'
|
5
|
+
# used only when you have custom `map` configuration in your config.ru
|
6
|
+
# config.prefix_path = "/internal"
|
5
7
|
|
6
8
|
# Where should the user be redirected when visting the `/<%= options[:path] %>` url
|
7
9
|
# config.home_path = nil
|