avo 3.0.0.pre13 → 3.0.0.pre14

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 (115) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +2 -1
  4. data/app/components/avo/alert_component.html.erb +1 -1
  5. data/app/components/avo/base_component.rb +7 -7
  6. data/app/components/avo/field_wrapper_component.rb +1 -1
  7. data/app/components/avo/fields/area_field/edit_component.html.erb +1 -1
  8. data/app/components/avo/fields/belongs_to_field/edit_component.html.erb +5 -5
  9. data/app/components/avo/fields/belongs_to_field/edit_component.rb +4 -4
  10. data/app/components/avo/fields/boolean_field/edit_component.html.erb +1 -0
  11. data/app/components/avo/fields/boolean_group_field/edit_component.html.erb +1 -1
  12. data/app/components/avo/fields/code_field/edit_component.html.erb +1 -0
  13. data/app/components/avo/fields/country_field/edit_component.html.erb +1 -0
  14. data/app/components/avo/fields/file_field/index_component.rb +2 -2
  15. data/app/components/avo/fields/has_one_field/show_component.html.erb +1 -0
  16. data/app/components/avo/fields/index_component.rb +1 -0
  17. data/app/components/avo/fields/location_field/show_component.html.erb +1 -1
  18. data/app/components/avo/fields/markdown_field/edit_component.html.erb +1 -0
  19. data/app/components/avo/fields/number_field/edit_component.html.erb +1 -0
  20. data/app/components/avo/fields/password_field/edit_component.html.erb +1 -0
  21. data/app/components/avo/fields/progress_bar_field/edit_component.html.erb +1 -0
  22. data/app/components/avo/fields/status_field/edit_component.html.erb +1 -1
  23. data/app/components/avo/fields/text_field/edit_component.html.erb +1 -1
  24. data/app/components/avo/fields/textarea_field/edit_component.html.erb +1 -0
  25. data/app/components/avo/fields/trix_field/edit_component.html.erb +2 -1
  26. data/app/components/avo/fields/trix_field/show_component.html.erb +1 -1
  27. data/app/components/avo/index/resource_controls_component.rb +6 -6
  28. data/app/components/avo/item_switcher_component.html.erb +9 -4
  29. data/app/components/avo/item_switcher_component.rb +2 -1
  30. data/app/components/avo/resource_component.rb +5 -3
  31. data/app/components/avo/resource_sidebar_component.rb +1 -1
  32. data/app/components/avo/row_component.html.erb +3 -0
  33. data/app/components/avo/row_component.rb +12 -0
  34. data/app/components/avo/sidebar/link_component.html.erb +2 -0
  35. data/app/components/avo/sidebar/link_component.rb +5 -3
  36. data/app/components/avo/sidebar_component.html.erb +3 -3
  37. data/app/components/avo/sidebar_component.rb +4 -4
  38. data/app/components/avo/sidebar_profile_component.html.erb +3 -3
  39. data/app/components/avo/views/resource_edit_component.rb +1 -1
  40. data/app/components/avo/views/resource_index_component.html.erb +1 -1
  41. data/app/components/avo/views/resource_index_component.rb +8 -8
  42. data/app/controllers/avo/actions_controller.rb +11 -7
  43. data/app/controllers/avo/application_controller.rb +71 -66
  44. data/app/controllers/avo/associations_controller.rb +4 -6
  45. data/app/controllers/avo/attachments_controller.rb +1 -1
  46. data/app/controllers/avo/base_controller.rb +22 -15
  47. data/app/controllers/avo/home_controller.rb +1 -1
  48. data/app/controllers/avo/search_controller.rb +14 -12
  49. data/app/controllers/concerns/avo/initializes_avo.rb +2 -5
  50. data/app/javascript/js/controllers/fields/easy_mde_controller.js +1 -0
  51. data/app/views/avo/associations/new.html.erb +1 -1
  52. data/app/views/avo/debug/status.html.erb +1 -1
  53. data/app/views/avo/partials/_custom_tools_alert.html.erb +2 -2
  54. data/app/views/avo/partials/_footer.html.erb +1 -1
  55. data/app/views/avo/partials/_javascript.html.erb +1 -1
  56. data/app/views/avo/partials/_navbar.html.erb +1 -1
  57. data/app/views/layouts/avo/application.html.erb +2 -2
  58. data/avo.gemspec +1 -0
  59. data/config/initializers/pagy.rb +12 -10
  60. data/config/routes.rb +3 -3
  61. data/db/factories.rb +2 -1
  62. data/lib/avo/base_action.rb +4 -1
  63. data/lib/avo/base_resource.rb +118 -89
  64. data/lib/avo/concerns/has_item_type.rb +4 -0
  65. data/lib/avo/concerns/has_items.rb +20 -15
  66. data/lib/avo/concerns/model_class_constantized.rb +0 -2
  67. data/lib/avo/current.rb +22 -1
  68. data/lib/avo/dsl/field_parser.rb +1 -1
  69. data/lib/avo/dynamic_router.rb +12 -1
  70. data/lib/avo/engine.rb +4 -7
  71. data/lib/avo/fields/base_field.rb +25 -3
  72. data/lib/avo/fields/belongs_to_field.rb +8 -7
  73. data/lib/avo/fields/concerns/is_searchable.rb +1 -1
  74. data/lib/avo/fields/concerns/use_resource.rb +1 -1
  75. data/lib/avo/fields/field_manager.rb +13 -3
  76. data/lib/avo/fields/has_base_field.rb +4 -4
  77. data/lib/avo/fields/has_one_field.rb +1 -1
  78. data/lib/avo/fields/location_field.rb +18 -1
  79. data/lib/avo/licensing/h_q.rb +11 -6
  80. data/lib/avo/licensing/license.rb +1 -1
  81. data/lib/avo/licensing/license_manager.rb +1 -1
  82. data/lib/avo/licensing/{null_license.rb → nil_license.rb} +1 -1
  83. data/lib/avo/loaders/fields_loader.rb +7 -1
  84. data/lib/avo/plugin_manager.rb +2 -4
  85. data/lib/avo/reloader.rb +1 -1
  86. data/lib/avo/resources/items/holder.rb +5 -1
  87. data/lib/avo/resources/items/item_group.rb +1 -0
  88. data/lib/avo/resources/items/row.rb +54 -0
  89. data/lib/avo/resources/resource_manager.rb +4 -7
  90. data/lib/avo/services/debug_service.rb +6 -6
  91. data/lib/avo/services/telemetry_service.rb +3 -3
  92. data/lib/avo/version.rb +1 -1
  93. data/lib/avo.rb +107 -25
  94. data/lib/generators/avo/action_generator.rb +8 -8
  95. data/lib/generators/avo/card_generator.rb +27 -0
  96. data/lib/generators/avo/filter_generator.rb +8 -8
  97. data/lib/generators/avo/templates/action.tt +3 -3
  98. data/lib/generators/avo/templates/cards/chartkick_card.tt +1 -1
  99. data/lib/generators/avo/templates/cards/chartkick_card_sample.tt +1 -1
  100. data/lib/generators/avo/templates/cards/metric_card.tt +1 -1
  101. data/lib/generators/avo/templates/cards/metric_card_sample.tt +1 -1
  102. data/lib/generators/avo/templates/cards/partial_card.tt +1 -1
  103. data/lib/generators/avo/templates/cards/partial_card_sample.tt +1 -1
  104. data/lib/generators/avo/templates/dashboards/dashboard.tt +1 -1
  105. data/lib/generators/avo/templates/scope.tt +1 -1
  106. data/lib/tasks/avo_tasks.rake +1 -28
  107. data/public/avo-assets/avo.base.css +26 -31
  108. data/public/avo-assets/avo.base.js +281 -280
  109. data/public/avo-assets/avo.base.js.map +3 -3
  110. metadata +21 -8
  111. data/lib/avo/app.rb +0 -170
  112. data/lib/generators/avo/card/chartkick_generator.rb +0 -18
  113. data/lib/generators/avo/card/metric_generator.rb +0 -18
  114. data/lib/generators/avo/card/partial_generator.rb +0 -19
  115. data/lib/generators/avo/templates/standalone_action.tt +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cbf17f6b86663450788938a16475eba907f1a85a400f72d0efd58b59baea131c
4
- data.tar.gz: be6d1682124dfbc7a0fdbff863b80caab538b7fdf28768d463169f2acd2fd086
3
+ metadata.gz: d0b96922b610c34442f4ef39940c378a6b5acc2638954c7eae30217fcfef32c4
4
+ data.tar.gz: '092dfa026329552be2be791d9493b4c0ca8db46caf72f7bb494e59aceab32275'
5
5
  SHA512:
6
- metadata.gz: 6c47148a510c188098e524e70c1f7782fdb6fdb0ad8592f6d1e7cdf44fb175c6973db23f4672e2361be971639a5943c44309ea69409967ebe427fc558d90367c
7
- data.tar.gz: f065601a617923ac787e0d468276d379f2cfd8798f34c9bdd604ed3a8df7c0722ded2f1013a121b0d69c9d75c85ae0b38ed7a61c745509c83264ca1502f8c9b3
6
+ metadata.gz: d1a47cfffce993596d1fd2edb977c4207ced53a597e174917848f69d3586a8d337dfcf7b131c4720cef4119ce5ff8d16577304533c4776e3e807b6307606396c
7
+ data.tar.gz: 94699f2123e35d23c0572d73137c86e025fa493c6f0637d9b7ea04ecbb93daef27ecaac42e818f3cdf01aba2dc2420aed7b18de6bb72cd87d8995afb29026ad1
data/Gemfile CHANGED
@@ -162,7 +162,7 @@ gem "sprockets-rails"
162
162
  gem "image_processing", "~> 1.12"
163
163
 
164
164
  # source "https://rubygems.pkg.github.com/avo-hq" do
165
- # gem "avo_filters"
165
+ # gem "avo-dynamic_filters"
166
166
  # end
167
167
  gem "prefixed_ids"
168
168
 
data/Gemfile.lock CHANGED
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (3.0.0.pre13)
4
+ avo (3.0.0.pre14)
5
5
  actionview (>= 6.1)
6
6
  active_link_to
7
7
  activerecord (>= 6.1)
8
+ activesupport (>= 6.1)
8
9
  addressable
9
10
  docile
10
11
  dry-initializer
@@ -10,7 +10,7 @@
10
10
  </div>
11
11
  <div class="ml-3 w-0 flex-1 pt-0.5">
12
12
  <p class="text-sm leading-5 font-semibold">
13
- <%= sanitize message %>
13
+ <%= sanitize message.to_s %>
14
14
  </p>
15
15
  </div>
16
16
  <div class="ml-4 flex-shrink-0 flex items-center">
@@ -4,7 +4,7 @@ class Avo::BaseComponent < ViewComponent::Base
4
4
  include Turbo::FramesHelper
5
5
 
6
6
  def has_with_trial(ability)
7
- ::Avo::App.license.has_with_trial(ability)
7
+ Avo.license.has_with_trial(ability)
8
8
  end
9
9
 
10
10
  private
@@ -18,7 +18,7 @@ class Avo::BaseComponent < ViewComponent::Base
18
18
 
19
19
  # Fetch the resource and hydrate it with the record
20
20
  def association_resource
21
- resource = ::Avo::App.resources.get_resource(params[:via_resource_class])
21
+ resource = Avo.resource_manager.get_resource(params[:via_resource_class])
22
22
 
23
23
  model_class = if params[:via_relation_class].present?
24
24
  ::Avo::BaseResource.get_model_by_name params[:via_relation_class]
@@ -26,23 +26,23 @@ class Avo::BaseComponent < ViewComponent::Base
26
26
  resource.model_class
27
27
  end
28
28
 
29
- resource = ::Avo::App.resources.get_resource_by_model_class model_class if resource.blank?
29
+ resource = Avo.resource_manager.get_resource_by_model_class model_class if resource.blank?
30
30
 
31
31
  record = resource.find_record params[:via_record_id], query: model_class, params: params
32
32
 
33
- resource.dup.hydrate record: record
33
+ resource.new record: record
34
34
  end
35
35
 
36
36
  # Get the resource for the resource using the klass attribute so we get the namespace too
37
37
  def reflection_resource
38
- ::Avo::App.resources.get_resource_by_model_class(@reflection.klass.to_s)
38
+ Avo.resource_manager.get_resource_by_model_class(@reflection.klass.to_s)
39
39
  rescue
40
40
  nil
41
41
  end
42
42
 
43
43
  # Get the resource for the resource using the klass attribute so we get the namespace too
44
44
  def reflection_parent_resource
45
- ::Avo::App.resources.get_resource_by_model_class(@reflection.active_record.to_s)
45
+ Avo.resource_manager.get_resource_by_model_class(@reflection.active_record.to_s)
46
46
  rescue
47
47
  nil
48
48
  end
@@ -51,7 +51,7 @@ class Avo::BaseComponent < ViewComponent::Base
51
51
  return @resource unless link_to_child_resource_is_enabled?
52
52
  return @resource if @resource.record.class.base_class == @resource.record.class
53
53
 
54
- ::Avo::App.resources.get_resource_by_model_class(@resource.record.class).dup || @resource
54
+ Avo.resource_manager.get_resource_by_model_class(@resource.record.class) || @resource
55
55
  end
56
56
 
57
57
  def link_to_child_resource_is_enabled?
@@ -43,7 +43,7 @@ class Avo::FieldWrapperComponent < ViewComponent::Base
43
43
  end
44
44
 
45
45
  def classes(extra_classes = "")
46
- "field-wrapper relative flex flex-col flex-grow pb-2 md:pb-0 leading-tight min-h-14 #{stacked? ? "field-wrapper-layout-stacked" : "field-wrapper-layout-inline md:flex-row md:items-center"} #{compact? ? "field-wrapper-size-compact" : "field-wrapper-size-regular"} #{full_width? ? "field-width-full" : "field-width-regular"} #{@classes || ""} #{extra_classes || ""} #{@field.get_html(:classes, view: view, element: :wrapper)}"
46
+ "field-wrapper relative flex flex-col grow pb-2 md:pb-0 leading-tight min-h-14 h-full #{stacked? ? "field-wrapper-layout-stacked" : "field-wrapper-layout-inline md:flex-row md:items-center"} #{compact? ? "field-wrapper-size-compact" : "field-wrapper-size-regular"} #{full_width? ? "field-width-full" : "field-width-regular"} #{@classes || ""} #{extra_classes || ""} #{@field.get_html(:classes, view: view, element: :wrapper)}"
47
47
  end
48
48
 
49
49
  def style
@@ -1,7 +1,7 @@
1
1
  <%= field_wrapper **field_wrapper_args do %>
2
2
  <%= @form.text_field field.id,
3
- class: classes("w-full"),
4
3
  value: field.value.to_s,
4
+ class: classes("w-full"),
5
5
  placeholder: field.placeholder,
6
6
  disabled: disabled? %>
7
7
  <% end %>
@@ -2,7 +2,7 @@
2
2
  <%
3
3
  # Set the model keys so we can pass them over
4
4
  model_keys = @field.types.map do |type|
5
- resource = Avo::App.resources.get_resource_by_model_class(type.to_s)
5
+ resource = Avo.resource_manager.get_resource_by_model_class(type.to_s)
6
6
  [type.to_s, resource.model_key]
7
7
  end.to_h
8
8
  %>
@@ -13,7 +13,7 @@
13
13
  data-association-class="<%= @field&.target_resource&.model_class || nil %>"
14
14
  >
15
15
  <%= field_wrapper **field_wrapper_args, help: @field.polymorphic_help || '' do %>
16
- <%= @form.select @field.type_input_foreign_key, @field.types.map { |type| [::Avo::App.resources.get_resource_by_model_class(type.to_s).name, type.to_s] },
16
+ <%= @form.select @field.type_input_foreign_key, @field.types.map { |type| [Avo.resource_manager.get_resource_by_model_class(type.to_s).name, type.to_s] },
17
17
  {
18
18
  value: @field.value,
19
19
  include_blank: @field.placeholder,
@@ -40,9 +40,9 @@
40
40
  data-belongs-to-field-target="type"
41
41
  data-type="<%= type %>"
42
42
  >
43
- <%= field_wrapper **field_wrapper_args, label: ::Avo::App.resources.get_resource_by_model_class(type.to_s).name do %>
43
+ <%= field_wrapper **field_wrapper_args, label: Avo.resource_manager.get_resource_by_model_class(type.to_s).name do %>
44
44
  <% if @field.is_searchable? %>
45
- <%= render AvoPro::SearchableAssociations::AutocompleteComponent.new form: @form,
45
+ <%= render Avo::Pro::SearchableAssociations::AutocompleteComponent.new form: @form,
46
46
  disabled: disabled,
47
47
  field: @field,
48
48
  foreign_key: @field.id_input_foreign_key,
@@ -81,7 +81,7 @@
81
81
  <% else %>
82
82
  <%= field_wrapper **field_wrapper_args do %>
83
83
  <% if @field.is_searchable? %>
84
- <%= render AvoPro::SearchableAssociations::AutocompleteComponent.new form: @form,
84
+ <%= render Avo::Pro::SearchableAssociations::AutocompleteComponent.new form: @form,
85
85
  field: @field,
86
86
  model_key: @field.target_resource&.model_key,
87
87
  foreign_key: @field.id_input_foreign_key,
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
4
- def initialize(field: nil, resource: nil, index: 0, form: nil, compact: false, **args)
5
- super field: field, resource: resource, index: index, form: form, compact: compact, **args
4
+ def initialize(...)
5
+ super(...)
6
6
 
7
7
  @polymorphic_record = nil
8
8
  end
@@ -32,7 +32,7 @@ class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
32
32
  end
33
33
 
34
34
  def polymorphic_resource
35
- Avo::App.resources.get_resource_by_model_class(polymorphic_class)
35
+ Avo.resource_manager.get_resource_by_model_class(polymorphic_class)
36
36
  end
37
37
 
38
38
  # Get the polymorphic id
@@ -60,6 +60,6 @@ class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
60
60
  private
61
61
 
62
62
  def visit_through_association?
63
- @field.target_resource.class.to_s == params[:via_resource_class].to_s
63
+ @field.target_resource.to_s == params[:via_resource_class].to_s
64
64
  end
65
65
  end
@@ -1,6 +1,7 @@
1
1
  <%= field_wrapper **field_wrapper_args, dash_if_blank: false do %>
2
2
  <div class="h-8 flex items-center">
3
3
  <%= @form.check_box @field.id,
4
+ value: @field.value,
4
5
  checked: @field.value,
5
6
  class: "text-lg h-4 w-4 checked:bg-primary-400 focus:checked:!bg-primary-400 rounded #{@field.get_html(:classes, view: view, element: :input)}",
6
7
  data: @field.get_html(:data, view: view, element: :input),
@@ -2,7 +2,7 @@
2
2
  <div class="flex items-center">
3
3
  <div class="space-y-2">
4
4
  <% model_param_key = model_name_from_record_or_class(@resource.record).param_key %>
5
- <%= check_box_tag "#{model_name_from_record_or_class(@resource.record).param_key}[#{@field.id}][]", '', true, { class: "hidden" } %>
5
+ <%= check_box_tag "#{model_param_key}[#{@field.id}][]", '', true, { class: "hidden" } %>
6
6
  <% @field.options.each do |id, label| %>
7
7
  <%
8
8
  checked = false
@@ -1,6 +1,7 @@
1
1
  <%= field_wrapper **field_wrapper_args, full_width: true do %>
2
2
  <div data-controller="code-field">
3
3
  <%= @form.text_area @field.id,
4
+ value: @field.value,
4
5
  class: classes("w-full"),
5
6
  data: {
6
7
  'code-field-target': 'element',
@@ -1,5 +1,6 @@
1
1
  <%= field_wrapper **field_wrapper_args do %>
2
2
  <%= @form.select @field.id, @field.select_options, {
3
+ value: @field.value,
3
4
  selected: @field.value,
4
5
  include_blank: @field.include_blank
5
6
  },
@@ -6,10 +6,10 @@ class Avo::Fields::FileField::IndexComponent < Avo::Fields::IndexComponent
6
6
  end
7
7
 
8
8
  def has_image_tag?
9
- @field.value.attached? && @field.value.representable? && @field.is_image
9
+ field.value.present? && field.value.attached? && field.value.representable? && field.is_image
10
10
  end
11
11
 
12
12
  def has_audio_tag?
13
- @field.value.attached? && @field.is_audio
13
+ field.value.present? && field.value.attached? && field.is_audio
14
14
  end
15
15
  end
@@ -9,6 +9,7 @@
9
9
  <%= a_link attach_path,
10
10
  icon: 'heroicons/outline/link',
11
11
  color: :primary,
12
+ style: :text,
12
13
  'data-turbo-frame': 'attach_modal' do %>
13
14
  <%= t('avo.attach_item', item: @field.name.downcase) %>
14
15
  <% end %>
@@ -3,6 +3,7 @@
3
3
  class Avo::Fields::IndexComponent < Avo::BaseComponent
4
4
  include Avo::ResourcesHelper
5
5
 
6
+ attr_reader :field
6
7
  attr_reader :parent_resource
7
8
  attr_reader :view
8
9
 
@@ -1,6 +1,6 @@
1
1
  <%= field_wrapper **field_wrapper_args do %>
2
2
  <% if field.value_present? %>
3
- <%= js_map [{latitude: field.value[0], longitude: field.value[1]}], id: "location-map" %>
3
+ <%= js_map [{latitude: field.value[0], longitude: field.value[1]}], id: "location-map", zoom: field.zoom, controls: true %>
4
4
  <% else %>
5
5
 
6
6
  <% end %>
@@ -1,6 +1,7 @@
1
1
  <%= field_wrapper **field_wrapper_args, full_width: true do %>
2
2
  <div data-controller="easy-mde">
3
3
  <%= @form.text_area @field.id,
4
+ value: @field.value,
4
5
  class: classes("w-full js-has-easy-mde-editor"),
5
6
  data: {
6
7
  view: view,
@@ -1,5 +1,6 @@
1
1
  <%= field_wrapper **field_wrapper_args do %>
2
2
  <%= @form.number_field @field.id,
3
+ value: @field.value,
3
4
  class: classes("w-full"),
4
5
  data: @field.get_html(:data, view: view, element: :input),
5
6
  disabled: disabled?,
@@ -1,5 +1,6 @@
1
1
  <%= field_wrapper **field_wrapper_args do %>
2
2
  <%= @form.password_field @field.id,
3
+ value: @field.value,
3
4
  class: classes("w-full"),
4
5
  data: @field.get_html(:data, view: view, element: :input),
5
6
  disabled: disabled?,
@@ -6,6 +6,7 @@
6
6
  </div>
7
7
  <% end %>
8
8
  <%= @form.range_field @field.id,
9
+ value: @field.value,
9
10
  class: "w-full #{@field.get_html(:classes, view: view, element: :input)}",
10
11
  data: {
11
12
  action: "input->progress-bar-field#update",
@@ -5,6 +5,6 @@
5
5
  disabled: disabled?,
6
6
  placeholder: @field.placeholder,
7
7
  style: @field.get_html(:style, view: view, element: :input),
8
- value: @resource.record.present? ? @resource.record[@field.id] : @field.value
8
+ value: @field.value
9
9
  %>
10
10
  <% end %>
@@ -1,11 +1,11 @@
1
1
  <%= field_wrapper **field_wrapper_args do %>
2
2
  <%= form.text_field @field.id,
3
+ value: @field.value,
3
4
  class: classes("w-full"),
4
5
  data: @field.get_html(:data, view: view, element: :input),
5
6
  disabled: disabled?,
6
7
  placeholder: @field.placeholder,
7
8
  style: @field.get_html(:style, view: view, element: :input),
8
- # value: @field.value,
9
9
  multiple: multiple,
10
10
  autocomplete: @field.autocomplete
11
11
  %>
@@ -1,5 +1,6 @@
1
1
  <%= field_wrapper **field_wrapper_args do %>
2
2
  <%= @form.text_area @field.id,
3
+ value: @field.value,
3
4
  class: classes("w-full"),
4
5
  data: @field.get_html(:data, view: view, element: :input),
5
6
  disabled: disabled?,
@@ -20,9 +20,10 @@
20
20
  },
21
21
  input: trix_id,
22
22
  placeholder: @field.placeholder do %>
23
- <%= sanitize @field.value %>
23
+ <%= sanitize @field.value.to_s %>
24
24
  <% end %>
25
25
  <%= @form.text_area @field.id,
26
+ value: @field.value,
26
27
  class: classes("w-full hidden"),
27
28
  data: @field.get_html(:data, view: view, element: :input),
28
29
  disabled: disabled?,
@@ -8,7 +8,7 @@
8
8
  <%= link_to t('avo.show_content'), 'javascript:void(0);', class: 'font-bold inline-block', data: { action: 'click->hidden-input#showContent' } %>
9
9
  <% end %>
10
10
  <div class="<%= content_classes %> " data-hidden-input-target="content">
11
- <%= sanitize @field.value %>
11
+ <%= sanitize @field.value.to_s %>
12
12
  </div>
13
13
  </div>
14
14
  <% end %>
@@ -44,7 +44,7 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
44
44
  }
45
45
  end
46
46
 
47
- helpers.resource_path(record: @resource.record, resource: parent_or_child_resource , **args)
47
+ helpers.resource_path(record: @resource.record, resource: parent_or_child_resource, **args)
48
48
  end
49
49
 
50
50
  def edit_path
@@ -73,7 +73,7 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
73
73
  return @parent_resource if @parent_resource.present?
74
74
  return nil if @parent_record.blank?
75
75
 
76
- ::Avo::App.resources.get_resource_by_model_class @parent_record.class
76
+ Avo.resource_manager.get_resource_by_model_class @parent_record.class
77
77
  end
78
78
 
79
79
  def is_has_many_association
@@ -81,11 +81,11 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
81
81
  end
82
82
 
83
83
  def referrer_path
84
- Avo::App.root_path(paths: ["resources", params[:resource_name], params[:id], params[:related_name]], query: request.query_parameters.to_h)
84
+ Avo.root_path(paths: ["resources", params[:resource_name], params[:id], params[:related_name]], query: request.query_parameters.to_h)
85
85
  end
86
86
 
87
87
  def can_reorder?
88
- return false unless Object.const_defined? "AvoPro::Ordering"
88
+ return false unless Object.const_defined? "Avo::Pro::Ordering"
89
89
 
90
90
  return authorize_association_for(:reorder) if @reflection.present?
91
91
 
@@ -167,13 +167,13 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
167
167
  target: "control:detach",
168
168
  control: :detach,
169
169
  "resource-id": @resource.record.id,
170
- "tippy": "tooltip",
170
+ tippy: :tooltip,
171
171
  }
172
172
  end
173
173
 
174
174
  def render_order_controls(control)
175
175
  if can_reorder?
176
- render AvoPro::Ordering::ButtonsComponent.new resource: @resource, reflection: @reflection, view_type: @view_type
176
+ render Avo::Pro::Ordering::ButtonsComponent.new resource: @resource, reflection: @reflection, view_type: @view_type
177
177
  end
178
178
  end
179
179
 
@@ -7,10 +7,7 @@
7
7
  <% c.with_body do %>
8
8
  <div class="divide-y">
9
9
  <% item.visible_items.each_with_index do |field, index| %>
10
- <%= render field
11
- .hydrate(resource: @resource, record: @resource.record, user: resource.user, view: view)
12
- .component_for_view(view)
13
- .new(field: field, resource: @resource, index: index, form: form) %>
10
+ <%= render Avo::ItemSwitcherComponent.new resource: @resource, item: field, index: index, view: @view, form: form %>
14
11
  <% end %>
15
12
  </div>
16
13
  <% end %>
@@ -19,4 +16,12 @@
19
16
  <%= render tab_group_component %>
20
17
  <% elsif item.is_field? %>
21
18
  <%= render field_component %>
19
+ <% elsif item.is_row? %>
20
+ <%= render Avo::RowComponent.new do |c| %>
21
+ <% c.with_body do %>
22
+ <% item.visible_items.each_with_index do |field, index| %>
23
+ <%= render Avo::ItemSwitcherComponent.new resource: @resource, item: field, index: index, view: @view, form: form %>
24
+ <% end %>
25
+ <% end %>
26
+ <% end %>
22
27
  <% end %>
@@ -42,6 +42,7 @@ class Avo::ItemSwitcherComponent < Avo::BaseComponent
42
42
  end
43
43
 
44
44
  def field_component
45
- item.component_for_view(@view).new(field: item.hydrate(resource: @resource, view: @view, record: @resource.record), resource: @resource, index: index, form: form)
45
+ final_item = item.dup.hydrate(resource: @resource, record: @resource.record, user: resource.user, view: view)
46
+ final_item.component_for_view(@view).new(field: final_item, resource: @resource, index: index, form: form)
46
47
  end
47
48
  end
@@ -102,7 +102,7 @@ class Avo::ResourceComponent < Avo::BaseComponent
102
102
  end
103
103
 
104
104
  def sidebar
105
- return if Avo::App.license.lacks_with_trial(:resource_sidebar)
105
+ return if Avo.license.lacks_with_trial(:resource_sidebar)
106
106
 
107
107
  @sidebar ||= search_for_sidebar
108
108
  end
@@ -113,7 +113,8 @@ class Avo::ResourceComponent < Avo::BaseComponent
113
113
 
114
114
  def has_reflection_and_is_read_only
115
115
  if @reflection.present? && @reflection.active_record.name && @reflection.name
116
- fields = ::Avo::App.resources.get_resource_by_model_class(@reflection.active_record.name).get_field_definitions
116
+ resource = Avo.resource_manager.get_resource_by_model_class(@reflection.active_record.name).new(params: helpers.params, view: view, user: helpers.current_user)
117
+ fields = resource.get_field_definitions
117
118
  filtered_fields = fields.filter { |f| f.id == @reflection.name }
118
119
  else
119
120
  return false
@@ -287,7 +288,8 @@ class Avo::ResourceComponent < Avo::BaseComponent
287
288
  end
288
289
 
289
290
  def render_action(action)
290
- return unless can_see_the_actions_button?
291
+ return if !can_see_the_actions_button?
292
+ return if !action.action.visible_in_view(parent_resource: @parent_resource)
291
293
 
292
294
  a_link action.path,
293
295
  color: action.color,
@@ -16,6 +16,6 @@ class Avo::ResourceSidebarComponent < ViewComponent::Base
16
16
  end
17
17
 
18
18
  def render?
19
- Avo::App.license.has_with_trial(:resource_sidebar)
19
+ Avo.license.has_with_trial(:resource_sidebar)
20
20
  end
21
21
  end
@@ -0,0 +1,3 @@
1
+ <div class="flex flex-col sm:flex-row min-h-14 grow shrink-0" data-component="<%= self.class %>">
2
+ <%= body %>
3
+ </div>
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Avo::RowComponent < ViewComponent::Base
4
+ attr_reader :classes
5
+
6
+ renders_one :body
7
+
8
+ def initialize(classes: nil, data: {})
9
+ @classes = classes
10
+ @data = data
11
+ end
12
+ end
@@ -1,5 +1,6 @@
1
1
  <% if path.present? %>
2
2
  <%= send link_method, path, class: classes, active: active, target: target, data: data do %>
3
+ <%= helpers.svg icon, class: "h-4 text-gray-700" if icon.present? %>
3
4
  <%= label %>
4
5
  <% if target == :_blank %>
5
6
  <%= helpers.svg('heroicons/outline/external-link', class: 'self-center ml-auto h-3 mr-2') %>
@@ -7,6 +8,7 @@
7
8
  <% end %>
8
9
  <% else %>
9
10
  <%= content_tag :div, class: classes, active: active, target: target, data: data do %>
11
+ <%= helpers.svg icon, class: "h-4 text-gray-700" if icon.present? %>
10
12
  <%= label %>
11
13
  <% end %>
12
14
  <% end %>
@@ -6,18 +6,20 @@ class Avo::Sidebar::LinkComponent < ViewComponent::Base
6
6
  attr_reader :label
7
7
  attr_reader :path
8
8
  attr_reader :data
9
+ attr_reader :icon
9
10
 
10
- def initialize(label: nil, path: nil, active: :inclusive, target: nil, data: {})
11
+ def initialize(label: nil, path: nil, active: :inclusive, target: nil, data: {}, icon: nil)
11
12
  @label = label
12
13
  @path = path
13
14
  @active = active
14
15
  @target = target
15
16
  @data = data
17
+ @icon = icon
16
18
  end
17
19
 
18
20
  def is_external?
19
21
  # If the path contains the scheme, check if it includes the root path or not
20
- return !path.include?(Avo::App.mount_path) if URI(path).scheme.present?
22
+ return !path.include?(Avo.mount_path) if URI(path).scheme.present?
21
23
 
22
24
  false
23
25
  end
@@ -28,6 +30,6 @@ class Avo::Sidebar::LinkComponent < ViewComponent::Base
28
30
  end
29
31
 
30
32
  def classes
31
- "px-4 pr-0 flex-1 flex mx-6 leading-none py-2 text-black rounded font-medium hover:bg-gray-100"
33
+ "px-4 pr-0 flex-1 flex mx-6 leading-none py-2 text-black rounded font-medium hover:bg-gray-100 gap-1"
32
34
  end
33
35
  end
@@ -13,8 +13,8 @@
13
13
  <div class="space-y-6 mb-4">
14
14
  <%= render Avo::Sidebar::LinkComponent.new label: 'Get started', path: helpers.avo.root_path, active: :exclusive if Rails.env.development? && Avo.configuration.home_path.nil? %>
15
15
 
16
- <% if Avo.plugin_manager.installed?(:avo_menu) && Avo::App.has_main_menu? %>
17
- <% Avo::App.main_menu.items.each do |item| %>
16
+ <% if Avo.plugin_manager.installed?("avo-menu") && Avo.has_main_menu? %>
17
+ <% Avo.main_menu.items.each do |item| %>
18
18
  <%= render Avo::Sidebar::ItemSwitcherComponent.new item: item %>
19
19
  <% end %>
20
20
  <% else %>
@@ -60,7 +60,7 @@
60
60
  <% if Rails.env.development? %>
61
61
  <div class="p-4 border-t group">
62
62
  <%= link_to helpers.avo.avo_private_status_path, class: "block px-4 py-2 border rounded flex justify-between items-center w-full text-black text-sm" do %>
63
- <span>Avo Status</span> <span><div class="rounded-full w-4 h-4 <%= Avo::App.instance.app_status ? "bg-green-400" : "bg-orange-400" %>"></div></span>
63
+ <span>Avo Status</span> <span><div class="rounded-full w-4 h-4 <%= Avo.app_status ? "bg-green-400" : "bg-orange-400" %>"></div></span>
64
64
  <% end %>
65
65
  <div class="absolute text-xs text-gray-700 group-hover:block hidden text-center w-full -ml-4">👆Visible only in development👆</div>
66
66
  </div>
@@ -7,17 +7,17 @@ class Avo::SidebarComponent < ViewComponent::Base
7
7
  end
8
8
 
9
9
  def dashboards
10
- return [] unless defined?(AvoDashboards)
10
+ return [] unless defined?(Avo::Dashboards)
11
11
 
12
- AvoDashboards.dashboard_manager.dashboards_for_navigation
12
+ Avo::Dashboards.dashboard_manager.dashboards_for_navigation
13
13
  end
14
14
 
15
15
  def resources
16
- Avo::Current.app.resource_manager.resources_for_navigation helpers._current_user
16
+ Avo.resource_manager.resources_for_navigation helpers._current_user
17
17
  end
18
18
 
19
19
  def tools
20
- Avo::App.tools.tools_for_navigation
20
+ Avo.tool_manager.tools_for_navigation
21
21
  end
22
22
 
23
23
  def stimulus_target
@@ -30,10 +30,10 @@
30
30
  data-transition-leave-start="transform opacity-100 translate-y-0"
31
31
  data-transition-leave-end="transform opacity-0 translate-y-1"
32
32
  >
33
- <% if Avo.plugin_manager.installed?(:avo_menu) && Avo::App.has_profile_menu? %>
33
+ <% if Avo.plugin_manager.installed?("avo-menu") && Avo.has_profile_menu? %>
34
34
  <div class="text-black space-y-4">
35
- <% Avo::App.profile_menu.items.each do |item| %>
36
- <% if item.is_a? AvoMenu::Link %>
35
+ <% Avo.profile_menu.items.each do |item| %>
36
+ <% if item.is_a? Avo::Menu::Link %>
37
37
  <%= render Avo::ProfileItemComponent.new label: item.name, path: item.path, icon: item.icon %>
38
38
  <% end %>
39
39
  <% end %>
@@ -79,6 +79,6 @@ class Avo::Views::ResourceEditComponent < Avo::ResourceComponent
79
79
 
80
80
  # Render :show view for read only trix fields
81
81
  def view_for(field)
82
- (field.is_a? Avo::Fields::TrixField) && field.is_disabled? ? :show : view
82
+ field.is_a?(Avo::Fields::TrixField) && field.is_disabled? ? :show : view
83
83
  end
84
84
  end
@@ -34,7 +34,7 @@
34
34
  </div>
35
35
  </div>
36
36
  <% if Avo.avo_filters_installed? && resource.has_filters? %>
37
- <%= render AvoFilters::FiltersComponent.new resource: resource, turbo_frame: turbo_frame %>
37
+ <%= render Avo::DynamicFilters::FiltersComponent.new resource: resource, turbo_frame: turbo_frame %>
38
38
  <% end %>
39
39
  </div>
40
40
  </div>