avo 2.29.1 → 2.30.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 +2 -0
- data/Gemfile.lock +4 -2
- data/app/components/avo/fields/common/single_file_viewer_component.html.erb +3 -1
- data/app/components/avo/fields/common/single_file_viewer_component.rb +7 -5
- data/app/components/avo/fields/location_field/edit_component.html.erb +22 -0
- data/app/components/avo/fields/location_field/edit_component.rb +4 -0
- data/app/components/avo/fields/location_field/show_component.html.erb +7 -0
- data/app/components/avo/fields/location_field/show_component.rb +4 -0
- data/app/javascript/js/application.js +2 -0
- data/db/factories.rb +1 -0
- data/lib/avo/fields/file_field.rb +2 -0
- data/lib/avo/fields/files_field.rb +2 -0
- data/lib/avo/fields/location_field.rb +70 -0
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/resource_generator.rb +1 -1
- data/public/avo-assets/avo.base.js +681 -185
- data/public/avo-assets/avo.base.js.map +3 -3
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47a6931f5fd184bfb437e0541849e04f4452764059b23582ca000a977f805bc8
|
4
|
+
data.tar.gz: ba1137efa1e302b64bb86635b7c6327cd145d0fa68b787f8540bd5089a9e8bd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0a68869c9647f57f3d3ffe1699e7e6fd1a2c0cc4fcbceadb127b1312893cf53eb8d2a89df9c160a058a824846bd128ed9e681eecbe06dd90c61bd91641a5132
|
7
|
+
data.tar.gz: e92694271216d763281657edc6b128f05dd8ff104b7228eabeca8570bb86dad6c91a2712410655a744f600db466fea2a25f349182881ab32fecceef3d1763669
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
avo (2.
|
4
|
+
avo (2.30.0)
|
5
5
|
actionview (>= 6.0)
|
6
6
|
active_link_to
|
7
7
|
activerecord (>= 6.0)
|
@@ -247,6 +247,7 @@ GEM
|
|
247
247
|
manifester (0.1.8)
|
248
248
|
rails (>= 6.0)
|
249
249
|
zeitwerk
|
250
|
+
mapkick-rb (0.1.4)
|
250
251
|
marcel (1.0.2)
|
251
252
|
matrix (0.4.2)
|
252
253
|
meta-tags (2.18.0)
|
@@ -274,7 +275,7 @@ GEM
|
|
274
275
|
nokogiri (1.14.2-x86_64-linux)
|
275
276
|
racc (~> 1.4)
|
276
277
|
orm_adapter (0.5.0)
|
277
|
-
pagy (6.0.
|
278
|
+
pagy (6.0.3)
|
278
279
|
parallel (1.22.1)
|
279
280
|
parser (3.2.0.0)
|
280
281
|
ast (~> 2.4.1)
|
@@ -492,6 +493,7 @@ DEPENDENCIES
|
|
492
493
|
launchy
|
493
494
|
listen (>= 3.5.1)
|
494
495
|
manifester
|
496
|
+
mapkick-rb (~> 0.1.4)
|
495
497
|
meta-tags
|
496
498
|
net-smtp
|
497
499
|
pg (>= 0.18, < 2.0)
|
@@ -16,7 +16,9 @@
|
|
16
16
|
</div>
|
17
17
|
</div>
|
18
18
|
<% end %>
|
19
|
-
|
19
|
+
<% if field.display_filename %>
|
20
|
+
<span class="text-gray-500 mt-2 text-sm truncate" title="<%= file.filename %>"><%= file.filename %></span>
|
21
|
+
<% end %>
|
20
22
|
</div>
|
21
23
|
<div class="flex space-x-2">
|
22
24
|
<div class="flex">
|
@@ -4,6 +4,8 @@ class Avo::Fields::Common::SingleFileViewerComponent < ViewComponent::Base
|
|
4
4
|
include Avo::ApplicationHelper
|
5
5
|
include Avo::Fields::Concerns::FileAuthorization
|
6
6
|
|
7
|
+
attr_reader :field
|
8
|
+
|
7
9
|
def initialize(field:, resource:, file: nil)
|
8
10
|
@file = file
|
9
11
|
@field = field
|
@@ -15,29 +17,29 @@ class Avo::Fields::Common::SingleFileViewerComponent < ViewComponent::Base
|
|
15
17
|
end
|
16
18
|
|
17
19
|
def id
|
18
|
-
|
20
|
+
field.id
|
19
21
|
end
|
20
22
|
|
21
23
|
def file
|
22
|
-
@file ||
|
24
|
+
@file || field.value.attachment
|
23
25
|
rescue
|
24
26
|
nil
|
25
27
|
end
|
26
28
|
|
27
29
|
def is_image?
|
28
|
-
file.image? ||
|
30
|
+
file.image? || field.is_image
|
29
31
|
rescue
|
30
32
|
false
|
31
33
|
end
|
32
34
|
|
33
35
|
def is_audio?
|
34
|
-
file.audio? ||
|
36
|
+
file.audio? || field.is_audio
|
35
37
|
rescue
|
36
38
|
false
|
37
39
|
end
|
38
40
|
|
39
41
|
def is_video?
|
40
|
-
file.video? ||
|
42
|
+
file.video? || field.is_video
|
41
43
|
rescue
|
42
44
|
false
|
43
45
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%= field_wrapper **field_wrapper_args do %>
|
2
|
+
<% if field.value_as_array? %>
|
3
|
+
<div class="flex gap-4">
|
4
|
+
<%= @form.text_field @field.as_lat_long_field_id(:lat),
|
5
|
+
value: @field.as_lat_long_value(:lat),
|
6
|
+
class: classes("w-full"),
|
7
|
+
placeholder: @field.as_lat_long_placeholder(:lat)
|
8
|
+
%>
|
9
|
+
<%= @form.text_field @field.as_lat_long_field_id(:long),
|
10
|
+
value: @field.as_lat_long_value(:long),
|
11
|
+
class: classes("w-full"),
|
12
|
+
placeholder: @field.as_lat_long_placeholder(:long)
|
13
|
+
%>
|
14
|
+
</div>
|
15
|
+
<% else %>
|
16
|
+
<%= @form.text_field @field.id,
|
17
|
+
value: @field.value,
|
18
|
+
class: classes("w-full"),
|
19
|
+
placeholder: @field.placeholder
|
20
|
+
%>
|
21
|
+
<% end %>
|
22
|
+
<% end %>
|
data/db/factories.rb
CHANGED
@@ -90,6 +90,7 @@ FactoryBot.define do
|
|
90
90
|
factory :city do
|
91
91
|
name { Faker::Address.city }
|
92
92
|
population { rand(10000..999000) }
|
93
|
+
coordinates { [Faker::Address.latitude, Faker::Address.longitude] }
|
93
94
|
is_capital { [true, false].sample }
|
94
95
|
features { Faker::Address.community }
|
95
96
|
metadata { Faker::Address.community }
|
@@ -7,6 +7,7 @@ module Avo
|
|
7
7
|
attr_accessor :is_audio
|
8
8
|
attr_accessor :direct_upload
|
9
9
|
attr_accessor :accept
|
10
|
+
attr_reader :display_filename
|
10
11
|
|
11
12
|
def initialize(id, **args, &block)
|
12
13
|
super(id, **args, &block)
|
@@ -17,6 +18,7 @@ module Avo
|
|
17
18
|
@is_audio = args[:is_audio].present? ? args[:is_audio] : false
|
18
19
|
@direct_upload = args[:direct_upload].present? ? args[:direct_upload] : false
|
19
20
|
@accept = args[:accept].present? ? args[:accept] : nil
|
21
|
+
@display_filename = args[:display_filename].nil? ? true : args[:display_filename]
|
20
22
|
end
|
21
23
|
|
22
24
|
def path
|
@@ -5,6 +5,7 @@ module Avo
|
|
5
5
|
attr_accessor :is_image
|
6
6
|
attr_accessor :direct_upload
|
7
7
|
attr_accessor :accept
|
8
|
+
attr_reader :display_filename
|
8
9
|
|
9
10
|
def initialize(id, **args, &block)
|
10
11
|
super(id, **args, &block)
|
@@ -13,6 +14,7 @@ module Avo
|
|
13
14
|
@is_image = args[:is_image].present? ? args[:is_image] : @is_avatar
|
14
15
|
@direct_upload = args[:direct_upload].present? ? args[:direct_upload] : false
|
15
16
|
@accept = args[:accept].present? ? args[:accept] : nil
|
17
|
+
@display_filename = args[:display_filename].nil? ? true : args[:display_filename]
|
16
18
|
end
|
17
19
|
|
18
20
|
def view_component_name
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avo
|
4
|
+
module Fields
|
5
|
+
class LocationField < BaseField
|
6
|
+
attr_reader :stored_as
|
7
|
+
|
8
|
+
def initialize(id, **args, &block)
|
9
|
+
hide_on :index
|
10
|
+
|
11
|
+
super(id, **args, &block)
|
12
|
+
|
13
|
+
@stored_as = args[:stored_as].present? ? args[:stored_as] : nil # You can pass it an array of db columns [:latitude, :longitude]
|
14
|
+
end
|
15
|
+
|
16
|
+
def value_as_array?
|
17
|
+
stored_as.is_a?(Array) && stored_as.count == 2
|
18
|
+
end
|
19
|
+
|
20
|
+
def as_lat_long_field_id(get)
|
21
|
+
if get == :lat
|
22
|
+
"#{id}[#{stored_as.first}]"
|
23
|
+
elsif get == :long
|
24
|
+
"#{id}[#{stored_as.last}]"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def as_lat_long_placeholder(get)
|
29
|
+
if get == :lat
|
30
|
+
"Enter #{stored_as.first}"
|
31
|
+
elsif get == :long
|
32
|
+
"Enter #{stored_as.last}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def as_lat_long_value(get)
|
37
|
+
if get == :lat
|
38
|
+
model.send(stored_as.first)
|
39
|
+
elsif get == :long
|
40
|
+
model.send(stored_as.last)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def fill_field(model, key, value, params)
|
45
|
+
if value_as_array?
|
46
|
+
latitude_field, longitude_field = stored_as
|
47
|
+
model.send("#{latitude_field}=", value[latitude_field])
|
48
|
+
model.send("#{longitude_field}=", value[longitude_field])
|
49
|
+
model
|
50
|
+
else
|
51
|
+
super(model, key, value.split(","), params)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def to_permitted_param
|
56
|
+
if value_as_array?
|
57
|
+
[:"#{id}", "#{id}": {}]
|
58
|
+
else
|
59
|
+
super
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def value_present?
|
64
|
+
return value.first.present? && value.second.present? if value.is_a?(Array) && value.count == 2
|
65
|
+
|
66
|
+
value.present?
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/avo/version.rb
CHANGED