effective_resources 1.8.8 → 1.8.13
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.rb +8 -2
- data/app/controllers/concerns/effective/crud_controller/respond.rb +2 -5
- data/app/controllers/concerns/effective/flash_messages.rb +8 -4
- data/app/controllers/concerns/effective/wizard_controller/save.rb +1 -1
- data/app/models/concerns/acts_as_wizard.rb +1 -1
- data/app/models/effective/resources/naming.rb +3 -3
- data/app/views/application/create.js.erb +1 -1
- data/app/views/application/destroy.js.erb +1 -0
- data/app/views/application/member_action.js.erb +4 -0
- data/app/views/application/update.js.erb +1 -0
- data/lib/effective_resources/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '064967a176b57ad12b7dd280d6f0471ca8655fd061cb9bf0aa58c6bac94772ad'
|
4
|
+
data.tar.gz: f5c4412bd5732c346a5aa7c5764c11178ab109afc58eb9949c97211dde972c00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3169964c8d02171156423cbb0439ed671887d095d2c26fa7ffbf254162cfb9b72b7ab0f63dcc8eef2420bb0139fe2cba00a7e16cec7632232d6af3383796ce34
|
7
|
+
data.tar.gz: cdc0afac03a21901fe95495e8b3ebb64c64017b71487173eb2cb85232a35da5cf367af0725d3a25f3170874e13c753c2fdeb67cb98aab8a5ea6cf75f136bc9a5
|
@@ -45,8 +45,10 @@ module Effective
|
|
45
45
|
@_effective_resource ||= begin
|
46
46
|
relation = instance_exec(&resource_scope_relation) if respond_to?(:resource_scope_relation)
|
47
47
|
|
48
|
-
if respond_to?(:resource_scope_relation)
|
49
|
-
|
48
|
+
if respond_to?(:resource_scope_relation)
|
49
|
+
unless relation.kind_of?(ActiveRecord::Relation) || (relation.kind_of?(Class) && relation.ancestors.include?(ActiveModel::Model))
|
50
|
+
raise('resource_scope must return an ActiveRecord::Relation or class including ActiveModel::Model')
|
51
|
+
end
|
50
52
|
end
|
51
53
|
|
52
54
|
resource = Effective::Resource.new(controller_path, relation: relation)
|
@@ -94,6 +96,10 @@ module Effective
|
|
94
96
|
effective_resource.klass
|
95
97
|
end
|
96
98
|
|
99
|
+
def resource_human_name
|
100
|
+
effective_resource.human_name
|
101
|
+
end
|
102
|
+
|
97
103
|
def resource_plural_name # 'things'
|
98
104
|
effective_resource.plural_name
|
99
105
|
end
|
@@ -15,7 +15,7 @@ module Effective
|
|
15
15
|
|
16
16
|
format.js do
|
17
17
|
flash[:success] ||= resource_flash(:success, resource, action)
|
18
|
-
|
18
|
+
render(action, locals: { remote_form_redirect: resource_redirect_path(resource, action)}) # action.js.erb
|
19
19
|
end
|
20
20
|
end
|
21
21
|
elsif template_present?(action)
|
@@ -27,7 +27,6 @@ module Effective
|
|
27
27
|
|
28
28
|
format.js do
|
29
29
|
flash.now[:success] ||= resource_flash(:success, resource, action)
|
30
|
-
#reload_resource unless action == :destroy # Removed.
|
31
30
|
render(action) # action.js.erb
|
32
31
|
end
|
33
32
|
end
|
@@ -96,9 +95,7 @@ module Effective
|
|
96
95
|
end
|
97
96
|
|
98
97
|
def template_present?(action)
|
99
|
-
|
100
|
-
|
101
|
-
formats = [request.format.symbol.to_s.sub('json', 'js').presence || 'html']
|
98
|
+
formats = [(request.format.symbol.to_s.sub('json', 'js').presence || 'html').to_sym]
|
102
99
|
lookup_context.template_exists?(action, _prefixes, formats: formats)
|
103
100
|
end
|
104
101
|
|
@@ -8,8 +8,10 @@ module Effective
|
|
8
8
|
def flash_success(resource, action = nil, name: nil)
|
9
9
|
raise 'expected an ActiveRecord resource' unless (name || resource.class.respond_to?(:model_name))
|
10
10
|
|
11
|
-
name ||=
|
12
|
-
|
11
|
+
name ||= if resource.respond_to?(:destroyed?) && resource.destroyed?
|
12
|
+
resource_human_name
|
13
|
+
else
|
14
|
+
resource.to_s.presence || resource_human_name
|
13
15
|
end
|
14
16
|
|
15
17
|
"Successfully #{action_verb(action)} #{name || 'resource'}".html_safe
|
@@ -24,8 +26,10 @@ module Effective
|
|
24
26
|
|
25
27
|
messages = flash_errors(resource, e: e)
|
26
28
|
|
27
|
-
name ||=
|
28
|
-
|
29
|
+
name ||= if resource.respond_to?(:destroyed?) && resource.destroyed?
|
30
|
+
resource_human_name
|
31
|
+
else
|
32
|
+
resource.to_s.presence || resource_human_name
|
29
33
|
end
|
30
34
|
|
31
35
|
["Unable to #{action}", (" #{name}" if name), (": #{messages}" if messages)].compact.join.html_safe
|
@@ -7,7 +7,7 @@ module Effective
|
|
7
7
|
action ||= resource.respond_to?("#{step}!") ? step : :save
|
8
8
|
|
9
9
|
if save_resource(resource, action)
|
10
|
-
flash[:success]
|
10
|
+
flash[:success] ||= options.delete(:success) || resource_flash(:success, resource, action)
|
11
11
|
|
12
12
|
@skip_to ||= next_step
|
13
13
|
@redirect_to ||= resource_wizard_path(resource, @skip_to) if was_new_record
|
@@ -31,14 +31,14 @@ module Effective
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def route_name_fallbacks
|
34
|
-
mod = class_name.split('::').first.downcase
|
34
|
+
mod = class_name.split('::').first.to_s.downcase
|
35
35
|
|
36
36
|
matches = [
|
37
37
|
route_name.singularize,
|
38
38
|
[*namespace, plural_name].join('/'),
|
39
39
|
[*namespace, name].join('/'),
|
40
|
-
[mod, *namespace, plural_name].join('/'),
|
41
|
-
[mod, *namespace, name].join('/')
|
40
|
+
[*mod, *namespace, plural_name].join('/'),
|
41
|
+
[*mod, *namespace, name].join('/')
|
42
42
|
]
|
43
43
|
end
|
44
44
|
|
@@ -4,8 +4,8 @@
|
|
4
4
|
EffectiveForm.remote_form_payload = "<%= j render_resource_form(@resource) %>";
|
5
5
|
EffectiveForm.remote_form_commit = "<%= params[:commit] %>";
|
6
6
|
EffectiveForm.remote_form_flash = <%= raw flash.to_json %>;
|
7
|
+
EffectiveForm.remote_form_redirect = "<%= local_assigns[:remote_form_redirect] %>";
|
7
8
|
|
8
9
|
<% if @resource.respond_to?(:refresh_datatables) && @resource.refresh_datatables.present? %>
|
9
10
|
EffectiveForm.remote_form_refresh_datatables = <%= raw Array(@resource.refresh_datatables).uniq.compact.map(&:to_s) %>;
|
10
11
|
<% end %>
|
11
|
-
|
@@ -4,6 +4,7 @@
|
|
4
4
|
EffectiveForm.remote_form_payload = '';
|
5
5
|
EffectiveForm.remote_form_commit = "<%= params[:commit] %>";
|
6
6
|
EffectiveForm.remote_form_flash = <%= raw flash.to_json %>;
|
7
|
+
EffectiveForm.remote_form_redirect = "<%= local_assigns[:remote_form_redirect] %>";
|
7
8
|
|
8
9
|
<% if @resource.respond_to?(:refresh_datatables) && @resource.refresh_datatables.present? %>
|
9
10
|
EffectiveForm.remote_form_refresh_datatables = <%= raw Array(@resource.refresh_datatables).uniq.compact.map(&:to_s) %>;
|
@@ -5,6 +5,10 @@ EffectiveForm.remote_form_payload = "<%= j render_resource_form(@resource, actio
|
|
5
5
|
EffectiveForm.remote_form_commit = "<%= params[:commit] %>";
|
6
6
|
EffectiveForm.remote_form_flash = <%= raw flash.to_json %>;
|
7
7
|
|
8
|
+
<% if !request.get? %>
|
9
|
+
EffectiveForm.remote_form_redirect = "<%= local_assigns[:remote_form_redirect] %>";
|
10
|
+
<% end %>
|
11
|
+
|
8
12
|
<% if !request.get? && @resource.respond_to?(:refresh_datatables) && @resource.refresh_datatables.present? %>
|
9
13
|
EffectiveForm.remote_form_refresh_datatables = <%= raw Array(@resource.refresh_datatables).uniq.compact.map(&:to_s) %>;
|
10
14
|
<% end %>
|
@@ -4,6 +4,7 @@
|
|
4
4
|
EffectiveForm.remote_form_payload = "<%= j render_resource_form(@resource) %>";
|
5
5
|
EffectiveForm.remote_form_commit = "<%= params[:commit] %>";
|
6
6
|
EffectiveForm.remote_form_flash = <%= raw flash.to_json %>;
|
7
|
+
EffectiveForm.remote_form_redirect = "<%= raw local_assigns[:remote_form_redirect] %>";
|
7
8
|
|
8
9
|
<% if @resource.respond_to?(:refresh_datatables) && @resource.refresh_datatables.present? %>
|
9
10
|
EffectiveForm.remote_form_refresh_datatables = <%= raw Array(@resource.refresh_datatables).uniq.compact.map(&:to_s) %>;
|
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: 1.8.
|
4
|
+
version: 1.8.13
|
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: 2021-
|
11
|
+
date: 2021-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|