avo 2.30.0 → 2.30.1.pre2.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.

Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +3 -3
  3. data/app/components/avo/field_wrapper_component.html.erb +2 -2
  4. data/app/components/avo/fields/common/files/controls_component.html.erb +29 -0
  5. data/app/components/avo/fields/common/files/controls_component.rb +19 -0
  6. data/app/components/avo/fields/common/files/list_viewer_component.html.erb +14 -0
  7. data/app/components/avo/fields/common/files/list_viewer_component.rb +32 -0
  8. data/app/components/avo/fields/common/files/view_type/grid_component.html.erb +27 -0
  9. data/app/components/avo/fields/common/{single_file_viewer_component.rb → files/view_type/grid_component.rb} +2 -9
  10. data/app/components/avo/fields/common/files/view_type/list_component.html.erb +22 -0
  11. data/app/components/avo/fields/common/files/view_type/list_component.rb +15 -0
  12. data/app/components/avo/fields/file_field/edit_component.html.erb +1 -1
  13. data/app/components/avo/fields/file_field/show_component.html.erb +1 -1
  14. data/app/components/avo/fields/files_field/edit_component.html.erb +1 -1
  15. data/app/components/avo/fields/files_field/show_component.html.erb +1 -1
  16. data/app/views/avo/partials/_view_toggle_button.html.erb +4 -0
  17. data/config/master.key +1 -0
  18. data/lib/avo/fields/base_field.rb +4 -2
  19. data/lib/avo/fields/files_field.rb +11 -0
  20. data/lib/avo/fields/id_field.rb +2 -1
  21. data/lib/avo/version.rb +1 -1
  22. data/public/avo-assets/avo.base.css +25 -22
  23. metadata +13 -8
  24. data/app/components/avo/fields/common/files_list_viewer_component.html.erb +0 -5
  25. data/app/components/avo/fields/common/files_list_viewer_component.rb +0 -8
  26. data/app/components/avo/fields/common/single_file_viewer_component.html.erb +0 -57
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47a6931f5fd184bfb437e0541849e04f4452764059b23582ca000a977f805bc8
4
- data.tar.gz: ba1137efa1e302b64bb86635b7c6327cd145d0fa68b787f8540bd5089a9e8bd9
3
+ metadata.gz: cb9bb94729b7e065e13af29ac65735d3234c26b1239dd649e6de5dada23b15aa
4
+ data.tar.gz: 71d338dab4be874a0d7acd450c64e420be9de5e124ca57d727591af3a9828cdd
5
5
  SHA512:
6
- metadata.gz: d0a68869c9647f57f3d3ffe1699e7e6fd1a2c0cc4fcbceadb127b1312893cf53eb8d2a89df9c160a058a824846bd128ed9e681eecbe06dd90c61bd91641a5132
7
- data.tar.gz: e92694271216d763281657edc6b128f05dd8ff104b7228eabeca8570bb86dad6c91a2712410655a744f600db466fea2a25f349182881ab32fecceef3d1763669
6
+ metadata.gz: b5fb2e3b4527c5181650f3c1cb73ef4e8808f9cc42e71b24dbaee687b768f1d5c8ed44be7514e13d5ba4c79408528abcb02eea5ec5cf07c4ffc7ee23bc30bfcb
7
+ data.tar.gz: f349827d0b287eeefd1296dba288abbf0226ae86d61e864562d10a07b74d225488c3f53a8190897b30b7e68acb54c521520e386a0737bb7175bb5624ea3fb8b4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.30.0)
4
+ avo (2.30.1.pre2.pr1683)
5
5
  actionview (>= 6.0)
6
6
  active_link_to
7
7
  activerecord (>= 6.0)
@@ -269,10 +269,10 @@ GEM
269
269
  net-smtp (0.3.3)
270
270
  net-protocol
271
271
  nio4r (2.5.8)
272
- nokogiri (1.14.2)
272
+ nokogiri (1.14.3)
273
273
  mini_portile2 (~> 2.8.0)
274
274
  racc (~> 1.4)
275
- nokogiri (1.14.2-x86_64-linux)
275
+ nokogiri (1.14.3-x86_64-linux)
276
276
  racc (~> 1.4)
277
277
  orm_adapter (0.5.0)
278
278
  pagy (6.0.3)
@@ -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 <%= @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">
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 flex-shrink-0 <%= @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 <% if full_width? || compact? || stacked? %> w-full <% else %> md:w-8/12 <% end %>">
14
+ <div class="self-center w-full <% if full_width? || compact? || stacked? %> <% 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,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
+ <%= content_tag :div, class: wrapper_classes do %>
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
+ <% end %>
@@ -0,0 +1,32 @@
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 ? "-mt-9" : ""
27
+ end
28
+
29
+ def available_view_types
30
+ [:list, :grid]
31
+ end
32
+ 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,10 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Avo::Fields::Common::SingleFileViewerComponent < ViewComponent::Base
4
- include Avo::ApplicationHelper
5
- include Avo::Fields::Concerns::FileAuthorization
6
-
7
- attr_reader :field
3
+ class Avo::Fields::Common::Files::ViewType::GridComponent < ViewComponent::Base
4
+ attr_reader :field, :resource
8
5
 
9
6
  def initialize(field:, resource:, file: nil)
10
7
  @file = file
@@ -12,10 +9,6 @@ class Avo::Fields::Common::SingleFileViewerComponent < ViewComponent::Base
12
9
  @resource = resource
13
10
  end
14
11
 
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
-
19
12
  def id
20
13
  field.id
21
14
  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="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>
@@ -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::SingleFileViewerComponent.new resource: @resource, field: @field %>
4
+ <%= render Avo::Fields::Common::Files::ViewType::GridComponent.new resource: @resource, field: @field %>
5
5
  </div>
6
6
  <% end %>
7
7
 
@@ -1,3 +1,3 @@
1
1
  <%= field_wrapper **field_wrapper_args do %>
2
- <%= render Avo::Fields::Common::SingleFileViewerComponent.new resource: @resource, field: @field %>
2
+ <%= render Avo::Fields::Common::Files::ViewType::GridComponent.new resource: @resource, field: @field %>
3
3
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <%= field_wrapper **field_wrapper_args, full_width: true do %>
2
- <%= render Avo::Fields::Common::FilesListViewerComponent.new(field: @field, resource: @resource) if @field.value.present? %>
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
1
  <%= field_wrapper **field_wrapper_args, full_width: true do %>
2
- <%= render Avo::Fields::Common::FilesListViewerComponent.new(field: @field, resource: @resource) if @field.value.present? %>
2
+ <%= render Avo::Fields::Common::Files::ListViewerComponent.new(field: @field, resource: @resource) if @field.value.present? %>
3
3
  <% end %>
@@ -11,6 +11,10 @@
11
11
  new_icon: 'grid-view-type',
12
12
  translation_key: 'avo.grid_view',
13
13
  },
14
+ list: {
15
+ new_view_type: 'list',
16
+ new_icon: 'queue-list',
17
+ },
14
18
  }
15
19
  %>
16
20
  <div class="flex">
data/config/master.key ADDED
@@ -0,0 +1 @@
1
+ 2aeb23d82b909d9c6b5abb62f7058c2a
@@ -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] || true
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
- if visible.present? && visible.respond_to?(:call)
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
@@ -6,6 +6,7 @@ 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_changer
9
10
 
10
11
  def initialize(id, **args, &block)
11
12
  super(id, **args, &block)
@@ -15,6 +16,8 @@ module Avo
15
16
  @direct_upload = args[:direct_upload].present? ? args[:direct_upload] : false
16
17
  @accept = args[:accept].present? ? args[:accept] : nil
17
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]
18
21
  end
19
22
 
20
23
  def view_component_name
@@ -37,6 +40,14 @@ module Avo
37
40
 
38
41
  model
39
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
40
51
  end
41
52
  end
42
53
  end
@@ -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
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.30.0" unless const_defined?(:VERSION)
2
+ VERSION = "2.30.1.pre2.pr1683" unless const_defined?(:VERSION)
3
3
  end
@@ -6386,6 +6386,10 @@ 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
+
6389
6393
  .float-right{
6390
6394
  float:right
6391
6395
  }
@@ -6595,6 +6599,10 @@ trix-toolbar .trix-button-group:not(:first-child){
6595
6599
  margin-bottom:0.25rem
6596
6600
  }
6597
6601
 
6602
+ .-mt-9{
6603
+ margin-top:-2.25rem
6604
+ }
6605
+
6598
6606
  .block{
6599
6607
  display:block
6600
6608
  }
@@ -6631,6 +6639,10 @@ trix-toolbar .trix-button-group:not(:first-child){
6631
6639
  aspect-ratio:1 / 1
6632
6640
  }
6633
6641
 
6642
+ .aspect-video{
6643
+ aspect-ratio:16 / 9
6644
+ }
6645
+
6634
6646
  .h-36{
6635
6647
  height:9rem
6636
6648
  }
@@ -6711,10 +6723,6 @@ trix-toolbar .trix-button-group:not(:first-child){
6711
6723
  height:2.25rem
6712
6724
  }
6713
6725
 
6714
- .max-h-\[42rem\]{
6715
- max-height:42rem
6716
- }
6717
-
6718
6726
  .max-h-full{
6719
6727
  max-height:100%
6720
6728
  }
@@ -6918,6 +6926,10 @@ trix-toolbar .trix-button-group:not(:first-child){
6918
6926
  grid-template-columns:repeat(1, minmax(0, 1fr))
6919
6927
  }
6920
6928
 
6929
+ .grid-cols-6{
6930
+ grid-template-columns:repeat(6, minmax(0, 1fr))
6931
+ }
6932
+
6921
6933
  .flex-row{
6922
6934
  flex-direction:row
6923
6935
  }
@@ -6998,10 +7010,6 @@ trix-toolbar .trix-button-group:not(:first-child){
6998
7010
  gap:1.5rem
6999
7011
  }
7000
7012
 
7001
- .gap-3{
7002
- gap:0.75rem
7003
- }
7004
-
7005
7013
  .gap-1{
7006
7014
  gap:0.25rem
7007
7015
  }
@@ -7066,12 +7074,6 @@ trix-toolbar .trix-button-group:not(:first-child){
7066
7074
  margin-left:calc(0.75rem * calc(1 - var(--tw-space-x-reverse)))
7067
7075
  }
7068
7076
 
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
-
7075
7077
  .divide-y > :not([hidden]) ~ :not([hidden]){
7076
7078
  --tw-divide-y-reverse:0;
7077
7079
  border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));
@@ -7561,6 +7563,11 @@ trix-toolbar .trix-button-group:not(:first-child){
7561
7563
  background-color:rgb(94 100 110 / var(--tw-bg-opacity))
7562
7564
  }
7563
7565
 
7566
+ .bg-slate-100{
7567
+ --tw-bg-opacity:1;
7568
+ background-color:rgb(241 245 249 / var(--tw-bg-opacity))
7569
+ }
7570
+
7564
7571
  .bg-opacity-25{
7565
7572
  --tw-bg-opacity:0.25
7566
7573
  }
@@ -7601,6 +7608,10 @@ trix-toolbar .trix-button-group:not(:first-child){
7601
7608
  padding:0.25rem
7602
7609
  }
7603
7610
 
7611
+ .p-1\.5{
7612
+ padding:0.375rem
7613
+ }
7614
+
7604
7615
  .px-1{
7605
7616
  padding-left:0.25rem;
7606
7617
  padding-right:0.25rem
@@ -9702,10 +9713,6 @@ trix-editor {
9702
9713
  grid-template-columns:repeat(4, minmax(0, 1fr))
9703
9714
  }
9704
9715
 
9705
- .xl\:grid-cols-3{
9706
- grid-template-columns:repeat(3, minmax(0, 1fr))
9707
- }
9708
-
9709
9716
  .xl\:flex-row{
9710
9717
  flex-direction:row
9711
9718
  }
@@ -9764,8 +9771,4 @@ trix-editor {
9764
9771
  .\32xl\:grid-cols-6{
9765
9772
  grid-template-columns:repeat(6, minmax(0, 1fr))
9766
9773
  }
9767
-
9768
- .\32xl\:grid-cols-4{
9769
- grid-template-columns:repeat(4, minmax(0, 1fr))
9770
- }
9771
9774
  }
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.0
4
+ version: 2.30.1.pre2.pr1683
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-04-11 00:00:00.000000000 Z
12
+ date: 2023-04-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -1371,8 +1371,14 @@ 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/files_list_viewer_component.html.erb
1375
- - app/components/avo/fields/common/files_list_viewer_component.rb
1374
+ - app/components/avo/fields/common/files/controls_component.html.erb
1375
+ - app/components/avo/fields/common/files/controls_component.rb
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
1376
1382
  - app/components/avo/fields/common/gravatar_viewer_component.html.erb
1377
1383
  - app/components/avo/fields/common/gravatar_viewer_component.rb
1378
1384
  - app/components/avo/fields/common/heading_component.html.erb
@@ -1381,8 +1387,6 @@ files:
1381
1387
  - app/components/avo/fields/common/key_value_component.rb
1382
1388
  - app/components/avo/fields/common/progress_bar_component.html.erb
1383
1389
  - 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
1386
1390
  - app/components/avo/fields/common/status_viewer_component.html.erb
1387
1391
  - app/components/avo/fields/common/status_viewer_component.rb
1388
1392
  - app/components/avo/fields/concerns/item_labels.rb
@@ -1700,6 +1704,7 @@ files:
1700
1704
  - config/credentials.yml.enc
1701
1705
  - config/i18n-tasks.yml
1702
1706
  - config/initializers/pagy.rb
1707
+ - config/master.key
1703
1708
  - config/routes.rb
1704
1709
  - config/spring.rb
1705
1710
  - db/factories.rb
@@ -1961,9 +1966,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
1961
1966
  version: 2.6.0
1962
1967
  required_rubygems_version: !ruby/object:Gem::Requirement
1963
1968
  requirements:
1964
- - - ">="
1969
+ - - ">"
1965
1970
  - !ruby/object:Gem::Version
1966
- version: '0'
1971
+ version: 1.3.1
1967
1972
  requirements: []
1968
1973
  rubygems_version: 3.3.3
1969
1974
  signing_key:
@@ -1,5 +0,0 @@
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>
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Avo::Fields::Common::FilesListViewerComponent < ViewComponent::Base
4
- def initialize(field:, resource:)
5
- @field = field
6
- @resource = resource
7
- end
8
- end
@@ -1,57 +0,0 @@
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>