avo 2.26.2.pre.pr1579 → 2.27.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 +2 -1
- data/Gemfile.lock +2 -2
- data/app/components/avo/index/ordering/buttons_component.html.erb +1 -1
- data/app/components/avo/index/resource_controls_component.html.erb +4 -1
- data/app/components/avo/index/resource_controls_component.rb +6 -0
- data/app/views/layouts/avo/application.html.erb +1 -1
- data/bin/prod +10 -0
- data/config/i18n-tasks.yml +1 -0
- data/lib/avo/app.rb +38 -1
- data/lib/avo/concerns/has_fields.rb +4 -0
- data/lib/avo/concerns/visible_items.rb +7 -0
- data/lib/avo/configuration.rb +2 -0
- data/lib/avo/dynamic_router.rb +6 -2
- data/lib/avo/tab.rb +8 -1
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/resource_generator.rb +1 -1
- data/lib/generators/avo/templates/locales/avo.en.yml +4 -0
- metadata +5 -5
- data/config/master.key +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aeea2a89ba96a4f920fe402b22ad5ec878c68f538d93d85e7c9e294a417fd20
|
4
|
+
data.tar.gz: cc521cbc9e8e6ac23b56af74f29222bdfacef50bc0adec8eb4e3bae29684ab45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f01a90d325dff0c0143e9a2ce3194c49b51ad42c4435621999be67463a33e201c94072b25a6d369f8230c76476e27bcaaef35de67aca1e88cff94a685aa1dbaf
|
7
|
+
data.tar.gz: 9368a51618b19f713d94f9f83e4922dbb307e5963d581a7ad55d8f10511f49befa28e95ab4a304c3ee7dbfab06748e3e64c0b4ea3907f308f34832bafb9e29c4
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
avo (2.
|
4
|
+
avo (2.27.0)
|
5
5
|
actionview (>= 6.0)
|
6
6
|
active_link_to
|
7
7
|
activerecord (>= 6.0)
|
@@ -273,7 +273,7 @@ GEM
|
|
273
273
|
nokogiri (1.14.2-x86_64-linux)
|
274
274
|
racc (~> 1.4)
|
275
275
|
orm_adapter (0.5.0)
|
276
|
-
pagy (6.0.
|
276
|
+
pagy (6.0.2)
|
277
277
|
parallel (1.22.1)
|
278
278
|
parser (3.2.0.0)
|
279
279
|
ast (~> 2.4.1)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div class="flex items-center justify-center">
|
1
|
+
<div class="flex items-center justify-center" data-component="<%= self.class.to_s.underscore %>">
|
2
2
|
<% if display_inline? %>
|
3
3
|
<div class="flex max-w-xs rounded">
|
4
4
|
<%= render Avo::Index::Ordering::ButtonComponent.new resource: @resource, reflection: @reflection, direction: :higher, svg: 'arrow-up' %>
|
@@ -1,6 +1,9 @@
|
|
1
1
|
<div class="space-x-2 flex flex-row justify-around w-full">
|
2
2
|
<% button_classes = "text-gray-600 h-6 hover:text-gray-600" %>
|
3
|
-
|
3
|
+
|
4
|
+
<% if can_reorder? %>
|
5
|
+
<%= render Avo::Index::Ordering::ButtonsComponent.new resource: @resource, reflection: @reflection, view_type: @view_type %>
|
6
|
+
<% end %>
|
4
7
|
|
5
8
|
<% if can_view? %>
|
6
9
|
<%= link_to helpers.svg('eye', class: button_classes),
|
@@ -31,6 +31,12 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
|
|
31
31
|
@resource.authorization.authorize_action(:show, raise_exception: false)
|
32
32
|
end
|
33
33
|
|
34
|
+
def can_reorder?
|
35
|
+
return authorize_association_for(:reorder) if @reflection.present?
|
36
|
+
|
37
|
+
@resource.authorization.authorize_action(:reorder, raise_exception: false)
|
38
|
+
end
|
39
|
+
|
34
40
|
def show_path
|
35
41
|
args = {}
|
36
42
|
|
@@ -36,7 +36,7 @@
|
|
36
36
|
<div class="content p-4 lg:p-6 flex-1 flex flex-col justify-between items-stretch <%= @container_classes %>">
|
37
37
|
<%= render partial: "avo/partials/custom_tools_alert" %>
|
38
38
|
<div class="flex flex-1 flex-col justify-between items-stretch space-y-8">
|
39
|
-
<%= yield %>
|
39
|
+
<%= yield.force_encoding('UTF-8') %>
|
40
40
|
<%= render partial: "avo/partials/footer" %>
|
41
41
|
</div>
|
42
42
|
</div>
|
data/bin/prod
ADDED
data/config/i18n-tasks.yml
CHANGED
@@ -117,6 +117,7 @@ ignore_missing:
|
|
117
117
|
- 'avo.field_translations.people'
|
118
118
|
- 'avo.number_of_items'
|
119
119
|
- 'avo.resource_translations.user'
|
120
|
+
- 'avo.resource_translations.team_members'
|
120
121
|
- 'avo.x_items_more'
|
121
122
|
|
122
123
|
# - 'errors.messages.{accepted,blank,invalid,too_short,too_long}'
|
data/lib/avo/app.rb
CHANGED
@@ -115,8 +115,45 @@ module Avo
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
+
# Fetches the resources available to the application.
|
119
|
+
# We have two ways of doing that.
|
120
|
+
#
|
121
|
+
# 1. Through eager loading.
|
122
|
+
# We automatically eager load the resources directory and fetch the descendants from the scanned files.
|
123
|
+
# This is the simple way to get started.
|
124
|
+
#
|
125
|
+
# 2. Manually, declared by the user.
|
126
|
+
# We have this option to load the resources because when they are loaded automatically through eager loading,
|
127
|
+
# those Resource classes and their methods may trigger loading other classes. And that may disrupt Rails booting process.
|
128
|
+
# Ex: AdminResource may use self.model_class = User. That will trigger Ruby to load the User class and itself load
|
129
|
+
# other classes in a chain reaction.
|
130
|
+
# The scenario that comes up most often is when Rails boots, the routes are being computed which eager loads the resource files.
|
131
|
+
# At that boot time some migration might have not been run yet, but Rails tries to access them through model associations,
|
132
|
+
# and they are not available.
|
133
|
+
#
|
134
|
+
# To enable this feature add a `resources` array config in your Avo initializer.
|
135
|
+
# config.resources = [
|
136
|
+
# "UserResource",
|
137
|
+
# "FishResource",
|
138
|
+
# ]
|
139
|
+
def fetch_resources
|
140
|
+
resources = if Avo.configuration.resources.nil?
|
141
|
+
BaseResource.descendants
|
142
|
+
else
|
143
|
+
Avo.configuration.resources
|
144
|
+
end
|
145
|
+
|
146
|
+
resources.map do |resource|
|
147
|
+
if resource.is_a?(Class)
|
148
|
+
resource
|
149
|
+
else
|
150
|
+
resource.to_s.safe_constantize
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
118
155
|
def init_resources
|
119
|
-
self.resources =
|
156
|
+
self.resources = fetch_resources
|
120
157
|
.select do |resource|
|
121
158
|
# Remove the BaseResource. We only need the descendants
|
122
159
|
resource != BaseResource
|
@@ -264,6 +264,10 @@ module Avo
|
|
264
264
|
panelfull_items = []
|
265
265
|
|
266
266
|
items.each do |item|
|
267
|
+
if item.respond_to? :hydrate
|
268
|
+
item.hydrate(view: view)
|
269
|
+
end
|
270
|
+
|
267
271
|
# fields and tabs can be hidden on some views
|
268
272
|
if item.respond_to? :visible_on?
|
269
273
|
next unless item.visible_on?(view)
|
data/lib/avo/configuration.rb
CHANGED
@@ -41,6 +41,7 @@ module Avo
|
|
41
41
|
attr_accessor :authorization_client
|
42
42
|
attr_accessor :field_wrapper_layout
|
43
43
|
attr_accessor :sign_out_path_name
|
44
|
+
attr_accessor :resources
|
44
45
|
attr_writer :branding
|
45
46
|
|
46
47
|
def initialize
|
@@ -92,6 +93,7 @@ module Avo
|
|
92
93
|
@resource_default_view = :show
|
93
94
|
@authorization_client = :pundit
|
94
95
|
@field_wrapper_layout = :inline
|
96
|
+
@resources = nil
|
95
97
|
end
|
96
98
|
|
97
99
|
def current_user_method(&block)
|
data/lib/avo/dynamic_router.rb
CHANGED
@@ -3,9 +3,13 @@ module Avo
|
|
3
3
|
def self.routes
|
4
4
|
Avo::Engine.routes.draw do
|
5
5
|
scope "resources", as: "resources" do
|
6
|
-
|
6
|
+
# Check if the user chose to manually register the resource files.
|
7
|
+
# If so, eager_load the resources dir.
|
8
|
+
if Avo.configuration.resources.nil?
|
9
|
+
Avo::App.eager_load(:resources) unless Rails.application.config.eager_load
|
10
|
+
end
|
7
11
|
|
8
|
-
|
12
|
+
Avo::App.fetch_resources
|
9
13
|
.select do |resource|
|
10
14
|
resource != :BaseResource
|
11
15
|
end
|
data/lib/avo/tab.rb
CHANGED
@@ -6,7 +6,6 @@ class Avo::Tab
|
|
6
6
|
class_attribute :item_type, default: :tab
|
7
7
|
delegate :items, :add_item, to: :items_holder
|
8
8
|
|
9
|
-
attr_reader :name
|
10
9
|
attr_reader :view
|
11
10
|
attr_accessor :description
|
12
11
|
attr_accessor :items_holder
|
@@ -28,6 +27,14 @@ class Avo::Tab
|
|
28
27
|
except_on args[:except_on] if args[:except_on].present?
|
29
28
|
end
|
30
29
|
|
30
|
+
def name
|
31
|
+
if @name.respond_to?(:call)
|
32
|
+
Avo::Hosts::BaseHost.new(block: @name).handle
|
33
|
+
else
|
34
|
+
@name
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
31
38
|
def hydrate(view: nil)
|
32
39
|
@view = view
|
33
40
|
|
data/lib/avo/version.rb
CHANGED
@@ -214,7 +214,7 @@ module Generators
|
|
214
214
|
end
|
215
215
|
|
216
216
|
def field(name, type)
|
217
|
-
names_mapping[name.to_sym] || fields_mapping[type
|
217
|
+
names_mapping[name.to_sym] || fields_mapping[type&.to_sym] || {field: "text"}
|
218
218
|
end
|
219
219
|
|
220
220
|
def associations_mapping
|
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: 2.
|
4
|
+
version: 2.27.0
|
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-02-
|
12
|
+
date: 2023-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -1686,6 +1686,7 @@ files:
|
|
1686
1686
|
- bin/dev
|
1687
1687
|
- bin/helpers.rb
|
1688
1688
|
- bin/init
|
1689
|
+
- bin/prod
|
1689
1690
|
- bin/rails
|
1690
1691
|
- bin/rspec
|
1691
1692
|
- bin/spring
|
@@ -1695,7 +1696,6 @@ files:
|
|
1695
1696
|
- config/credentials.yml.enc
|
1696
1697
|
- config/i18n-tasks.yml
|
1697
1698
|
- config/initializers/pagy.rb
|
1698
|
-
- config/master.key
|
1699
1699
|
- config/routes.rb
|
1700
1700
|
- config/spring.rb
|
1701
1701
|
- db/factories.rb
|
@@ -1951,9 +1951,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1951
1951
|
version: 2.6.0
|
1952
1952
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1953
1953
|
requirements:
|
1954
|
-
- - "
|
1954
|
+
- - ">="
|
1955
1955
|
- !ruby/object:Gem::Version
|
1956
|
-
version:
|
1956
|
+
version: '0'
|
1957
1957
|
requirements: []
|
1958
1958
|
rubygems_version: 3.3.3
|
1959
1959
|
signing_key:
|
data/config/master.key
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2aeb23d82b909d9c6b5abb62f7058c2a
|