effective_resources 1.4.11 → 1.4.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32323055f3cf20452972cf11e64f696a64eb240bee54990e71a41a0179db8ce8
4
- data.tar.gz: 0f3612b1b220e6011c2d7094be638886a6689ab8273555cefc94552afb285361
3
+ metadata.gz: 257e008e3128f7406e1326a914150fff64ef02bd5fd066eaa5f0eae4dda85504
4
+ data.tar.gz: 395118768affb307c80e80ee94b2a07396400697986b4a4a9e582336460b9057
5
5
  SHA512:
6
- metadata.gz: a8b4bfa9a2a682de256222b9e2961be1ba178f44731acba3860e41cd7a030dea93bcc920b863351335f35f05ab473ef613982c4182319e42b73fe9b699e43854
7
- data.tar.gz: 939a5f4e51b5865c4d70c0627edd747c0d2c7c5477d97b9b75ee05e60b3a0a3b304c6890892898302e70d96e860a4e986e3ebe53ff60f8817c3a68a4d5fee88c
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)
@@ -8,7 +8,7 @@
8
8
  .col-4.text-right
9
9
  = render_resource_buttons(@resource, show: false)
10
10
 
11
- = render @resource
11
+ = render_resource_partial(@resource)
12
12
 
13
13
  .form-actions
14
14
  = link_to 'Continue', (resource.action_path(:index) || root_path), class: 'btn btn-primary'
@@ -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 render(@resource) %>";
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 %>;
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.4.11'.freeze
2
+ VERSION = '1.4.12'.freeze
3
3
  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: 1.4.11
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 00:00:00.000000000 Z
11
+ date: 2020-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails