avo 2.29.1 → 2.30.1.pre1.pr1683
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 +6 -4
- data/app/components/avo/fields/common/files/controls_component.html.erb +29 -0
- data/app/components/avo/fields/common/files/controls_component.rb +19 -0
- data/app/components/avo/fields/common/files/list_viewer_component.html.erb +14 -0
- data/app/components/avo/fields/common/files/list_viewer_component.rb +26 -0
- data/app/components/avo/fields/common/files/view_type/grid_component.html.erb +27 -0
- data/app/components/avo/fields/common/{single_file_viewer_component.rb → files/view_type/grid_component.rb} +7 -12
- data/app/components/avo/fields/common/files/view_type/list_component.html.erb +22 -0
- data/app/components/avo/fields/common/files/view_type/list_component.rb +15 -0
- data/app/components/avo/fields/file_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/file_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/files_field/edit_component.html.erb +2 -2
- data/app/components/avo/fields/files_field/show_component.html.erb +2 -2
- 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/app/views/avo/partials/_view_toggle_button.html.erb +4 -0
- data/config/master.key +1 -0
- data/db/factories.rb +1 -0
- data/lib/avo/fields/base_field.rb +4 -2
- data/lib/avo/fields/file_field.rb +2 -0
- data/lib/avo/fields/files_field.rb +13 -0
- data/lib/avo/fields/id_field.rb +2 -1
- 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.css +29 -22
- data/public/avo-assets/avo.base.js +681 -185
- data/public/avo-assets/avo.base.js.map +3 -3
- metadata +18 -8
- data/app/components/avo/fields/common/files_list_viewer_component.html.erb +0 -5
- data/app/components/avo/fields/common/files_list_viewer_component.rb +0 -8
- data/app/components/avo/fields/common/single_file_viewer_component.html.erb +0 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3c650833493f18162beff6fcb0244af4a5a2a6d91041a9be0b0103cb027f85b
|
4
|
+
data.tar.gz: af1f9219ac03dc7bfe05812010d025e26d5f26fec0b59feb56519045ae6385d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a5b5b6e180b2d66d218b5e3d3f9f32622cacbb44104ac4a2d0e5ab6e0725d8e469ea0c5c830d04c0a489f9265bd6f2483ad92a2ec3c343d86a379bce63a8914
|
7
|
+
data.tar.gz: fd0a75e4c866d6a8562045ac0626378528a0751260788a9c9c3cf80183a4a698a0ac188396bba5c19e370b40a9831b1ce9d1d56e17bebc4638b0e8dbe7bffaec
|
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.1.pre1.pr1683)
|
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)
|
@@ -268,13 +269,13 @@ GEM
|
|
268
269
|
net-smtp (0.3.3)
|
269
270
|
net-protocol
|
270
271
|
nio4r (2.5.8)
|
271
|
-
nokogiri (1.14.
|
272
|
+
nokogiri (1.14.3)
|
272
273
|
mini_portile2 (~> 2.8.0)
|
273
274
|
racc (~> 1.4)
|
274
|
-
nokogiri (1.14.
|
275
|
+
nokogiri (1.14.3-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)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<div class="flex">
|
2
|
+
<% if can_download_file? %>
|
3
|
+
<%= a_link Rails.application.routes.url_helpers.rails_blob_path(file, only_path: true, disposition: :attachment),
|
4
|
+
icon: 'heroicons/outline/download',
|
5
|
+
color: :primary,
|
6
|
+
download: true,
|
7
|
+
class: 'text-center',
|
8
|
+
title: t('avo.download_file'),
|
9
|
+
data: { tippy: :tooltip },
|
10
|
+
compact: true,
|
11
|
+
size: :xs %>
|
12
|
+
<% end %>
|
13
|
+
</div>
|
14
|
+
<div>
|
15
|
+
<% if can_delete_file? %>
|
16
|
+
<%= a_link destroy_path,
|
17
|
+
icon: 'heroicons/outline/trash',
|
18
|
+
color: :red,
|
19
|
+
compact: true,
|
20
|
+
size: :xs,
|
21
|
+
class: 'text-center',
|
22
|
+
title: t('avo.delete_file', item: file.filename),
|
23
|
+
data: {
|
24
|
+
turbo_method: :delete,
|
25
|
+
turbo_confirm: t('avo.are_you_sure'),
|
26
|
+
tippy: :tooltip
|
27
|
+
} %>
|
28
|
+
<% end %>
|
29
|
+
</div>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Avo::Fields::Common::Files::ControlsComponent < ViewComponent::Base
|
4
|
+
include Avo::ApplicationHelper
|
5
|
+
include Avo::Fields::Concerns::FileAuthorization
|
6
|
+
|
7
|
+
attr_reader :file, :field, :resource
|
8
|
+
delegate :id, to: :field
|
9
|
+
|
10
|
+
def initialize(field:, file:, resource:)
|
11
|
+
@field = field
|
12
|
+
@file = file
|
13
|
+
@resource = resource
|
14
|
+
end
|
15
|
+
|
16
|
+
def destroy_path
|
17
|
+
Avo::Services::URIService.parse(@resource.record_path).append_paths("active_storage_attachments", id, file.id).to_s
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<div class="-mt-9">
|
2
|
+
<%= turbo_frame_tag @field.id do %>
|
3
|
+
<% unless @field.hide_view_type_changer %>
|
4
|
+
<div class="justify-self-end flex justify-end items-center space-x-3">
|
5
|
+
<%= render partial: 'avo/partials/view_toggle_button', locals: { available_view_types: available_view_types, view_type: @field.view_type, turbo_frame: @field.id } %>
|
6
|
+
</div>
|
7
|
+
<% end %>
|
8
|
+
<div class="<%= classes %>">
|
9
|
+
<% @field.value.attachments.each do |file| %>
|
10
|
+
<%= render @field.viewer_component.new field: @field, resource: @resource, file: file %>
|
11
|
+
<% end %>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
14
|
+
</div>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Avo::Fields::Common::Files::ListViewerComponent < ViewComponent::Base
|
4
|
+
include Turbo::FramesHelper
|
5
|
+
|
6
|
+
def initialize(field:, resource:)
|
7
|
+
@field = field
|
8
|
+
@resource = resource
|
9
|
+
end
|
10
|
+
|
11
|
+
def classes
|
12
|
+
base_classes = "py-4 rounded-xl"
|
13
|
+
|
14
|
+
view_type_classes = if @field.view_type == :list
|
15
|
+
"flex flex-col space-y-2"
|
16
|
+
else
|
17
|
+
"relative grid xs:grid-cols-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-6 gap-6"
|
18
|
+
end
|
19
|
+
|
20
|
+
"#{base_classes} #{view_type_classes}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def available_view_types
|
24
|
+
[:list, :grid]
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<div class="relative min-h-full max-w-full flex-1 flex flex-col justify-between space-y-2">
|
2
|
+
<% if file.present? %>
|
3
|
+
<div class="flex flex-col justify-between h-full">
|
4
|
+
<% if file.representable? && is_image? %>
|
5
|
+
<%= image_tag helpers.main_app.url_for(file), class: 'rounded-lg object-cover w-full aspect-video' %>
|
6
|
+
<% elsif is_audio? %>
|
7
|
+
<%= audio_tag(helpers.main_app.url_for(file), controls: true, preload: false, class: 'w-full') %>
|
8
|
+
<% elsif is_video? %>
|
9
|
+
<%= video_tag(helpers.main_app.url_for(file), controls: true, preload: false, class: 'w-full') %>
|
10
|
+
<% else %>
|
11
|
+
<div class="relative flex flex-col justify-evenly items-center px-2 rounded-lg border bg-white border-gray-500 min-h-24">
|
12
|
+
<div class="flex flex-col justify-center items-center w-full">
|
13
|
+
<%= helpers.svg 'document-text', class: 'h-10 text-gray-600 mb-2' %>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
<% end %>
|
17
|
+
<% if field.display_filename %>
|
18
|
+
<span class="text-gray-500 mt-1 text-sm truncate" title="<%= file.filename %>"><%= file.filename %></span>
|
19
|
+
<% end %>
|
20
|
+
</div>
|
21
|
+
<div class="flex space-x-2">
|
22
|
+
<%= render Avo::Fields::Common::Files::ControlsComponent.new(field: field, file: file, resource: resource) %>
|
23
|
+
</div>
|
24
|
+
<% else %>
|
25
|
+
–
|
26
|
+
<% end %>
|
27
|
+
</div>
|
@@ -1,8 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class Avo::Fields::Common::
|
4
|
-
|
5
|
-
include Avo::Fields::Concerns::FileAuthorization
|
3
|
+
class Avo::Fields::Common::Files::ViewType::GridComponent < ViewComponent::Base
|
4
|
+
attr_reader :field, :resource
|
6
5
|
|
7
6
|
def initialize(field:, resource:, file: nil)
|
8
7
|
@file = file
|
@@ -10,34 +9,30 @@ class Avo::Fields::Common::SingleFileViewerComponent < ViewComponent::Base
|
|
10
9
|
@resource = resource
|
11
10
|
end
|
12
11
|
|
13
|
-
def destroy_path
|
14
|
-
Avo::Services::URIService.parse(@resource.record_path).append_paths("active_storage_attachments", id, file.id).to_s
|
15
|
-
end
|
16
|
-
|
17
12
|
def id
|
18
|
-
|
13
|
+
field.id
|
19
14
|
end
|
20
15
|
|
21
16
|
def file
|
22
|
-
@file ||
|
17
|
+
@file || field.value.attachment
|
23
18
|
rescue
|
24
19
|
nil
|
25
20
|
end
|
26
21
|
|
27
22
|
def is_image?
|
28
|
-
file.image? ||
|
23
|
+
file.image? || field.is_image
|
29
24
|
rescue
|
30
25
|
false
|
31
26
|
end
|
32
27
|
|
33
28
|
def is_audio?
|
34
|
-
file.audio? ||
|
29
|
+
file.audio? || field.is_audio
|
35
30
|
rescue
|
36
31
|
false
|
37
32
|
end
|
38
33
|
|
39
34
|
def is_video?
|
40
|
-
file.video? ||
|
35
|
+
file.video? || field.is_video
|
41
36
|
rescue
|
42
37
|
false
|
43
38
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<div class="relative min-h-full max-w-full flex-1 flex">
|
2
|
+
<% if file.present? %>
|
3
|
+
<div class="flex gap-2 items-center max-w-full w-full">
|
4
|
+
<div class="flex-1 flex flex-row col-span-7 items-center text-gray-700 truncate">
|
5
|
+
<div class="rounded-full bg-slate-100 border border-gray-500 p-1.5 flex items-center justify-center">
|
6
|
+
<%= helpers.svg icon_for_file, class: "h-5 text-gray-600" %>
|
7
|
+
</div>
|
8
|
+
<p class="overflow-x-scroll items-center h-full p-2 whitespace-nowrap">
|
9
|
+
<%= file.filename %>
|
10
|
+
</p>
|
11
|
+
</div>
|
12
|
+
<div class="col-span-4 text-gray-700 flex-shrink-0 text-sm">
|
13
|
+
<%= helpers.number_to_human_size(file.byte_size) %>
|
14
|
+
</div>
|
15
|
+
<div class="flex space-x-2 justify-end col-span-1 flex-shrink-0">
|
16
|
+
<%= render Avo::Fields::Common::Files::ControlsComponent.new(field: field, file: file, resource: resource) %>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
<% else %>
|
20
|
+
–
|
21
|
+
<% end %>
|
22
|
+
</div>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Avo::Fields::Common::Files::ViewType::ListComponent < Avo::Fields::Common::Files::ViewType::GridComponent
|
4
|
+
def icon_for_file
|
5
|
+
if is_image?
|
6
|
+
"photo"
|
7
|
+
elsif is_audio?
|
8
|
+
"speaker-wave"
|
9
|
+
elsif is_video?
|
10
|
+
"video-camera"
|
11
|
+
else
|
12
|
+
"document"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%= field_wrapper **field_wrapper_args do %>
|
2
2
|
<% if @field.value.present? %>
|
3
3
|
<div class="mb-2">
|
4
|
-
<%= render Avo::Fields::Common::
|
4
|
+
<%= render Avo::Fields::Common::Files::ViewType::GridComponent.new resource: @resource, field: @field %>
|
5
5
|
</div>
|
6
6
|
<% end %>
|
7
7
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<%= field_wrapper **field_wrapper_args,
|
2
|
-
<%= render Avo::Fields::Common::
|
1
|
+
<%= field_wrapper **field_wrapper_args, stacked: true do %>
|
2
|
+
<%= render Avo::Fields::Common::Files::ListViewerComponent.new(field: @field, resource: @resource) if @field.value.present? %>
|
3
3
|
|
4
4
|
<% if can_upload_file? %>
|
5
5
|
<div class="mt-2">
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%= field_wrapper **field_wrapper_args,
|
2
|
-
<%= render Avo::Fields::Common::
|
1
|
+
<%= field_wrapper **field_wrapper_args, stacked: true do %>
|
2
|
+
<%= render Avo::Fields::Common::Files::ListViewerComponent.new(field: @field, resource: @resource) if @field.value.present? %>
|
3
3
|
<% 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/config/master.key
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2aeb23d82b909d9c6b5abb62f7058c2a
|
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 }
|
@@ -73,7 +73,7 @@ module Avo
|
|
73
73
|
@placeholder = args[:placeholder]
|
74
74
|
@help = args[:help] || nil
|
75
75
|
@default = args[:default] || nil
|
76
|
-
@visible = args[:visible]
|
76
|
+
@visible = args[:visible]
|
77
77
|
@as_label = args[:as_label] || false
|
78
78
|
@as_avatar = args[:as_avatar] || false
|
79
79
|
@as_description = args[:as_description] || false
|
@@ -156,7 +156,9 @@ module Avo
|
|
156
156
|
end
|
157
157
|
|
158
158
|
def visible?
|
159
|
-
|
159
|
+
return true if visible.nil?
|
160
|
+
|
161
|
+
if visible.respond_to?(:call)
|
160
162
|
visible.call resource: @resource
|
161
163
|
else
|
162
164
|
visible
|
@@ -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,8 @@ module Avo
|
|
5
5
|
attr_accessor :is_image
|
6
6
|
attr_accessor :direct_upload
|
7
7
|
attr_accessor :accept
|
8
|
+
attr_reader :display_filename
|
9
|
+
attr_reader :hide_view_type_changer
|
8
10
|
|
9
11
|
def initialize(id, **args, &block)
|
10
12
|
super(id, **args, &block)
|
@@ -13,6 +15,9 @@ module Avo
|
|
13
15
|
@is_image = args[:is_image].present? ? args[:is_image] : @is_avatar
|
14
16
|
@direct_upload = args[:direct_upload].present? ? args[:direct_upload] : false
|
15
17
|
@accept = args[:accept].present? ? args[:accept] : nil
|
18
|
+
@display_filename = args[:display_filename].nil? ? true : args[:display_filename]
|
19
|
+
@view_type = args[:view_type] || :grid
|
20
|
+
@hide_view_type_changer = args[:hide_view_type_changer]
|
16
21
|
end
|
17
22
|
|
18
23
|
def view_component_name
|
@@ -35,6 +40,14 @@ module Avo
|
|
35
40
|
|
36
41
|
model
|
37
42
|
end
|
43
|
+
|
44
|
+
def viewer_component
|
45
|
+
"Avo::Fields::Common::Files::ViewType::#{view_type.to_s.capitalize}Component".constantize
|
46
|
+
end
|
47
|
+
|
48
|
+
def view_type
|
49
|
+
(@resource.params.dig(:view_type) || @view_type).to_sym
|
50
|
+
end
|
38
51
|
end
|
39
52
|
end
|
40
53
|
end
|
data/lib/avo/fields/id_field.rb
CHANGED
@@ -5,12 +5,13 @@ module Avo
|
|
5
5
|
|
6
6
|
def initialize(id, **args, &block)
|
7
7
|
args[:readonly] = true
|
8
|
-
args[:sortable] = true
|
9
8
|
|
10
9
|
hide_on [:edit, :new]
|
11
10
|
|
12
11
|
super(id, **args, &block)
|
13
12
|
|
13
|
+
add_boolean_prop args, :sortable, true
|
14
|
+
|
14
15
|
@link_to_resource = args[:link_to_resource].present? ? args[:link_to_resource] : false
|
15
16
|
end
|
16
17
|
end
|
@@ -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