avo 1.6.4.pre.1 → 1.7.3

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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -1
  3. data/Gemfile.lock +90 -69
  4. data/README.md +2 -2
  5. data/app/components/avo/edit/field_wrapper_component.html.erb +1 -1
  6. data/app/components/avo/edit/field_wrapper_component.rb +6 -1
  7. data/app/components/avo/fields/belongs_to_field/edit_component.html.erb +65 -15
  8. data/app/components/avo/fields/belongs_to_field/edit_component.rb +1 -1
  9. data/app/components/avo/fields/common/badge_viewer_component.html.erb +1 -1
  10. data/app/components/avo/fields/common/multiple_file_viewer_component.html.erb +1 -1
  11. data/app/components/avo/fields/common/single_file_viewer_component.html.erb +1 -1
  12. data/app/components/avo/fields/file_field/index_component.html.erb +1 -1
  13. data/app/components/avo/fields/trix_field/edit_component.html.erb +3 -0
  14. data/app/components/avo/index/grid_item_component.html.erb +4 -6
  15. data/app/components/avo/views/resource_index_component.html.erb +48 -46
  16. data/app/components/avo/views/resource_index_component.rb +1 -1
  17. data/app/controllers/avo/application_controller.rb +11 -9
  18. data/app/controllers/avo/base_controller.rb +21 -0
  19. data/app/controllers/avo/search_controller.rb +3 -1
  20. data/app/packs/js/controllers/fields/belongs_to_field_controller.js +65 -0
  21. data/app/packs/js/controllers/fields/trix_field_controller.js +16 -0
  22. data/app/views/avo/actions/show.html.erb +1 -1
  23. data/app/views/avo/attachments/show.html.erb +1 -1
  24. data/app/views/avo/base/_actions.html.erb +2 -2
  25. data/app/views/avo/home/index.html.erb +2 -2
  26. data/app/views/avo/partials/_javascript.html.erb +1 -1
  27. data/app/views/avo/partials/_resource_search.html.erb +1 -1
  28. data/app/views/avo/relations/new.html.erb +1 -1
  29. data/app/views/avo/sidebar/_sidebar.html.erb +1 -1
  30. data/db/factories.rb +4 -0
  31. data/lib/avo/app.rb +3 -1
  32. data/lib/avo/base_resource.rb +40 -43
  33. data/lib/avo/configuration.rb +7 -1
  34. data/lib/avo/fields/base_field.rb +5 -3
  35. data/lib/avo/fields/belongs_to_field.rb +96 -12
  36. data/lib/avo/fields/boolean_group_field.rb +1 -1
  37. data/lib/avo/fields/date_time_field.rb +1 -1
  38. data/lib/avo/fields/file_field.rb +0 -8
  39. data/lib/avo/fields/files_field.rb +1 -1
  40. data/lib/avo/fields/has_and_belongs_to_many_field.rb +4 -4
  41. data/lib/avo/fields/has_many_field.rb +4 -4
  42. data/lib/avo/fields/has_one_field.rb +5 -5
  43. data/lib/avo/fields/key_value_field.rb +1 -1
  44. data/lib/avo/fields/trix_field.rb +6 -0
  45. data/lib/avo/fields_collector.rb +0 -2
  46. data/lib/avo/version.rb +1 -1
  47. data/lib/generators/avo/field_generator.rb +1 -1
  48. data/lib/generators/avo/install_generator.rb +1 -1
  49. data/lib/generators/avo/templates/initializer/avo.tt +1 -0
  50. data/lib/generators/avo/templates/tool/sidebar_item.tt +1 -1
  51. data/public/avo-packs/css/application-797341b7.css.map +1 -1
  52. data/public/avo-packs/css/application-797341b7.css.map.br +0 -0
  53. data/public/avo-packs/css/application-797341b7.css.map.gz +0 -0
  54. data/public/avo-packs/js/application-651ed7b9bc727c83f673.js +26 -0
  55. data/public/avo-packs/js/{application-b444cbf11135b4b23654.js.LICENSE.txt → application-651ed7b9bc727c83f673.js.LICENSE.txt} +0 -0
  56. data/public/avo-packs/js/application-651ed7b9bc727c83f673.js.br +0 -0
  57. data/public/avo-packs/js/application-651ed7b9bc727c83f673.js.gz +0 -0
  58. data/public/avo-packs/js/application-651ed7b9bc727c83f673.js.map +1 -0
  59. data/public/avo-packs/js/application-651ed7b9bc727c83f673.js.map.br +0 -0
  60. data/public/avo-packs/js/application-651ed7b9bc727c83f673.js.map.gz +0 -0
  61. data/public/avo-packs/manifest.json +8 -8
  62. metadata +12 -11
  63. data/public/avo-packs/js/application-b444cbf11135b4b23654.js +0 -26
  64. data/public/avo-packs/js/application-b444cbf11135b4b23654.js.br +0 -0
  65. data/public/avo-packs/js/application-b444cbf11135b4b23654.js.gz +0 -0
  66. data/public/avo-packs/js/application-b444cbf11135b4b23654.js.map +0 -1
  67. data/public/avo-packs/js/application-b444cbf11135b4b23654.js.map.br +0 -0
  68. data/public/avo-packs/js/application-b444cbf11135b4b23654.js.map.gz +0 -0
@@ -17,7 +17,7 @@
17
17
  <%= a_link helpers.main_app.url_for(@file), color: 'indigo', download: true, class: '', size: :md do %>
18
18
  <%= helpers.svg 'download' %> <%= t('avo.download_file') %>
19
19
  <% end %>
20
- <%= a_link "#{Avo.configuration.root_path}/resources/#{@resource.model.model_name.route_key}/#{@resource.model.id
20
+ <%= a_link "#{Avo::App.root_path}/resources/#{@resource.model.model_name.route_key}/#{@resource.model.id
21
21
  }/active_storage_attachments/#{@id}/#{@file.id}", color: :red, variant: :outlined, size: :md, class: '', 'data-turbo-frame': 'destroy_attachment_form', data: { confirm: t('avo.are_you_sure')} do %>
22
22
  <%= helpers.svg 'trash' %> <%= t 'avo.delete_file', item: @file.filename %>
23
23
  <% end %>
@@ -1,7 +1,7 @@
1
1
  <%= index_field_wrapper field: @field do %>
2
2
  <% if @field.value.present? %>
3
3
  <% if @field.value.attached? && @field.value.representable? && @field.is_image %>
4
- <%= link_to_if @field.link_to_resource, image_tag(@field.variant, class: 'max-h-full'), resource_path, class: 'block h-8' %>
4
+ <%= link_to_if @field.link_to_resource, image_tag(helpers.main_app.url_for(@field.value), class: 'max-h-full'), resource_path, class: 'block h-8' %>
5
5
  <% else %>
6
6
  <%= @field.value.filename %>
7
7
  <% end %>
@@ -6,6 +6,9 @@
6
6
  data-resource-id="<%= @resource.model.id %>"
7
7
  data-attachments-disabled="<%= @field.attachments_disabled %>"
8
8
  data-attachment-key="<%= @field.attachment_key %>"
9
+ data-hide-attachment-filename="<%= @field.hide_attachment_filename %>"
10
+ data-hide-attachment-filesize="<%= @field.hide_attachment_filesize %>"
11
+ data-hide-attachment-url="<%= @field.hide_attachment_url %>"
9
12
  >
10
13
  <% trix_id = "trix_#{@resource.name.underscore}_#{@field.id}" %>
11
14
  <trix-editor data-trix-field-target="editor" input="<%= trix_id %>" placeholder="<%= @field.placeholder %>"><%== @field.value %></trix-editor>
@@ -10,18 +10,16 @@
10
10
  <%= link_to_if cover.link_to_resource, image_tag(cover.to_image, class: 'absolute h-full w-full object-cover'), helpers.resource_path(@resource.model), class: 'absolute h-full w-full object-cover', title: title.value %>
11
11
  <% elsif cover.type == 'file' %>
12
12
  <% if cover.value.attached? && cover.value.representable? %>
13
- <%= link_to_if cover.link_to_resource, image_tag(cover.variant(resize_to_limit: [480, 480]), class: 'absolute h-full w-full object-cover'), helpers.resource_path(@resource.model), class: 'absolute h-full w-full object-cover', title: title.value %>
13
+ <%= link_to_if cover.link_to_resource, image_tag(helpers.main_app.url_for(cover.value.variant(resize_to_limit: [480, 480])), class: 'absolute h-full w-full object-cover'), helpers.resource_path(@resource.model), class: 'absolute h-full w-full object-cover', title: title.value %>
14
14
  <% else %>
15
15
  <div class="absolute bg-gray-100 w-full h-full">
16
16
  <%= helpers.svg 'avocado', class: 'relative transform -translate-x-1/2 -translate-y-1/2 h-20 text-gray-400 inset-auto top-1/2 left-1/2' %>
17
17
  </div>
18
18
  <% end %>
19
+ <% elsif cover.value.present? %>
20
+ <%= link_to_if cover.link_to_resource, image_tag(cover.value, class: 'absolute h-full w-full object-cover'), helpers.resource_path(@resource.model), class: 'absolute h-full w-full object-cover', title: title.value %>
19
21
  <% else %>
20
- <% if cover.value.present? %>
21
- <%= link_to_if cover.link_to_resource, image_tag(cover.value, class: 'absolute h-full w-full object-cover'), helpers.resource_path(@resource.model), class: 'absolute h-full w-full object-cover', title: title.value %>
22
- <% else %>
23
- <%= render Avo::Index::GridCoverEmptyStateComponent.new %>
24
- <% end %>
22
+ <%= render Avo::Index::GridCoverEmptyStateComponent.new %>
25
23
  <% end %>
26
24
  </div>
27
25
  <div class="grid grid-cols-1 place-content-between p-4 h-full">
@@ -1,62 +1,64 @@
1
- <%= render Avo::PanelComponent.new(title: title, body_classes: 'py-4', data: { component: 'resources-index' }, display_breadcrumbs: @reflection.blank?) do |c| %>
2
- <% c.tools do %>
3
- <%= render 'actions' if @actions.present? %>
1
+ <div>
2
+ <%= render Avo::PanelComponent.new(title: title, body_classes: 'py-4', data: { component: 'resources-index' }, display_breadcrumbs: @reflection.blank?) do |c| %>
3
+ <% c.tools do %>
4
+ <%= render 'actions' if @actions.present? %>
4
5
 
5
- <% if can_create? %>
6
- <%= a_link create_path do %>
7
- <%= svg 'plus' %> <%= t('avo.create_new_item', item: @resource.model_class.model_name.human.downcase ) %>
6
+ <% if can_create? %>
7
+ <%= a_link create_path do %>
8
+ <%= svg 'plus' %> <%= t('avo.create_new_item', item: @resource.model_class.model_name.human.downcase ) %>
9
+ <% end %>
8
10
  <% end %>
9
- <% end %>
10
11
 
11
- <% if can_detach? %>
12
- <%= a_link detach_path, color: 'indigo', method: :delete, data: { confirm: "Are you sure you want to detach this #{@resource.singular_name}." } do %>
13
- <%= svg 'trash' %> <%= t('avo.detach_item', item: @resource.singular_name).capitalize %>
12
+ <% if can_detach? %>
13
+ <%= a_link detach_path, color: 'indigo', method: :delete, data: { confirm: "Are you sure you want to detach this #{@resource.singular_name}." } do %>
14
+ <%= svg 'trash' %> <%= t('avo.detach_item', item: @resource.singular_name).capitalize %>
15
+ <% end %>
14
16
  <% end %>
15
- <% end %>
16
17
 
17
- <% if can_attach? %>
18
- <%= a_link attach_path, color: 'indigo', 'data-turbo-frame': 'attach_modal' do %>
19
- <%= svg 'view-grid-add' %> <%= t('avo.attach_item', item: @resource.singular_name).capitalize %>
18
+ <% if can_attach? %>
19
+ <%= a_link attach_path, color: 'indigo', 'data-turbo-frame': 'attach_modal' do %>
20
+ <%= svg 'view-grid-add' %> <%= t('avo.attach_item', item: @resource.singular_name).capitalize %>
21
+ <% end %>
20
22
  <% end %>
21
23
  <% end %>
22
- <% end %>
23
24
 
24
- <% c.body do %>
25
- <div class="flex justify-between pt-2 pb-2 min-h-16"
26
- data-selected-resources-name="<%= @resource.plural_name.downcase %>"
27
- data-selected-resources="[]"
28
- >
29
- <div class="flex items-center px-6 w-64">
30
- <%= render partial: 'avo/partials/resource_search', locals: {resource: @resource.route_key} if @resource.search_query.present? %>
31
- </div>
32
- <div class="flex justify-end items-center px-6 space-x-3">
33
- <%= render partial: 'avo/partials/view_toggle_button', locals: { available_view_types: available_view_types, view_type: view_type, turbo_frame: @turbo_frame } if @models.present? %>
34
- <%= render 'filters' if @filters.present? %>
35
- </div>
36
- </div>
37
-
38
- <% if view_type.to_sym == :table %>
39
- <div class="w-full overflow-auto flex flex-col mt-4">
40
- <div class="relative flex-1 flex">
41
- <%= render(Avo::Index::ResourceTableComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_model: @parent_model)) %>
25
+ <% c.body do %>
26
+ <div class="flex justify-between pt-2 pb-2 min-h-16"
27
+ data-selected-resources-name="<%= @resource.plural_name.downcase %>"
28
+ data-selected-resources="[]"
29
+ >
30
+ <div class="flex items-center px-6 w-64">
31
+ <%= render partial: 'avo/partials/resource_search', locals: {resource: @resource.route_key} if @resource.search_query.present? %>
32
+ </div>
33
+ <div class="flex justify-end items-center px-6 space-x-3">
34
+ <%= render partial: 'avo/partials/view_toggle_button', locals: { available_view_types: available_view_types, view_type: view_type, turbo_frame: @turbo_frame } if @models.present? %>
35
+ <%= render 'filters' if @filters.present? %>
42
36
  </div>
37
+ </div>
43
38
 
44
- <% if @models.present? %>
45
- <div class="py-4">
46
- <%= render partial: 'avo/partials/paginator', locals: { pagy: @pagy, turbo_frame: @turbo_frame || 'none' } %>
39
+ <% if view_type.to_sym == :table %>
40
+ <div class="w-full overflow-auto flex flex-col mt-4">
41
+ <div class="relative flex-1 flex">
42
+ <%= render(Avo::Index::ResourceTableComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_model: @parent_model)) %>
47
43
  </div>
48
- <% end %>
49
- </div>
44
+
45
+ <% if @models.present? %>
46
+ <div class="py-4">
47
+ <%= render partial: 'avo/partials/paginator', locals: { pagy: @pagy, turbo_frame: @turbo_frame || 'none' } %>
48
+ </div>
49
+ <% end %>
50
+ </div>
51
+ <% end %>
50
52
  <% end %>
51
- <% end %>
52
53
 
53
- <% c.bare_content do %>
54
- <% if view_type.to_sym == :grid %>
55
- <%= render Avo::Index::ResourceGridComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_model: @parent_model) %>
54
+ <% c.bare_content do %>
55
+ <% if view_type.to_sym == :grid %>
56
+ <%= render Avo::Index::ResourceGridComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_model: @parent_model) %>
56
57
 
57
- <div class="bg-white rounded-xl shadow-xl mt-8 py-6">
58
- <%= render partial: 'avo/partials/paginator', locals: { pagy: @pagy, turbo_frame: @turbo_frame || 'none' } %>
59
- </div>
58
+ <div class="bg-white rounded-xl shadow-xl mt-8 py-6">
59
+ <%= render partial: 'avo/partials/paginator', locals: { pagy: @pagy, turbo_frame: @turbo_frame || 'none' } %>
60
+ </div>
61
+ <% end %>
60
62
  <% end %>
61
63
  <% end %>
62
- <% end %>
64
+ </div>
@@ -77,7 +77,7 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
77
77
  end
78
78
 
79
79
  def attach_path
80
- "#{Avo.configuration.root_path}#{request.env["PATH_INFO"]}/new"
80
+ "#{Avo::App.root_path}#{request.env["PATH_INFO"]}/new"
81
81
  end
82
82
 
83
83
  def detach_path
@@ -17,7 +17,7 @@ module Avo
17
17
  add_flash_types :info, :warning, :success, :error
18
18
 
19
19
  def init_app
20
- Avo::App.init request: request, context: context, current_user: _current_user
20
+ Avo::App.init request: request, context: context, root_path: avo.root_path.delete_suffix("/"), current_user: _current_user
21
21
 
22
22
  @license = Avo::App.license
23
23
  end
@@ -78,6 +78,7 @@ module Avo
78
78
  existing_params = Addressable::URI.parse(request.fullpath).query_values.symbolize_keys
79
79
  end
80
80
  rescue; end
81
+
81
82
  avo.send :"resources_#{model.model_name.route_key}_path", **existing_params, **args
82
83
  end
83
84
 
@@ -91,7 +92,7 @@ module Avo
91
92
  existing_params = Addressable::URI.parse(request.fullpath).query_values.symbolize_keys
92
93
  end
93
94
  rescue; end
94
- Addressable::Template.new("#{Avo.configuration.root_path}/resources/#{@parent_resource.model.model_name.route_key}/#{@parent_resource.model.id}/#{@resource.route_key}{?query*}")
95
+ Addressable::Template.new("#{Avo::App.root_path}/resources/#{@parent_resource.model.model_name.route_key}/#{@parent_resource.model.id}/#{@resource.route_key}{?query*}")
95
96
  .expand({query: {**existing_params, **args}})
96
97
  .to_str
97
98
  end
@@ -103,7 +104,7 @@ module Avo
103
104
  end
104
105
 
105
106
  def resource_attach_path(model_name, model_id, related_name, related_id = nil)
106
- path = "#{Avo.configuration.root_path}/resources/#{model_name}/#{model_id}/#{related_name}/new"
107
+ path = "#{Avo::App.root_path}/resources/#{model_name}/#{model_id}/#{related_name}/new"
107
108
 
108
109
  path += "/#{related_id}" if related_id.present?
109
110
 
@@ -111,7 +112,7 @@ module Avo
111
112
  end
112
113
 
113
114
  def resource_detach_path(model_name, model_id, related_name, related_id = nil)
114
- path = "#{Avo.configuration.root_path}/resources/#{model_name}/#{model_id}/#{related_name}"
115
+ path = "#{Avo::App.root_path}/resources/#{model_name}/#{model_id}/#{related_name}"
115
116
 
116
117
  path += "/#{related_id}" if related_id.present?
117
118
 
@@ -147,7 +148,8 @@ module Avo
147
148
  end
148
149
 
149
150
  def set_model
150
- @model = eager_load_files(@resource, @resource.model_class).find params[:id]
151
+ # @model = eager_load_files(@resource, @resource.model_class).find params[:id]
152
+ @model = @resource.model_class.find params[:id]
151
153
  end
152
154
 
153
155
  def set_related_model
@@ -179,7 +181,7 @@ module Avo
179
181
 
180
182
  begin
181
183
  request.path
182
- .match(/\/?#{Avo.configuration.root_path.delete('/')}\/resources\/([a-z1-9\-_]*)\/?/mi)
184
+ .match(/\/?#{Avo::App.root_path.delete('/')}\/resources\/([a-z1-9\-_]*)\/?/mi)
183
185
  .captures
184
186
  .first
185
187
  rescue
@@ -273,15 +275,15 @@ module Avo
273
275
  end
274
276
 
275
277
  def on_root_path
276
- [Avo.configuration.root_path, "#{Avo.configuration.root_path}/"].include?(request.original_fullpath)
278
+ [Avo::App.root_path, "#{Avo::App.root_path}/"].include?(request.original_fullpath)
277
279
  end
278
280
 
279
281
  def on_resources_path
280
- request.original_url.match?(/.*#{Avo.configuration.root_path}\/resources\/.*/)
282
+ request.original_url.match?(/.*#{Avo::App.root_path}\/resources\/.*/)
281
283
  end
282
284
 
283
285
  def on_api_path
284
- request.original_url.match?(/.*#{Avo.configuration.root_path}\/avo_api\/.*/)
286
+ request.original_url.match?(/.*#{Avo::App.root_path}\/avo_api\/.*/)
285
287
  end
286
288
  end
287
289
  end
@@ -7,6 +7,8 @@ module Avo
7
7
  before_action :hydrate_resource
8
8
  before_action :authorize_action
9
9
  before_action :set_model, only: [:show, :edit, :destroy, :update]
10
+ before_action :reset_pagination_if_filters_changed, only: :index
11
+ before_action :cache_applied_filters, only: :index
10
12
 
11
13
  def index
12
14
  @page_title = resource_name.humanize
@@ -21,6 +23,11 @@ module Avo
21
23
  @query = @authorization.apply_policy @resource.model_class
22
24
  end
23
25
 
26
+ # Remove default_scope for index view
27
+ if @resource.unscoped_queries_on_index
28
+ @query = @query.unscoped
29
+ end
30
+
24
31
  # Eager load the relations
25
32
  if @resource.includes.present?
26
33
  @query = @query.includes(*@resource.includes)
@@ -255,5 +262,19 @@ module Avo
255
262
 
256
263
  filter_defaults
257
264
  end
265
+
266
+ def cache_applied_filters
267
+ ::Avo::App.cache_store.delete applied_filters_cache_key if params[:filters].nil?
268
+
269
+ ::Avo::App.cache_store.write(applied_filters_cache_key, params[:filters], expires_in: 7.days)
270
+ end
271
+
272
+ def reset_pagination_if_filters_changed
273
+ params[:page] = 1 if params[:filters] != ::Avo::App.cache_store.read(applied_filters_cache_key)
274
+ end
275
+
276
+ def applied_filters_cache_key
277
+ "avo.base_controller.#{@resource.route_key}.applied_filters"
278
+ end
258
279
  end
259
280
  end
@@ -2,6 +2,8 @@ require_dependency "avo/application_controller"
2
2
 
3
3
  module Avo
4
4
  class SearchController < ApplicationController
5
+ include Rails.application.routes.url_helpers
6
+
5
7
  before_action :set_resource_name, only: [:show]
6
8
  before_action :set_resource, only: [:show]
7
9
 
@@ -61,7 +63,7 @@ module Avo
61
63
 
62
64
  if App.license.has_with_trial(:enhanced_search_results)
63
65
  result[:_description] = resource.description
64
- result[:_avatar] = resource.avatar
66
+ result[:_avatar] = resource.avatar.present? ? main_app.url_for(resource.avatar) : nil
65
67
  result[:_avatar_type] = resource.avatar_type
66
68
  end
67
69
 
@@ -0,0 +1,65 @@
1
+ import { Controller } from 'stimulus'
2
+
3
+ export default class extends Controller {
4
+ static targets = ['select', 'type']
5
+
6
+ get selectedType() {
7
+ return this.selectTarget.value
8
+ }
9
+
10
+ connect() {
11
+ this.setValidNames()
12
+ this.changedType()
13
+ }
14
+
15
+ setValidNames() {
16
+ this.typeTargets.forEach((target) => {
17
+ const { type } = target.dataset
18
+ const select = target.querySelector('select')
19
+ const name = select.getAttribute('name')
20
+
21
+ select.setAttribute('valid-name', name)
22
+ if (this.selectedType !== type) {
23
+ select.selectedIndex = 0
24
+ }
25
+ })
26
+ }
27
+
28
+ changedType() {
29
+ this.hideAllTypeTargets()
30
+ this.enableType(this.selectTarget.value)
31
+ }
32
+
33
+ hideAllTypeTargets() {
34
+ this.typeTargets.forEach((target) => {
35
+ this.hideTarget(target)
36
+ this.invalidateTarget(target)
37
+ })
38
+ }
39
+
40
+ hideTarget(target) {
41
+ target.classList.add('hidden')
42
+ }
43
+
44
+ invalidateTarget(target) {
45
+ const select = target.querySelector('select')
46
+
47
+ select.setAttribute('name', '')
48
+ }
49
+
50
+ validateTarget(target) {
51
+ const select = target.querySelector('select')
52
+ const validName = select.getAttribute('valid-name')
53
+
54
+ select.setAttribute('name', validName)
55
+ }
56
+
57
+ enableType(type) {
58
+ const target = this.typeTargets.find((typeTarget) => typeTarget.dataset.type === type)
59
+
60
+ if (target) {
61
+ target.classList.remove('hidden')
62
+ this.validateTarget(target)
63
+ }
64
+ }
65
+ }
@@ -21,6 +21,18 @@ export default class extends Controller {
21
21
  return castBoolean(this.controllerTarget.dataset.attachmentsDisabled)
22
22
  }
23
23
 
24
+ get hideAttachmentFilename() {
25
+ return castBoolean(this.controllerTarget.dataset.hideAttachmentFilename)
26
+ }
27
+
28
+ get hideAttachmentFilesize() {
29
+ return castBoolean(this.controllerTarget.dataset.hideAttachmentFilesize)
30
+ }
31
+
32
+ get hideAttachmentUrl() {
33
+ return castBoolean(this.controllerTarget.dataset.hideAttachmentUrl)
34
+ }
35
+
24
36
  get uploadUrl() {
25
37
  return `${window.location.origin}${window.Avo.configuration.root_path}/avo_api/resources/${this.resourceName}/${this.resourceId}/attachments`
26
38
  }
@@ -102,6 +114,10 @@ export default class extends Controller {
102
114
  href: response.href,
103
115
  }
104
116
 
117
+ if (this.hideAttachmentFilename) attributes.filename = null
118
+ if (this.hideAttachmentFilesize) attributes.filesize = null
119
+ if (this.hideAttachmentUrl) attributes.href = null
120
+
105
121
  successCallback(attributes)
106
122
  }
107
123
  })
@@ -7,7 +7,7 @@
7
7
  data-resource-id="<%= params[:id] %>"
8
8
  class="hidden text-blue-gray-800"
9
9
  >
10
- <%= form_with model: @model, scope: 'fields', url: "#{Avo.configuration.root_path}/resources/#{@resource.model_class.model_name.route_key}/actions/#{@action.param_id}", data: {'turbo-frame': '_top', 'action-target': 'form'} do |form| %>
10
+ <%= form_with model: @model, scope: 'fields', url: "#{avo.root_path}resources/#{@resource.model_class.model_name.route_key}/actions/#{@action.param_id}", data: {'turbo-frame': '_top', 'action-target': 'form'} do |form| %>
11
11
  <%= render Avo::ModalComponent.new do |c| %>
12
12
  <% c.heading do %>
13
13
  <%= @action.action_name %>
@@ -1,5 +1,5 @@
1
1
  <%= turbo_frame_tag 'destroy_attachment_form' do %>
2
- <%= form_with url: "#{Avo.configuration.root_path}/resources/#{params[:resource_name]}/#{params[:id]
2
+ <%= form_with url: "#{avo.root_path}resources/#{params[:resource_name]}/#{params[:id]
3
3
  }/active_storage_attachments/#{params[:attachment_name]}/#{params[:signed_attachment_id]}",
4
4
  method: :delete,
5
5
  html: {
@@ -15,8 +15,8 @@
15
15
  <%
16
16
  @actions.each_with_index do |action, index|
17
17
  path = action_name == 'show' ?
18
- "#{Avo.configuration.root_path}/resources/#{@resource.model_class.model_name.route_key}/#{@model.id}/actions/#{action.param_id}" :
19
- "#{Avo.configuration.root_path}/resources/#{@resource.model_class.model_name.route_key}/actions/#{action.param_id}"
18
+ "#{avo.root_path}resources/#{@resource.model_class.model_name.route_key}/#{@model.id}/actions/#{action.param_id}" :
19
+ "#{avo.root_path}resources/#{@resource.model_class.model_name.route_key}/actions/#{action.param_id}"
20
20
  %>
21
21
  <%= link_to path,
22
22
  'data-turbo-frame': 'actions_show',
@@ -28,8 +28,8 @@
28
28
  <li><span class="mr-2">👍</span> Authorization</li>
29
29
  <li><span class="mr-2">👍</span> Localization</li>
30
30
  <li><span class="mr-2">👍</span> Custom tools</li>
31
- <li><span class="mr-2">⏳</span> Custom fields</li>
32
- <li><span class="mr-2">⏳</span> Search</li>
31
+ <li><span class="mr-2">👍</span> Custom fields</li>
32
+ <li><span class="mr-2">👍</span> Search</li>
33
33
  <li><span class="mr-2">🕐</span> Dashboards</li>
34
34
  <li><span class="mr-2">🕐</span> Themes</li>
35
35
  </ul>