effective_resources 2.27.13 → 2.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/concerns/effective/crud_controller/actions.rb +27 -2
- data/app/controllers/concerns/effective/crud_controller/users.rb +15 -0
- data/app/controllers/concerns/effective/crud_controller.rb +1 -0
- data/app/views/application/nested_datatable_action.js.erb +5 -0
- data/lib/effective_resources/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf2ef756b2bbdecbc58084d754dc2174bbd3c6ac3bf3109bfeaac0b5eb90405d
|
4
|
+
data.tar.gz: ac73d16805a6a7b2a693d73cc22a0c5d06ea955079478f2beff574a07c8d7708
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dde2d18c768d7940950d5aa0aaa78b41090d96a14067bb9f913027da55ba04a6b6d396fa8bacdcbc9bcddd1c64a203427c9096bd142da9ccbfe8c7ec321339d5
|
7
|
+
data.tar.gz: d834d2b0f76383055355aeb261d7871bfcefb983661e1c228fbcca8c5148730f0cf50dfdc859237f8091a63d197c995d7588638b059467ad4997d2ee85158487
|
@@ -81,7 +81,7 @@ module Effective
|
|
81
81
|
end
|
82
82
|
|
83
83
|
if respond_to?(:current_user) && resource.respond_to?(:created_by=)
|
84
|
-
resource.created_by ||= current_user
|
84
|
+
resource.created_by ||= (impersonation_user || current_user)
|
85
85
|
end
|
86
86
|
|
87
87
|
resource.assign_attributes(send(resource_params_method_name))
|
@@ -142,7 +142,7 @@ module Effective
|
|
142
142
|
end
|
143
143
|
|
144
144
|
if respond_to?(:current_user) && resource.respond_to?(:updated_by=)
|
145
|
-
resource.updated_by ||= current_user
|
145
|
+
resource.updated_by ||= (impersonation_user || current_user)
|
146
146
|
end
|
147
147
|
|
148
148
|
resource.assign_attributes(send(resource_params_method_name))
|
@@ -255,5 +255,30 @@ module Effective
|
|
255
255
|
end
|
256
256
|
end
|
257
257
|
|
258
|
+
def nested_datatable_action(action = nil)
|
259
|
+
Rails.logger.info "Processed by Effective::CrudController#nested_datatable_action"
|
260
|
+
|
261
|
+
raise('expected a GET request') unless request.get?
|
262
|
+
raise('expected @datatable to be present') if @datatable.nil?
|
263
|
+
|
264
|
+
action ||= action_name
|
265
|
+
|
266
|
+
EffectiveResources.authorize!(self, :index, @datatable)
|
267
|
+
@page_title ||= @datatable.datatable_name
|
268
|
+
|
269
|
+
respond_to do |format|
|
270
|
+
format.html do
|
271
|
+
html_template = action if template_present?(action, format: :html)
|
272
|
+
render(html_template || 'index')
|
273
|
+
end
|
274
|
+
|
275
|
+
format.js do
|
276
|
+
html_template = [controller_path, action].join('/') if template_present?(action, format: :html)
|
277
|
+
template = template_present?(action) ? action : 'nested_datatable_action'
|
278
|
+
|
279
|
+
render(template, formats: :js, locals: { action: action, html_template: html_template })
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
258
283
|
end
|
259
284
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Effective
|
2
|
+
module CrudController
|
3
|
+
module Users
|
4
|
+
|
5
|
+
# If we're impersonating, this is the original user
|
6
|
+
def impersonation_user
|
7
|
+
return unless current_user.present?
|
8
|
+
return unless session[:impersonation_user_id].present?
|
9
|
+
|
10
|
+
@impersonation_user ||= current_user.class.find(session[:impersonation_user_id])
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -10,6 +10,7 @@ module Effective
|
|
10
10
|
include Effective::CrudController::Respond
|
11
11
|
include Effective::CrudController::Save
|
12
12
|
include Effective::CrudController::Submits
|
13
|
+
include Effective::CrudController::Users
|
13
14
|
|
14
15
|
included do
|
15
16
|
define_callbacks :resource_render, :resource_before_save, :resource_after_save, :resource_after_commit, :resource_error
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<% if local_assigns[:html_template].present? %>
|
2
|
+
EffectiveForm.remote_form_payload = "<%= j(render(template: local_assigns[:html_template], formats: :html)) %>";
|
3
|
+
<% else %>
|
4
|
+
EffectiveForm.remote_form_payload = "<%= j(render_datatable(@datatable, nested: true)) %>";
|
5
|
+
<% end %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.29.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -197,6 +197,7 @@ files:
|
|
197
197
|
- app/controllers/concerns/effective/crud_controller/respond.rb
|
198
198
|
- app/controllers/concerns/effective/crud_controller/save.rb
|
199
199
|
- app/controllers/concerns/effective/crud_controller/submits.rb
|
200
|
+
- app/controllers/concerns/effective/crud_controller/users.rb
|
200
201
|
- app/controllers/concerns/effective/flash_messages.rb
|
201
202
|
- app/controllers/concerns/effective/impersonation_controller/destroy.rb
|
202
203
|
- app/controllers/concerns/effective/impersonation_controller/impersonate.rb
|
@@ -267,6 +268,7 @@ files:
|
|
267
268
|
- app/views/application/edit.js.erb
|
268
269
|
- app/views/application/index.html.haml
|
269
270
|
- app/views/application/member_action.js.erb
|
271
|
+
- app/views/application/nested_datatable_action.js.erb
|
270
272
|
- app/views/application/new.html.haml
|
271
273
|
- app/views/application/new.js.erb
|
272
274
|
- app/views/application/show.html.haml
|