effective_resources 1.4.11 → 1.4.12
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 257e008e3128f7406e1326a914150fff64ef02bd5fd066eaa5f0eae4dda85504
|
4
|
+
data.tar.gz: 395118768affb307c80e80ee94b2a07396400697986b4a4a9e582336460b9057
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bdd4a65ca14b8c0e92f312d6d4ad7e49f1fd4966608dd01afb49a637b2f075e6ff92d740148c609ae6239709f786bf5d75fffd7a6292aef5ea60388fcd3c035
|
7
|
+
data.tar.gz: 8e2099089a87a6833f0e1041f85ea8b91954de940ce63433197f8372cf18901d2e8ee6a384529acca2568d5c99b9a2bf7b50713c573e219477055c2707e46153
|
@@ -146,6 +146,30 @@ module EffectiveResourcesHelper
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
+
# Similar to render_resource_form
|
150
|
+
def render_resource_partial(resource, atts = {})
|
151
|
+
unless resource.kind_of?(ActiveRecord::Base) || resource.class.ancestors.include?(ActiveModel::Model)
|
152
|
+
raise 'expected first argument to be an ActiveRecord or ActiveModel object'
|
153
|
+
end
|
154
|
+
|
155
|
+
raise 'expected attributes to be a Hash' unless atts.kind_of?(Hash)
|
156
|
+
|
157
|
+
effective_resource = (atts.delete(:effective_resource) || find_effective_resource)
|
158
|
+
|
159
|
+
action = atts.delete(:action)
|
160
|
+
atts = { :namespace => (effective_resource.namespace.to_sym if effective_resource.namespace), effective_resource.name.to_sym => resource }.compact.merge(atts)
|
161
|
+
|
162
|
+
if lookup_context.template_exists?(effective_resource.name, controller._prefixes, :partial)
|
163
|
+
render(effective_resource.name, atts)
|
164
|
+
elsif lookup_context.template_exists?(effective_resource.name, [effective_resource.plural_name], :partial)
|
165
|
+
render(effective_resource.plural_name + '/' + effective_resource.name, atts)
|
166
|
+
elsif lookup_context.template_exists?(effective_resource.name, [effective_resource.name], :partial)
|
167
|
+
render(effective_resource.name + '/' + effective_resource.name, atts)
|
168
|
+
else
|
169
|
+
render(resource, atts) # Will raise the regular error
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
149
173
|
# Tableize attributes
|
150
174
|
# This is used by effective_orders, effective_logging, effective_trash and effective_mergery
|
151
175
|
def tableize_hash(obj, table: 'table', th: true, sub_table: 'table', sub_th: true, flatten: true)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% resource = (@_effective_resource || Effective::Resource.new(controller_path)) %>
|
2
2
|
<% @resource = instance_variable_get('@' + resource.name) if resource.name %>
|
3
3
|
|
4
|
-
EffectiveForm.remote_form_payload = "<%= j
|
4
|
+
EffectiveForm.remote_form_payload = "<%= j render_resource_partial(@resource) %>";
|
5
5
|
EffectiveForm.remote_form_commit = "<%= params[:commit] %>";
|
6
6
|
EffectiveForm.remote_form_flash = <%= raw flash.to_json %>;
|
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.4.
|
4
|
+
version: 1.4.12
|
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: 2020-05-
|
11
|
+
date: 2020-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|