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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/components/avo/actions_component.html.erb +3 -3
- data/app/components/avo/actions_component.rb +3 -12
- data/app/components/avo/button_component.rb +3 -1
- data/app/components/avo/card_component.html.erb +8 -8
- data/app/components/avo/cards_list_component.html.erb +16 -0
- data/app/components/avo/cards_list_component.rb +13 -0
- data/app/components/avo/panel_component.html.erb +1 -1
- data/app/components/avo/resource_component.rb +4 -6
- data/app/components/avo/sidebar_component.html.erb +1 -1
- data/app/components/avo/views/resource_edit_component.rb +20 -0
- data/app/components/avo/views/resource_index_component.html.erb +90 -42
- data/app/components/avo/views/resource_show_component.html.erb +50 -137
- data/app/components/avo/views/resource_show_component.rb +0 -1
- data/app/controllers/avo/application_controller.rb +2 -2
- data/app/controllers/avo/associations_controller.rb +1 -1
- data/app/controllers/avo/base_controller.rb +7 -3
- data/app/controllers/avo/cards_controller.rb +18 -5
- data/app/controllers/avo/dashboards_controller.rb +4 -2
- data/app/javascript/js/controllers/{dashboard_card_controller.js → card_controller.js} +0 -0
- data/app/javascript/js/controllers.js +2 -2
- data/app/views/avo/cards/_metric_card.html.erb +2 -2
- data/app/views/avo/dashboards/show.html.erb +2 -19
- data/app/views/avo/debug/report.html.erb +0 -1
- data/app/views/avo/private/design.html.erb +1 -1
- data/app/views/layouts/avo/application.html.erb +1 -1
- data/config/routes.rb +3 -0
- data/lib/avo/base_card.rb +40 -20
- data/lib/avo/base_resource.rb +2 -5
- data/lib/avo/concerns/has_cards.rb +88 -0
- data/lib/avo/concerns/has_model.rb +11 -0
- data/lib/avo/concerns/styles_cards.rb +48 -0
- data/lib/avo/dashboards/base_dashboard.rb +15 -50
- data/lib/avo/dashboards/base_divider.rb +5 -1
- data/lib/avo/dashboards/chartkick_card.rb +3 -3
- data/lib/avo/fields/base_field.rb +2 -6
- data/lib/avo/fields/field_extensions/visible_in_different_views.rb +12 -1
- data/lib/avo/hosts/dashboard_card.rb +1 -1
- data/lib/avo/licensing/pro_license.rb +0 -1
- data/lib/avo/tab.rb +3 -1
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/templates/action.tt +1 -1
- data/lib/generators/avo/templates/cards/partial_card_partial.tt +1 -1
- data/lib/generators/avo/templates/resource_tools/partial.tt +1 -1
- data/lib/generators/avo/templates/standalone_action.tt +1 -1
- data/public/avo-assets/avo.css +150 -594
- data/public/avo-assets/avo.js +6 -6
- data/public/avo-assets/avo.js.map +3 -3
- metadata +7 -13
- data/lib/avo/concerns/has_editable_controls.rb +0 -34
- data/lib/avo/resources/controls/action.rb +0 -32
- data/lib/avo/resources/controls/actions_list.rb +0 -19
- data/lib/avo/resources/controls/back_button.rb +0 -13
- data/lib/avo/resources/controls/base_control.rb +0 -59
- data/lib/avo/resources/controls/delete_button.rb +0 -13
- data/lib/avo/resources/controls/detach_button.rb +0 -13
- data/lib/avo/resources/controls/edit_button.rb +0 -13
- data/lib/avo/resources/controls/execution_context.rb +0 -59
- data/lib/avo/resources/controls/items_holder.rb +0 -19
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4af2bced12108d7f563a575286b2406816c124175702899f292ff70f037a1b2
|
4
|
+
data.tar.gz: 5dabe5c91bec202127a43a8314344fdf7e9b9dc6d44eb707df3deaf4bfac9cf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b80c8c9697ac3e295b020e3441544ea333fbd31ec21d8fe051cb5385d164cd7a991f714b1ad6c0e19a08bffcaa0eba66b8f1f32f177b49e7f4a6bc1a85ef575
|
7
|
+
data.tar.gz: b77b943063b6830d8371cc09748c85e7c7fef75fbcf4574c53d01cc2af956f510cbfdc2d0381f6cd41ceb38266ff1f226ead36a6ed37061bcd83256a6d256538
|
data/Gemfile.lock
CHANGED
@@ -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:
|
6
|
+
<%= a_button style: :outline,
|
7
7
|
type: :button,
|
8
|
-
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
|
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
|
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="
|
3
|
-
data-
|
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
|
10
|
-
|
11
|
-
|
12
|
-
|
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-
|
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 %>
|
@@ -17,7 +17,7 @@
|
|
17
17
|
<% end %>
|
18
18
|
</div>
|
19
19
|
<% if tools.present? %>
|
20
|
-
<div class="flex-1 w-full flex flex-
|
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-
|
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::
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
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
|
-
|
30
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
57
|
-
|
58
|
-
|
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
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
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.
|
11
|
-
<%
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
99
|
-
<% if
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
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
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
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
|
-
|
125
|
-
|
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
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
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 %>
|
@@ -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
|
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]
|