avo 1.21.0.pre.1 → 1.21.0
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 +3 -1
- data/Gemfile.lock +5 -5
- data/app/assets/svgs/x.svg +3 -0
- data/app/components/avo/fields/belongs_to_field/autocomplete_component.html.erb +22 -0
- data/app/components/avo/fields/belongs_to_field/autocomplete_component.rb +33 -0
- data/app/components/avo/fields/belongs_to_field/edit_component.html.erb +39 -33
- data/app/components/avo/views/resource_index_component.html.erb +1 -1
- data/app/controllers/avo/relations_controller.rb +4 -4
- data/app/controllers/avo/search_controller.rb +0 -1
- data/app/javascript/js/controllers/fields/belongs_to_field_controller.js +96 -33
- data/app/javascript/js/controllers/search_controller.js +83 -17
- data/app/views/avo/partials/_global_search.html.erb +0 -1
- data/app/views/avo/partials/_javascript.html.erb +1 -0
- data/app/views/avo/partials/_resource_search.html.erb +0 -1
- data/db/factories.rb +4 -0
- data/lib/avo/fields/base_field.rb +1 -1
- data/lib/avo/fields/belongs_to_field.rb +19 -2
- data/lib/avo/fields/files_field.rb +2 -1
- data/lib/avo/licensing/pro_license.rb +2 -1
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/templates/locales/avo.en.yml +1 -0
- data/public/avo-assets/avo.css +16 -0
- data/public/avo-assets/avo.js +317 -234
- data/public/avo-assets/avo.js.map +2 -2
- metadata +7 -7
- data/app/assets/builds/avo.css +0 -8590
- data/app/assets/builds/avo.js +0 -87755
- data/app/assets/builds/avo.js.map +0 -7
@@ -1,10 +1,9 @@
|
|
1
1
|
module Avo
|
2
2
|
module Fields
|
3
3
|
class BelongsToField < BaseField
|
4
|
-
attr_reader :searchable
|
5
4
|
attr_reader :polymorphic_as
|
6
5
|
attr_reader :relation_method
|
7
|
-
attr_reader :types
|
6
|
+
attr_reader :types # for Polymorphic associations
|
8
7
|
|
9
8
|
def initialize(id, **args, &block)
|
10
9
|
args[:placeholder] ||= I18n.t("avo.choose_an_option")
|
@@ -17,10 +16,28 @@ module Avo
|
|
17
16
|
@relation_method = name.to_s.parameterize.underscore
|
18
17
|
end
|
19
18
|
|
19
|
+
def searchable
|
20
|
+
@searchable && ::Avo::App.license.has_with_trial(:searchable_belongs_to)
|
21
|
+
end
|
22
|
+
|
20
23
|
def value
|
21
24
|
super(polymorphic_as)
|
22
25
|
end
|
23
26
|
|
27
|
+
# The value
|
28
|
+
def field_value
|
29
|
+
value.send(database_value)
|
30
|
+
rescue
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
|
34
|
+
# What the user sees in the text field
|
35
|
+
def field_label
|
36
|
+
value.send(target_resource.class.title)
|
37
|
+
rescue
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
|
24
41
|
def options
|
25
42
|
::Avo::Services::AuthorizationService.apply_policy(user, target_resource.class.query_scope).all.map do |model|
|
26
43
|
{
|
@@ -1,14 +1,15 @@
|
|
1
1
|
module Avo
|
2
2
|
module Fields
|
3
3
|
class FilesField < BaseField
|
4
|
+
attr_accessor :is_audio
|
4
5
|
attr_accessor :is_image
|
5
6
|
attr_accessor :direct_upload
|
6
7
|
|
7
8
|
def initialize(id, **args, &block)
|
8
9
|
super(id, **args, &block)
|
9
10
|
|
10
|
-
@is_image = args[:is_image].present? ? args[:is_image] : @is_avatar
|
11
11
|
@is_audio = args[:is_audio].present? ? args[:is_audio] : false
|
12
|
+
@is_image = args[:is_image].present? ? args[:is_image] : @is_avatar
|
12
13
|
@direct_upload = args[:direct_upload].present? ? args[:direct_upload] : false
|
13
14
|
end
|
14
15
|
|
data/lib/avo/version.rb
CHANGED
data/public/avo-assets/avo.css
CHANGED
@@ -6402,6 +6402,14 @@ progress[value]::-moz-progress-bar{
|
|
6402
6402
|
top:-1px
|
6403
6403
|
}
|
6404
6404
|
|
6405
|
+
.left-auto{
|
6406
|
+
left:auto
|
6407
|
+
}
|
6408
|
+
|
6409
|
+
.right-3{
|
6410
|
+
right:0.75rem
|
6411
|
+
}
|
6412
|
+
|
6405
6413
|
.z-10{
|
6406
6414
|
z-index:10
|
6407
6415
|
}
|
@@ -6571,6 +6579,14 @@ progress[value]::-moz-progress-bar{
|
|
6571
6579
|
margin-left:0.5rem
|
6572
6580
|
}
|
6573
6581
|
|
6582
|
+
.mr-px{
|
6583
|
+
margin-right:1px
|
6584
|
+
}
|
6585
|
+
|
6586
|
+
.-mt-2{
|
6587
|
+
margin-top:-0.5rem
|
6588
|
+
}
|
6589
|
+
|
6574
6590
|
.ml-6{
|
6575
6591
|
margin-left:1.5rem
|
6576
6592
|
}
|