avo 2.11.3.pre.3 → 2.12.0
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 -3
- data/app/components/avo/card_component.html.erb +8 -8
- data/app/components/avo/index/ordering/buttons_component.html.erb +1 -1
- data/app/components/avo/index/resource_controls_component.rb +1 -1
- data/app/components/avo/sidebar_component.html.erb +1 -1
- data/app/components/avo/views/resource_edit_component.rb +0 -20
- data/app/components/avo/views/resource_index_component.html.erb +49 -97
- data/app/components/avo/views/resource_index_component.rb +2 -0
- data/app/components/avo/views/resource_show_component.html.erb +0 -5
- data/app/controllers/avo/application_controller.rb +7 -3
- data/app/controllers/avo/associations_controller.rb +2 -2
- data/app/controllers/avo/base_controller.rb +3 -7
- data/app/controllers/avo/cards_controller.rb +5 -18
- data/app/controllers/avo/dashboards_controller.rb +2 -4
- data/app/javascript/js/controllers/{card_controller.js → dashboard_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 +19 -2
- data/app/views/layouts/avo/application.html.erb +1 -1
- data/config/routes.rb +0 -3
- data/lib/avo/base_card.rb +21 -40
- data/lib/avo/base_resource.rb +0 -1
- data/lib/avo/dashboards/base_dashboard.rb +50 -15
- data/lib/avo/dashboards/base_divider.rb +1 -5
- data/lib/avo/dashboards/chartkick_card.rb +4 -5
- data/lib/avo/fields/base_field.rb +12 -6
- data/lib/avo/fields/field_extensions/visible_in_different_views.rb +1 -12
- data/lib/avo/fields/has_base_field.rb +16 -1
- data/lib/avo/hosts/dashboard_card.rb +1 -1
- data/lib/avo/tab.rb +1 -3
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/templates/cards/partial_card_partial.tt +1 -1
- data/public/avo-assets/avo.css +34 -86
- data/public/avo-assets/avo.js +6 -6
- data/public/avo-assets/avo.js.map +3 -3
- metadata +5 -9
- data/app/components/avo/cards_list_component.html.erb +0 -16
- data/app/components/avo/cards_list_component.rb +0 -13
- data/lib/avo/concerns/has_cards.rb +0 -88
- data/lib/avo/concerns/styles_cards.rb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb6907b0e852005ad23b73029892ac673ef73f955afe6b317d61c0c9303d3ef3
|
4
|
+
data.tar.gz: 980fbca1412954ea0e5d1f75ae12e653cd10bfb58307a2fec1a8eafc08c51852
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c43462a617f2bb6131b899665687ab371823a2c983338f32d095e0b33dfd543a4e3488e94b03f8e6dec1b7ed6162c0fa86d1cbacfde7b1cf07ef6ed5120192e6
|
7
|
+
data.tar.gz: e06be5c7fd0c244f683d4bf9960892dac729dc155bbc90f0903758ba3beca5a0394feea932db9c8d67c3ef2836fcf03a1e0056efcb90f8fded28998969cb6e56
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
avo (2.
|
4
|
+
avo (2.12.0)
|
5
5
|
active_link_to
|
6
6
|
addressable
|
7
7
|
breadcrumbs_on_rails
|
@@ -252,8 +252,6 @@ GEM
|
|
252
252
|
nokogiri (1.13.7)
|
253
253
|
mini_portile2 (~> 2.8.0)
|
254
254
|
racc (~> 1.4)
|
255
|
-
nokogiri (1.13.7-x86_64-linux)
|
256
|
-
racc (~> 1.4)
|
257
255
|
orm_adapter (0.5.0)
|
258
256
|
pagy (5.10.1)
|
259
257
|
activesupport
|
@@ -1,19 +1,19 @@
|
|
1
1
|
<div class="relative flex-1 flex flex-col justify-between h-full"
|
2
|
-
data-controller="card"
|
3
|
-
data-card-target="card"
|
2
|
+
data-controller="dashboard-card"
|
3
|
+
data-dashboard-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
|
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">
|
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-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',
|
17
17
|
data: {
|
18
18
|
target: 'select',
|
19
19
|
action: 'change->select#onChange'
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<% else %>
|
10
10
|
<div class="popover inline-block"
|
11
11
|
data-controller="popover"
|
12
|
-
data-popover-translate-x="-100%"
|
12
|
+
data-popover-translate-x="<%= Avo.configuration.resource_controls_placement == :left ? '20%' : '-100%' %>"
|
13
13
|
data-popover-translate-y="-32px"
|
14
14
|
data-action="mouseover->popover#mouseOver mouseout->popover#mouseOut"
|
15
15
|
>
|
@@ -58,7 +58,7 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
|
|
58
58
|
|
59
59
|
def singular_resource_name
|
60
60
|
if @reflection.present?
|
61
|
-
reflection_resource.name
|
61
|
+
field&.name&.singularize || reflection_resource.name
|
62
62
|
else
|
63
63
|
@resource.singular_name.present? ? @resource.singular_name : @resource.model_class.model_name.name.downcase
|
64
64
|
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-gray-25 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,26 +35,6 @@ 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
|
-
|
58
38
|
private
|
59
39
|
|
60
40
|
def via_index?
|
@@ -1,126 +1,78 @@
|
|
1
1
|
<%= content_tag :div,
|
2
|
-
class: 'space-y-6',
|
3
2
|
data: {
|
4
3
|
**@resource.stimulus_data_attributes
|
5
4
|
} do %>
|
6
|
-
<%= render Avo::
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
<% if can_attach? %>
|
11
|
-
<%= a_link attach_path,
|
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,
|
12
9
|
icon: 'heroicons/outline/link',
|
13
10
|
color: :primary,
|
14
11
|
style: :text,
|
15
12
|
'data-turbo-frame': 'attach_modal',
|
16
13
|
'data-target': 'attach' do %>
|
17
|
-
|
18
|
-
<% end %>
|
14
|
+
<%= t('avo.attach_item', item: singular_resource_name).capitalize %>
|
19
15
|
<% end %>
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
16
|
+
<% end %>
|
17
|
+
<% if can_see_the_actions_button? %>
|
18
|
+
<%= render Avo::ActionsComponent.new actions: @actions, resource: @resource, view: @view %>
|
19
|
+
<% end %>
|
20
|
+
<% if can_see_the_create_button? %>
|
21
|
+
<%= a_link create_path,
|
25
22
|
icon: 'heroicons/outline/plus',
|
26
23
|
'data-target': 'create',
|
27
24
|
style: :primary,
|
28
25
|
color: :primary do %>
|
29
|
-
|
30
|
-
<% end %>
|
26
|
+
<%= t('avo.create_new_item', item: singular_resource_name.downcase ) %>
|
31
27
|
<% end %>
|
32
28
|
<% end %>
|
33
|
-
|
34
|
-
|
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 %>"
|
35
32
|
data-selected-resources-name="<%= @resource.model_key %>"
|
36
33
|
data-selected-resources="[]"
|
37
34
|
>
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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 %>
|
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>
|
63
42
|
<% end %>
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
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)) %>
|
70
55
|
</div>
|
71
|
-
|
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 %>
|
72
59
|
<% end %>
|
73
|
-
|
74
|
-
|
75
|
-
|
60
|
+
<% end %>
|
61
|
+
<% end %>
|
62
|
+
<% c.bare_content do %>
|
63
|
+
<% if view_type.to_sym == :table %>
|
64
|
+
<% if @models.present? %>
|
65
|
+
<div class="mt-4">
|
76
66
|
<%= 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 %>
|
77
67
|
</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 %>
|
122
68
|
<% end %>
|
123
69
|
<% 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 %>
|
124
76
|
<% end %>
|
125
77
|
<% end %>
|
126
78
|
<% end %>
|
@@ -124,6 +124,8 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
|
|
124
124
|
|
125
125
|
def singular_resource_name
|
126
126
|
if @reflection.present?
|
127
|
+
return name.singularize if field.present?
|
128
|
+
|
127
129
|
reflection_resource.name
|
128
130
|
else
|
129
131
|
@resource.singular_name || @resource.model_class.model_name.name.downcase
|
@@ -5,11 +5,6 @@
|
|
5
5
|
selected_resources: [@resource.model.id],
|
6
6
|
**@resource.stimulus_data_attributes
|
7
7
|
} do %>
|
8
|
-
<% if @resource.cards.present? %>
|
9
|
-
<%= content_tag :div, class: "mb-6" do %>
|
10
|
-
<%= render Avo::CardsListComponent.new parent: @resource %>
|
11
|
-
<% end %>
|
12
|
-
<% end %>
|
13
8
|
<%= render Avo::PanelComponent.new(title: title, description: @resource.resource_description, display_breadcrumbs: @reflection.blank?, index: 0, data: { panel_id: "main" }) do |c| %>
|
14
9
|
<% c.tools do %>
|
15
10
|
<% if @reflection.present? && @resource.model.present? %>
|
@@ -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.hydrate(params: params)
|
122
122
|
end
|
123
123
|
|
124
124
|
def set_related_resource
|
@@ -126,7 +126,6 @@ module Avo
|
|
126
126
|
end
|
127
127
|
|
128
128
|
def set_model
|
129
|
-
puts ["controller_name->", controller_name].inspect
|
130
129
|
@model = eager_load_files(@resource, @resource.class.find_scope).find params[:id]
|
131
130
|
end
|
132
131
|
|
@@ -157,7 +156,7 @@ module Avo
|
|
157
156
|
end
|
158
157
|
|
159
158
|
def hydrate_resource
|
160
|
-
@resource.hydrate(view: action_name.to_sym, user: _current_user
|
159
|
+
@resource.hydrate(view: action_name.to_sym, user: _current_user)
|
161
160
|
end
|
162
161
|
|
163
162
|
def hydrate_related_resource
|
@@ -208,6 +207,11 @@ module Avo
|
|
208
207
|
end
|
209
208
|
|
210
209
|
def related_resource
|
210
|
+
# Find the field from the parent resource
|
211
|
+
field = @resource.get_field params[:related_name]
|
212
|
+
|
213
|
+
return field.use_resource if field&.use_resource.present?
|
214
|
+
|
211
215
|
reflection = @model._reflections[params[:related_name]]
|
212
216
|
|
213
217
|
reflected_model = reflection.klass
|
@@ -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 :set_related_model, only: [:show, :order]
|
10
9
|
before_action :hydrate_related_resource, only: [:show, :index, :create, :destroy, :order]
|
10
|
+
before_action :set_related_model, only: [:show, :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]
|
@@ -102,7 +102,7 @@ module Avo
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def set_attachment_resource
|
105
|
-
@attachment_resource = App.get_resource_by_model_name @attachment_class
|
105
|
+
@attachment_resource = @field.use_resource || (App.get_resource_by_model_name @attachment_class)
|
106
106
|
end
|
107
107
|
|
108
108
|
def set_attachment_model
|
@@ -7,7 +7,6 @@ module Avo
|
|
7
7
|
before_action :hydrate_resource
|
8
8
|
before_action :set_applied_filters, only: :index
|
9
9
|
before_action :set_model, only: [:show, :edit, :destroy, :update, :order]
|
10
|
-
before_action :hydrate_resource
|
11
10
|
before_action :set_model_to_fill
|
12
11
|
before_action :set_edit_title_and_breadcrumbs, only: [:edit, :update]
|
13
12
|
before_action :fill_model, only: [:create, :update]
|
@@ -101,7 +100,7 @@ module Avo
|
|
101
100
|
|
102
101
|
def new
|
103
102
|
@model = @resource.model_class.new
|
104
|
-
@resource = @resource.hydrate(model: @model, view: :new)
|
103
|
+
@resource = @resource.hydrate(model: @model, view: :new, user: _current_user)
|
105
104
|
|
106
105
|
set_actions
|
107
106
|
|
@@ -171,7 +170,7 @@ module Avo
|
|
171
170
|
def update
|
172
171
|
# model gets instantiated and filled in the fill_model method
|
173
172
|
saved = save_model
|
174
|
-
@resource = @resource.hydrate(model: @model, view: :edit)
|
173
|
+
@resource = @resource.hydrate(model: @model, view: :edit, user: _current_user)
|
175
174
|
|
176
175
|
respond_to do |format|
|
177
176
|
if saved
|
@@ -210,9 +209,6 @@ module Avo
|
|
210
209
|
end
|
211
210
|
end
|
212
211
|
|
213
|
-
def cards
|
214
|
-
end
|
215
|
-
|
216
212
|
private
|
217
213
|
|
218
214
|
def save_model
|
@@ -380,7 +376,7 @@ module Avo
|
|
380
376
|
end
|
381
377
|
|
382
378
|
def set_edit_title_and_breadcrumbs
|
383
|
-
@resource = @resource.hydrate(model: @model, view: :edit)
|
379
|
+
@resource = @resource.hydrate(model: @model, view: :edit, user: _current_user)
|
384
380
|
@page_title = @resource.default_panel_name.to_s
|
385
381
|
|
386
382
|
last_crumb_args = {}
|
@@ -2,12 +2,7 @@ require_dependency "avo/application_controller"
|
|
2
2
|
|
3
3
|
module Avo
|
4
4
|
class CardsController < ApplicationController
|
5
|
-
before_action :set_dashboard
|
6
|
-
before_action :set_resource_name
|
7
|
-
before_action :set_resource, if: -> { @dashboard.blank? }
|
8
|
-
before_action :set_model, only: :show, if: -> { @resource.present? }
|
9
|
-
before_action :hydrate_resource, if: -> { @resource.present? }
|
10
|
-
before_action :set_parent, only: :show
|
5
|
+
before_action :set_dashboard, only: :show
|
11
6
|
before_action :set_card, only: :show
|
12
7
|
|
13
8
|
def show
|
@@ -15,23 +10,15 @@ module Avo
|
|
15
10
|
|
16
11
|
private
|
17
12
|
|
18
|
-
def set_parent
|
19
|
-
@parent = @dashboard || @resource
|
20
|
-
end
|
21
|
-
|
22
13
|
def set_dashboard
|
23
|
-
|
24
|
-
|
25
|
-
@dashboard_class = Avo::App.get_dashboard_by_id params[:dashboard_id]
|
26
|
-
|
27
|
-
raise ActionController::RoutingError.new("Not Found") if @dashboard_class.nil? || @dashboard_class.is_hidden?
|
14
|
+
@dashboard = Avo::App.get_dashboard_by_id params[:dashboard_id]
|
28
15
|
|
29
|
-
@dashboard
|
16
|
+
raise ActionController::RoutingError.new("Not Found") if @dashboard.nil? || @dashboard.is_hidden?
|
30
17
|
end
|
31
18
|
|
32
19
|
def set_card
|
33
|
-
@card = @
|
34
|
-
card.hydrate(
|
20
|
+
@card = @dashboard.item_at_index(params[:index].to_i).tap do |card|
|
21
|
+
card.hydrate(dashboard: @dashboard, params: params)
|
35
22
|
end
|
36
23
|
end
|
37
24
|
end
|
@@ -10,11 +10,9 @@ module Avo
|
|
10
10
|
private
|
11
11
|
|
12
12
|
def set_dashboard
|
13
|
-
@
|
13
|
+
@dashboard = Avo::App.get_dashboard_by_id params[:id]
|
14
14
|
|
15
|
-
raise ActionController::RoutingError.new("Not Found") if @
|
16
|
-
|
17
|
-
@dashboard = @dashboard_class.new.hydrate(params: params) if @dashboard_class.present?
|
15
|
+
raise ActionController::RoutingError.new("Not Found") if @dashboard.nil? || @dashboard.is_hidden?
|
18
16
|
end
|
19
17
|
end
|
20
18
|
end
|
File without changes
|
@@ -5,9 +5,9 @@ import ActionsPickerController from './controllers/actions_picker_controller'
|
|
5
5
|
import AttachmentsController from './controllers/attachments_controller'
|
6
6
|
import BelongsToFieldController from './controllers/fields/belongs_to_field_controller'
|
7
7
|
import BooleanFilterController from './controllers/boolean_filter_controller'
|
8
|
-
import CardController from './controllers/card_controller'
|
9
8
|
import CodeFieldController from './controllers/fields/code_field_controller'
|
10
9
|
import CopyToClipboardController from './controllers/copy_to_clipboard_controller'
|
10
|
+
import DashboardCardController from './controllers/dashboard_card_controller'
|
11
11
|
import DateFieldController from './controllers/fields/date_field_controller'
|
12
12
|
import FilterController from './controllers/filter_controller'
|
13
13
|
import HiddenInputController from './controllers/hidden_input_controller'
|
@@ -38,8 +38,8 @@ application.register('action', ActionController)
|
|
38
38
|
application.register('actions-picker', ActionsPickerController)
|
39
39
|
application.register('attachments', AttachmentsController)
|
40
40
|
application.register('boolean-filter', BooleanFilterController)
|
41
|
-
application.register('card', CardController)
|
42
41
|
application.register('copy-to-clipboard', CopyToClipboardController)
|
42
|
+
application.register('dashboard-card', DashboardCardController)
|
43
43
|
application.register('filter', FilterController)
|
44
44
|
application.register('hidden-input', HiddenInputController)
|
45
45
|
application.register('item-select-all', ItemSelectAllController)
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<div class="flex items-end
|
1
|
+
<div class="flex mt-4 items-end">
|
2
2
|
<span class="text-3xl"><%= @card.prefix %></span>
|
3
|
-
<span class="text-5xl
|
3
|
+
<span class="text-5xl"><%= @card.result_data %></span>
|
4
4
|
<span class="text-3xl"><%= @card.suffix %></span>
|
5
5
|
</div>
|
@@ -1,7 +1,24 @@
|
|
1
1
|
<%= render Avo::PanelComponent.new(title: @dashboard.name, description: @dashboard.description) do |c| %>
|
2
2
|
<% c.bare_content do %>
|
3
|
-
<% if @dashboard.
|
4
|
-
|
3
|
+
<% if @dashboard.items.present? %>
|
4
|
+
<div class="min-h-24">
|
5
|
+
<%= content_tag(:div, class: "grid gap-4 grid-cols-1 #{@dashboard.classes}") do %>
|
6
|
+
<% @dashboard.items.each do |item| %>
|
7
|
+
<% if item.is_divider? %>
|
8
|
+
<%= render Avo::Dashboards::DividerComponent.new(divider: item) %>
|
9
|
+
<% elsif item.is_card? %>
|
10
|
+
<%= content_tag(:div, class: "relative bg-white rounded shadow-panel space-y-2 #{item.card_classes} overflow-hidden") do %>
|
11
|
+
<turbo-frame id="<%= item.turbo_frame %>"
|
12
|
+
src="<%= item.frame_url(enforced_range: @range, params: params) %>"
|
13
|
+
data-card-index="<%= item.index %>"
|
14
|
+
>
|
15
|
+
<%= render(Avo::LoadingComponent.new(title: item.label)) %>
|
16
|
+
</turbo-frame>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
20
|
+
<% end %>
|
21
|
+
</div>
|
5
22
|
<% else %>
|
6
23
|
<div class="w-full h-full">
|
7
24
|
<% if Rails.env.development? %>
|
@@ -18,7 +18,7 @@
|
|
18
18
|
<% end %>
|
19
19
|
<% end %>
|
20
20
|
</head>
|
21
|
-
<body class="bg-
|
21
|
+
<body class="bg-gray-25 os-mac">
|
22
22
|
<div class="relative flex flex-1 w-full min-h-full" data-controller="sidebar" data-sidebar-open-value="<%= @sidebar_open %>">
|
23
23
|
<div class="flex-1 flex flex-col max-w-full">
|
24
24
|
<%= render partial: "avo/partials/navbar" %>
|
data/config/routes.rb
CHANGED
@@ -35,9 +35,6 @@ Avo::Engine.routes.draw do
|
|
35
35
|
# resources :posts
|
36
36
|
Avo::DynamicRouter.routes(self)
|
37
37
|
|
38
|
-
# Cards
|
39
|
-
get "/:resource_name/:id/cards/:card_id", to: "cards#show"
|
40
|
-
|
41
38
|
# Associations
|
42
39
|
get "/:resource_name/:id/:related_name/new", to: "associations#new", as: "associations_new"
|
43
40
|
get "/:resource_name/:id/:related_name/", to: "associations#index", as: "associations_index"
|