avo 1.0.4 → 1.3.0.pre.1

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 (81) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -1
  3. data/Gemfile.lock +11 -3
  4. data/README.md +3 -1
  5. data/app/components/avo/common/key_value_component.html.erb +53 -0
  6. data/app/components/avo/common/key_value_component.rb +11 -0
  7. data/app/components/avo/edit/fields/belongs_to_field_component.html.erb +0 -1
  8. data/app/components/avo/edit/fields/belongs_to_field_component.rb +7 -0
  9. data/app/components/avo/edit/fields/key_value_field_component.html.erb +3 -0
  10. data/app/components/avo/edit/fields/key_value_field_component.rb +4 -0
  11. data/app/components/avo/index/grid_cover_empty_state_component.html.erb +3 -0
  12. data/app/components/avo/index/grid_cover_empty_state_component.rb +4 -0
  13. data/app/components/avo/index/grid_item_component.html.erb +4 -4
  14. data/app/components/avo/modal_component.rb +2 -1
  15. data/app/components/avo/panel_component.html.erb +7 -2
  16. data/app/components/avo/panel_component.rb +4 -1
  17. data/app/components/avo/show/fields/has_one_field_component.html.erb +3 -3
  18. data/app/components/avo/show/fields/key_value_field_component.html.erb +3 -0
  19. data/app/components/avo/show/fields/key_value_field_component.rb +4 -0
  20. data/app/components/avo/views/resource_edit_component.html.erb +3 -3
  21. data/app/components/avo/views/resource_index_component.html.erb +4 -4
  22. data/app/components/avo/views/resource_new_component.html.erb +3 -3
  23. data/app/components/avo/views/resource_show_component.html.erb +2 -2
  24. data/app/controllers/avo/application_controller.rb +12 -8
  25. data/app/controllers/avo/base_controller.rb +16 -0
  26. data/app/controllers/avo/home_controller.rb +2 -0
  27. data/app/helpers/avo/application_helper.rb +0 -30
  28. data/app/packs/entrypoints/application.css +1 -0
  29. data/app/packs/entrypoints/application.js +14 -10
  30. data/app/packs/js/controllers/fields/key_value_controller.js +132 -0
  31. data/app/packs/stylesheets/breadcrumbs.css +12 -0
  32. data/app/packs/svgs/chevron-right.svg +3 -0
  33. data/app/views/avo/actions/show.html.erb +2 -2
  34. data/app/views/avo/home/index.html.erb +3 -3
  35. data/{lib/generators/avo/templates → app/views/avo}/partials/_scripts.html.erb +0 -0
  36. data/app/views/avo/relations/new.html.erb +2 -2
  37. data/app/views/avo/sidebar/_sidebar.html.erb +11 -2
  38. data/app/views/layouts/avo/application.html.erb +5 -4
  39. data/avo.gemspec +2 -0
  40. data/lib/avo/app.rb +28 -9
  41. data/lib/avo/base_resource.rb +12 -12
  42. data/lib/avo/configuration.rb +11 -1
  43. data/lib/avo/fields/belongs_to_field.rb +0 -2
  44. data/lib/avo/fields/key_value_field.rb +24 -1
  45. data/lib/avo/grid_collector.rb +1 -1
  46. data/lib/avo/version.rb +1 -1
  47. data/lib/generators/avo/eject_generator.rb +55 -0
  48. data/lib/generators/avo/templates/tool/controller.tt +2 -0
  49. data/lib/generators/avo/templates/tool/sidebar_item.tt +1 -0
  50. data/lib/generators/avo/templates/tool/view.tt +27 -0
  51. data/lib/generators/avo/tool_generator.rb +62 -0
  52. data/public/avo-packs/css/{application-9d115b7e.css → application-5af67922.css} +132 -24
  53. data/public/avo-packs/css/application-5af67922.css.br +0 -0
  54. data/public/avo-packs/css/application-5af67922.css.gz +0 -0
  55. data/public/avo-packs/css/application-5af67922.css.map +1 -0
  56. data/public/avo-packs/css/application-5af67922.css.map.br +0 -0
  57. data/public/avo-packs/css/application-5af67922.css.map.gz +0 -0
  58. data/public/avo-packs/js/application-a48a99244065c8d7a1d1.js +26 -0
  59. data/public/avo-packs/js/{application-e351ef988a3cb9687542.js.LICENSE.txt → application-a48a99244065c8d7a1d1.js.LICENSE.txt} +0 -0
  60. data/public/avo-packs/js/application-a48a99244065c8d7a1d1.js.br +0 -0
  61. data/public/avo-packs/js/application-a48a99244065c8d7a1d1.js.gz +0 -0
  62. data/public/avo-packs/js/application-a48a99244065c8d7a1d1.js.map +1 -0
  63. data/public/avo-packs/js/application-a48a99244065c8d7a1d1.js.map.br +0 -0
  64. data/public/avo-packs/js/application-a48a99244065c8d7a1d1.js.map.gz +0 -0
  65. data/public/avo-packs/manifest.json +15 -15
  66. metadata +62 -22
  67. data/lib/generators/avo/partials_generator.rb +0 -14
  68. data/lib/generators/avo/templates/partials/_footer.html.erb +0 -3
  69. data/lib/generators/avo/templates/partials/_header.html.erb +0 -1
  70. data/lib/generators/avo/templates/partials/_logo.html.erb +0 -1
  71. data/public/avo-packs/css/application-9d115b7e.css.br +0 -0
  72. data/public/avo-packs/css/application-9d115b7e.css.gz +0 -0
  73. data/public/avo-packs/css/application-9d115b7e.css.map +0 -1
  74. data/public/avo-packs/css/application-9d115b7e.css.map.br +0 -0
  75. data/public/avo-packs/css/application-9d115b7e.css.map.gz +0 -0
  76. data/public/avo-packs/js/application-e351ef988a3cb9687542.js +0 -26
  77. data/public/avo-packs/js/application-e351ef988a3cb9687542.js.br +0 -0
  78. data/public/avo-packs/js/application-e351ef988a3cb9687542.js.gz +0 -0
  79. data/public/avo-packs/js/application-e351ef988a3cb9687542.js.map +0 -1
  80. data/public/avo-packs/js/application-e351ef988a3cb9687542.js.map.br +0 -0
  81. data/public/avo-packs/js/application-e351ef988a3cb9687542.js.map.gz +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f9541820f46494f3f993a870b717fb817ecaa83f4bd8cc6aa8b9e80d586a0cb
4
- data.tar.gz: f9bd42e6372e23153ac57aefb13373cdb9662f74bf410ee82e25f7d482c64626
3
+ metadata.gz: a62f55a2092f0dd2716cdaacc87e2eea086745d164d032ff8024757748830e54
4
+ data.tar.gz: a104302aecf8c7f57ac9915fe61eaf26866d3ac25678f40eee2b2244de5d3664
5
5
  SHA512:
6
- metadata.gz: 49d6e0faa8b0ac9386702b11cf7301f993211c89bb4f8368b8c6fefaa09167c492d9f5bc6f55cf622854d1c56231924dfa4fd78b9664cab49bd09cb0a56d33da
7
- data.tar.gz: ba3295cd86157590af2b60bd364089210aa8e8b516b22b7cd4e8ddf09b6b9ca4e700216d099cf2722973e6125aa876c3f349b56c17ecfc00ae4457e5f3d42d2e
6
+ metadata.gz: 88e0ca48ccbc7ff735cbf14178e8bfce1085b34996ed3cad80238e3a625adc0eeab918092b5fee304a3fc31ab9d2465a5f0b5580aac6b5efd308b09218f340cd
7
+ data.tar.gz: 8b1847c9083ef9998ee2e6a49202addcb9e670c2b5fa1904672287bfa902dd886df4ed5a6ba21de1f5db9020a3a1bc1e5e868765d672677928840d9c14ad83e1
data/Gemfile CHANGED
@@ -52,7 +52,7 @@ gem "byebug", platforms: [:mri, :mingw, :x64_mingw]
52
52
  gem "dotenv-rails"
53
53
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
54
54
  gem "web-console", ">= 3.3.0"
55
- gem "listen", ">= 3.3.0"
55
+ gem "listen", ">= 3.5.1"
56
56
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
57
57
  gem "spring"
58
58
 
@@ -119,3 +119,7 @@ gem "view_component", require: "view_component/engine"
119
119
  gem "addressable"
120
120
 
121
121
  gem "appraisal"
122
+
123
+ gem 'meta-tags'
124
+
125
+ gem 'breadcrumbs_on_rails'
data/Gemfile.lock CHANGED
@@ -1,13 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (1.0.4)
4
+ avo (1.3.0.pre.1)
5
5
  active_link_to
6
6
  addressable
7
+ breadcrumbs_on_rails
7
8
  countries
8
9
  hotwire-rails
9
10
  httparty
10
11
  image_processing
12
+ meta-tags
11
13
  pagy
12
14
  pundit
13
15
  rails (>= 6.0)
@@ -87,6 +89,8 @@ GEM
87
89
  bindex (0.8.1)
88
90
  bootsnap (1.4.8)
89
91
  msgpack (~> 1.0)
92
+ breadcrumbs_on_rails (4.0.0)
93
+ rails (>= 5.0)
90
94
  builder (3.2.4)
91
95
  bump (0.9.0)
92
96
  byebug (11.1.3)
@@ -161,6 +165,8 @@ GEM
161
165
  mail (2.7.1)
162
166
  mini_mime (>= 0.1.1)
163
167
  marcel (1.0.0)
168
+ meta-tags (2.14.0)
169
+ actionpack (>= 3.2.0, < 6.2)
164
170
  method_source (1.0.0)
165
171
  mime-types (3.3.1)
166
172
  mime-types-data (~> 3.2015)
@@ -356,6 +362,7 @@ DEPENDENCIES
356
362
  appraisal
357
363
  avo!
358
364
  bootsnap (>= 1.4.2)
365
+ breadcrumbs_on_rails
359
366
  bump
360
367
  byebug
361
368
  capybara (>= 2.15)
@@ -372,7 +379,8 @@ DEPENDENCIES
372
379
  image_processing (~> 1.2)
373
380
  iso
374
381
  jbuilder (~> 2.7)
375
- listen (>= 3.3.0)
382
+ listen (>= 3.5.1)
383
+ meta-tags
376
384
  pg (>= 0.18, < 2.0)
377
385
  puma (~> 4.3.5)
378
386
  pundit
@@ -397,4 +405,4 @@ DEPENDENCIES
397
405
  zeitwerk (~> 2.3)
398
406
 
399
407
  BUNDLED WITH
400
- 2.2.15
408
+ 2.2.5
data/README.md CHANGED
@@ -15,10 +15,12 @@ Avo is a beautiful next-generation framework that empowers you, the developer, t
15
15
  **Documentation**: [docs.avohq.io](https://docs.avohq.io)\
16
16
  **Twitter**: [avo_hq](https://twitter.com/avo_hq)\
17
17
  **Community chat**: [discord](https://discord.gg/pkTF6y8)\
18
- **Issue tracker**: [GitHub issues](http://github.com/avo-hq/avo/issues)
18
+ **Issue tracker**: [GitHub issues](http://github.com/avo-hq/avo/issues)\
19
+ **Discussions and feature requests**: [GitHub issues](http://github.com/avo-hq/avo/discussions)
19
20
 
20
21
  ## Features
21
22
 
23
+ - **Powered by Hotwire** - Rails ❤️ Hotwire
22
24
  - **Code driven configuration** - Configure your Rails dashboard entirely by writing Ruby code.
23
25
  - **Resource Management** - Create a CRUD interface for Active Record from one command. No more copy-pasting view and controller files around.
24
26
  - **Active Storage support** - Amazingly easy, **one-line**, single or multi-file integration with **ActiveStorage**.
@@ -0,0 +1,53 @@
1
+ <div class="w-full shadow-lg rounded-lg overflow-hidden"
2
+ data-controller="key-value"
3
+ data-key-value-target="controller"
4
+ data-options="<%= @field.options.to_json %>"
5
+ data-input-classes="<%= input_classes %>"
6
+ data-editable="<%= @view.in?([:edit, :create]) %>"
7
+ >
8
+ <div class="w-full flex flex-col">
9
+ <div class="flex w-full">
10
+ <div class="flex w-full bg-gray-800 shadow overflow-hidden">
11
+ <div class="w-1/2 py-3 px-3 uppercase font-semibold text-xs text-white border-gray-600 border-r">
12
+ <%= @field.key_label %>
13
+ </div>
14
+ <div class="w-1/2 py-3 px-3 uppercase font-semibold text-xs text-white">
15
+ <%= @field.value_label %>
16
+ </div>
17
+ <% if @view.in?([:edit, :create]) %>
18
+ <div class="flex items-center justify-center p-2 px-3 border-l border-gray-600">
19
+ <a href="javascript:void(0);"
20
+ title="<%= @field.action_text %>"
21
+ data-tippy="tooltip"
22
+ data-button="add-row"
23
+ data-action="click->key-value#addRow"
24
+ <% if @field.disable_adding_rows %>
25
+ class="cursor-not-allowed"
26
+ <% end %>
27
+ >
28
+ <%= svg 'plus-circle', class: 'text-gray-400 h-5 hover:text-gray-500' %>
29
+ </a>
30
+ </div>
31
+ <% end %>
32
+ </div>
33
+ </div>
34
+ <div data-key-value-target="rows"></div>
35
+ </div>
36
+ <% if @form.present? %>
37
+ <%= @form.text_area @field.id,
38
+ value: @field.parsed_value,
39
+ class: 'hidden',
40
+ placeholder: @field.placeholder,
41
+ 'data-key-value-target': 'input',
42
+ 'data-view': :edit
43
+ %>
44
+ <% else %>
45
+ <%= text_area_tag @field.id,
46
+ @field.parsed_value,
47
+ class: 'hidden',
48
+ placeholder: @field.placeholder,
49
+ 'data-key-value-target': 'input',
50
+ 'data-view': :edit
51
+ %>
52
+ <% end %>
53
+ </div>
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Avo::Common::KeyValueComponent < ViewComponent::Base
4
+ include Avo::ApplicationHelper
5
+
6
+ def initialize(field:, form: nil, view: :show)
7
+ @field = field
8
+ @form = form
9
+ @view = view
10
+ end
11
+ end
@@ -1,5 +1,4 @@
1
1
  <%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
2
- <% disabled = @field.readonly || params[:via_resource_id] %>
3
2
  <%= @form.select @field.foreign_key, @field.options.map { |o| [o[:label], o[:value]] },
4
3
  {
5
4
  include_blank: @field.placeholder,
@@ -1,4 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Avo::Edit::Fields::BelongsToFieldComponent < Avo::Edit::Fields::FieldComponent
4
+ def disabled
5
+ return true if @field.readonly
6
+ return true if @field.target_resource.model_class.name == params[:via_resource_class]
7
+ return true if @field.id.to_s == params[:via_relation].to_s
8
+
9
+ false
10
+ end
4
11
  end
@@ -0,0 +1,3 @@
1
+ <%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
2
+ <%= render Avo::Common::KeyValueComponent.new field: @field, form: @form, view: :edit %>
3
+ <% end %>
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Avo::Edit::Fields::KeyValueFieldComponent < Avo::Edit::Fields::FieldComponent
4
+ end
@@ -0,0 +1,3 @@
1
+ <div class="absolute bg-gray-100 w-full h-full">
2
+ <%= 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' %>
3
+ </div>
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Avo::Index::GridCoverEmptyStateComponent < ViewComponent::Base
4
+ end
@@ -4,7 +4,9 @@
4
4
  <div class="relative w-full pb-3/4 rounded-t-xl overflow-hidden">
5
5
  <%== item_selector_input floating: true, size: :lg %>
6
6
 
7
- <% if cover.respond_to? :to_image %>
7
+ <% if cover.blank? %>
8
+ <%= render Avo::Index::GridCoverEmptyStateComponent.new %>
9
+ <% elsif cover.respond_to? :to_image %>
8
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 %>
9
11
  <% elsif cover.type == 'file' %>
10
12
  <% if cover.value.attached? && cover.value.representable? %>
@@ -18,9 +20,7 @@
18
20
  <% if cover.value.present? %>
19
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 %>
20
22
  <% else %>
21
- <div class="absolute bg-gray-100 w-full h-full">
22
- <%= 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' %>
23
- </div>
23
+ <%= render Avo::Index::GridCoverEmptyStateComponent.new %>
24
24
  <% end %>
25
25
  <% end %>
26
26
  </div>
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Avo::ModalComponent < ViewComponent::Base
4
- with_content_areas :heading, :controls
4
+ renders_one :heading
5
+ renders_one :controls
5
6
  end
@@ -1,7 +1,12 @@
1
1
  <div <%== data_attributes %>>
2
2
  <div class="mb-6">
3
- <div class="text-2xl tracking-normal font-bold text-gray-800 truncate mb-3">
4
- <%= @title %>
3
+ <div>
4
+ <div class="breadcrumbs">
5
+ <%= 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 %>
6
+ </div>
7
+ <div class="text-2xl tracking-normal font-bold text-gray-800 truncate">
8
+ <%= @title %>
9
+ </div>
5
10
  </div>
6
11
 
7
12
  <div>
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Avo::PanelComponent < ViewComponent::Base
4
- with_content_areas :tools, :body, :bare_content, :footer
4
+ renders_one :tools
5
+ renders_one :body
6
+ renders_one :bare_content
7
+ renders_one :footer
5
8
 
6
9
  def initialize(title: nil, body_classes: nil, data: {})
7
10
  @title = title
@@ -3,14 +3,14 @@
3
3
  <%= render(Avo::LoadingComponent.new(title: @field.name)) %>
4
4
  </turbo-frame>
5
5
  <% else %>
6
- <%= panel(title: @field.id.capitalize) do |c| %>
7
- <% c.with :tools do %>
6
+ <%= render Avo::PanelComponent.new(title: @field.id.capitalize) do |c| %>
7
+ <% c.tools do %>
8
8
  <%= a_link helpers.resource_attach_path(@resource.model.model_name.route_key, @resource.model.id, @field.id), color: 'indigo', 'data-turbo-frame': 'attach_modal' do %>
9
9
  <%= svg 'view-grid-add' %> <%= t('avo.attach_item', item: @field.id).capitalize %>
10
10
  <% end %>
11
11
  <% end %>
12
12
 
13
- <% c.with :body do %>
13
+ <% c.body do %>
14
14
  <div class="py-8 flex justify-center items-center">
15
15
  <%= empty_state @field.id %>
16
16
  </div>
@@ -0,0 +1,3 @@
1
+ <%= show_field_wrapper field: @field, index: @index do %>
2
+ <%= render Avo::Common::KeyValueComponent.new field: @field, view: :show %>
3
+ <% end %>
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Avo::Show::Fields::KeyValueFieldComponent < Avo::Show::Fields::FieldComponent
4
+ end
@@ -3,8 +3,8 @@
3
3
  <%= form_with model: @resource.model, url: helpers.resource_path(@resource.model), method: :put, multipart: true do |form| %>
4
4
  <%= hidden_field_tag :referrer, back_path if params[:via_resource_class] %>
5
5
 
6
- <%= panel(title: resource_panel[:name]) do |component| %>
7
- <% component.with :tools do %>
6
+ <%= render Avo::PanelComponent.new(title: resource_panel[:name]) do |c| %>
7
+ <% c.tools do %>
8
8
  <div class="flex justify-end space-x-2">
9
9
  <%= a_link back_path do %>
10
10
  <%= helpers.svg 'arrow-left' %> <%= t('avo.cancel').capitalize %>
@@ -18,7 +18,7 @@
18
18
  </div>
19
19
  <% end %>
20
20
 
21
- <% component.with :body do %>
21
+ <% c.body do %>
22
22
  <% @resource.get_fields.each_with_index do |field, index| %>
23
23
  <%= edit_field field, index, @resource, form unless field.computed %>
24
24
  <% end %>
@@ -1,5 +1,5 @@
1
- <%= panel title: title, body_classes: 'py-4', data: { component: 'resources-index' } do |c| %>
2
- <% c.with :tools do %>
1
+ <%= render Avo::PanelComponent.new title: title, body_classes: 'py-4', data: { component: 'resources-index' } do |c| %>
2
+ <% c.tools do %>
3
3
  <%= render 'actions' if @actions.present? %>
4
4
 
5
5
  <% if can_create? %>
@@ -21,7 +21,7 @@
21
21
  <% end %>
22
22
  <% end %>
23
23
 
24
- <% c.with :body do %>
24
+ <% c.body do %>
25
25
  <div class="flex justify-between py-6 min-h-24"
26
26
  data-selected-resources-name="<%= @resource.plural_name.downcase %>"
27
27
  data-selected-resources="[]"
@@ -51,7 +51,7 @@
51
51
  <% end %>
52
52
 
53
53
  <% if view_type.to_sym == :grid %>
54
- <% c.with :bare_content do %>
54
+ <% c.bare_content do %>
55
55
  <%= render Avo::Index::ResourceGridComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_model: @parent_model) %>
56
56
 
57
57
  <div class="bg-white rounded-xl shadow-xl mt-8 py-6">
@@ -1,8 +1,8 @@
1
1
  <div>
2
2
  <% @resource.panels.each do |resource_panel| %>
3
3
  <%= form_with model: @resource.model, url: helpers.resources_path(@resource.model, via_relation_class: params[:via_relation_class], via_resource_id: params[:via_resource_id]), local: true, multipart: true do |form| %>
4
- <%= panel(title: resource_panel[:name]) do |component| %>
5
- <% component.with :tools do %>
4
+ <%= render Avo::PanelComponent.new(title: resource_panel[:name]) do |c| %>
5
+ <% c.tools do %>
6
6
  <div class="flex justify-end space-x-2">
7
7
  <%= a_link back_path do %>
8
8
  <%= svg 'arrow-left' %> <%= t('avo.cancel').capitalize %>
@@ -14,7 +14,7 @@
14
14
  </div>
15
15
  <% end %>
16
16
 
17
- <% component.with :body do %>
17
+ <% c.body do %>
18
18
  <% @resource.get_fields.each_with_index do |field, index| %>
19
19
  <%= edit_field field, index, @resource, form unless field.computed %>
20
20
  <% end %>
@@ -4,7 +4,7 @@
4
4
  >
5
5
  <% @resource.panels.each do |resource_panel| %>
6
6
  <%= render(Avo::PanelComponent.new(title: resource_panel[:name])) do |c| %>
7
- <% c.with :tools do %>
7
+ <% c.tools do %>
8
8
  <% if resource_panel[:name] == @resource.default_panel_name %>
9
9
  <%= render 'actions' %>
10
10
 
@@ -44,7 +44,7 @@
44
44
  <% end %>
45
45
  <% end %>
46
46
 
47
- <% c.with :body do %>
47
+ <% c.body do %>
48
48
  <% if fields_by_panel[resource_panel[:name]].present? %>
49
49
  <% fields_by_panel[resource_panel[:name]].each_with_index do |field, index| %>
50
50
  <%= show_field field, index, @resource %>
@@ -7,6 +7,7 @@ module Avo
7
7
  before_action :set_authorization
8
8
  before_action :_authenticate!
9
9
  before_action :set_container_classes
10
+ before_action :add_initial_breadcrumbs
10
11
 
11
12
  rescue_from Pundit::NotAuthorizedError, with: :render_unauthorized
12
13
  rescue_from ActiveRecord::RecordInvalid, with: :exception_logger
@@ -51,7 +52,7 @@ module Avo
51
52
  existing_params = Addressable::URI.parse(request.fullpath).query_values.symbolize_keys
52
53
  end
53
54
  rescue; end
54
- send :"resources_#{model.model_name.route_key}_path", **existing_params, **args
55
+ avo.send :"resources_#{model.model_name.route_key}_path", **existing_params, **args
55
56
  end
56
57
 
57
58
  def related_resources_path(parent_model, model, keep_query_params: false, **args)
@@ -70,9 +71,9 @@ module Avo
70
71
  end
71
72
 
72
73
  def resource_path(model = nil, resource_id: nil, keep_query_params: false, **args)
73
- return send :"resources_#{model.model_name.route_key.singularize}_path", resource_id, **args if resource_id.present?
74
+ return avo.send :"resources_#{model.model_name.route_key.singularize}_path", resource_id, **args if resource_id.present?
74
75
 
75
- send :"resources_#{model.model_name.route_key.singularize}_path", model, **args
76
+ avo.send :"resources_#{model.model_name.route_key.singularize}_path", model, **args
76
77
  end
77
78
 
78
79
  def resource_attach_path(model_name, model_id, related_name, related_id = nil)
@@ -92,11 +93,11 @@ module Avo
92
93
  end
93
94
 
94
95
  def new_resource_path(model, **args)
95
- send :"new_resources_#{model.model_name.route_key.singularize}_path", **args
96
+ avo.send :"new_resources_#{model.model_name.route_key.singularize}_path", **args
96
97
  end
97
98
 
98
99
  def edit_resource_path(model, **args)
99
- send :"edit_resources_#{model.model_name.route_key.singularize}_path", model, **args
100
+ avo.send :"edit_resources_#{model.model_name.route_key.singularize}_path", model, **args
100
101
  end
101
102
 
102
103
  private
@@ -110,6 +111,8 @@ module Avo
110
111
  end
111
112
 
112
113
  def set_resource
114
+ raise ActionController::RoutingError.new "No route matches" if resource.nil?
115
+
113
116
  @resource = resource.hydrate(params: params)
114
117
  end
115
118
 
@@ -182,8 +185,6 @@ module Avo
182
185
  def eager_load_files(resource, query)
183
186
  if resource.attached_file_fields.present?
184
187
  resource.attached_file_fields.map do |field|
185
- # abort "#{field.pluralize}".inspect
186
- # abort field.class.inspect
187
188
  attachment = case field.class.to_s
188
189
  when "Avo::Fields::FileField"
189
190
  "attachment"
@@ -194,7 +195,6 @@ module Avo
194
195
  end
195
196
 
196
197
  return query.eager_load "#{field.id}_#{attachment}": :blob
197
- # return query.send :"with_attached_#{field}"
198
198
  end
199
199
  end
200
200
 
@@ -241,5 +241,9 @@ module Avo
241
241
 
242
242
  @container_classes = contain ? "2xl:container 2xl:mx-auto" : ""
243
243
  end
244
+
245
+ def add_initial_breadcrumbs
246
+ instance_eval(&Avo.configuration.initial_breadcrumbs) if Avo.configuration.initial_breadcrumbs.present?
247
+ end
244
248
  end
245
249
  end