avo 2.30.1.pre4.pr1683 → 2.30.1
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/field_wrapper_component.html.erb +2 -2
- data/app/components/avo/fields/common/files_list_viewer_component.html.erb +5 -0
- data/app/components/avo/fields/common/files_list_viewer_component.rb +8 -0
- data/app/components/avo/fields/common/single_file_viewer_component.html.erb +57 -0
- data/app/components/avo/fields/common/{files/view_type/grid_component.rb → single_file_viewer_component.rb} +9 -2
- 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 +1 -1
- data/app/components/avo/fields/files_field/show_component.html.erb +1 -1
- data/app/views/avo/partials/_view_toggle_button.html.erb +0 -4
- data/lib/avo/configuration.rb +1 -1
- data/lib/avo/fields/files_field.rb +0 -11
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/templates/initializer/avo.tt +1 -1
- data/public/avo-assets/avo.base.css +22 -25
- metadata +7 -12
- data/app/components/avo/fields/common/files/controls_component.html.erb +0 -29
- data/app/components/avo/fields/common/files/controls_component.rb +0 -19
- data/app/components/avo/fields/common/files/list_viewer_component.html.erb +0 -14
- data/app/components/avo/fields/common/files/list_viewer_component.rb +0 -32
- data/app/components/avo/fields/common/files/view_type/grid_component.html.erb +0 -27
- data/app/components/avo/fields/common/files/view_type/list_component.html.erb +0 -22
- data/app/components/avo/fields/common/files/view_type/list_component.rb +0 -15
- data/config/master.key +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7162a2279663c821bd7bd45d46606874d27cec50facbe95868b5e6e9f7cad108
|
4
|
+
data.tar.gz: 364cdaa46a18459fb2193334cce6c9a40b18b46e0570eb0a8f769f2c10237059
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42f77ef3c0fd013c1940ecef19ff1e7d6f15386ce7dc211d9ca2eb3b18c162d31579f589ac20ef82b98f10e8bb309a6b76f63cda580186da594a9826b717c274
|
7
|
+
data.tar.gz: 4bddfafbec2fad7372daea55f5926ae7e0bddb34984c1c848f926e5112f0fc86edf452573f9bad7e28a22753dfccd2f2fbabce15aec73fd773c3931524255566
|
data/Gemfile.lock
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
class: classes,
|
3
3
|
style: style,
|
4
4
|
data: data do %>
|
5
|
-
<div class="h-full <% if stacked? %> md:pt-4 <% else %> md:pt-0 md:h-14 <% end %> pt-4 flex self-start items-center
|
5
|
+
<div class="h-full <% if stacked? %> md:pt-4 <% else %> md:pt-0 md:h-14 <% end %> pt-4 flex self-start items-center <%= @field.get_html(:classes, view: view, element: :label) %> w-48 <% if compact? %> md:w-48 xl:w-64 <% else %> md:w-64 <% end %> px-6 uppercase font-semibold text-gray-500 text-sm" data-slot="label">
|
6
6
|
<% if form.present? %>
|
7
7
|
<%= form.label field.id, label %>
|
8
8
|
<% else %>
|
@@ -11,7 +11,7 @@
|
|
11
11
|
<% if on_edit? && field.is_required? %> <span class="text-red-600 ml-1">*</span> <% end %>
|
12
12
|
</div>
|
13
13
|
<div class="flex-1 flex flex-row md:min-h-inherit py-2 <% if stacked? %> pb-4 <% else %><% end %> px-6 <%= @field.get_html(:classes, view: view, element: :content) %>" data-slot="value">
|
14
|
-
<div class="self-center
|
14
|
+
<div class="self-center <% if full_width? || compact? || stacked? %> w-full <% else %> md:w-8/12 <% end %>">
|
15
15
|
<% if on_show? %>
|
16
16
|
<% if field.value.blank? and dash_if_blank %>
|
17
17
|
—
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<div class="relative py-3 grid xs:grid-cols-2 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 gap-3 rounded-xl">
|
2
|
+
<% @field.value.attachments.each do |file| %>
|
3
|
+
<%= render Avo::Fields::Common::SingleFileViewerComponent.new field: @field, resource: @resource, file: file %>
|
4
|
+
<% end %>
|
5
|
+
</div>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<div class="relative min-h-full max-w-full flex-1 flex flex-col justify-between space-y-3">
|
2
|
+
<% if file.present? %>
|
3
|
+
<div class="flex flex-col justify-between h-full">
|
4
|
+
<% if file.representable? && is_image? %>
|
5
|
+
<div class="max-h-[42rem] h-full flex">
|
6
|
+
<%= image_tag helpers.main_app.url_for(file), class: 'rounded-lg object-cover' %>
|
7
|
+
</div>
|
8
|
+
<% elsif is_audio? %>
|
9
|
+
<%= audio_tag(helpers.main_app.url_for(file), controls: true, preload: false, class: 'w-full') %>
|
10
|
+
<% elsif is_video? %>
|
11
|
+
<%= video_tag(helpers.main_app.url_for(file), controls: true, preload: false, class: 'w-full') %>
|
12
|
+
<% else %>
|
13
|
+
<div class="relative flex flex-col justify-evenly items-center px-2 rounded-lg border bg-white border-gray-500 min-h-24">
|
14
|
+
<div class="flex flex-col justify-center items-center w-full">
|
15
|
+
<%= helpers.svg 'document-text', class: 'h-10 text-gray-600 mb-2' %>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
19
|
+
<% if field.display_filename %>
|
20
|
+
<span class="text-gray-500 mt-2 text-sm truncate" title="<%= file.filename %>"><%= file.filename %></span>
|
21
|
+
<% end %>
|
22
|
+
</div>
|
23
|
+
<div class="flex space-x-2">
|
24
|
+
<div class="flex">
|
25
|
+
<% if can_download_file? %>
|
26
|
+
<%= a_link Rails.application.routes.url_helpers.rails_blob_path(file, only_path: true, disposition: :attachment),
|
27
|
+
icon: 'heroicons/outline/download',
|
28
|
+
color: :primary,
|
29
|
+
download: true,
|
30
|
+
class: 'text-center',
|
31
|
+
title: t('avo.download_file'),
|
32
|
+
data: { tippy: :tooltip },
|
33
|
+
compact: true,
|
34
|
+
size: :xs %>
|
35
|
+
<% end %>
|
36
|
+
</div>
|
37
|
+
<div>
|
38
|
+
<% if can_delete_file? %>
|
39
|
+
<%= a_link destroy_path,
|
40
|
+
icon: 'heroicons/outline/trash',
|
41
|
+
color: :red,
|
42
|
+
compact: true,
|
43
|
+
size: :xs,
|
44
|
+
class: 'text-center',
|
45
|
+
title: t('avo.delete_file', item: file.filename),
|
46
|
+
data: {
|
47
|
+
turbo_method: :delete,
|
48
|
+
turbo_confirm: t('avo.are_you_sure'),
|
49
|
+
tippy: :tooltip
|
50
|
+
} %>
|
51
|
+
<% end %>
|
52
|
+
</div>
|
53
|
+
</div>
|
54
|
+
<% else %>
|
55
|
+
–
|
56
|
+
<% end %>
|
57
|
+
</div>
|
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class Avo::Fields::Common::
|
4
|
-
|
3
|
+
class Avo::Fields::Common::SingleFileViewerComponent < ViewComponent::Base
|
4
|
+
include Avo::ApplicationHelper
|
5
|
+
include Avo::Fields::Concerns::FileAuthorization
|
6
|
+
|
7
|
+
attr_reader :field
|
5
8
|
|
6
9
|
def initialize(field:, resource:, file: nil)
|
7
10
|
@file = file
|
@@ -9,6 +12,10 @@ class Avo::Fields::Common::Files::ViewType::GridComponent < ViewComponent::Base
|
|
9
12
|
@resource = resource
|
10
13
|
end
|
11
14
|
|
15
|
+
def destroy_path
|
16
|
+
Avo::Services::URIService.parse(@resource.record_path).append_paths("active_storage_attachments", id, file.id).to_s
|
17
|
+
end
|
18
|
+
|
12
19
|
def id
|
13
20
|
field.id
|
14
21
|
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::SingleFileViewerComponent.new resource: @resource, field: @field %>
|
5
5
|
</div>
|
6
6
|
<% end %>
|
7
7
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%= field_wrapper **field_wrapper_args, full_width: true do %>
|
2
|
-
<%= render Avo::Fields::Common::
|
2
|
+
<%= render Avo::Fields::Common::FilesListViewerComponent.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
1
|
<%= field_wrapper **field_wrapper_args, full_width: true do %>
|
2
|
-
<%= render Avo::Fields::Common::
|
2
|
+
<%= render Avo::Fields::Common::FilesListViewerComponent.new(field: @field, resource: @resource) if @field.value.present? %>
|
3
3
|
<% end %>
|
data/lib/avo/configuration.rb
CHANGED
@@ -71,7 +71,7 @@ module Avo
|
|
71
71
|
@id_links_to_resource = false
|
72
72
|
@full_width_container = false
|
73
73
|
@full_width_index_view = false
|
74
|
-
@cache_resources_on_index_view =
|
74
|
+
@cache_resources_on_index_view = Avo::PACKED
|
75
75
|
@cache_resource_filters = false
|
76
76
|
@context = proc {}
|
77
77
|
@initial_breadcrumbs = proc {
|
@@ -6,7 +6,6 @@ module Avo
|
|
6
6
|
attr_accessor :direct_upload
|
7
7
|
attr_accessor :accept
|
8
8
|
attr_reader :display_filename
|
9
|
-
attr_reader :hide_view_type_switcher
|
10
9
|
|
11
10
|
def initialize(id, **args, &block)
|
12
11
|
super(id, **args, &block)
|
@@ -16,8 +15,6 @@ module Avo
|
|
16
15
|
@direct_upload = args[:direct_upload].present? ? args[:direct_upload] : false
|
17
16
|
@accept = args[:accept].present? ? args[:accept] : nil
|
18
17
|
@display_filename = args[:display_filename].nil? ? true : args[:display_filename]
|
19
|
-
@view_type = args[:view_type] || :grid
|
20
|
-
@hide_view_type_switcher = args[:hide_view_type_switcher]
|
21
18
|
end
|
22
19
|
|
23
20
|
def view_component_name
|
@@ -40,14 +37,6 @@ module Avo
|
|
40
37
|
|
41
38
|
model
|
42
39
|
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
|
51
40
|
end
|
52
41
|
end
|
53
42
|
end
|
data/lib/avo/version.rb
CHANGED
@@ -47,7 +47,7 @@ Avo.configure do |config|
|
|
47
47
|
# config.per_page_steps = [12, 24, 48, 72]
|
48
48
|
# config.via_per_page = 8
|
49
49
|
# config.id_links_to_resource = false
|
50
|
-
# config.cache_resources_on_index_view =
|
50
|
+
# config.cache_resources_on_index_view = true
|
51
51
|
## permanent enable or disable cache_resource_filters, default value is false
|
52
52
|
# config.cache_resource_filters = false
|
53
53
|
## provide a lambda to enable or disable cache_resource_filters per user/resource.
|
@@ -6386,10 +6386,6 @@ trix-toolbar .trix-button-group:not(:first-child){
|
|
6386
6386
|
grid-column:1 / -1
|
6387
6387
|
}
|
6388
6388
|
|
6389
|
-
.col-span-4{
|
6390
|
-
grid-column:span 4 / span 4
|
6391
|
-
}
|
6392
|
-
|
6393
6389
|
.float-right{
|
6394
6390
|
float:right
|
6395
6391
|
}
|
@@ -6599,10 +6595,6 @@ trix-toolbar .trix-button-group:not(:first-child){
|
|
6599
6595
|
margin-bottom:0.25rem
|
6600
6596
|
}
|
6601
6597
|
|
6602
|
-
.-mt-9{
|
6603
|
-
margin-top:-2.25rem
|
6604
|
-
}
|
6605
|
-
|
6606
6598
|
.block{
|
6607
6599
|
display:block
|
6608
6600
|
}
|
@@ -6639,10 +6631,6 @@ trix-toolbar .trix-button-group:not(:first-child){
|
|
6639
6631
|
aspect-ratio:1 / 1
|
6640
6632
|
}
|
6641
6633
|
|
6642
|
-
.aspect-video{
|
6643
|
-
aspect-ratio:16 / 9
|
6644
|
-
}
|
6645
|
-
|
6646
6634
|
.h-36{
|
6647
6635
|
height:9rem
|
6648
6636
|
}
|
@@ -6723,6 +6711,10 @@ trix-toolbar .trix-button-group:not(:first-child){
|
|
6723
6711
|
height:2.25rem
|
6724
6712
|
}
|
6725
6713
|
|
6714
|
+
.max-h-\[42rem\]{
|
6715
|
+
max-height:42rem
|
6716
|
+
}
|
6717
|
+
|
6726
6718
|
.max-h-full{
|
6727
6719
|
max-height:100%
|
6728
6720
|
}
|
@@ -6926,10 +6918,6 @@ trix-toolbar .trix-button-group:not(:first-child){
|
|
6926
6918
|
grid-template-columns:repeat(1, minmax(0, 1fr))
|
6927
6919
|
}
|
6928
6920
|
|
6929
|
-
.grid-cols-6{
|
6930
|
-
grid-template-columns:repeat(6, minmax(0, 1fr))
|
6931
|
-
}
|
6932
|
-
|
6933
6921
|
.flex-row{
|
6934
6922
|
flex-direction:row
|
6935
6923
|
}
|
@@ -7010,6 +6998,10 @@ trix-toolbar .trix-button-group:not(:first-child){
|
|
7010
6998
|
gap:1.5rem
|
7011
6999
|
}
|
7012
7000
|
|
7001
|
+
.gap-3{
|
7002
|
+
gap:0.75rem
|
7003
|
+
}
|
7004
|
+
|
7013
7005
|
.gap-1{
|
7014
7006
|
gap:0.25rem
|
7015
7007
|
}
|
@@ -7074,6 +7066,12 @@ trix-toolbar .trix-button-group:not(:first-child){
|
|
7074
7066
|
margin-left:calc(0.75rem * calc(1 - var(--tw-space-x-reverse)))
|
7075
7067
|
}
|
7076
7068
|
|
7069
|
+
.space-y-3 > :not([hidden]) ~ :not([hidden]){
|
7070
|
+
--tw-space-y-reverse:0;
|
7071
|
+
margin-top:calc(0.75rem * calc(1 - var(--tw-space-y-reverse)));
|
7072
|
+
margin-bottom:calc(0.75rem * var(--tw-space-y-reverse))
|
7073
|
+
}
|
7074
|
+
|
7077
7075
|
.divide-y > :not([hidden]) ~ :not([hidden]){
|
7078
7076
|
--tw-divide-y-reverse:0;
|
7079
7077
|
border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));
|
@@ -7563,11 +7561,6 @@ trix-toolbar .trix-button-group:not(:first-child){
|
|
7563
7561
|
background-color:rgb(94 100 110 / var(--tw-bg-opacity))
|
7564
7562
|
}
|
7565
7563
|
|
7566
|
-
.bg-slate-100{
|
7567
|
-
--tw-bg-opacity:1;
|
7568
|
-
background-color:rgb(241 245 249 / var(--tw-bg-opacity))
|
7569
|
-
}
|
7570
|
-
|
7571
7564
|
.bg-opacity-25{
|
7572
7565
|
--tw-bg-opacity:0.25
|
7573
7566
|
}
|
@@ -7608,10 +7601,6 @@ trix-toolbar .trix-button-group:not(:first-child){
|
|
7608
7601
|
padding:0.25rem
|
7609
7602
|
}
|
7610
7603
|
|
7611
|
-
.p-1\.5{
|
7612
|
-
padding:0.375rem
|
7613
|
-
}
|
7614
|
-
|
7615
7604
|
.px-1{
|
7616
7605
|
padding-left:0.25rem;
|
7617
7606
|
padding-right:0.25rem
|
@@ -9713,6 +9702,10 @@ trix-editor {
|
|
9713
9702
|
grid-template-columns:repeat(4, minmax(0, 1fr))
|
9714
9703
|
}
|
9715
9704
|
|
9705
|
+
.xl\:grid-cols-3{
|
9706
|
+
grid-template-columns:repeat(3, minmax(0, 1fr))
|
9707
|
+
}
|
9708
|
+
|
9716
9709
|
.xl\:flex-row{
|
9717
9710
|
flex-direction:row
|
9718
9711
|
}
|
@@ -9771,4 +9764,8 @@ trix-editor {
|
|
9771
9764
|
.\32xl\:grid-cols-6{
|
9772
9765
|
grid-template-columns:repeat(6, minmax(0, 1fr))
|
9773
9766
|
}
|
9767
|
+
|
9768
|
+
.\32xl\:grid-cols-4{
|
9769
|
+
grid-template-columns:repeat(4, minmax(0, 1fr))
|
9770
|
+
}
|
9774
9771
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.30.1
|
4
|
+
version: 2.30.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Marin
|
@@ -1371,14 +1371,8 @@ files:
|
|
1371
1371
|
- app/components/avo/fields/common/boolean_check_component.rb
|
1372
1372
|
- app/components/avo/fields/common/boolean_group_component.html.erb
|
1373
1373
|
- app/components/avo/fields/common/boolean_group_component.rb
|
1374
|
-
- app/components/avo/fields/common/
|
1375
|
-
- app/components/avo/fields/common/
|
1376
|
-
- app/components/avo/fields/common/files/list_viewer_component.html.erb
|
1377
|
-
- app/components/avo/fields/common/files/list_viewer_component.rb
|
1378
|
-
- app/components/avo/fields/common/files/view_type/grid_component.html.erb
|
1379
|
-
- app/components/avo/fields/common/files/view_type/grid_component.rb
|
1380
|
-
- app/components/avo/fields/common/files/view_type/list_component.html.erb
|
1381
|
-
- app/components/avo/fields/common/files/view_type/list_component.rb
|
1374
|
+
- app/components/avo/fields/common/files_list_viewer_component.html.erb
|
1375
|
+
- app/components/avo/fields/common/files_list_viewer_component.rb
|
1382
1376
|
- app/components/avo/fields/common/gravatar_viewer_component.html.erb
|
1383
1377
|
- app/components/avo/fields/common/gravatar_viewer_component.rb
|
1384
1378
|
- app/components/avo/fields/common/heading_component.html.erb
|
@@ -1387,6 +1381,8 @@ files:
|
|
1387
1381
|
- app/components/avo/fields/common/key_value_component.rb
|
1388
1382
|
- app/components/avo/fields/common/progress_bar_component.html.erb
|
1389
1383
|
- app/components/avo/fields/common/progress_bar_component.rb
|
1384
|
+
- app/components/avo/fields/common/single_file_viewer_component.html.erb
|
1385
|
+
- app/components/avo/fields/common/single_file_viewer_component.rb
|
1390
1386
|
- app/components/avo/fields/common/status_viewer_component.html.erb
|
1391
1387
|
- app/components/avo/fields/common/status_viewer_component.rb
|
1392
1388
|
- app/components/avo/fields/concerns/item_labels.rb
|
@@ -1704,7 +1700,6 @@ files:
|
|
1704
1700
|
- config/credentials.yml.enc
|
1705
1701
|
- config/i18n-tasks.yml
|
1706
1702
|
- config/initializers/pagy.rb
|
1707
|
-
- config/master.key
|
1708
1703
|
- config/routes.rb
|
1709
1704
|
- config/spring.rb
|
1710
1705
|
- db/factories.rb
|
@@ -1966,9 +1961,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1966
1961
|
version: 2.6.0
|
1967
1962
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1968
1963
|
requirements:
|
1969
|
-
- - "
|
1964
|
+
- - ">="
|
1970
1965
|
- !ruby/object:Gem::Version
|
1971
|
-
version:
|
1966
|
+
version: '0'
|
1972
1967
|
requirements: []
|
1973
1968
|
rubygems_version: 3.3.3
|
1974
1969
|
signing_key:
|
@@ -1,29 +0,0 @@
|
|
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>
|
@@ -1,19 +0,0 @@
|
|
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
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<%= content_tag :div, class: wrapper_classes do %>
|
2
|
-
<%= turbo_frame_tag @field.id do %>
|
3
|
-
<% unless @field.hide_view_type_switcher %>
|
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
|
-
<% end %>
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Avo::Fields::Common::Files::ListViewerComponent < ViewComponent::Base
|
4
|
-
include Turbo::FramesHelper
|
5
|
-
|
6
|
-
attr_reader :field
|
7
|
-
|
8
|
-
def initialize(field:, resource:)
|
9
|
-
@field = field
|
10
|
-
@resource = resource
|
11
|
-
end
|
12
|
-
|
13
|
-
def classes
|
14
|
-
base_classes = "py-4 rounded-xl max-w-full"
|
15
|
-
|
16
|
-
view_type_classes = if @field.view_type == :list
|
17
|
-
"flex flex-col space-y-2"
|
18
|
-
else
|
19
|
-
"relative grid xs:grid-cols-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-6 gap-6"
|
20
|
-
end
|
21
|
-
|
22
|
-
"#{base_classes} #{view_type_classes}"
|
23
|
-
end
|
24
|
-
|
25
|
-
def wrapper_classes
|
26
|
-
(field.stacked && !field.hide_view_type_switcher) ? "-mt-9" : ""
|
27
|
-
end
|
28
|
-
|
29
|
-
def available_view_types
|
30
|
-
[:list, :grid]
|
31
|
-
end
|
32
|
-
end
|
@@ -1,27 +0,0 @@
|
|
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,22 +0,0 @@
|
|
1
|
-
<div class="relative min-h-full max-w-full flex-1 flex">
|
2
|
-
<% if file.present? %>
|
3
|
-
<div class="grid grid-cols-6 gap-2 items-center max-w-full w-full">
|
4
|
-
<div class="col-span-4 flex-1 flex flex-row items-center text-gray-700 overflow-x-auto mac-styled-scrollbar ">
|
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="items-center h-full p-2 flex-shrink-0">
|
9
|
-
<%= file.filename %>
|
10
|
-
</p>
|
11
|
-
</div>
|
12
|
-
<div class="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>
|
@@ -1,15 +0,0 @@
|
|
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
|
data/config/master.key
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2aeb23d82b909d9c6b5abb62f7058c2a
|