avo 0.5.0.beta8 → 0.5.0.beta13
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 +46 -50
- data/Gemfile.lock +3 -8
- data/Rakefile +14 -14
- data/app/components/avo/common/multiple_file_viewer_component.rb +1 -1
- data/app/components/avo/common/single_file_viewer_component.rb +1 -1
- data/app/components/avo/edit/field_wrapper_component.rb +3 -3
- data/app/components/avo/edit/fields/trix_field_component.html.erb +1 -1
- data/app/components/avo/index/field_wrapper_component.rb +1 -1
- data/app/components/avo/index/grid_item_component.rb +10 -9
- data/app/components/avo/index/resource_controls_component.rb +2 -2
- data/app/components/avo/panel_component.rb +7 -6
- data/app/components/avo/resource_component.rb +4 -3
- data/app/components/avo/show/field_wrapper_component.rb +3 -3
- data/app/components/avo/views/resource_edit_component.rb +4 -3
- data/app/components/avo/views/resource_index_component.rb +8 -7
- data/app/components/avo/views/resource_new_component.rb +4 -3
- data/app/components/avo/views/resource_show_component.rb +21 -21
- data/app/controllers/avo/actions_controller.rb +30 -29
- data/app/controllers/avo/application_controller.rb +113 -126
- data/app/controllers/avo/attachments_controller.rb +3 -3
- data/app/controllers/avo/base_controller.rb +81 -80
- data/app/controllers/avo/home_controller.rb +2 -2
- data/app/controllers/avo/relations_controller.rb +29 -28
- data/app/controllers/avo/resources_controller.rb +1 -1
- data/app/controllers/avo/search_controller.rb +20 -19
- data/app/helpers/avo/application_helper.rb +48 -42
- data/app/helpers/avo/resources_helper.rb +11 -11
- data/app/mailers/avo/application_mailer.rb +2 -2
- data/app/packs/entrypoints/application.js +9 -4
- data/app/packs/images/logo.png +0 -0
- data/app/packs/js/controllers/fields/code_field_controller.js +14 -14
- data/app/packs/js/controllers/filter_controller.js +9 -8
- data/app/packs/js/toastr.js +1 -0
- data/app/packs/stylesheets/components/code.css +0 -16
- data/avo.gemspec +30 -31
- data/bin/webpack +1 -0
- data/config/initializers/pagy.rb +1 -1
- data/config/routes.rb +12 -12
- data/config/spring.rb +5 -5
- data/config/webpack/base.js +3 -3
- data/config/webpacker.yml +32 -0
- data/db/factories.rb +3 -5
- data/lib/avo.rb +6 -6
- data/lib/avo/app.rb +18 -18
- data/lib/avo/base_action.rb +20 -20
- data/lib/avo/base_resource.rb +41 -45
- data/lib/avo/configuration.rb +16 -18
- data/lib/avo/engine.rb +18 -18
- data/lib/avo/fields/badge_field.rb +2 -2
- data/lib/avo/fields/base_field.rb +25 -26
- data/lib/avo/fields/belongs_to_field.rb +13 -12
- data/lib/avo/fields/boolean_field.rb +4 -4
- data/lib/avo/fields/boolean_group_field.rb +3 -3
- data/lib/avo/fields/code_field.rb +4 -4
- data/lib/avo/fields/country_field.rb +2 -2
- data/lib/avo/fields/currency_field.rb +3 -3
- data/lib/avo/fields/date_field.rb +3 -3
- data/lib/avo/fields/date_time_field.rb +2 -2
- data/lib/avo/fields/external_image_field.rb +2 -2
- data/lib/avo/fields/field_extensions/has_field_name.rb +2 -2
- data/lib/avo/fields/field_extensions/visible_in_different_views.rb +34 -33
- data/lib/avo/fields/file_field.rb +1 -1
- data/lib/avo/fields/files_field.rb +2 -2
- data/lib/avo/fields/gravatar_field.rb +9 -9
- data/lib/avo/fields/has_and_belongs_to_many_field.rb +1 -1
- data/lib/avo/fields/has_many_field.rb +1 -1
- data/lib/avo/fields/has_one_field.rb +2 -2
- data/lib/avo/fields/heading_field.rb +2 -2
- data/lib/avo/fields/hidden_field.rb +1 -1
- data/lib/avo/fields/id_field.rb +3 -3
- data/lib/avo/fields/key_value_field.rb +12 -12
- data/lib/avo/fields/markdown_field.rb +2 -2
- data/lib/avo/fields/number_field.rb +3 -3
- data/lib/avo/fields/password_field.rb +1 -1
- data/lib/avo/fields/select_field.rb +8 -12
- data/lib/avo/fields/status_field.rb +4 -4
- data/lib/avo/fields/text_field.rb +2 -2
- data/lib/avo/fields/textarea_field.rb +2 -2
- data/lib/avo/fields/trix_field.rb +1 -1
- data/lib/avo/fields_collector.rb +4 -5
- data/lib/avo/filters/base_filter.rb +6 -6
- data/lib/avo/filters/boolean_filter.rb +1 -1
- data/lib/avo/filters/select_filter.rb +1 -1
- data/lib/avo/licensing/h_q.rb +56 -55
- data/lib/avo/licensing/license.rb +5 -5
- data/lib/avo/licensing/license_manager.rb +4 -4
- data/lib/avo/licensing/null_license.rb +2 -2
- data/lib/avo/licensing/pro_license.rb +1 -1
- data/lib/avo/loaders/fields_loader.rb +4 -4
- data/lib/avo/services/authorization_service.rb +2 -2
- data/lib/avo/services/panel_service.rb +4 -4
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/action_generator.rb +4 -4
- data/lib/generators/avo/controller_generator.rb +4 -4
- data/lib/generators/avo/filter_generator.rb +5 -5
- data/lib/generators/avo/install_generator.rb +8 -8
- data/lib/generators/avo/locales_generator.rb +5 -5
- data/lib/generators/avo/partials_generator.rb +4 -4
- data/lib/generators/avo/resource_generator.rb +5 -5
- data/lib/generators/avo/templates/action.tt +0 -4
- data/lib/generators/avo/templates/resource/resource.tt +3 -13
- data/lib/tasks/avo_tasks.rake +0 -60
- data/public/avo-packs/css/{application-5bb09ba4.css → application-9d115b7e.css} +124 -276
- data/public/avo-packs/css/application-9d115b7e.css.br +0 -0
- data/public/avo-packs/css/application-9d115b7e.css.gz +0 -0
- data/public/avo-packs/css/application-9d115b7e.css.map +1 -0
- data/public/avo-packs/css/application-9d115b7e.css.map.br +0 -0
- data/public/avo-packs/css/application-9d115b7e.css.map.gz +0 -0
- data/public/avo-packs/js/application-4751feac1bb0404b9c47.js +26 -0
- data/public/avo-packs/js/{application-86a3ea5a835b0c758203.js.LICENSE.txt → application-4751feac1bb0404b9c47.js.LICENSE.txt} +0 -0
- data/public/avo-packs/js/application-4751feac1bb0404b9c47.js.br +0 -0
- data/public/avo-packs/js/application-4751feac1bb0404b9c47.js.gz +0 -0
- data/public/avo-packs/js/application-4751feac1bb0404b9c47.js.map +1 -0
- data/public/avo-packs/js/application-4751feac1bb0404b9c47.js.map.br +0 -0
- data/public/avo-packs/js/application-4751feac1bb0404b9c47.js.map.gz +0 -0
- data/public/avo-packs/manifest.json +16 -16
- data/public/avo-packs/media/images/dadf2db36589607d107d.png +0 -0
- metadata +16 -31
- data/config/initializers/inline_svg.rb +0 -33
- data/public/avo-packs/css/application-5bb09ba4.css.br +0 -0
- data/public/avo-packs/css/application-5bb09ba4.css.gz +0 -0
- data/public/avo-packs/css/application-5bb09ba4.css.map +0 -1
- data/public/avo-packs/css/application-5bb09ba4.css.map.br +0 -0
- data/public/avo-packs/css/application-5bb09ba4.css.map.gz +0 -0
- data/public/avo-packs/js/application-86a3ea5a835b0c758203.js +0 -26
- data/public/avo-packs/js/application-86a3ea5a835b0c758203.js.br +0 -0
- data/public/avo-packs/js/application-86a3ea5a835b0c758203.js.gz +0 -0
- data/public/avo-packs/js/application-86a3ea5a835b0c758203.js.map +0 -1
- data/public/avo-packs/js/application-86a3ea5a835b0c758203.js.map.br +0 -0
- data/public/avo-packs/js/application-86a3ea5a835b0c758203.js.map.gz +0 -0
- data/public/avo-packs/media/images/f1b4befac91a3336db9a.png +0 -0
@@ -21,7 +21,8 @@ class Avo::Views::ResourceNewComponent < ViewComponent::Base
|
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
|
25
|
+
def via_resource?
|
26
|
+
params[:via_relation_class].present? && params[:via_resource_id].present?
|
27
|
+
end
|
27
28
|
end
|
@@ -38,29 +38,29 @@ class Avo::Views::ResourceShowComponent < Avo::ResourceComponent
|
|
38
38
|
end
|
39
39
|
|
40
40
|
private
|
41
|
-
def via_resource?
|
42
|
-
params[:via_resource_class].present? and params[:via_resource_id].present?
|
43
|
-
end
|
44
41
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
@has_many_panels = []
|
49
|
-
@has_as_belongs_to_many_panels = []
|
42
|
+
def via_resource?
|
43
|
+
params[:via_resource_class].present? && params[:via_resource_id].present?
|
44
|
+
end
|
50
45
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
@has_many_panels << field
|
57
|
-
when 'Avo::Fields::HasAndBelongsToManyField'
|
58
|
-
@has_as_belongs_to_many_panels << field
|
59
|
-
else
|
60
|
-
@fields_by_panel[field.panel_name] ||= []
|
61
|
-
@fields_by_panel[field.panel_name] << field
|
62
|
-
end
|
63
|
-
end
|
46
|
+
def split_panel_fields
|
47
|
+
@fields_by_panel = {}
|
48
|
+
@has_one_panels = []
|
49
|
+
@has_many_panels = []
|
50
|
+
@has_as_belongs_to_many_panels = []
|
64
51
|
|
52
|
+
@resource.get_fields.each do |field|
|
53
|
+
case field.class.to_s
|
54
|
+
when "Avo::Fields::HasOneField"
|
55
|
+
@has_one_panels << field
|
56
|
+
when "Avo::Fields::HasManyField"
|
57
|
+
@has_many_panels << field
|
58
|
+
when "Avo::Fields::HasAndBelongsToManyField"
|
59
|
+
@has_as_belongs_to_many_panels << field
|
60
|
+
else
|
61
|
+
@fields_by_panel[field.panel_name] ||= []
|
62
|
+
@fields_by_panel[field.panel_name] << field
|
63
|
+
end
|
65
64
|
end
|
65
|
+
end
|
66
66
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_dependency
|
1
|
+
require_dependency "avo/application_controller"
|
2
2
|
|
3
3
|
module Avo
|
4
4
|
class ActionsController < ApplicationController
|
@@ -11,11 +11,11 @@ module Avo
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def handle
|
14
|
-
resource_ids = action_params[:fields][:resource_ids].split(
|
14
|
+
resource_ids = action_params[:fields][:resource_ids].split(",").map(&:to_i)
|
15
15
|
models = @resource.model_class.find resource_ids
|
16
16
|
|
17
17
|
fields = action_params[:fields].select do |key, value|
|
18
|
-
key !=
|
18
|
+
key != "resource_ids"
|
19
19
|
end
|
20
20
|
|
21
21
|
performed_action = @action.handle_action(models: models, fields: fields)
|
@@ -24,44 +24,45 @@ module Avo
|
|
24
24
|
end
|
25
25
|
|
26
26
|
private
|
27
|
-
def action_params
|
28
|
-
params.permit(:resource_name, :action_id, fields: {})
|
29
|
-
end
|
30
27
|
|
31
|
-
|
32
|
-
|
28
|
+
def action_params
|
29
|
+
params.permit(:resource_name, :action_id, fields: {})
|
30
|
+
end
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
end
|
32
|
+
def set_action
|
33
|
+
action_class = params[:action_id].gsub("avo_actions_", "").classify.safe_constantize
|
37
34
|
|
38
|
-
|
35
|
+
if params[:id].present?
|
36
|
+
model = @resource.model_class.find params[:id]
|
39
37
|
end
|
40
38
|
|
41
|
-
|
42
|
-
|
43
|
-
response[:message_type] ||= :notice
|
44
|
-
response[:message] ||= I18n.t('avo.action_ran_successfully')
|
39
|
+
@action = action_class.new(model: model, resource: resource, user: _current_user)
|
40
|
+
end
|
45
41
|
|
46
|
-
|
47
|
-
|
48
|
-
|
42
|
+
def respond(response)
|
43
|
+
response[:type] ||= :reload
|
44
|
+
response[:message_type] ||= :notice
|
45
|
+
response[:message] ||= I18n.t("avo.action_ran_successfully")
|
49
46
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
path = response[:path]
|
47
|
+
if response[:type] == :download
|
48
|
+
return send_data response[:path], filename: response[:filename]
|
49
|
+
end
|
54
50
|
|
55
|
-
|
56
|
-
|
57
|
-
|
51
|
+
respond_to do |format|
|
52
|
+
format.html do
|
53
|
+
if response[:type] == :redirect
|
54
|
+
path = response[:path]
|
58
55
|
|
59
|
-
|
60
|
-
|
61
|
-
redirect_back fallback_location: resources_path(@resource.model_class), "#{response[:message_type]}": response[:message]
|
56
|
+
if path.respond_to? :call
|
57
|
+
path = instance_eval(&path)
|
62
58
|
end
|
59
|
+
|
60
|
+
redirect_to path, "#{response[:message_type]}": response[:message]
|
61
|
+
elsif response[:type] == :reload
|
62
|
+
redirect_back fallback_location: resources_path(@resource.model_class), "#{response[:message_type]}": response[:message]
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
66
|
+
end
|
66
67
|
end
|
67
68
|
end
|
@@ -23,11 +23,13 @@ module Avo
|
|
23
23
|
def exception_logger(exception)
|
24
24
|
respond_to do |format|
|
25
25
|
format.html { raise exception }
|
26
|
-
format.json {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
format.json {
|
27
|
+
render json: {
|
28
|
+
errors: exception.respond_to?(:record) && exception.record.present? ? exception.record.errors : [],
|
29
|
+
message: exception.message,
|
30
|
+
traces: exception.backtrace
|
31
|
+
}, status: ActionDispatch::ExceptionWrapper.status_code_for_exception(exception.class.name)
|
32
|
+
}
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
@@ -48,8 +50,7 @@ module Avo
|
|
48
50
|
if keep_query_params
|
49
51
|
existing_params = Addressable::URI.parse(request.fullpath).query_values.symbolize_keys
|
50
52
|
end
|
51
|
-
rescue;end
|
52
|
-
|
53
|
+
rescue; end
|
53
54
|
send :"resources_#{model.model_name.route_key}_path", **existing_params, **args
|
54
55
|
end
|
55
56
|
|
@@ -62,22 +63,13 @@ module Avo
|
|
62
63
|
if keep_query_params
|
63
64
|
existing_params = Addressable::URI.parse(request.fullpath).query_values.symbolize_keys
|
64
65
|
end
|
65
|
-
rescue;end
|
66
|
-
|
66
|
+
rescue; end
|
67
67
|
Addressable::Template.new("#{Avo.configuration.root_path}/resources/#{@parent_resource.model.model_name.route_key}/#{@parent_resource.model.id}/#{@resource.route_key}{?query*}")
|
68
68
|
.expand({query: {**existing_params, **args}})
|
69
69
|
.to_str
|
70
70
|
end
|
71
71
|
|
72
72
|
def resource_path(model = nil, resource_id: nil, keep_query_params: false, **args)
|
73
|
-
existing_params = {}
|
74
|
-
|
75
|
-
begin
|
76
|
-
if keep_query_params
|
77
|
-
existing_params = Addressable::URI.parse(request.fullpath).query_values.symbolize_keys
|
78
|
-
end
|
79
|
-
rescue;end
|
80
|
-
|
81
73
|
return send :"resources_#{model.model_name.route_key.singularize}_path", resource_id, **args if resource_id.present?
|
82
74
|
|
83
75
|
send :"resources_#{model.model_name.route_key.singularize}_path", model, **args
|
@@ -108,151 +100,146 @@ module Avo
|
|
108
100
|
end
|
109
101
|
|
110
102
|
private
|
111
|
-
def set_resource_name
|
112
|
-
@resource_name = resource_name
|
113
|
-
end
|
114
103
|
|
115
|
-
|
116
|
-
|
117
|
-
|
104
|
+
def set_resource_name
|
105
|
+
@resource_name = resource_name
|
106
|
+
end
|
118
107
|
|
119
|
-
|
120
|
-
|
121
|
-
|
108
|
+
def set_related_resource_name
|
109
|
+
@related_resource_name = related_resource_name
|
110
|
+
end
|
122
111
|
|
123
|
-
|
124
|
-
|
125
|
-
|
112
|
+
def set_resource
|
113
|
+
@resource = resource.hydrate(params: params)
|
114
|
+
end
|
126
115
|
|
127
|
-
|
128
|
-
|
129
|
-
|
116
|
+
def set_related_resource
|
117
|
+
@related_resource = related_resource.hydrate(params: params)
|
118
|
+
end
|
130
119
|
|
131
|
-
|
132
|
-
|
133
|
-
|
120
|
+
def set_model
|
121
|
+
@model = eager_load_files(@resource, @resource.model_class).find params[:id]
|
122
|
+
end
|
134
123
|
|
135
|
-
|
136
|
-
|
137
|
-
|
124
|
+
def set_related_model
|
125
|
+
@related_model = eager_load_files(@related_resource, @related_resource.model_class).find params[:related_id]
|
126
|
+
end
|
138
127
|
|
139
|
-
|
140
|
-
|
141
|
-
|
128
|
+
def hydrate_resource
|
129
|
+
@resource.hydrate(view: action_name.to_sym, user: _current_user)
|
130
|
+
end
|
142
131
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
else
|
147
|
-
@authorization.set_record(@resource.model_class).authorize_action :index
|
148
|
-
end
|
149
|
-
end
|
132
|
+
def hydrate_related_resource
|
133
|
+
@related_resource.hydrate(view: action_name.to_sym, user: _current_user)
|
134
|
+
end
|
150
135
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
136
|
+
def authorize_action
|
137
|
+
if @model.present?
|
138
|
+
@authorization.set_record(@model).authorize_action :index
|
139
|
+
else
|
140
|
+
@authorization.set_record(@resource.model_class).authorize_action :index
|
141
|
+
end
|
142
|
+
end
|
155
143
|
|
156
|
-
|
144
|
+
# Get the pluralized resource name for this request
|
145
|
+
# Ex: projects, teams, users
|
146
|
+
def resource_name
|
147
|
+
return params[:resource_name] if params[:resource_name].present?
|
157
148
|
|
158
|
-
|
159
|
-
request.path
|
160
|
-
.match(/\/?#{Avo.configuration.root_path.gsub('/', '')}\/resources\/([a-z1-9\-_]*)\/?/mi)
|
161
|
-
.captures
|
162
|
-
.first
|
163
|
-
rescue => exception
|
164
|
-
end
|
165
|
-
end
|
149
|
+
return controller_name if controller_name.present?
|
166
150
|
|
167
|
-
|
168
|
-
|
151
|
+
begin
|
152
|
+
request.path
|
153
|
+
.match(/\/?#{Avo.configuration.root_path.delete('/')}\/resources\/([a-z1-9\-_]*)\/?/mi)
|
154
|
+
.captures
|
155
|
+
.first
|
156
|
+
rescue
|
169
157
|
end
|
158
|
+
end
|
170
159
|
|
171
|
-
|
172
|
-
|
173
|
-
|
160
|
+
def related_resource_name
|
161
|
+
params[:related_name]
|
162
|
+
end
|
174
163
|
|
175
|
-
|
164
|
+
# Gets the Avo resource for this request based on the request from the `resource_name` "param"
|
165
|
+
# Ex: Avo::Resources::Project, Avo::Resources::Team, Avo::Resources::User
|
166
|
+
def resource
|
167
|
+
resource = App.get_resource @resource_name.to_s.camelize.singularize
|
176
168
|
|
177
|
-
|
169
|
+
return resource if resource.present?
|
178
170
|
|
179
|
-
|
180
|
-
|
171
|
+
App.get_resource_by_controller_name @resource_name
|
172
|
+
end
|
181
173
|
|
182
|
-
|
183
|
-
|
174
|
+
def related_resource
|
175
|
+
reflection = @model._reflections[params[:related_name]]
|
184
176
|
|
185
|
-
|
186
|
-
reflected_model = reflection.klass
|
187
|
-
else
|
188
|
-
reflected_model = reflection.klass
|
189
|
-
end
|
177
|
+
reflected_model = reflection.klass
|
190
178
|
|
191
|
-
|
192
|
-
|
179
|
+
App.get_resource_by_model_name reflected_model
|
180
|
+
end
|
193
181
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
end
|
207
|
-
|
208
|
-
return query.eager_load "#{field.id}_#{attachment}": :blob
|
209
|
-
# return query.send :"with_attached_#{field}"
|
182
|
+
def eager_load_files(resource, query)
|
183
|
+
if resource.attached_file_fields.present?
|
184
|
+
resource.attached_file_fields.map do |field|
|
185
|
+
# abort "#{field.pluralize}".inspect
|
186
|
+
# abort field.class.inspect
|
187
|
+
attachment = case field.class.to_s
|
188
|
+
when "Avo::Fields::FileField"
|
189
|
+
"attachment"
|
190
|
+
when "Avo::Fields::FilesField"
|
191
|
+
"attachments"
|
192
|
+
else
|
193
|
+
"attachment"
|
210
194
|
end
|
211
|
-
end
|
212
195
|
|
213
|
-
|
196
|
+
return query.eager_load "#{field.id}_#{attachment}": :blob
|
197
|
+
# return query.send :"with_attached_#{field}"
|
198
|
+
end
|
214
199
|
end
|
215
200
|
|
201
|
+
query
|
202
|
+
end
|
216
203
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
# model = record = resource.model
|
204
|
+
# def authorize_user
|
205
|
+
# return if params[:controller] == 'avo/search'
|
221
206
|
|
222
|
-
|
223
|
-
# record = resource
|
224
|
-
# end
|
207
|
+
# model = record = resource.model
|
225
208
|
|
226
|
-
|
227
|
-
|
209
|
+
# if ['show', 'edit', 'update'].include?(params[:action]) && params[:controller] == 'avo/resources'
|
210
|
+
# record = resource
|
211
|
+
# end
|
228
212
|
|
229
|
-
|
230
|
-
|
231
|
-
end
|
213
|
+
# # AuthorizationService::authorize_action _current_user, record, params[:action] return render_unauthorized unless
|
214
|
+
# end
|
232
215
|
|
233
|
-
|
234
|
-
|
235
|
-
|
216
|
+
def _authenticate!
|
217
|
+
instance_eval(&Avo.configuration.authenticate)
|
218
|
+
end
|
236
219
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
request.referrer
|
241
|
-
end
|
220
|
+
def render_unauthorized(exception)
|
221
|
+
if !exception.is_a? Pundit::NotDefinedError
|
222
|
+
flash[:notice] = t "avo.not_authorized"
|
242
223
|
|
243
|
-
|
224
|
+
redirect_url = if request.referrer.blank? || (request.referrer == request.url)
|
225
|
+
root_url
|
226
|
+
else
|
227
|
+
request.referrer
|
244
228
|
end
|
245
|
-
end
|
246
229
|
|
247
|
-
|
248
|
-
@authorization = Services::AuthorizationService.new _current_user
|
230
|
+
redirect_to(redirect_url)
|
249
231
|
end
|
232
|
+
end
|
250
233
|
|
251
|
-
|
252
|
-
|
253
|
-
|
234
|
+
def set_authorization
|
235
|
+
@authorization = Services::AuthorizationService.new _current_user
|
236
|
+
end
|
254
237
|
|
255
|
-
|
256
|
-
|
238
|
+
def set_container_classes
|
239
|
+
contain = !Avo.configuration.full_width_container
|
240
|
+
contain = false if Avo.configuration.full_width_index_view && action_name.to_sym == :index && self.class.superclass.to_s == "Avo::ResourcesController"
|
241
|
+
|
242
|
+
@container_classes = contain ? "2xl:container 2xl:mx-auto" : ""
|
243
|
+
end
|
257
244
|
end
|
258
245
|
end
|