avo 2.19.0 → 2.21.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.

Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -2
  3. data/Gemfile.lock +6 -6
  4. data/app/components/avo/card_component.html.erb +15 -15
  5. data/app/components/avo/card_component.rb +7 -5
  6. data/app/components/avo/empty_state_component.html.erb +1 -1
  7. data/app/components/avo/empty_state_component.rb +12 -10
  8. data/app/components/avo/fields/belongs_to_field/edit_component.rb +1 -1
  9. data/app/components/avo/fields/boolean_field/edit_component.html.erb +1 -1
  10. data/app/components/avo/fields/boolean_group_field/edit_component.html.erb +1 -1
  11. data/app/components/avo/fields/code_field/edit_component.html.erb +2 -2
  12. data/app/components/avo/fields/country_field/edit_component.html.erb +1 -1
  13. data/app/components/avo/fields/date_field/edit_component.html.erb +2 -2
  14. data/app/components/avo/fields/date_time_field/edit_component.html.erb +2 -2
  15. data/app/components/avo/fields/edit_component.rb +4 -0
  16. data/app/components/avo/fields/external_image_field/edit_component.html.erb +1 -1
  17. data/app/components/avo/fields/file_field/edit_component.html.erb +1 -1
  18. data/app/components/avo/fields/files_field/edit_component.html.erb +1 -1
  19. data/app/components/avo/fields/has_one_field/show_component.html.erb +3 -3
  20. data/app/components/avo/fields/markdown_field/edit_component.html.erb +1 -1
  21. data/app/components/avo/fields/markdown_field/show_component.html.erb +1 -1
  22. data/app/components/avo/fields/number_field/edit_component.html.erb +1 -1
  23. data/app/components/avo/fields/password_field/edit_component.html.erb +1 -1
  24. data/app/components/avo/fields/progress_bar_field/edit_component.html.erb +1 -1
  25. data/app/components/avo/fields/select_field/edit_component.html.erb +2 -2
  26. data/app/components/avo/fields/show_component.rb +4 -0
  27. data/app/components/avo/fields/status_field/edit_component.html.erb +1 -1
  28. data/app/components/avo/fields/tags_field/edit_component.html.erb +2 -2
  29. data/app/components/avo/fields/text_field/edit_component.html.erb +1 -1
  30. data/app/components/avo/fields/textarea_field/edit_component.html.erb +1 -1
  31. data/app/components/avo/fields/time_field/edit_component.html.erb +2 -2
  32. data/app/components/avo/fields/trix_field/edit_component.html.erb +3 -2
  33. data/app/components/avo/fields/trix_field/edit_component.rb +5 -1
  34. data/app/components/avo/index/resource_grid_component.html.erb +1 -1
  35. data/app/components/avo/index/resource_table_component.rb +3 -3
  36. data/app/components/avo/paginator_component.html.erb +1 -5
  37. data/app/components/avo/paginator_component.rb +8 -0
  38. data/app/components/avo/panel_component.html.erb +1 -1
  39. data/app/components/avo/resource_component.rb +17 -2
  40. data/app/components/avo/sidebar/group_component.html.erb +18 -12
  41. data/app/components/avo/sidebar/heading_component.html.erb +17 -10
  42. data/app/components/avo/views/resource_index_component.html.erb +1 -1
  43. data/app/controllers/avo/actions_controller.rb +27 -5
  44. data/app/controllers/avo/application_controller.rb +3 -2
  45. data/app/controllers/avo/associations_controller.rb +2 -1
  46. data/app/controllers/avo/attachments_controller.rb +4 -0
  47. data/app/controllers/avo/base_controller.rb +27 -16
  48. data/app/controllers/avo/dashboards/cards_controller.rb +1 -1
  49. data/app/controllers/avo/dashboards_controller.rb +1 -0
  50. data/app/controllers/avo/search_controller.rb +11 -5
  51. data/app/javascript/js/controllers/fields/trix_field_controller.js +6 -3
  52. data/app/javascript/js/controllers/item_select_all_controller.js +7 -4
  53. data/app/views/avo/actions/keep_modal_open.turbo_stream.erb +5 -0
  54. data/app/views/avo/actions/show.html.erb +3 -2
  55. data/app/views/avo/base/_multiple_select_filter.html.erb +1 -1
  56. data/app/views/avo/partials/_resource_search.html.erb +1 -1
  57. data/app/views/layouts/avo/application.html.erb +1 -1
  58. data/avo.gemspec +0 -1
  59. data/config/i18n-tasks.yml +1 -1
  60. data/config/initializers/pagy.rb +16 -0
  61. data/lib/avo/app.rb +4 -1
  62. data/lib/avo/base_action.rb +25 -4
  63. data/lib/avo/base_card.rb +8 -3
  64. data/lib/avo/base_resource.rb +21 -6
  65. data/lib/avo/concerns/breadcrumbs.rb +96 -0
  66. data/lib/avo/concerns/handles_field_args.rb +8 -1
  67. data/lib/avo/concerns/has_html_attributes.rb +14 -16
  68. data/lib/avo/dashboards/base_dashboard.rb +7 -1
  69. data/lib/avo/fields/base_field.rb +2 -1
  70. data/lib/avo/fields/concerns/is_disabled.rb +19 -0
  71. data/lib/avo/fields/select_field.rb +39 -34
  72. data/lib/avo/filters/base_filter.rb +9 -3
  73. data/lib/avo/hosts/resource_record_host.rb +7 -0
  74. data/lib/avo/hosts/visibility_host.rb +2 -1
  75. data/lib/avo/services/authorization_service.rb +2 -2
  76. data/lib/avo/version.rb +1 -1
  77. data/lib/generators/avo/templates/field/components/edit_component.html.erb.tt +1 -1
  78. data/lib/generators/avo/templates/locales/avo.en.yml +3 -2
  79. data/lib/generators/avo/templates/locales/avo.fr.yml +3 -2
  80. data/lib/generators/avo/templates/locales/avo.nb.yml +3 -2
  81. data/lib/generators/avo/templates/locales/avo.nn.yml +3 -2
  82. data/lib/generators/avo/templates/locales/avo.pt-BR.yml +3 -2
  83. data/lib/generators/avo/templates/locales/avo.pt.yml +120 -0
  84. data/lib/generators/avo/templates/locales/avo.ro.yml +56 -55
  85. data/lib/generators/avo/templates/locales/avo.tr.yml +3 -2
  86. data/lib/generators/avo/templates/locales/pagy/nn.yml +15 -0
  87. data/lib/generators/avo/templates/locales/pagy/ro.yml +17 -0
  88. data/public/avo-assets/avo.base.css +4 -4
  89. data/public/avo-assets/avo.base.js +2 -2
  90. data/public/avo-assets/avo.base.js.map +2 -2
  91. metadata +9 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2b092c8d9df1951b5ccd6a07b31c8c96a6cb68846ab2b2342f43082449a5ced
4
- data.tar.gz: 5bb4985123f45ad9aeca49892559d43a80130a29ff823fc6c7f35127e5de3e5c
3
+ metadata.gz: 302280e8ea8c09012d0f68c72b017a8e903261346e02fdb8b4eaf2daa3160d39
4
+ data.tar.gz: eef2ab4ee6fd1576311d85ef6ae91add6f655f9762e3cc736f39bbb2f039c31e
5
5
  SHA512:
6
- metadata.gz: e28f40d6e4559541cd2e08a76753ef87bcbfe54a48bd3ba2c7ea368436762bb287ddbac6641df9b18f6196071dd6bd7bb3f5e2f6e0bb95e2b7b10a5ab0cc6a2b
7
- data.tar.gz: c6a64520f187b1e725b167bc396e23d6177c9c83e8f5ff2864a56cd12aed87ec757bfd34ee76955e93718268e888c9693dfa6899d6633e37f93874d2d86cbd73
6
+ metadata.gz: bdf810fecb08f2a6d8a157238b28df1141b396b1a62387a88bb6094d0ac4c39195d36c319751eb7dca1368ed6f5174a241a23279bf558ade568091ce201d65ae
7
+ data.tar.gz: 983acf054fc7a5c8fd4f1f32b9f1a6c45e187d9c87f70a223203e8445f3d0ecd1d05eb80ac0fc02ec497604636a37a20d8ab8365a21477dbd9decc60ad1760f5
data/Gemfile CHANGED
@@ -121,8 +121,7 @@ gem "appraisal"
121
121
 
122
122
  gem 'meta-tags'
123
123
 
124
- gem 'breadcrumbs_on_rails'
125
-
124
+ gem 'manifester'
126
125
 
127
126
  # Search
128
127
  gem 'ransack'
data/Gemfile.lock CHANGED
@@ -1,12 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.19.0)
4
+ avo (2.21.0)
5
5
  actionview (>= 6.0)
6
6
  active_link_to
7
7
  activerecord (>= 6.0)
8
8
  addressable
9
- breadcrumbs_on_rails
10
9
  docile
11
10
  dry-initializer
12
11
  httparty
@@ -127,8 +126,6 @@ GEM
127
126
  bootsnap (1.13.0)
128
127
  msgpack (~> 1.2)
129
128
  brakeman (5.3.1)
130
- breadcrumbs_on_rails (4.1.0)
131
- railties (>= 5.0)
132
129
  builder (3.2.4)
133
130
  bump (0.10.0)
134
131
  bundler-integrity (1.0.9)
@@ -238,6 +235,9 @@ GEM
238
235
  nokogiri (>= 1.5.9)
239
236
  mail (2.7.1)
240
237
  mini_mime (>= 0.1.1)
238
+ manifester (0.1.8)
239
+ rails (>= 6.0)
240
+ zeitwerk
241
241
  marcel (1.0.2)
242
242
  matrix (0.4.2)
243
243
  meta-tags (2.17.0)
@@ -409,7 +409,7 @@ GEM
409
409
  tzinfo (2.0.5)
410
410
  concurrent-ruby (~> 1.0)
411
411
  unicode-display_width (2.2.0)
412
- view_component (2.74.1)
412
+ view_component (2.78.0)
413
413
  activesupport (>= 5.0.0, < 8.0)
414
414
  concurrent-ruby (~> 1.0)
415
415
  method_source (~> 1.0)
@@ -454,7 +454,6 @@ DEPENDENCIES
454
454
  aws-sdk-s3
455
455
  bootsnap (>= 1.4.2)
456
456
  brakeman
457
- breadcrumbs_on_rails
458
457
  bump
459
458
  bundler-integrity (~> 1.0)
460
459
  byebug
@@ -482,6 +481,7 @@ DEPENDENCIES
482
481
  jsbundling-rails
483
482
  launchy
484
483
  listen (>= 3.5.1)
484
+ manifester
485
485
  meta-tags
486
486
  net-smtp
487
487
  pg (>= 0.18, < 2.0)
@@ -1,18 +1,18 @@
1
1
  <div class="relative flex-1 flex flex-col justify-between h-full"
2
2
  data-controller="dashboard-card"
3
3
  data-dashboard-card-target="card"
4
- data-refresh-every="<%= @card.refresh_every %>"
5
- data-card-id="<%= @card.id %>"
6
- data-card-index="<%= @card.index %>">
7
- <% if @card.class.display_header %>
4
+ data-refresh-every="<%= card.refresh_every %>"
5
+ data-card-id="<%= card.id %>"
6
+ data-card-index="<%= card.index %>">
7
+ <% if card.class.display_header %>
8
8
  <div class="px-4 pt-4">
9
9
  <div class="flex justify-between items-center min-h-6">
10
10
  <div class="text-base font-bold text-gray-700 leading-none">
11
- <%= @card.label %>
11
+ <%= card.label %>
12
12
  </div>
13
13
  <div data-controller="select">
14
- <% if @card.type.in?([:metric, :chartkick, :partial]) && @card.ranges.present? %>
15
- <%= select_tag "#{@card.id}_#{@card.index}_range", options_for_select(@card.ranges, @card.range),
14
+ <% if card.type.in?([:metric, :chartkick, :partial]) && card.ranges.present? %>
15
+ <%= select_tag "#{card.id}_#{card.index}_range", options_for_select(card.ranges, card.range),
16
16
  class: 'appearance-none inline-flex bg-blue-gray-100 disabled:bg-blue-gray-300 disabled:cursor-not-allowed focus:bg-white text-sm text-blue-gray-700 disabled:text-blue-gray-700 leading-none rounded-md py-px px-2 leading-tight border outline-none outline w-24',
17
17
  data: {
18
18
  target: 'select',
@@ -24,18 +24,18 @@
24
24
  </div>
25
25
  </div>
26
26
  <% end %>
27
- <% if @card.type == :chartkick %>
28
- <%= render 'chartkick_card', card: @card %>
29
- <% elsif @card.type === :partial %>
30
- <%= render @card.class.partial %>
31
- <% elsif @card.type === :metric %>
27
+ <% if card.type == :chartkick %>
28
+ <%= render 'chartkick_card', card: card %>
29
+ <% elsif card.type === :partial %>
30
+ <%= render card.class.partial %>
31
+ <% elsif card.type === :metric %>
32
32
  <div class="flex-1 flex px-4 pb-4">
33
- <%= render 'metric_card', card: @card %>
33
+ <%= render 'metric_card', card: card %>
34
34
  </div>
35
35
  <% end %>
36
- <% if @card.description.present? %>
36
+ <% if card.description.present? %>
37
37
  <%= content_tag :div, class: "absolute inset-auto bottom-0 right-0 mb-4 mr-4",
38
- title: @card.description,
38
+ title: card.description,
39
39
  data: {
40
40
  target: 'card-description',
41
41
  tippy: 'tooltip',
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Avo::CardComponent < ViewComponent::Base
4
+ attr_reader :card
5
+
4
6
  def initialize(card: nil)
5
7
  @card = card
6
8
 
@@ -8,16 +10,16 @@ class Avo::CardComponent < ViewComponent::Base
8
10
  end
9
11
 
10
12
  def render?
11
- !@card.nil?
13
+ card.present?
12
14
  end
13
15
 
14
16
  # Initializing the card byt running the query method.
15
17
  # We'll still keep the query block around for compatibility reasons.
16
18
  def init_card
17
- if @card.respond_to? :query
18
- @card.query
19
- elsif @card.query_block.present?
20
- @card.compute_result
19
+ if card.respond_to? :query
20
+ card.query
21
+ elsif card.query_block.present?
22
+ card.compute_result
21
23
  end
22
24
  end
23
25
  end
@@ -4,7 +4,7 @@
4
4
  <div class="relative flex-1 flex flex-col items-center justify-center space-y-12 py-24">
5
5
  <%= helpers.svg view_type_svg, class: 'h-[250px]' %>
6
6
  <div class="text-gray-500 text-center">
7
- <%= message %>
7
+ <%= text %>
8
8
  </div>
9
9
  </div>
10
10
  <% if @add_background %>
@@ -1,24 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Avo::EmptyStateComponent < ViewComponent::Base
4
- def initialize(message: nil, resource_name: nil, related_name: nil, view_type: :table, add_background: false)
4
+ attr_reader :message, :view_type, :add_background, :by_association
5
+
6
+ def initialize(message: nil, view_type: :table, add_background: false, by_association: false)
5
7
  @message = message
6
8
  @view_type = view_type
7
- @related_name = related_name
8
- @resource_name = resource_name
9
9
  @add_background = add_background
10
+ @by_association = by_association
10
11
  end
11
12
 
12
- def message
13
- return @message if @message.present?
14
-
15
- translation_tag = @related_name.present? ? 'avo.no_related_item_found' : 'avo.no_item_found'
16
- helpers.t translation_tag, item: @resource_name
13
+ def text
14
+ message || locale_message
17
15
  end
18
16
 
19
17
  def view_type_svg
20
- return "grid-empty-state" if @view_type.to_sym == :grid
18
+ "#{view_type}-empty-state"
19
+ end
20
+
21
+ private
21
22
 
22
- "table-empty-state"
23
+ def locale_message
24
+ helpers.t by_association ? 'avo.no_related_item_found' : 'avo.no_item_found'
23
25
  end
24
26
  end
@@ -8,7 +8,7 @@ class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
8
8
  end
9
9
 
10
10
  def disabled
11
- return true if @field.is_readonly?
11
+ return true if @field.is_readonly? || @field.is_disabled?
12
12
 
13
13
  # When visiting the record through it's association we keep the field disabled by default
14
14
  # We make an exception when the user deliberately instructs Avo to allow detaching in this scenario
@@ -4,7 +4,7 @@
4
4
  checked: @field.value,
5
5
  class: "text-lg h-4 w-4 checked:bg-primary-400 focus:checked:!bg-primary-400 #{@field.get_html(:classes, view: view, element: :input)}",
6
6
  data: @field.get_html(:data, view: view, element: :input),
7
- disabled: @field.is_readonly?,
7
+ disabled: disabled?,
8
8
  style: @field.get_html(:style, view: view, element: :input)
9
9
  %>
10
10
  </div>
@@ -20,7 +20,7 @@
20
20
  <%= check_box_tag "#{model_param_key}[#{@field.id}][]", id, checked, {
21
21
  class: "w-4 h-4 #{@field.get_html(:classes, view: view, element: :input)}",
22
22
  data: @field.get_html(:data, view: view, element: :input),
23
- disabled: @field.is_readonly?,
23
+ disabled: disabled?,
24
24
  id: "#{model_param_key}_#{@field.id}_#{id}",
25
25
  style: @field.get_html(:style, view: view, element: :input)
26
26
  } %> <%= label %>
@@ -8,12 +8,12 @@
8
8
  language: @field.language,
9
9
  theme: @field.theme,
10
10
  'tab-size': @field.tab_size,
11
- 'read-only': @field.is_readonly?,
11
+ 'read-only': disabled?,
12
12
  'indent-with-tabs': @field.indent_with_tabs,
13
13
  'line-wrapping': @field.line_wrapping,
14
14
  **@field.get_html(:data, view: view, element: :input),
15
15
  },
16
- disabled: @field.is_readonly?,
16
+ disabled: disabled?,
17
17
  placeholder: @field.placeholder,
18
18
  style: @field.get_html(:style, view: view, element: :input)
19
19
  %>
@@ -8,7 +8,7 @@
8
8
  },
9
9
  class: classes("w-full"),
10
10
  data: @field.get_html(:data, view: view, element: :input),
11
- disabled: @field.is_readonly?,
11
+ disabled: disabled?,
12
12
  style: @field.get_html(:style, view: view, element: :input),
13
13
  placeholder: @field.include_blank.present? ? nil : @field.placeholder
14
14
  %>
@@ -18,7 +18,7 @@
18
18
  placeholder: @field.placeholder,
19
19
  **@field.get_html(:data, view: view, element: :input)
20
20
  },
21
- disabled: @field.is_readonly?,
21
+ disabled: disabled?,
22
22
  placeholder: @field.placeholder,
23
23
  style: @field.get_html(:style, view: view, element: :input)
24
24
  %>
@@ -30,7 +30,7 @@
30
30
  placeholder: @field.placeholder,
31
31
  **@field.get_html(:data, view: view, element: :input)
32
32
  },
33
- disabled: @field.is_readonly?,
33
+ disabled: disabled?,
34
34
  placeholder: @field.placeholder,
35
35
  style: @field.get_html(:style, view: view, element: :input)
36
36
  %>
@@ -20,7 +20,7 @@
20
20
  placeholder: @field.placeholder,
21
21
  **@field.get_html(:data, view: view, element: :input)
22
22
  },
23
- disabled: @field.is_readonly?,
23
+ disabled: disabled?,
24
24
  placeholder: @field.placeholder,
25
25
  style: @field.get_html(:style, view: view, element: :input)
26
26
  %>
@@ -32,7 +32,7 @@
32
32
  placeholder: @field.placeholder,
33
33
  **@field.get_html(:data, view: view, element: :input)
34
34
  },
35
- disabled: @field.is_readonly?,
35
+ disabled: disabled?,
36
36
  placeholder: @field.placeholder,
37
37
  style: @field.get_html(:style, view: view, element: :input)
38
38
  %>
@@ -42,4 +42,8 @@ class Avo::Fields::EditComponent < ViewComponent::Base
42
42
  view: view
43
43
  }
44
44
  end
45
+
46
+ def disabled?
47
+ field.is_readonly? || field.is_disabled?
48
+ end
45
49
  end
@@ -2,7 +2,7 @@
2
2
  <%= @form.text_field @field.id,
3
3
  class: classes("w-full"),
4
4
  data: @field.get_html(:data, view: view, element: :input),
5
- disabled: @field.is_readonly?,
5
+ disabled: disabled?,
6
6
  placeholder: @field.placeholder,
7
7
  style: @field.get_html(:style, view: view, element: :input)
8
8
  %>
@@ -10,7 +10,7 @@
10
10
  accept: @field.accept,
11
11
  data: @field.get_html(:data, view: view, element: :input),
12
12
  direct_upload: @field.direct_upload,
13
- disabled: @field.is_readonly?,
13
+ disabled: disabled?,
14
14
  style: @field.get_html(:style, view: view, element: :input),
15
15
  class: "w-full"
16
16
  %>
@@ -7,7 +7,7 @@
7
7
  accept: @field.accept,
8
8
  data: @field.get_html(:data, view: view, element: :input),
9
9
  direct_upload: @field.direct_upload,
10
- disabled: @field.is_readonly?,
10
+ disabled: disabled?,
11
11
  multiple: true,
12
12
  style: @field.get_html(:style, view: view, element: :input),
13
13
  class: "w-full"
@@ -5,7 +5,7 @@
5
5
  <% else %>
6
6
  <%= render Avo::PanelComponent.new(name: @field.name) do |c| %>
7
7
  <% c.tools do %>
8
- <% if !@field.is_readonly? && can_attach? %>
8
+ <% if !@field.is_readonly? && !@field.is_disabled? && can_attach? %>
9
9
  <%= a_link attach_path,
10
10
  icon: 'heroicons/outline/link',
11
11
  color: :primary,
@@ -13,7 +13,7 @@
13
13
  <%= t('avo.attach_item', item: @field.name.downcase) %>
14
14
  <% end %>
15
15
  <% end %>
16
- <% if !@field.is_readonly? && can_see_the_create_button? %>
16
+ <% if !@field.is_readonly? && !@field.is_disabled? && can_see_the_create_button? %>
17
17
  <%= a_link create_path,
18
18
  icon: 'heroicons/outline/plus',
19
19
  'data-target': 'create',
@@ -27,7 +27,7 @@
27
27
 
28
28
  <% c.body do %>
29
29
  <div class="py-8 flex justify-center items-center">
30
- <%= empty_state resource_name: @field.id, related_name: params[:related_name] %>
30
+ <%= empty_state by_association: params[:related_name].present? %>
31
31
  </div>
32
32
  <% end %>
33
33
  <% end %>
@@ -7,7 +7,7 @@
7
7
  'simple-mde-target': 'element',
8
8
  'component-options': @field.options.to_json,
9
9
  },
10
- disabled: @field.is_readonly?,
10
+ disabled: disabled?,
11
11
  placeholder: @field.placeholder,
12
12
  style: @field.get_html(:style, view: view, element: :input)
13
13
  %>
@@ -3,7 +3,7 @@
3
3
  <%= text_area_tag @field.id, @field.value,
4
4
  class: helpers.input_classes('w-full js-has-simple-mde-editor'),
5
5
  placeholder: @field.placeholder,
6
- disabled: @field.is_readonly?,
6
+ disabled: disabled?,
7
7
  'data-simple-mde-target': 'element',
8
8
  'data-component-options': @field.options.to_json,
9
9
  'data-view': :show %>
@@ -2,7 +2,7 @@
2
2
  <%= @form.number_field @field.id,
3
3
  class: classes("w-full"),
4
4
  data: @field.get_html(:data, view: view, element: :input),
5
- disabled: @field.is_readonly?,
5
+ disabled: disabled?,
6
6
  max: @field.max,
7
7
  min: @field.min,
8
8
  placeholder: @field.placeholder,
@@ -2,7 +2,7 @@
2
2
  <%= @form.password_field @field.id,
3
3
  class: classes("w-full"),
4
4
  data: @field.get_html(:data, view: view, element: :input),
5
- disabled: @field.is_readonly?,
5
+ disabled: disabled?,
6
6
  placeholder: @field.placeholder,
7
7
  style: @field.get_html(:style, view: view, element: :input)
8
8
  %>
@@ -7,7 +7,7 @@
7
7
  <%= @form.range_field @field.id,
8
8
  class: "w-full #{@field.get_html(:classes, view: view, element: :input)}",
9
9
  data: @field.get_html(:data, view: view, element: :input),
10
- disabled: @field.is_readonly?,
10
+ disabled: disabled?,
11
11
  max: @field.max,
12
12
  min: 0,
13
13
  placeholder: @field.placeholder,
@@ -1,5 +1,5 @@
1
1
  <%= field_wrapper **field_wrapper_args do %>
2
- <%= @form.select @field.id, @field.options_for_select, {
2
+ <%= @form.select @field.id, options_for_select(@field.options_for_select, selected: @field.value), {
3
3
  include_blank: @field.include_blank
4
4
  },
5
5
  aria: {
@@ -7,7 +7,7 @@
7
7
  },
8
8
  class: classes("w-full"),
9
9
  data: @field.get_html(:data, view: view, element: :input),
10
- disabled: @field.is_readonly?,
10
+ disabled: disabled?,
11
11
  style: @field.get_html(:style, view: view, element: :input),
12
12
  value: @field.model.present? ? @field.model[@field.id] : @field.value,
13
13
  placeholder: @field.include_blank.present? ? nil : @field.placeholder
@@ -52,4 +52,8 @@ class Avo::Fields::ShowComponent < ViewComponent::Base
52
52
  view: view
53
53
  }
54
54
  end
55
+
56
+ def disabled?
57
+ field.is_readonly? || field.is_disabled?
58
+ end
55
59
  end
@@ -2,7 +2,7 @@
2
2
  <%= @form.text_field @field.id,
3
3
  class: classes("w-full"),
4
4
  data: @field.get_html(:data, view: view, element: :input),
5
- disabled: @field.is_readonly?,
5
+ disabled: disabled?,
6
6
  placeholder: @field.placeholder,
7
7
  style: @field.get_html(:style, view: view, element: :input),
8
8
  value: @resource.model.present? ? @resource.model[@field.id] : @field.value
@@ -6,7 +6,7 @@
6
6
  data: {
7
7
  'tags-field-target': 'fakeInput',
8
8
  },
9
- disabled: @field.is_readonly?,
9
+ disabled: disabled?,
10
10
  placeholder: @field.placeholder,
11
11
  style: @field.get_html(:style, view: view, element: :input),
12
12
  value: ''
@@ -22,7 +22,7 @@
22
22
  'delimiters': @field.delimiters,
23
23
  'close-on-select': @field.close_on_select ? 1 : 0,
24
24
  },
25
- disabled: @field.is_readonly?,
25
+ disabled: disabled?,
26
26
  placeholder: @field.placeholder,
27
27
  style: @field.get_html(:style, view: view, element: :input),
28
28
  value: @field.field_value.to_json
@@ -2,7 +2,7 @@
2
2
  <%= form.text_field @field.id,
3
3
  class: classes("w-full"),
4
4
  data: @field.get_html(:data, view: view, element: :input),
5
- disabled: @field.is_readonly?,
5
+ disabled: disabled?,
6
6
  placeholder: @field.placeholder,
7
7
  style: @field.get_html(:style, view: view, element: :input),
8
8
  # value: @field.value,
@@ -2,7 +2,7 @@
2
2
  <%= @form.text_area @field.id,
3
3
  class: classes("w-full"),
4
4
  data: @field.get_html(:data, view: view, element: :input),
5
- disabled: @field.is_readonly?,
5
+ disabled: disabled?,
6
6
  placeholder: @field.placeholder,
7
7
  rows: @field.rows,
8
8
  style: @field.get_html(:style, view: view, element: :input)
@@ -20,7 +20,7 @@
20
20
  placeholder: @field.placeholder,
21
21
  **@field.get_html(:data, view: view, element: :input)
22
22
  },
23
- disabled: @field.is_readonly?,
23
+ disabled: disabled?,
24
24
  placeholder: @field.placeholder,
25
25
  style: @field.get_html(:style, view: view, element: :input)
26
26
  %>
@@ -32,7 +32,7 @@
32
32
  placeholder: @field.placeholder,
33
33
  **@field.get_html(:data, view: view, element: :input)
34
34
  },
35
- disabled: @field.is_readonly?,
35
+ disabled: disabled?,
36
36
  placeholder: @field.placeholder,
37
37
  style: @field.get_html(:style, view: view, element: :input)
38
38
  %>
@@ -1,5 +1,6 @@
1
1
  <%= field_wrapper **field_wrapper_args, full_width: true do %>
2
- <%= content_tag :div, class: "relative block overflow-x-auto max-w-full",
2
+ <%= content_tag :div,
3
+ class: "relative block overflow-x-auto max-w-full",
3
4
  data: {
4
5
  controller: "trix-field",
5
6
  trix_field_target: "controller",
@@ -24,7 +25,7 @@
24
25
  <%= @form.text_area @field.id,
25
26
  class: classes("w-full hidden"),
26
27
  data: @field.get_html(:data, view: view, element: :input),
27
- disabled: @field.is_readonly?,
28
+ disabled: disabled?,
28
29
  id: trix_id,
29
30
  placeholder: @field.placeholder,
30
31
  style: @field.get_html(:style, view: view, element: :input)
@@ -20,6 +20,10 @@ class Avo::Fields::TrixField::EditComponent < Avo::Fields::EditComponent
20
20
  end
21
21
 
22
22
  def trix_id
23
- "trix_#{resource_name}_#{@field.id}"
23
+ if resource_name.present?
24
+ "trix_#{resource_name}_#{@field.id}"
25
+ elsif form.present?
26
+ "trix_#{form.index}_#{@field.id}"
27
+ end
24
28
  end
25
29
  end
@@ -9,6 +9,6 @@
9
9
  </div>
10
10
  <% else %>
11
11
  <div class="bg-white rounded shadow-panel">
12
- <%= helpers.empty_state resource_name: @resource.name.downcase.pluralize, related_name: params[:related_name], view_type: :grid %>
12
+ <%= helpers.empty_state by_association: params[:related_name].present?, view_type: :grid %>
13
13
  </div>
14
14
  <% end %>
@@ -2,7 +2,7 @@
2
2
 
3
3
  class Avo::Index::ResourceTableComponent < ViewComponent::Base
4
4
  include Avo::ApplicationHelper
5
- attr_reader :pagy
5
+ attr_reader :pagy, :query
6
6
 
7
7
  def initialize(resources: nil, resource: nil, reflection: nil, parent_model: nil, parent_resource: nil, pagy: nil, query: nil)
8
8
  @resources = resources
@@ -15,10 +15,10 @@ class Avo::Index::ResourceTableComponent < ViewComponent::Base
15
15
  end
16
16
 
17
17
  def encrypted_query
18
- return if @query.nil?
18
+ return :select_all_disabled if query.nil? || !query.respond_to?(:all) || !query.all.respond_to?(:to_sql)
19
19
 
20
20
  Avo::Services::EncryptionService.encrypt(
21
- message: @query.all.to_sql,
21
+ message: query.all.to_sql,
22
22
  purpose: :select_all
23
23
  )
24
24
  end
@@ -25,11 +25,7 @@
25
25
  %> <%= t('avo.per_page').downcase %>
26
26
  </div>
27
27
  <% per_page_options.each do |option| %>
28
- <% if parent_model.present? %>
29
- <%= link_to "Change to #{option} items per page", helpers.related_resources_path(parent_model, parent_model, per_page: option, keep_query_params: true, page: 1), class: 'hidden', 'data-per-page-option': option, 'data-turbo-frame': turbo_frame %>
30
- <% else %>
31
- <%= link_to "Change to #{option} items per page", helpers.resources_path(resource: resource, per_page: option, keep_query_params: true, page: 1), class: 'hidden', 'data-per-page-option': option, 'data-turbo-frame': turbo_frame %>
32
- <% end %>
28
+ <%= link_to "Change to #{option} items per page", change_items_per_page_url(option), class: 'hidden', 'data-per-page-option': option, 'data-turbo-frame': turbo_frame %>
33
29
  <% end %>
34
30
  </div>
35
31
  </div>
@@ -16,4 +16,12 @@ class Avo::PaginatorComponent < ViewComponent::Base
16
16
  @parent_model = parent_model
17
17
  @discreet_pagination = discreet_pagination
18
18
  end
19
+
20
+ def change_items_per_page_url(option)
21
+ if parent_model.present?
22
+ helpers.related_resources_path(parent_model, parent_model, per_page: option, keep_query_params: true, page: 1)
23
+ else
24
+ helpers.resources_path(resource: resource, per_page: option, keep_query_params: true, page: 1)
25
+ end
26
+ end
19
27
  end
@@ -4,7 +4,7 @@
4
4
  <div class="overflow-hidden flex flex-col">
5
5
  <% if display_breadcrumbs? %>
6
6
  <div class="breadcrumbs truncate mb-2">
7
- <%= helpers.render_breadcrumbs(separator: helpers.svg('chevron-right', class: 'inline-block h-3 stroke-current relative top-[-1px] ml-1' )) if Avo.configuration.display_breadcrumbs %>
7
+ <%= helpers.render_avo_breadcrumbs(separator: helpers.svg('chevron-right', class: 'inline-block h-3 stroke-current relative top-[-1px] ml-1' )) if Avo.configuration.display_breadcrumbs %>
8
8
  </div>
9
9
  <% end %>
10
10
  <div class="text-2xl tracking-normal font-semibold text-gray-800 truncate items-center flex flex-1" data-target="title">