avo 2.11.3.pre.1 → 2.11.3.pre.2

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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/app/components/avo/actions_component.html.erb +3 -3
  4. data/app/components/avo/actions_component.rb +3 -12
  5. data/app/components/avo/button_component.rb +3 -1
  6. data/app/components/avo/card_component.html.erb +8 -8
  7. data/app/components/avo/cards_list_component.html.erb +16 -0
  8. data/app/components/avo/cards_list_component.rb +13 -0
  9. data/app/components/avo/panel_component.html.erb +1 -1
  10. data/app/components/avo/resource_component.rb +4 -6
  11. data/app/components/avo/sidebar_component.html.erb +1 -1
  12. data/app/components/avo/views/resource_edit_component.rb +20 -0
  13. data/app/components/avo/views/resource_index_component.html.erb +90 -42
  14. data/app/components/avo/views/resource_show_component.html.erb +50 -137
  15. data/app/components/avo/views/resource_show_component.rb +0 -1
  16. data/app/controllers/avo/application_controller.rb +2 -2
  17. data/app/controllers/avo/associations_controller.rb +1 -1
  18. data/app/controllers/avo/base_controller.rb +7 -3
  19. data/app/controllers/avo/cards_controller.rb +18 -5
  20. data/app/controllers/avo/dashboards_controller.rb +4 -2
  21. data/app/javascript/js/controllers/{dashboard_card_controller.js → card_controller.js} +0 -0
  22. data/app/javascript/js/controllers.js +2 -2
  23. data/app/views/avo/cards/_metric_card.html.erb +2 -2
  24. data/app/views/avo/dashboards/show.html.erb +2 -19
  25. data/app/views/avo/debug/report.html.erb +0 -1
  26. data/app/views/avo/private/design.html.erb +1 -1
  27. data/app/views/layouts/avo/application.html.erb +1 -1
  28. data/config/routes.rb +3 -0
  29. data/lib/avo/base_card.rb +40 -20
  30. data/lib/avo/base_resource.rb +2 -5
  31. data/lib/avo/concerns/has_cards.rb +88 -0
  32. data/lib/avo/concerns/has_model.rb +11 -0
  33. data/lib/avo/concerns/styles_cards.rb +48 -0
  34. data/lib/avo/dashboards/base_dashboard.rb +15 -50
  35. data/lib/avo/dashboards/base_divider.rb +5 -1
  36. data/lib/avo/dashboards/chartkick_card.rb +3 -3
  37. data/lib/avo/fields/base_field.rb +2 -6
  38. data/lib/avo/fields/field_extensions/visible_in_different_views.rb +12 -1
  39. data/lib/avo/hosts/dashboard_card.rb +1 -1
  40. data/lib/avo/licensing/pro_license.rb +0 -1
  41. data/lib/avo/tab.rb +3 -1
  42. data/lib/avo/version.rb +1 -1
  43. data/lib/generators/avo/templates/action.tt +1 -1
  44. data/lib/generators/avo/templates/cards/partial_card_partial.tt +1 -1
  45. data/lib/generators/avo/templates/resource_tools/partial.tt +1 -1
  46. data/lib/generators/avo/templates/standalone_action.tt +1 -1
  47. data/public/avo-assets/avo.css +150 -594
  48. data/public/avo-assets/avo.js +6 -6
  49. data/public/avo-assets/avo.js.map +3 -3
  50. metadata +7 -13
  51. data/lib/avo/concerns/has_editable_controls.rb +0 -34
  52. data/lib/avo/resources/controls/action.rb +0 -32
  53. data/lib/avo/resources/controls/actions_list.rb +0 -19
  54. data/lib/avo/resources/controls/back_button.rb +0 -13
  55. data/lib/avo/resources/controls/base_control.rb +0 -59
  56. data/lib/avo/resources/controls/delete_button.rb +0 -13
  57. data/lib/avo/resources/controls/detach_button.rb +0 -13
  58. data/lib/avo/resources/controls/edit_button.rb +0 -13
  59. data/lib/avo/resources/controls/execution_context.rb +0 -59
  60. data/lib/avo/resources/controls/items_holder.rb +0 -19
  61. data/lib/avo/resources/controls/link_to.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6322eef586c1cf132343d666fa513b2733699349d2945a86ddb2b37669cfcd1c
4
- data.tar.gz: 5fb654449921d9fde5312adbeee074f96752445c34416ea4a6a22e6c5f9be9df
3
+ metadata.gz: a4af2bced12108d7f563a575286b2406816c124175702899f292ff70f037a1b2
4
+ data.tar.gz: 5dabe5c91bec202127a43a8314344fdf7e9b9dc6d44eb707df3deaf4bfac9cf3
5
5
  SHA512:
6
- metadata.gz: 8c9ee8afe73d49806a42032b5c3f2b8c49a05763d44048e44c55ab4831d30c475ad2792cb6ad11ce5bd8ce296202c20173dd8bf274b05c64f6ac60174835953b
7
- data.tar.gz: f22c15ebaaee96768cd5c38c2935a513410a32a5e46729b22c4c8375c1b7a229b4e3e733572f3fe47207229bae4775ce3a5510c528a532759c81b8b2b0b39fc7
6
+ metadata.gz: 4b80c8c9697ac3e295b020e3441544ea333fbd31ec21d8fe051cb5385d164cd7a991f714b1ad6c0e19a08bffcaa0eba66b8f1f32f177b49e7f4a6bc1a85ef575
7
+ data.tar.gz: b77b943063b6830d8371cc09748c85e7c7fef75fbcf4574c53d01cc2af956f510cbfdc2d0381f6cd41ceb38266ff1f226ead36a6ed37061bcd83256a6d256538
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.11.3.pre.1)
4
+ avo (2.11.3.pre.2)
5
5
  active_link_to
6
6
  addressable
7
7
  breadcrumbs_on_rails
@@ -3,9 +3,9 @@
3
3
  data-actions-picker-enabled-class="text-black hover:bg-blue-500 hover:text-white"
4
4
  data-actions-picker-disabled-class="cursor-wait text-gray-500"
5
5
  >
6
- <%= a_button style: @style,
6
+ <%= a_button style: :outline,
7
7
  type: :button,
8
- color: @color,
8
+ color: :primary,
9
9
  class: "focus:outline-none",
10
10
  icon: 'arrow-circle-right',
11
11
  icon_class: 'transform rotate-90',
@@ -18,7 +18,7 @@
18
18
  data-toggle-panel-target="panel"
19
19
  >
20
20
  <div class="w-full space divide-y">
21
- <% actions.each_with_index do |action, index| %>
21
+ <% @actions.each_with_index do |action, index| %>
22
22
  <%= link_to action_path(action.param_id),
23
23
  data: {
24
24
  'turbo-frame': 'actions_show',
@@ -3,23 +3,14 @@
3
3
  class Avo::ActionsComponent < ViewComponent::Base
4
4
  include Avo::ApplicationHelper
5
5
 
6
- def initialize(actions: [], resource: nil, view: nil, exclude: [], style: :outline, color: :blue)
7
- @actions = actions || []
6
+ def initialize(actions: [], resource: nil, view: nil)
7
+ @actions = actions
8
8
  @resource = resource
9
9
  @view = view
10
- @exclude = exclude
11
- @color = color
12
- @style = style
13
10
  end
14
11
 
15
12
  def render?
16
- actions.present?
17
- end
18
-
19
- def actions
20
- @actions.select do |action|
21
- !action.class.in?(@exclude)
22
- end
13
+ @actions.present?
23
14
  end
24
15
 
25
16
  # When running an action for one record we should do it on a special path.
@@ -43,7 +43,9 @@ class Avo::ButtonComponent < ViewComponent::Base
43
43
  classes = "button-component inline-flex flex-grow-0 items-center font-semibold leading-6 fill-current whitespace-nowrap transition duration-100 transform transition duration-100 cursor-pointer disabled:cursor-not-allowed disabled:opacity-70 border justify-center active:outline active:outline-1 #{@class}"
44
44
 
45
45
  classes += " rounded" if @rounded.present?
46
+
46
47
  classes += style_classes
48
+
47
49
  classes += horizontal_padding_classes
48
50
  classes += vertical_padding_classes
49
51
  classes += text_size_classes
@@ -149,7 +151,7 @@ class Avo::ButtonComponent < ViewComponent::Base
149
151
  def style_classes
150
152
  case @style
151
153
  when :primary
152
- " bg-#{@color}-500 text-white border-#{@color}-500 hover:bg-#{@color}-600 hover:border-#{@color}-600 active:border-#{@color}-700 active:outline-#{@color}-700 active:bg-#{@color}-600"
154
+ " bg-primary-500 text-white border-primary-500 hover:bg-primary-600 hover:border-primary-600 active:border-primary-700 active:outline-primary-700 active:bg-primary-600"
153
155
  when :outline
154
156
  " bg-white text-#{@color}-500 border-#{@color}-500 hover:bg-#{@color}-100 active:bg-#{@color}-100 active:border-#{@color}-500 active:outline-#{@color}-500"
155
157
  when :text
@@ -1,19 +1,19 @@
1
1
  <div class="relative flex-1 flex flex-col justify-between h-full"
2
- data-controller="dashboard-card"
3
- data-dashboard-card-target="card"
2
+ data-controller="card"
3
+ data-card-target="card"
4
4
  data-refresh-every="<%= @card.refresh_every %>"
5
5
  data-card-id="<%= @card.id %>"
6
6
  data-card-index="<%= @card.index %>">
7
7
  <% if @card.class.display_header %>
8
8
  <div class="px-4 pt-4">
9
- <div class="flex justify-between items-center min-h-6">
10
- <div class="text-base font-bold text-gray-700 leading-none">
11
- <%= @card.label %>
12
- </div>
13
- <div data-controller="select">
9
+ <div class="flex justify-between items-center">
10
+ <div class="text-sm font-bold text-gray-700 leading-none">
11
+ <%= @card.label %>
12
+ </div>
13
+ <div class="flex" data-controller="select">
14
14
  <% if @card.type.in?([:metric, :chartkick, :partial]) && @card.ranges.present? %>
15
15
  <%= select_tag "#{@card.id}_#{@card.index}_range", options_for_select(@card.ranges, @card.range),
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',
16
+ class: 'appearance-none inline-flex bg-blue-gray-100 disabled:bg-blue-gray-300 disabled:cursor-not-allowed focus:bg-white text-xs text-blue-gray-700 disabled:text-blue-gray-700 leading-none rounded-md py-px px-2 border outline-none outline w-24',
17
17
  data: {
18
18
  target: 'select',
19
19
  action: 'change->select#onChange'
@@ -0,0 +1,16 @@
1
+ <%= content_tag(:div, class: "grid gap-4 grid-cols-1 #{parent.class.cards_classes}") do %>
2
+ <% parent.cards.each do |card| %>
3
+ <% if card.is_divider? %>
4
+ <%= render Avo::Dashboards::DividerComponent.new(divider: card) %>
5
+ <% elsif card.is_card? %>
6
+ <%= content_tag(:div, class: "relative bg-white rounded shadow-panel space-y-2 overflow-hidden h-full #{card.card_classes}") do %>
7
+ <turbo-frame id="<%= card.turbo_frame %>"
8
+ src="<%= card.frame_url(enforced_range: @range, params: params) %>"
9
+ data-card-index="<%= card.index %>"
10
+ >
11
+ <%= render(Avo::LoadingComponent.new(title: card.label)) %>
12
+ </turbo-frame>
13
+ <% end %>
14
+ <% end %>
15
+ <% end %>
16
+ <% end %>
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Avo::CardsListComponent < ViewComponent::Base
4
+ attr_reader :parent
5
+
6
+ def initialize(parent: nil)
7
+ @parent = parent
8
+ end
9
+
10
+ def render?
11
+ parent.cards.present?
12
+ end
13
+ end
@@ -17,7 +17,7 @@
17
17
  <% end %>
18
18
  </div>
19
19
  <% if tools.present? %>
20
- <div class="flex-1 w-full flex flex-wrap flex-col sm:flex-row xl:justify-end sm:items-end gap-2 mt-4 xl:mt-0" data-target="panel-controls">
20
+ <div class="flex-1 w-full flex flex-col sm:flex-row xl:justify-end sm:items-end space-y-2 sm:space-y-0 sm:space-x-2 mt-4 xl:mt-0">
21
21
  <%= tools %>
22
22
  </div>
23
23
  <% end %>
@@ -22,12 +22,6 @@ class Avo::ResourceComponent < Avo::BaseComponent
22
22
  authorize_association_for("detach")
23
23
  end
24
24
 
25
- def detach_path
26
- return "/" if @reflection.blank?
27
-
28
- helpers.resource_detach_path(params[:resource_name], params[:id], @reflection.name.to_s, @resource.model.id)
29
- end
30
-
31
25
  def can_see_the_edit_button?
32
26
  @resource.authorization.authorize_action(:edit, raise_exception: false)
33
27
  end
@@ -36,6 +30,10 @@ class Avo::ResourceComponent < Avo::BaseComponent
36
30
  @resource.authorization.authorize_action(:destroy, raise_exception: false)
37
31
  end
38
32
 
33
+ def detach_path
34
+ helpers.resource_detach_path(params[:resource_name], params[:id], @reflection.name.to_s, @resource.model.id)
35
+ end
36
+
39
37
  def destroy_path
40
38
  helpers.resource_path(model: @resource.model, resource: @resource)
41
39
  end
@@ -1,5 +1,5 @@
1
1
  <div
2
- class="avo-sidebar fixed z-[60] t-0 application-sidebar w-64 flex-1 border-r lg:border-none bg-none h-[calc(100vh-4rem)] bg-gray-25 lg:bg-transparent <%= 'print:hidden' if Avo.configuration.hide_layout_when_printing %> <%= @sidebar_open ? 'flex' : 'hidden' %>"
2
+ class="avo-sidebar fixed z-[60] t-0 application-sidebar w-64 flex-1 border-r lg:border-none bg-none h-[calc(100vh-4rem)] bg-application lg:bg-transparent <%= 'print:hidden' if Avo.configuration.hide_layout_when_printing %> <%= @sidebar_open ? 'flex' : 'hidden' %>"
3
3
  data-sidebar-target="<%= stimulus_target %>"
4
4
  data-transition-enter="transition ease-out duration-100"
5
5
  data-transition-enter-start="transform opacity-0 -translate-x-full"
@@ -35,6 +35,26 @@ class Avo::Views::ResourceEditComponent < Avo::ResourceComponent
35
35
  @resource.authorization.authorize_action @view, raise_exception: false
36
36
  end
37
37
 
38
+ def is_edit?
39
+ view == :edit
40
+ end
41
+
42
+ def form_url
43
+ if is_edit?
44
+ helpers.resource_path(
45
+ model: @resource.model,
46
+ resource: @resource
47
+ )
48
+ else
49
+ helpers.resources_path(
50
+ resource: @resource,
51
+ via_relation_class: params[:via_relation_class],
52
+ via_relation: params[:via_relation],
53
+ via_resource_id: params[:via_resource_id]
54
+ )
55
+ end
56
+ end
57
+
38
58
  private
39
59
 
40
60
  def via_index?
@@ -1,17 +1,21 @@
1
1
  <%= content_tag :div,
2
+ class: 'space-y-6',
2
3
  data: {
3
4
  **@resource.stimulus_data_attributes
4
5
  } do %>
5
- <%= render Avo::PanelComponent.new(title: title, description: description, data: { component: 'resources-index' }, display_breadcrumbs: @reflection.blank?) do |c| %>
6
- <% c.tools do %>
7
- <% if can_attach? %>
8
- <%= a_link attach_path,
6
+ <%= render Avo::CardsListComponent.new parent: @resource %>
7
+ <%= content_tag :div, class: "space-y-12" do %>
8
+ <%= render Avo::PanelComponent.new(title: title, description: description, data: { component: 'resources-index' }, display_breadcrumbs: @reflection.blank?) do |c| %>
9
+ <% c.tools do %>
10
+ <% if can_attach? %>
11
+ <%= a_link attach_path,
9
12
  icon: 'heroicons/outline/link',
10
13
  color: :primary,
11
14
  style: :text,
12
15
  'data-turbo-frame': 'attach_modal',
13
16
  'data-target': 'attach' do %>
14
- <%= t('avo.attach_item', item: singular_resource_name).capitalize %>
17
+ <%= t('avo.attach_item', item: singular_resource_name).capitalize %>
18
+ <% end %>
15
19
  <% end %>
16
20
  <% end %>
17
21
  <% if can_see_the_actions_button? %>
@@ -26,53 +30,97 @@
26
30
  <%= t('avo.create_new_item', item: singular_resource_name.downcase ) %>
27
31
  <% end %>
28
32
  <% end %>
29
- <% end %>
30
- <% c.body do %>
31
- <div class="flex flex-col xs:flex-row xs:justify-between space-y-2 xs:space-y-0 py-4 <%= 'hidden' if @resource.search_query.nil? && @filters.empty? && available_view_types.count <= 1 %>"
33
+ <% c.body do %>
34
+ <div class="flex flex-col xs:flex-row xs:justify-between space-y-2 xs:space-y-0 py-4 <%= 'hidden' if @resource.search_query.nil? && @filters.empty? && available_view_types.count <= 1 %>"
32
35
  data-selected-resources-name="<%= @resource.model_key %>"
33
36
  data-selected-resources="[]"
34
37
  >
35
- <% if @resource.search_query.present? %>
36
- <div class="flex items-center px-4 w-64">
37
- <%= render partial: 'avo/partials/resource_search', locals: {resource: @resource.route_key} %>
38
- </div>
39
- <% else %>
40
- <%# Offset for the space-y-2 property when the search is missing %>
41
- <div class="-mb-2"></div>
42
- <% end %>
43
- <% if @filters.present? || available_view_types.count > 1 %>
44
- <div class="justify-self-end flex justify-start xs:justify-end items-center px-4 space-x-3">
45
- <%= render Avo::FiltersComponent.new filters: @filters, resource: @resource, applied_filters: @applied_filters %>
46
- <%= render partial: 'avo/partials/view_toggle_button', locals: { available_view_types: available_view_types, view_type: view_type, turbo_frame: @turbo_frame } if available_view_types.count > 1 %>
47
- </div>
48
- <% end %>
49
- </div>
50
- <% if view_type.to_sym == :table %>
51
- <% if @resources.present? %>
52
- <div class="w-full overflow-auto flex flex-col mt-0 mac-styled-scrollbar">
53
- <div class="relative flex-1 flex">
54
- <%= render(Avo::Index::ResourceTableComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_model: @parent_model, parent_resource: @parent_resource)) %>
38
+ <% if @resource.search_query.present? %>
39
+ <div class="flex items-center px-4 w-64">
40
+ <%= render partial: 'avo/partials/resource_search', locals: {resource: @resource.route_key} %>
55
41
  </div>
56
- </div>
57
- <% else %>
58
- <%= helpers.empty_state resource_name: @resource.name.downcase.pluralize, related_name: params[:related_name], view_type: view_type, add_background: true %>
42
+ <% else %>
43
+ <%# Offset for the space-y-2 property when the search is missing %>
44
+ <div class="-mb-2"></div>
45
+ <% end %>
46
+ <% if @filters.present? || available_view_types.count > 1 %>
47
+ <div class="justify-self-end flex justify-start xs:justify-end items-center px-4 space-x-3">
48
+ <%= render Avo::FiltersComponent.new filters: @filters, resource: @resource, applied_filters: @applied_filters %>
49
+ <%= render partial: 'avo/partials/view_toggle_button', locals: { available_view_types: available_view_types, view_type: view_type, turbo_frame: @turbo_frame } if available_view_types.count > 1 %>
50
+ </div>
51
+ <% end %>
52
+ </div>
53
+ <% if view_type.to_sym == :table %>
54
+ <% if @resources.present? %>
55
+ <div class="w-full overflow-auto flex flex-col mt-0 mac-styled-scrollbar">
56
+ <div class="relative flex-1 flex">
57
+ <%= render(Avo::Index::ResourceTableComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_model: @parent_model, parent_resource: @parent_resource)) %>
58
+ </div>
59
+ </div>
60
+ <% else %>
61
+ <%= helpers.empty_state resource_name: @resource.name.downcase.pluralize, related_name: params[:related_name], view_type: view_type, add_background: true %>
62
+ <% end %>
59
63
  <% end %>
60
64
  <% end %>
61
- <% end %>
62
- <% c.bare_content do %>
63
- <% if view_type.to_sym == :table %>
64
- <% if @models.present? %>
65
- <div class="mt-4">
65
+ <% c.bare_content do %>
66
+ <% if view_type.to_sym == :table %>
67
+ <% if @models.present? %>
68
+ <div class="mt-4">
69
+ <%= render Avo::PaginatorComponent.new pagy: @pagy, turbo_frame: @turbo_frame || 'none', index_params: @index_params, resource: @resource, parent_model: @parent_model, discreet_pagination: field&.discreet_pagination %>
70
+ </div>
71
+ <% end %>
72
+ <% end %>
73
+ <% if view_type.to_sym == :grid %>
74
+ <%= render Avo::Index::ResourceGridComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_model: @parent_model) %>
75
+ <div class="mt-6">
66
76
  <%= render Avo::PaginatorComponent.new pagy: @pagy, turbo_frame: @turbo_frame || 'none', index_params: @index_params, resource: @resource, parent_model: @parent_model, discreet_pagination: field&.discreet_pagination %>
67
77
  </div>
78
+ <% if view_type.to_sym == :table %>
79
+ <% if @resources.present? %>
80
+ <div class="w-full overflow-auto flex flex-col mt-0">
81
+ <div class="relative flex-1 flex">
82
+ <%= render(Avo::Index::ResourceTableComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_model: @parent_model)) %>
83
+ </div>
84
+ <% else %>
85
+ <%# Offset for the space-y-2 property when the serach is missing %>
86
+ <div class="-mb-2"></div>
87
+ <% end %>
88
+ <% if @filters.present? || available_view_types.count > 1 %>
89
+ <div class="justify-self-end flex justify-start xs:justify-end items-center px-4 space-x-3">
90
+ <%= render Avo::FiltersComponent.new filters: @filters, resource: @resource, applied_filters: @applied_filters %>
91
+ <%= render partial: 'avo/partials/view_toggle_button', locals: { available_view_types: available_view_types, view_type: view_type, turbo_frame: @turbo_frame } if available_view_types.count > 1 %>
92
+ </div>
93
+ <% end %>
94
+ </div>
95
+ <% if view_type.to_sym == :table %>
96
+ <% if @resources.present? %>
97
+ <div class="w-full overflow-auto flex flex-col mt-0">
98
+ <div class="relative flex-1 flex">
99
+ <%= render(Avo::Index::ResourceTableComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_model: @parent_model)) %>
100
+ </div>
101
+ </div>
102
+ <% else %>
103
+ <%= helpers.empty_state resource_name: @resource.name.downcase.pluralize, related_name: params[:related_name], view_type: view_type, add_background: true %>
104
+ <% end %>
105
+ <% end %>
106
+ <% end %>
107
+ <% c.bare_content do %>
108
+ <% if view_type.to_sym == :table %>
109
+ <% if @models.present? %>
110
+ <div class="mt-4">
111
+ <%= render Avo::PaginatorComponent.new pagy: @pagy, turbo_frame: @turbo_frame || 'none', index_params: @index_params, resource: @resource, parent_model: @parent_model %>
112
+ </div>
113
+ <% end %>
114
+ <% end %>
115
+ <% if view_type.to_sym == :grid %>
116
+ <%= render Avo::Index::ResourceGridComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_model: @parent_model) %>
117
+ <div class="mt-6">
118
+ <%= render Avo::PaginatorComponent.new pagy: @pagy, turbo_frame: @turbo_frame || 'none', index_params: @index_params, resource: @resource, parent_model: @parent_model %>
119
+ </div>
120
+ <% end %>
121
+ <% end %>
68
122
  <% end %>
69
123
  <% end %>
70
- <% if view_type.to_sym == :grid %>
71
- <%= render Avo::Index::ResourceGridComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_model: @parent_model) %>
72
- <div class="mt-6">
73
- <%= render Avo::PaginatorComponent.new pagy: @pagy, turbo_frame: @turbo_frame || 'none', index_params: @index_params, resource: @resource, parent_model: @parent_model, discreet_pagination: field&.discreet_pagination %>
74
- </div>
75
- <% end %>
76
124
  <% end %>
77
125
  <% end %>
78
126
  <% end %>
@@ -5,150 +5,63 @@
5
5
  selected_resources: [@resource.model.id],
6
6
  **@resource.stimulus_data_attributes
7
7
  } do %>
8
+ <div class="mb-6">
9
+ <%= render Avo::CardsListComponent.new parent: @resource %>
10
+ </div>
8
11
  <%= render Avo::PanelComponent.new(title: title, description: @resource.resource_description, display_breadcrumbs: @reflection.blank?, index: 0, data: { panel_id: "main" }) do |c| %>
9
12
  <% c.tools do %>
10
- <% if @resource.has_show_controls? %>
11
- <% @resource.render_show_controls.each do |control| %>
12
- <% if control.back_button? %>
13
- <%= a_link back_path,
14
- style: :text,
15
- title: control.title,
16
- data: {
17
- tippy: control.title ? :tooltip : nil,
18
- },
19
- icon: 'arrow-left' do %>
20
- <%= control.label %>
21
- <% end %>
22
- <% elsif control.delete_button? %>
23
- <% if can_see_the_destroy_button? %>
24
- <% end %>
25
- <%= a_button url: helpers.resource_path(model: @resource.model, resource: @resource),
26
- method: :delete,
27
- local: true,
28
- style: :text,
29
- loading: true,
30
- confirm: t('avo.are_you_sure', item: @resource.model.model_name.name.downcase),
31
- color: :red,
32
- icon: 'trash',
33
- form_class: 'flex flex-col sm:flex-row sm:inline-flex',
34
- title: control.title,
35
- data: {
36
- control: :destroy,
37
- tippy: control.title ? :tooltip : nil,
38
- 'resource-id': @resource.model.id,
39
- } do %>
40
- <% end %>
41
- <% elsif control.actions_list? %>
42
- <%= render Avo::ActionsComponent.new actions: @actions, resource: @resource, view: @view, exclude: control.exclude, style: control.style, color: control.color %>
43
- <% elsif control.edit_button? %>
44
- <% if @resource.authorization.authorize_action(:edit, raise_exception: false) %>
45
- <% end %>
46
- <%= a_link edit_path,
47
- color: :primary,
48
- style: :primary,
49
- title: control.title,
50
- data: {
51
- tippy: control.title ? :tooltip : nil,
52
- },
53
- icon: 'edit' do %>
54
- <%= control.label %>
55
- <% end %>
56
- <% elsif control.action? %>
57
- <%= a_link control.path,
58
- color: control.color,
59
- style: control.style,
60
- icon: control.icon,
61
- title: control.title,
62
- data: {
63
- tippy: control.title ? :tooltip : nil,
64
- 'turbo-frame': 'actions_show',
65
- 'action': 'click->actions-picker#visitAction',
66
- } do %>
67
- <%= control.label %>
68
- <% end %>
69
- <% elsif control.link_to? %>
70
- <%= a_link control.path,
71
- color: control.color,
72
- style: control.style,
73
- icon: control.icon,
74
- title: control.title,
75
- target: control.target,
76
- class: control.class,
77
- data: {
78
- **control.data,
79
- tippy: control.title ? :tooltip : nil,
80
- } do %>
81
- <%= control.label %>
82
- <% end %>
83
- <% elsif control.detach_button? %>
84
- <% if @reflection.present? && @resource.model.present? && can_detach? %>
85
- <%= a_button url: detach_path,
86
- icon: 'detach',
87
- method: :delete,
88
- form_class: 'flex flex-col sm:flex-row sm:inline-flex',
89
- style: :text,
90
- data: {
91
- confirm: "Are you sure you want to detach this #{title}."
92
- } do %>
93
- <%= t('avo.detach_item', item: title).capitalize %>
94
- <% end %>
95
- <% end %>
13
+ <% if @reflection.present? && @resource.model.present? %>
14
+ <% if can_detach? %>
15
+ <%= a_button url: detach_path,
16
+ icon: 'detach',
17
+ method: :delete,
18
+ form_class: 'flex flex-col sm:flex-row sm:inline-flex',
19
+ style: :text,
20
+ data: {
21
+ confirm: "Are you sure you want to detach this #{title}."
22
+ } do %>
23
+ <%= t('avo.detach_item', item: title).capitalize %>
96
24
  <% end %>
97
25
  <% end %>
98
- <% else %>
99
- <% if @reflection.present? && @resource.model.present? %>
100
- <% if can_detach? %>
101
- <%= a_button url: detach_path,
102
- icon: 'detach',
103
- method: :delete,
104
- form_class: 'flex flex-col sm:flex-row sm:inline-flex',
105
- style: :text,
106
- data: {
107
- confirm: "Are you sure you want to detach this #{title}."
108
- } do %>
109
- <%= t('avo.detach_item', item: title).capitalize %>
110
- <% end %>
26
+ <%= render Avo::ActionsComponent.new actions: @actions, resource: @resource, view: @view %>
27
+ <% if can_see_the_edit_button? %>
28
+ <%= a_link edit_path,
29
+ color: :primary,
30
+ style: :primary,
31
+ icon: 'edit' do %>
32
+ <%= t('avo.edit').capitalize %>
111
33
  <% end %>
112
- <%= render Avo::ActionsComponent.new actions: @actions, resource: @resource, view: @view %>
113
- <% if can_see_the_edit_button? %>
114
- <%= a_link edit_path,
115
- color: :primary,
116
- style: :primary,
117
- icon: 'edit' do %>
118
- <%= t('avo.edit').capitalize %>
119
- <% end %>
120
- <% end %>
121
- <% else %>
122
- <%= a_link back_path,
34
+ <% end %>
35
+ <% else %>
36
+ <%= a_link back_path,
37
+ style: :text,
38
+ icon: 'arrow-left' do %>
39
+ <%= t('avo.go_back') %>
40
+ <% end %>
41
+ <% if can_see_the_destroy_button? %>
42
+ <%= a_button url: helpers.resource_path(model: @resource.model, resource: @resource),
43
+ method: :delete,
44
+ local: true,
123
45
  style: :text,
124
- icon: 'arrow-left' do %>
125
- <%= t('avo.go_back') %>
46
+ loading: true,
47
+ confirm: t('avo.are_you_sure', item: @resource.model.model_name.name.downcase),
48
+ color: :red,
49
+ icon: 'trash',
50
+ form_class: 'flex flex-col sm:flex-row sm:inline-flex',
51
+ data: {
52
+ control: :destroy,
53
+ 'resource-id': @resource.model.id,
54
+ } do %>
55
+ <%= t('avo.delete').capitalize %>
126
56
  <% end %>
127
- <% if can_see_the_destroy_button? %>
128
- <%= a_button url: helpers.resource_path(model: @resource.model, resource: @resource),
129
- method: :delete,
130
- local: true,
131
- style: :text,
132
- loading: true,
133
- confirm: t('avo.are_you_sure', item: @resource.model.model_name.name.downcase),
134
- color: :red,
135
- icon: 'trash',
136
- form_class: 'flex flex-col sm:flex-row sm:inline-flex',
137
- data: {
138
- control: :destroy,
139
- 'resource-id': @resource.model.id,
140
- } do %>
141
- <%= t('avo.delete').capitalize %>
142
- <% end %>
143
- <% end %>
144
- <%= render Avo::ActionsComponent.new actions: @actions, resource: @resource, view: @view %>
145
- <% if @resource.authorization.authorize_action(:edit, raise_exception: false) %>
146
- <%= a_link edit_path,
147
- color: :primary,
148
- style: :primary,
149
- icon: 'edit' do %>
150
- <%= t('avo.edit').capitalize %>
151
- <% end %>
57
+ <% end %>
58
+ <%= render Avo::ActionsComponent.new actions: @actions, resource: @resource, view: @view %>
59
+ <% if @resource.authorization.authorize_action(:edit, raise_exception: false) %>
60
+ <%= a_link edit_path,
61
+ color: :primary,
62
+ style: :primary,
63
+ icon: 'edit' do %>
64
+ <%= t('avo.edit').capitalize %>
152
65
  <% end %>
153
66
  <% end %>
154
67
  <% end %>
@@ -17,7 +17,6 @@ class Avo::Views::ResourceShowComponent < Avo::ResourceComponent
17
17
  def title
18
18
  if @reflection.present?
19
19
  return field.name if has_one_field?
20
-
21
20
  reflection_resource.name
22
21
  else
23
22
  @resource.default_panel_name
@@ -118,7 +118,7 @@ module Avo
118
118
  def set_resource
119
119
  raise ActionController::RoutingError.new "No route matches" if resource.nil?
120
120
 
121
- @resource = resource.hydrate(params: params)
121
+ @resource = resource
122
122
  end
123
123
 
124
124
  def set_related_resource
@@ -156,7 +156,7 @@ module Avo
156
156
  end
157
157
 
158
158
  def hydrate_resource
159
- @resource.hydrate(view: action_name.to_sym, user: _current_user)
159
+ @resource.hydrate(view: action_name.to_sym, user: _current_user, model: @model, params: params)
160
160
  end
161
161
 
162
162
  def hydrate_related_resource
@@ -6,8 +6,8 @@ module Avo
6
6
  before_action :set_related_resource_name
7
7
  before_action :set_related_resource, only: [:show, :index, :new, :create, :destroy, :order]
8
8
  before_action :set_reflection_field
9
- before_action :hydrate_related_resource, only: [:show, :index, :create, :destroy, :order]
10
9
  before_action :set_related_model, only: [:show, :order]
10
+ before_action :hydrate_related_resource, only: [:show, :index, :new, :create, :destroy, :order]
11
11
  before_action :set_reflection
12
12
  before_action :set_attachment_class, only: [:show, :index, :new, :create, :destroy, :order]
13
13
  before_action :set_attachment_resource, only: [:show, :index, :new, :create, :destroy, :order]