avo 1.21.0.pre.1 → 1.22.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 +61 -61
- data/README.md +1 -1
- data/app/assets/svgs/x.svg +3 -0
- data/app/components/avo/fields/belongs_to_field/autocomplete_component.html.erb +29 -0
- data/app/components/avo/fields/belongs_to_field/autocomplete_component.rb +77 -0
- data/app/components/avo/fields/belongs_to_field/edit_component.html.erb +73 -46
- data/app/components/avo/fields/belongs_to_field/edit_component.rb +37 -0
- data/app/components/avo/navigation_link_component.html.erb +1 -1
- data/app/components/avo/navigation_link_component.rb +2 -1
- data/app/components/avo/views/resource_index_component.html.erb +1 -1
- data/app/controllers/avo/application_controller.rb +16 -14
- data/app/controllers/avo/base_controller.rb +1 -4
- 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/fields/date_field_controller.js +10 -2
- data/app/javascript/js/controllers/item_selector_controller.js +29 -19
- data/app/javascript/js/controllers/search_controller.js +88 -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/_logo.html.erb +3 -1
- data/app/views/avo/partials/_resource_search.html.erb +0 -1
- data/app/views/avo/partials/_turbo_frame_wrap.html.erb +7 -1
- data/app/views/avo/sidebar/_sidebar.html.erb +1 -3
- data/db/factories.rb +11 -3
- data/lib/avo/base_resource.rb +16 -14
- 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/fields/key_value_field.rb +28 -8
- 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 +2 -0
- data/lib/generators/avo/templates/locales/avo.nb-NO.yml +1 -0
- data/lib/generators/avo/templates/locales/avo.pt-BR.yml +1 -0
- data/lib/generators/avo/templates/locales/avo.ro.yml +1 -0
- data/public/avo-assets/avo.css +20 -4
- data/public/avo-assets/avo.js +330 -237
- 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
|
|
@@ -3,10 +3,6 @@ require "json"
|
|
3
3
|
module Avo
|
4
4
|
module Fields
|
5
5
|
class KeyValueField < BaseField
|
6
|
-
attr_reader :key_label
|
7
|
-
attr_reader :value_label
|
8
|
-
attr_reader :action_text
|
9
|
-
attr_reader :delete_text
|
10
6
|
attr_reader :disable_editing_keys
|
11
7
|
attr_reader :disable_adding_rows
|
12
8
|
|
@@ -15,10 +11,10 @@ module Avo
|
|
15
11
|
|
16
12
|
hide_on :index
|
17
13
|
|
18
|
-
@key_label = args[:key_label]
|
19
|
-
@value_label = args[:value_label]
|
20
|
-
@action_text = args[:action_text]
|
21
|
-
@delete_text = args[:delete_text]
|
14
|
+
@key_label = args[:key_label] if args[:key_label].present?
|
15
|
+
@value_label = args[:value_label]if args[:value_label].present?
|
16
|
+
@action_text = args[:action_text] if args[:action_text].present?
|
17
|
+
@delete_text = args[:delete_text] if args[:delete_text].present?
|
22
18
|
|
23
19
|
@disable_editing_keys = args[:disable_editing_keys].present? ? args[:disable_editing_keys] : false
|
24
20
|
# disabling editing keys also disables adding rows (doesn't take into account the value of disable_adding_rows)
|
@@ -32,6 +28,30 @@ module Avo
|
|
32
28
|
@disable_deleting_rows = args[:disable_deleting_rows].present? ? args[:disable_deleting_rows] : false
|
33
29
|
end
|
34
30
|
|
31
|
+
def key_label
|
32
|
+
return @key_label if @key_label.present?
|
33
|
+
|
34
|
+
I18n.translate('avo.key_value_field.key')
|
35
|
+
end
|
36
|
+
|
37
|
+
def value_label
|
38
|
+
return @value_label if @value_label.present?
|
39
|
+
|
40
|
+
I18n.translate('avo.key_value_field.value')
|
41
|
+
end
|
42
|
+
|
43
|
+
def action_text
|
44
|
+
return @action_text if @action_text.present?
|
45
|
+
|
46
|
+
I18n.translate('avo.key_value_field.add_row')
|
47
|
+
end
|
48
|
+
|
49
|
+
def delete_text
|
50
|
+
return @delete_text if @delete_text.present?
|
51
|
+
|
52
|
+
I18n.translate('avo.key_value_field.delete_row')
|
53
|
+
end
|
54
|
+
|
35
55
|
def to_permitted_param
|
36
56
|
[:"#{id}", "#{id}": {}]
|
37
57
|
end
|
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
|
}
|
@@ -6635,6 +6651,10 @@ progress[value]::-moz-progress-bar{
|
|
6635
6651
|
height:10rem
|
6636
6652
|
}
|
6637
6653
|
|
6654
|
+
.h-16{
|
6655
|
+
height:4rem
|
6656
|
+
}
|
6657
|
+
|
6638
6658
|
.h-full{
|
6639
6659
|
height:100%
|
6640
6660
|
}
|
@@ -6643,10 +6663,6 @@ progress[value]::-moz-progress-bar{
|
|
6643
6663
|
height:3rem
|
6644
6664
|
}
|
6645
6665
|
|
6646
|
-
.h-16{
|
6647
|
-
height:4rem
|
6648
|
-
}
|
6649
|
-
|
6650
6666
|
.h-3{
|
6651
6667
|
height:0.75rem
|
6652
6668
|
}
|