avo 3.11.8 → 3.11.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,3 @@
1
1
  //= link_directory ../images/avo
2
2
  //= link_directory ../svgs
3
3
  //= link_tree ../builds
4
- //= link avo-rhino_field
@@ -10,7 +10,7 @@
10
10
  } do %>
11
11
  <% @resources.each_with_index do |resource, index| %>
12
12
  <% cache_if Avo.configuration.cache_resources_on_index_view, resource.cache_hash(@parent_record) do %>
13
- <%= render(Avo::Index::GridItemComponent.new(resource: resource, reflection: @reflection, parent_record: @parent_record, parent_resource: @parent_resource, actions: actions)) %>
13
+ <%= render(resource.resolve_component(Avo::Index::GridItemComponent).new(resource: resource, reflection: @reflection, parent_record: @parent_record, parent_resource: @parent_resource, actions: actions)) %>
14
14
  <% end %>
15
15
  <% end %>
16
16
  <% end %>
@@ -5,7 +5,7 @@
5
5
  </div>
6
6
  <% if render_table? %>
7
7
  <div class="overflow-auto <%= table_component_order_class %>">
8
- <%= render(Avo::Index::ResourceTableComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_record: @parent_record, parent_resource: @parent_resource, pagy: @pagy, query: @query)) %>
8
+ <%= render(@resource.resolve_component(Avo::Index::ResourceTableComponent).new(resources: @resources, resource: @resource, reflection: @reflection, parent_record: @parent_record, parent_resource: @parent_resource, pagy: @pagy, query: @query)) %>
9
9
  </div>
10
10
  <% end %>
11
11
  </div>
@@ -71,7 +71,7 @@ class Avo::Index::ResourceTableComponent < Avo::BaseComponent
71
71
  header_fields.concat row_fields
72
72
 
73
73
  # Create a TableRowComponent instance for the resource and add it to @table_row_components
74
- table_row_components << Avo::Index::TableRowComponent.new(
74
+ table_row_components << resource.resolve_component(Avo::Index::TableRowComponent).new(
75
75
  resource: resource,
76
76
  fields: row_fields,
77
77
  reflection: @reflection,
@@ -11,7 +11,7 @@ class Avo::Index::TableRowComponent < Avo::BaseComponent
11
11
  prop :parent_resource, _Nilable(Avo::BaseResource)
12
12
  prop :actions, _Nilable(_Array(Avo::BaseAction))
13
13
  prop :fields, _Nilable(_Array(Avo::Fields::BaseField))
14
- prop :header_fields, _Nilable(_Array(Avo::Fields::BaseField))
14
+ prop :header_fields, _Nilable(_Array(String))
15
15
 
16
16
  def resource_controls_component
17
17
  Avo::Index::ResourceControlsComponent.new(
@@ -59,7 +59,7 @@
59
59
  <% if view_type.to_sym == :table %>
60
60
  <% if @resources.present? %>
61
61
  <div class="w-full relative flex-1 flex mt-0">
62
- <%= render(Avo::Index::ResourceTableComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_record: @parent_record, parent_resource: @parent_resource, pagy: @pagy, query: @query, actions: @actions)) %>
62
+ <%= render(@resource.resolve_component(Avo::Index::ResourceTableComponent).new(resources: @resources, resource: @resource, reflection: @reflection, parent_record: @parent_record, parent_resource: @parent_resource, pagy: @pagy, query: @query, actions: @actions)) %>
63
63
  </div>
64
64
  <% else %>
65
65
  <%= helpers.empty_state by_association: params[:related_name].present?, view_type: view_type, add_background: true %>
@@ -70,7 +70,7 @@
70
70
  <% if view_type.to_sym == :map %>
71
71
  <% if @resources.present? %>
72
72
  <div>
73
- <%= render(Avo::Index::ResourceMapComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_record: @parent_record, parent_resource: @parent_resource, pagy: @pagy, query: @query)) %>
73
+ <%= render(@resource.resolve_component(Avo::Index::ResourceMapComponent).new(resources: @resources, resource: @resource, reflection: @reflection, parent_record: @parent_record, parent_resource: @parent_resource, pagy: @pagy, query: @query)) %>
74
74
  </div>
75
75
  <% else %>
76
76
  <%= helpers.empty_state by_association: params[:related_name].present?, view_type: view_type, add_background: true %>
@@ -581,18 +581,14 @@ module Avo
581
581
  # Set the view component for the current view
582
582
  # It will try to use the custom component if it's set, otherwise it will use the default one
583
583
  def set_component_for(view, fallback_view: nil)
584
- # Fetch the components from the resource
585
- components = Avo::ExecutionContext.new(
586
- target: @resource.components,
587
- resource: @resource,
588
- record: @record,
589
- view: @view
590
- ).handle
584
+ default_component = "Avo::Views::Resource#{(fallback_view || view).to_s.classify}Component"
585
+
586
+ # Search for the custom component by key and by class name:
587
+ custom_component = @resource.custom_components.dig(:"resource_#{view}_component") ||
588
+ @resource.custom_components.dig(default_component)
591
589
 
592
590
  # If the component is not set, use the default one
593
- if (custom_component = components.dig(:"resource_#{view}_component")).nil?
594
- return @component = "Avo::Views::Resource#{(fallback_view || view).to_s.classify}Component".constantize
595
- end
591
+ return @component = default_component.constantize if custom_component.nil?
596
592
 
597
593
  # If the component is set, try to use it
598
594
  @component = custom_component.to_s.safe_constantize
@@ -3,8 +3,6 @@ module Avo
3
3
  include ::Pagy::Frontend
4
4
  include Avo::ResourcesHelper
5
5
 
6
- AVO_CACHED_SVGS = {}
7
-
8
6
  def render_license_warning(title: "", message: "", icon: "exclamation")
9
7
  render partial: "avo/sidebar/license_warning", locals: {
10
8
  title: title,
@@ -67,12 +65,9 @@ module Avo
67
65
 
68
66
  file_name = "#{file_name}.svg" unless file_name.end_with? ".svg"
69
67
 
70
- inline_svg svg_path(file_name), **args
71
- end
72
-
73
- # The path shouldn't change between reboots so we can memoize the paths based on the filename.
74
- def svg_path(file_name)
75
- AVO_CACHED_SVGS[file_name] ||= Avo::SvgFinder.find_asset(file_name).pathname.to_s
68
+ with_asset_finder(::Avo::SvgFinder) do
69
+ inline_svg file_name, **args
70
+ end
76
71
  end
77
72
 
78
73
  def input_classes(extra_classes = "", has_error: false)
@@ -619,6 +619,19 @@ module Avo
619
619
  @record_param ||= @record.persisted? ? @record.to_param : nil
620
620
  end
621
621
 
622
+ def custom_components
623
+ @custom_components ||= Avo::ExecutionContext.new(
624
+ target: components,
625
+ resource: self,
626
+ record: @record,
627
+ view: @view
628
+ ).handle.with_indifferent_access
629
+ end
630
+
631
+ def resolve_component(original_component)
632
+ custom_components.dig(original_component.to_s)&.to_s&.safe_constantize || original_component
633
+ end
634
+
622
635
  private
623
636
 
624
637
  def flatten_keys(array)
@@ -28,7 +28,7 @@ class Avo::SvgFinder
28
28
  Avo::Engine.root.join("app", "assets", "svgs", "heroicons", "outline", @filename),
29
29
  Avo::Engine.root.join(@filename).to_s,
30
30
  # Add all paths from Rails including engines
31
- *Rails.application.assets.paths.map { |path| File.join(path, @filename) }
31
+ *Rails.application.config.assets&.paths&.map { |path| File.join(path, @filename) }
32
32
  ].map(&:to_s).uniq
33
33
  end
34
34
 
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "3.11.8" unless const_defined?(:VERSION)
2
+ VERSION = "3.11.9" unless const_defined?(:VERSION)
3
3
  end
@@ -7346,10 +7346,6 @@ tag.tagify__tag{
7346
7346
  bottom:0.25rem
7347
7347
  }
7348
7348
 
7349
- .bottom-4{
7350
- bottom:1rem
7351
- }
7352
-
7353
7349
  .bottom-full{
7354
7350
  bottom:100%
7355
7351
  }
@@ -7394,10 +7390,6 @@ tag.tagify__tag{
7394
7390
  right:0.75rem
7395
7391
  }
7396
7392
 
7397
- .right-4{
7398
- right:1rem
7399
- }
7400
-
7401
7393
  .start-1{
7402
7394
  inset-inline-start:0.25rem
7403
7395
  }
@@ -7654,6 +7646,10 @@ tag.tagify__tag{
7654
7646
  margin-top:-1rem
7655
7647
  }
7656
7648
 
7649
+ .-mt-6{
7650
+ margin-top:-1.5rem
7651
+ }
7652
+
7657
7653
  .-mt-9{
7658
7654
  margin-top:-2.25rem
7659
7655
  }
@@ -7702,10 +7698,6 @@ tag.tagify__tag{
7702
7698
  margin-left:2.5rem
7703
7699
  }
7704
7700
 
7705
- .ml-12{
7706
- margin-left:3rem
7707
- }
7708
-
7709
7701
  .ml-2{
7710
7702
  margin-left:0.5rem
7711
7703
  }
@@ -7722,6 +7714,10 @@ tag.tagify__tag{
7722
7714
  margin-left:1.5rem
7723
7715
  }
7724
7716
 
7717
+ .ml-8{
7718
+ margin-left:2rem
7719
+ }
7720
+
7725
7721
  .ml-auto{
7726
7722
  margin-left:auto
7727
7723
  }
@@ -7913,6 +7909,16 @@ tag.tagify__tag{
7913
7909
  height:6rem
7914
7910
  }
7915
7911
 
7912
+ .size-36{
7913
+ width:9rem;
7914
+ height:9rem
7915
+ }
7916
+
7917
+ .size-48{
7918
+ width:12rem;
7919
+ height:12rem
7920
+ }
7921
+
7916
7922
  .size-6{
7917
7923
  width:1.5rem;
7918
7924
  height:1.5rem
@@ -7966,10 +7972,6 @@ tag.tagify__tag{
7966
7972
  height:1.5rem
7967
7973
  }
7968
7974
 
7969
- .h-60{
7970
- height:15rem
7971
- }
7972
-
7973
7975
  .h-64{
7974
7976
  height:16rem
7975
7977
  }
@@ -8066,10 +8068,6 @@ tag.tagify__tag{
8066
8068
  min-height:8rem
8067
8069
  }
8068
8070
 
8069
- .min-h-dvh{
8070
- min-height:100dvh
8071
- }
8072
-
8073
8071
  .min-h-full{
8074
8072
  min-height:100%
8075
8073
  }
@@ -8432,10 +8430,6 @@ tag.tagify__tag{
8432
8430
  flex-direction:column
8433
8431
  }
8434
8432
 
8435
- .flex-col-reverse{
8436
- flex-direction:column-reverse
8437
- }
8438
-
8439
8433
  .flex-wrap{
8440
8434
  flex-wrap:wrap
8441
8435
  }
@@ -9418,10 +9412,6 @@ tag.tagify__tag{
9418
9412
  padding-bottom:2rem
9419
9413
  }
9420
9414
 
9421
- .pe-1{
9422
- padding-inline-end:0.25rem
9423
- }
9424
-
9425
9415
  .pl-1{
9426
9416
  padding-left:0.25rem
9427
9417
  }
@@ -9446,10 +9436,6 @@ tag.tagify__tag{
9446
9436
  padding-top:0.125rem
9447
9437
  }
9448
9438
 
9449
- .pt-1{
9450
- padding-top:0.25rem
9451
- }
9452
-
9453
9439
  .pt-16{
9454
9440
  padding-top:4rem
9455
9441
  }
@@ -9928,12 +9914,6 @@ tag.tagify__tag{
9928
9914
  transition-duration:150ms
9929
9915
  }
9930
9916
 
9931
- .transition-colors{
9932
- transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;
9933
- transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);
9934
- transition-duration:150ms
9935
- }
9936
-
9937
9917
  .transition-opacity{
9938
9918
  transition-property:opacity;
9939
9919
  transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);
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: 3.11.8
4
+ version: 3.11.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -222,6 +222,9 @@ files:
222
222
  - Gemfile.lock
223
223
  - README.md
224
224
  - Rakefile
225
+ - app/assets/builds/avo.base.css
226
+ - app/assets/builds/avo.base.js
227
+ - app/assets/builds/avo.base.js.map
225
228
  - app/assets/config/avo_manifest.js
226
229
  - app/assets/stylesheets/avo.base.css
227
230
  - app/assets/stylesheets/css/active-storage.css