avo 3.0.0.pre9 → 3.0.0.pre10
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.rb +4 -2
- data/app/components/avo/index/resource_map_component.html.erb +1 -1
- data/app/components/avo/resource_component.rb +37 -1
- data/app/components/avo/views/resource_index_component.html.erb +3 -3
- data/app/controllers/avo/actions_controller.rb +1 -4
- data/app/controllers/avo/application_controller.rb +17 -3
- data/app/controllers/avo/base_controller.rb +0 -5
- data/app/views/avo/actions/show.html.erb +2 -1
- data/app/views/avo/debug/status.html.erb +2 -1
- data/config/routes.rb +2 -2
- data/lib/avo/app.rb +1 -0
- data/lib/avo/base_action.rb +1 -1
- data/lib/avo/base_resource.rb +7 -9
- data/lib/avo/concerns/has_items.rb +1 -1
- data/lib/avo/engine.rb +0 -1
- data/lib/avo/plugin.rb +10 -0
- data/lib/avo/version.rb +1 -1
- data/lib/avo.rb +1 -1
- data/lib/generators/avo/install_generator.rb +11 -0
- data/lib/tasks/avo_tasks.rake +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 883d169ce316d8345f84fd5a0a7f7faf181c0413a6bc88c85c6e0c1c96327324
|
4
|
+
data.tar.gz: 3278c58cc427a66c926bccd3c64a80048e60ca21c1620059884628cc2ed5813e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c158e071e12fb5171dcd1f139baba1fe17fd223d31a9d6c12cd40b02cca3222c856804ab25b9154609a441131a400bb57845c0993245ac6e307883f929f31989
|
7
|
+
data.tar.gz: 7694320d99342f71280894eb0b448a5e22c69cdfe12325ab85c4dcf4acf49ba17f245bcc035a98447fe15a2599975eb81ef3f0e7fd90a286d33bb31149a9b5aa
|
data/Gemfile.lock
CHANGED
@@ -56,13 +56,15 @@ class Avo::ActionsComponent < ViewComponent::Base
|
|
56
56
|
|
57
57
|
def single_record_path(id)
|
58
58
|
Avo::Services::URIService.parse(@resource.record_path)
|
59
|
-
.append_paths("actions"
|
59
|
+
.append_paths("actions")
|
60
|
+
.append_query(action_id: id)
|
60
61
|
.to_s
|
61
62
|
end
|
62
63
|
|
63
64
|
def many_records_path(id)
|
64
65
|
Avo::Services::URIService.parse(@resource.records_path)
|
65
|
-
.append_paths("actions"
|
66
|
+
.append_paths("actions")
|
67
|
+
.append_query(action_id: id)
|
66
68
|
.to_s
|
67
69
|
end
|
68
70
|
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<%= js_map(resource_location_markers, **resource_mapkick_options) %>
|
5
5
|
</div>
|
6
6
|
<% if render_table? %>
|
7
|
-
<div class="overflow-auto<%= table_component_order_class %>">
|
7
|
+
<div class="overflow-auto <%= table_component_order_class %>">
|
8
8
|
<%= render(Avo::Index::ResourceTableComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_record: @parent_record, parent_resource: @parent_resource, pagy: @pagy, query: @query)) %>
|
9
9
|
</div>
|
10
10
|
<% end %>
|
@@ -245,7 +245,6 @@ class Avo::ResourceComponent < Avo::BaseComponent
|
|
245
245
|
a_link create_path,
|
246
246
|
color: :primary,
|
247
247
|
style: :primary,
|
248
|
-
target: "_top",
|
249
248
|
icon: "heroicons/outline/plus",
|
250
249
|
data: {
|
251
250
|
target: :create
|
@@ -269,6 +268,43 @@ class Avo::ResourceComponent < Avo::BaseComponent
|
|
269
268
|
end
|
270
269
|
end
|
271
270
|
|
271
|
+
def render_link_to(link)
|
272
|
+
a_link link.path,
|
273
|
+
color: link.color,
|
274
|
+
style: link.style,
|
275
|
+
icon: link.icon,
|
276
|
+
icon_class: link.icon_class,
|
277
|
+
title: link.title, target: link.target,
|
278
|
+
class: link.classes,
|
279
|
+
size: link.size,
|
280
|
+
data: {
|
281
|
+
**link.data,
|
282
|
+
tippy: link.title ? :tooltip : nil,
|
283
|
+
} do
|
284
|
+
link.label
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
def render_action(action)
|
289
|
+
return unless can_see_the_actions_button?
|
290
|
+
|
291
|
+
a_link action.path,
|
292
|
+
color: action.color,
|
293
|
+
style: action.style,
|
294
|
+
icon: action.icon,
|
295
|
+
icon_class: action.icon_class,
|
296
|
+
title: action.title,
|
297
|
+
size: action.size,
|
298
|
+
data: {
|
299
|
+
turbo_frame: "actions_show",
|
300
|
+
action_name: action.action.action_name,
|
301
|
+
tippy: action.title ? :tooltip : nil,
|
302
|
+
action: "click->actions-picker#visitAction",
|
303
|
+
} do
|
304
|
+
action.label
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
272
308
|
def is_a_related_resource?
|
273
309
|
@reflection.present? && @resource.record.present?
|
274
310
|
end
|
@@ -14,8 +14,8 @@
|
|
14
14
|
<% c.with_body do %>
|
15
15
|
<div class="flex flex-col">
|
16
16
|
<%= render scopes_list if can_render_scopes? %>
|
17
|
-
<div class="flex flex-col
|
18
|
-
<div class="flex flex-col xs:flex-row xs:justify-between space-y-2 xs:space-y-0 <%= 'hidden' unless header_visible? %>">
|
17
|
+
<div class="flex flex-col">
|
18
|
+
<div class="flex flex-col xs:flex-row xs:justify-between space-y-2 xs:space-y-0 py-4 <%= 'hidden' unless header_visible? %>">
|
19
19
|
<div class="flex items-center px-4 w-64">
|
20
20
|
<% if show_search_input %>
|
21
21
|
<%= render partial: 'avo/partials/resource_search', locals: {resource: @resource.route_key, via_reflection: via_reflection} %>
|
@@ -34,7 +34,7 @@
|
|
34
34
|
</div>
|
35
35
|
</div>
|
36
36
|
<% if Avo.avo_filters_installed? && resource.has_filters? %>
|
37
|
-
<%= render AvoFilters::FiltersComponent.new resource: resource %>
|
37
|
+
<%= render AvoFilters::FiltersComponent.new resource: resource, turbo_frame: turbo_frame %>
|
38
38
|
<% end %>
|
39
39
|
</div>
|
40
40
|
</div>
|
@@ -61,11 +61,8 @@ module Avo
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def action_class
|
64
|
-
klass_name = params[:action_id].gsub("avo_actions_", "").camelize
|
65
|
-
klass_name = "Avo::Actions::#{klass_name}"
|
66
|
-
|
67
64
|
Avo::BaseAction.descendants.find do |action|
|
68
|
-
action.to_s ==
|
65
|
+
action.to_s == params[:action_id]
|
69
66
|
end
|
70
67
|
end
|
71
68
|
|
@@ -115,10 +115,24 @@ module Avo
|
|
115
115
|
|
116
116
|
def fill_record
|
117
117
|
# We have to skip filling the the record if this is an attach action
|
118
|
-
|
118
|
+
return if is_attach_action?
|
119
119
|
|
120
|
-
|
121
|
-
|
120
|
+
@record = @resource.fill_record(@record_to_fill, cast_nullable(model_params), extra_params: extra_params)
|
121
|
+
assign_default_value_to_disabled_fields if @view == :create
|
122
|
+
end
|
123
|
+
|
124
|
+
def is_attach_action?
|
125
|
+
params[model_param_key].blank? && params[:related_name].present? && params[:fields].present?
|
126
|
+
end
|
127
|
+
|
128
|
+
def assign_default_value_to_disabled_fields
|
129
|
+
@resource.get_field_definitions.select do |field|
|
130
|
+
field.is_disabled? && field.visible? && !field.computed
|
131
|
+
end.each do |field|
|
132
|
+
# Get the default value from the field default definition
|
133
|
+
# If there is no default value specified on the resource, get the value from the record (DB, Callbacks, etc.)
|
134
|
+
default_value = field.default || @record.send(field.id)
|
135
|
+
field.fill_field @record, field.id, default_value, params
|
122
136
|
end
|
123
137
|
end
|
124
138
|
|
@@ -29,11 +29,6 @@ module Avo
|
|
29
29
|
@query = @resource.class.query_scope
|
30
30
|
end
|
31
31
|
|
32
|
-
# Remove default_scope for index view if no parent_resource present
|
33
|
-
if @resource.unscoped_queries_on_index && @parent_resource.blank?
|
34
|
-
@query = @query.unscoped
|
35
|
-
end
|
36
|
-
|
37
32
|
# Eager load the associations
|
38
33
|
if @resource.includes.present?
|
39
34
|
@query = @query.includes(*@resource.includes)
|
@@ -9,7 +9,7 @@
|
|
9
9
|
>
|
10
10
|
<%= form_with model: @record,
|
11
11
|
scope: 'fields',
|
12
|
-
url: "#{@resource.records_path}/actions
|
12
|
+
url: "#{@resource.records_path}/actions",
|
13
13
|
local: true,
|
14
14
|
data: @action.class.form_data_attributes do |form|
|
15
15
|
%>
|
@@ -20,6 +20,7 @@
|
|
20
20
|
<div class="flex-1 flex">
|
21
21
|
<%= @action.get_message %>
|
22
22
|
</div>
|
23
|
+
<%= hidden_field_tag :action_id, @action.param_id %>
|
23
24
|
<%= form.hidden_field :avo_resource_ids, value: params[:id] || params[:resource_ids], 'data-action-target': 'resourceIds' %>
|
24
25
|
<%= form.hidden_field :avo_selected_query, 'data-action-target': 'selectedAllQuery' %>
|
25
26
|
<% if @action.get_fields.present? %>
|
@@ -74,8 +74,9 @@
|
|
74
74
|
<div class="flex flex-col flex-1">
|
75
75
|
<div>
|
76
76
|
<ul>
|
77
|
+
<li>Avo <%= Avo::VERSION %></li>
|
77
78
|
<% Avo.plugin_manager.plugins.each do |plugin| %>
|
78
|
-
<li><%= plugin.klass.to_s.split("::").first %></li>
|
79
|
+
<li><%= plugin.klass.to_s.split("::").first %> <%= plugin.klass.version %></li>
|
79
80
|
<% end %>
|
80
81
|
</ul>
|
81
82
|
</div>
|
data/config/routes.rb
CHANGED
@@ -23,8 +23,8 @@ Avo::Engine.routes.draw do
|
|
23
23
|
delete "/:resource_name/:id/active_storage_attachments/:attachment_name/:attachment_id", to: "attachments#destroy"
|
24
24
|
|
25
25
|
# Actions
|
26
|
-
get "/:resource_name(/:id)/actions
|
27
|
-
post "/:resource_name(/:id)/actions
|
26
|
+
get "/:resource_name(/:id)/actions/(:action_id)", to: "actions#show"
|
27
|
+
post "/:resource_name(/:id)/actions/(:action_id)", to: "actions#handle"
|
28
28
|
|
29
29
|
# Generate resource routes as below:
|
30
30
|
# resources :posts
|
data/lib/avo/app.rb
CHANGED
data/lib/avo/base_action.rb
CHANGED
data/lib/avo/base_resource.rb
CHANGED
@@ -52,8 +52,9 @@ module Avo
|
|
52
52
|
class_attribute :filters_loader
|
53
53
|
class_attribute :grid_loader
|
54
54
|
class_attribute :visible_on_sidebar, default: true
|
55
|
-
class_attribute :
|
56
|
-
|
55
|
+
class_attribute :index_query, default: -> {
|
56
|
+
query
|
57
|
+
}
|
57
58
|
class_attribute :find_record_method, default: -> {
|
58
59
|
query.find id
|
59
60
|
}
|
@@ -110,13 +111,10 @@ module Avo
|
|
110
111
|
|
111
112
|
# This resolves the scope when doing "where" queries (not find queries)
|
112
113
|
def query_scope
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
end
|
118
|
-
|
119
|
-
authorization.apply_policy final_scope
|
114
|
+
authorization.apply_policy Avo::ExecutionContext.new(
|
115
|
+
target: index_query,
|
116
|
+
query: model_class
|
117
|
+
).handle
|
120
118
|
end
|
121
119
|
|
122
120
|
# This resolves the scope when finding records (not "where" queries)
|
@@ -6,7 +6,7 @@ module Avo
|
|
6
6
|
class_methods do
|
7
7
|
def deprecated_dsl_api(name = nil)
|
8
8
|
message = "This API was deprecated. Please use the `#{name}` method inside the `fields` method."
|
9
|
-
raise
|
9
|
+
raise DeprecatedAPIError.new message
|
10
10
|
end
|
11
11
|
|
12
12
|
# DSL methods
|
data/lib/avo/engine.rb
CHANGED
data/lib/avo/plugin.rb
CHANGED
data/lib/avo/version.rb
CHANGED
data/lib/avo.rb
CHANGED
@@ -14,6 +14,17 @@ module Generators
|
|
14
14
|
|
15
15
|
template "initializer/avo.tt", "config/initializers/avo.rb"
|
16
16
|
directory File.join(__dir__, "templates", "locales"), "config/locales"
|
17
|
+
create_resources
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_resources
|
21
|
+
if defined?(User).present?
|
22
|
+
Rails::Generators.invoke("avo:resource", ["user", "-q"], {destination_root: Rails.root })
|
23
|
+
end
|
24
|
+
|
25
|
+
if defined?(Account).present?
|
26
|
+
Rails::Generators.invoke("avo:resource", ["account", "-q"], {destination_root: Rails.root })
|
27
|
+
end
|
17
28
|
end
|
18
29
|
end
|
19
30
|
end
|
data/lib/tasks/avo_tasks.rake
CHANGED
@@ -3,6 +3,11 @@
|
|
3
3
|
# # Task goes here
|
4
4
|
# end
|
5
5
|
|
6
|
+
desc "Runs the update command for all Avo gems."
|
7
|
+
task "avo:update" do
|
8
|
+
system "bundle update avo avo_pro avo_advanced avo_dashboards avo_filters avo_menu avo_upgrade"
|
9
|
+
end
|
10
|
+
|
6
11
|
desc "Installs Avo assets and bundles them for when you want to use the GitHub repo in your app"
|
7
12
|
task "avo:build-assets" do
|
8
13
|
spec = get_gem_spec "avo"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.
|
4
|
+
version: 3.0.0.pre10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Marin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-05-
|
12
|
+
date: 2023-05-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|