avo 3.5.6 → 3.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/components/avo/fields/select_field/show_component.html.erb +2 -2
- data/app/components/avo/views/resource_index_component.rb +0 -3
- data/app/controllers/avo/base_controller.rb +4 -3
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/concerns/override_controller.rb +20 -0
- data/lib/generators/avo/controller_generator.rb +5 -1
- data/lib/generators/avo/resource_generator.rb +6 -2
- data/lib/generators/rails/avo_resource_generator.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a39429d6be1a1dfcd0f353896f3eec3cf894d03cdd3aa19ddb7353cf13535f9f
|
4
|
+
data.tar.gz: 19d1c9bedadc87f54cc9601d11732706684b890097e712f4d462e46a86b4aca6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7af08e4b3b0682c3ddaa7a407e13ccd06de87aa2b3e28b2c62a99373714a668a4832ebf57f4afa7a91c5878bd8a8c87e175ac4077476384812ed3936f38af77a
|
7
|
+
data.tar.gz: 228d061f6acfb8cce03d06ab8fe8b98178bb7aa3da1e7e717036aa4f4f347b075f27cb4770ae8adb09927f33cf48f884bf636fdc87ef974cd2c5928fff8fa4e8
|
data/Gemfile.lock
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
<%= field_wrapper **field_wrapper_args do %>
|
2
|
-
<%= @field.label %>
|
1
|
+
<%= field_wrapper **field_wrapper_args.merge(dash_if_blank: false) do %>
|
2
|
+
<%= @field.value.nil? ? "—" : @field.label %>
|
3
3
|
<% end %>
|
@@ -135,9 +135,6 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
|
|
135
135
|
|
136
136
|
def authorized_to_search?
|
137
137
|
# Hide the search if the authorization prevents it
|
138
|
-
return true unless resource.authorization.respond_to?(:has_action_method?)
|
139
|
-
return false unless resource.authorization.has_action_method?("search")
|
140
|
-
|
141
138
|
resource.authorization.authorize_action("search", raise_exception: false)
|
142
139
|
end
|
143
140
|
|
@@ -8,8 +8,8 @@ module Avo
|
|
8
8
|
before_action :set_resource
|
9
9
|
before_action :set_applied_filters, only: :index
|
10
10
|
before_action :set_record, only: [:show, :edit, :destroy, :update, :preview]
|
11
|
+
before_action :set_record_to_fill, only: [:new, :edit, :create, :update]
|
11
12
|
before_action :detect_fields
|
12
|
-
before_action :set_record_to_fill
|
13
13
|
before_action :set_edit_title_and_breadcrumbs, only: [:edit, :update]
|
14
14
|
before_action :fill_record, only: [:create, :update]
|
15
15
|
# Don't run base authorizations for associations
|
@@ -102,8 +102,9 @@ module Avo
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def new
|
105
|
-
|
106
|
-
@
|
105
|
+
# Record is already hydrated on set_record_to_fill method
|
106
|
+
@record = @resource.record
|
107
|
+
@resource.hydrate(view: :new, user: _current_user)
|
107
108
|
|
108
109
|
# Handle special cases when creating a new record via a belongs_to relationship
|
109
110
|
if params[:via_belongs_to_resource_class].present?
|
data/lib/avo/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Generators
|
2
|
+
module Avo
|
3
|
+
module Concerns
|
4
|
+
module OverrideController
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
def override_controller?
|
8
|
+
return false unless controller_name.in? controllers_list
|
9
|
+
|
10
|
+
say("Avo uses #{controller_class} internally, overriding it would cause malfunctions.", :red)
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
def controllers_list
|
15
|
+
Dir["app/controllers/avo/*.rb"].map { |file_path| File.basename(file_path, ".rb") }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,16 +1,20 @@
|
|
1
1
|
require_relative "named_base_generator"
|
2
2
|
require_relative "concerns/parent_controller"
|
3
|
+
require_relative "concerns/override_controller"
|
3
4
|
|
4
5
|
module Generators
|
5
6
|
module Avo
|
6
7
|
class ControllerGenerator < NamedBaseGenerator
|
7
|
-
include
|
8
|
+
include Concerns::ParentController
|
9
|
+
include Concerns::OverrideController
|
8
10
|
|
9
11
|
source_root File.expand_path("templates", __dir__)
|
10
12
|
|
11
13
|
namespace "avo:controller"
|
12
14
|
|
13
15
|
def create
|
16
|
+
return if override_controller?
|
17
|
+
|
14
18
|
template "resource/controller.tt", "app/controllers/avo/#{controller_name}.rb"
|
15
19
|
end
|
16
20
|
|
@@ -1,10 +1,12 @@
|
|
1
1
|
require_relative "named_base_generator"
|
2
2
|
require_relative "concerns/parent_controller"
|
3
|
+
require_relative "concerns/override_controller"
|
3
4
|
|
4
5
|
module Generators
|
5
6
|
module Avo
|
6
7
|
class ResourceGenerator < NamedBaseGenerator
|
7
|
-
include
|
8
|
+
include Concerns::ParentController
|
9
|
+
include Concerns::OverrideController
|
8
10
|
|
9
11
|
source_root File.expand_path("templates", __dir__)
|
10
12
|
|
@@ -16,8 +18,10 @@ module Generators
|
|
16
18
|
required: false
|
17
19
|
|
18
20
|
def create
|
21
|
+
return if override_controller?
|
22
|
+
|
19
23
|
template "resource/resource.tt", "app/avo/resources/#{resource_name}.rb"
|
20
|
-
|
24
|
+
invoke "avo:controller", [resource_name], options
|
21
25
|
end
|
22
26
|
|
23
27
|
def resource_class
|
@@ -4,7 +4,7 @@ module Rails
|
|
4
4
|
module Generators
|
5
5
|
class AvoResourceGenerator < ::Rails::Generators::Base
|
6
6
|
def invoke_avo_command
|
7
|
-
invoke "avo:resource", @args, {from_model_generator: true}
|
7
|
+
invoke "avo:resource", @args, {from_model_generator: true}.merge(options)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
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.5.
|
4
|
+
version: 3.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Marin
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-04-
|
13
|
+
date: 2024-04-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -2309,6 +2309,7 @@ files:
|
|
2309
2309
|
- lib/generators/avo/action_generator.rb
|
2310
2310
|
- lib/generators/avo/base_generator.rb
|
2311
2311
|
- lib/generators/avo/card_generator.rb
|
2312
|
+
- lib/generators/avo/concerns/override_controller.rb
|
2312
2313
|
- lib/generators/avo/concerns/parent_controller.rb
|
2313
2314
|
- lib/generators/avo/controller_generator.rb
|
2314
2315
|
- lib/generators/avo/dashboard_generator.rb
|