avo 2.8.0 → 2.9.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 +2 -2
- data/README.md +11 -0
- data/app/assets/stylesheets/avo.css +4 -4
- data/app/assets/stylesheets/css/{components → fields}/code.css +0 -0
- data/app/assets/stylesheets/css/{components → fields}/progress.css +0 -0
- data/app/assets/stylesheets/css/{components → fields}/status.css +0 -0
- data/app/assets/stylesheets/css/fields/trix.css +17 -0
- data/app/components/avo/actions_component.html.erb +5 -13
- data/app/components/avo/actions_component.rb +39 -1
- data/app/components/avo/common_field_wrapper_component.html.erb +1 -1
- data/app/components/avo/fields/belongs_to_field/edit_component.rb +1 -1
- data/app/components/avo/fields/trix_field/edit_component.html.erb +1 -0
- data/app/components/avo/fields/trix_field/show_component.html.erb +1 -1
- data/app/components/avo/sidebar/item_switcher_component.html.erb +2 -2
- data/app/components/avo/views/resource_edit_component.html.erb +6 -4
- data/app/components/avo/views/resource_edit_component.rb +31 -3
- data/app/components/avo/views/resource_index_component.html.erb +1 -1
- data/app/components/avo/views/resource_show_component.html.erb +2 -2
- data/app/controllers/avo/base_controller.rb +11 -6
- data/app/helpers/avo/url_helpers.rb +8 -9
- data/app/javascript/js/controllers.js +0 -2
- data/app/views/avo/base/edit.html.erb +2 -1
- data/app/views/avo/base/new.html.erb +1 -1
- data/app/views/avo/partials/_custom_tools_alert.html.erb +21 -7
- data/app/views/avo/partials/_table_header.html.erb +9 -1
- data/bin/test +1 -0
- data/lib/avo/app.rb +18 -1
- data/lib/avo/base_action.rb +7 -2
- data/lib/avo/base_resource.rb +6 -1
- data/lib/avo/concerns/fetches_things.rb +19 -12
- data/lib/avo/concerns/has_model.rb +11 -0
- data/lib/avo/dynamic_router.rb +1 -1
- data/lib/avo/engine.rb +1 -3
- data/lib/avo/fields/base_field.rb +1 -0
- data/lib/avo/fields/concerns/is_required.rb +17 -0
- data/lib/avo/hosts/view_record_host.rb +7 -0
- data/lib/avo/menu/base_item.rb +4 -0
- data/lib/avo/menu/dashboard.rb +5 -0
- data/lib/avo/menu/resource.rb +5 -0
- data/lib/avo/version.rb +1 -1
- data/lib/avo.rb +1 -0
- data/lib/generators/avo/install_generator.rb +1 -4
- data/public/avo-assets/avo.css +467 -1069
- data/public/avo-assets/avo.js +70 -70
- data/public/avo-assets/avo.js.map +3 -3
- metadata +9 -8
- data/app/components/avo/views/resource_new_component.html.erb +0 -60
- data/app/components/avo/views/resource_new_component.rb +0 -39
- data/app/javascript/js/controllers/custom/course_resource_controller.js +0 -102
@@ -22,6 +22,13 @@ module Avo
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
# Filters out the resources that are missing the model_class
|
26
|
+
def valid_resources
|
27
|
+
resources.select do |resource|
|
28
|
+
resource.model_class.present?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
25
32
|
# Returns the Avo resource by camelized name
|
26
33
|
#
|
27
34
|
# get_resource_by_name('User') => UserResource
|
@@ -45,9 +52,10 @@ module Avo
|
|
45
52
|
# get_resource_by_name('User') => UserResource
|
46
53
|
# get_resource_by_name(User) => UserResource
|
47
54
|
def get_resource_by_model_name(name)
|
48
|
-
|
49
|
-
|
50
|
-
|
55
|
+
valid_resources
|
56
|
+
.find do |resource|
|
57
|
+
resource.model_class.model_name.name == name.to_s
|
58
|
+
end
|
51
59
|
end
|
52
60
|
|
53
61
|
# Returns the Avo resource by singular snake_cased name
|
@@ -55,9 +63,10 @@ module Avo
|
|
55
63
|
# get_resource_by_controller_name('delayed_backend_active_record_jobs') => DelayedJobResource
|
56
64
|
# get_resource_by_controller_name('users') => UserResource
|
57
65
|
def get_resource_by_controller_name(name)
|
58
|
-
|
59
|
-
|
60
|
-
|
66
|
+
valid_resources
|
67
|
+
.find do |resource|
|
68
|
+
resource.model_class.to_s.pluralize.underscore.tr("/", "_") == name.to_s
|
69
|
+
end
|
61
70
|
end
|
62
71
|
|
63
72
|
# Returns the Avo resource by some name
|
@@ -73,9 +82,10 @@ module Avo
|
|
73
82
|
end
|
74
83
|
|
75
84
|
def get_available_resources(user = nil)
|
76
|
-
|
77
|
-
|
78
|
-
|
85
|
+
valid_resources
|
86
|
+
.select do |resource|
|
87
|
+
Services::AuthorizationService.authorize user, resource.model_class, Avo.configuration.authorization_methods.stringify_keys["index"], raise_exception: false
|
88
|
+
end
|
79
89
|
.sort_by { |r| r.name }
|
80
90
|
end
|
81
91
|
|
@@ -85,9 +95,6 @@ module Avo
|
|
85
95
|
|
86
96
|
def resources_for_navigation(user = nil)
|
87
97
|
get_available_resources(current_user)
|
88
|
-
.select do |resource|
|
89
|
-
resource.model_class.present?
|
90
|
-
end
|
91
98
|
.select do |resource|
|
92
99
|
resource.visible_on_sidebar
|
93
100
|
end
|
data/lib/avo/dynamic_router.rb
CHANGED
data/lib/avo/engine.rb
CHANGED
@@ -17,8 +17,6 @@ module Avo
|
|
17
17
|
::Avo::App.boot
|
18
18
|
end
|
19
19
|
|
20
|
-
config.i18n.load_path += Dir[Avo::Engine.root.join("lib", "generators", "avo", "templates", "locales", "*.{rb,yml}")]
|
21
|
-
|
22
20
|
initializer "avo.autoload" do |app|
|
23
21
|
[
|
24
22
|
["app", "avo", "fields"],
|
@@ -73,7 +71,7 @@ module Avo
|
|
73
71
|
begin
|
74
72
|
Licensing::HQ.new.clear_response
|
75
73
|
rescue => exception
|
76
|
-
puts "Failed to clear Avo HQ response: #{
|
74
|
+
puts "Failed to clear Avo HQ response: #{exception.message}"
|
77
75
|
end
|
78
76
|
end
|
79
77
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Avo
|
2
|
+
module Fields
|
3
|
+
module Concerns
|
4
|
+
module IsRequired
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
def is_required?
|
8
|
+
if required.respond_to? :call
|
9
|
+
Avo::Hosts::ViewRecordHost.new(block: required, record: model, view: view).handle
|
10
|
+
else
|
11
|
+
required
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/avo/menu/base_item.rb
CHANGED
data/lib/avo/menu/dashboard.rb
CHANGED
@@ -2,6 +2,7 @@ class Avo::Menu::Dashboard < Avo::Menu::BaseItem
|
|
2
2
|
extend Dry::Initializer
|
3
3
|
|
4
4
|
option :dashboard
|
5
|
+
option :label, optional: true
|
5
6
|
|
6
7
|
def parsed_dashboard
|
7
8
|
dashboard_by_id || dashboard_by_name
|
@@ -14,4 +15,8 @@ class Avo::Menu::Dashboard < Avo::Menu::BaseItem
|
|
14
15
|
def dashboard_by_id
|
15
16
|
Avo::App.get_dashboard_by_id dashboard.to_s
|
16
17
|
end
|
18
|
+
|
19
|
+
def entity_label
|
20
|
+
parsed_dashboard.navigation_label
|
21
|
+
end
|
17
22
|
end
|
data/lib/avo/menu/resource.rb
CHANGED
@@ -2,8 +2,13 @@ class Avo::Menu::Resource < Avo::Menu::BaseItem
|
|
2
2
|
extend Dry::Initializer
|
3
3
|
|
4
4
|
option :resource
|
5
|
+
option :label, optional: true
|
5
6
|
|
6
7
|
def parsed_resource
|
7
8
|
Avo::App.guess_resource resource.to_s
|
8
9
|
end
|
10
|
+
|
11
|
+
def entity_label
|
12
|
+
parsed_resource.navigation_label
|
13
|
+
end
|
9
14
|
end
|
data/lib/avo/version.rb
CHANGED
data/lib/avo.rb
CHANGED
@@ -13,10 +13,7 @@ module Generators
|
|
13
13
|
route "mount Avo::Engine, at: Avo.configuration.root_path"
|
14
14
|
|
15
15
|
template "initializer/avo.tt", "config/initializers/avo.rb"
|
16
|
-
|
17
|
-
template "locales/avo.nb-NO.yml", "config/locales/avo.nb-NO.yml"
|
18
|
-
template "locales/avo.pt-BR.yml", "config/locales/avo.pt-BR.yml"
|
19
|
-
template "locales/avo.ro.yml", "config/locales/avo.ro.yml"
|
16
|
+
directory File.join(__dir__, "templates", "locales"), "config/locales"
|
20
17
|
end
|
21
18
|
end
|
22
19
|
end
|