effective_resources 1.2.8 → 1.2.9

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
  SHA1:
3
- metadata.gz: f5796766ca6ef1da75bc85df2b729de8fc3e02bf
4
- data.tar.gz: afe319a2b8728d399fd1aec332efd81a3ec84d57
3
+ metadata.gz: 80f342d10de6f2f7786972e79f3afa354685bf31
4
+ data.tar.gz: efe2fbb67f1f01c850e2e6a5e4040b03889fd20c
5
5
  SHA512:
6
- metadata.gz: 8bc1b3ceecac8b739cfb4abb5709f874f242232686442e6d84b2304c5b3d13d93c8ac2ff9ab99e91c1bee24a89142a8fd5ae09429985fc744d14e4a32e2b1691
7
- data.tar.gz: 4871a543d1b8776a17c88b40219b22a90213a5288918b1ae41d2e4c97bd3040a3ff0b61aad94e6e6c99f1da9bf8a92874bdfc823a9af3ee43289aa24cc8e3c97
6
+ metadata.gz: aeed7f84960367679ebab343fc64638aa1ad433ee64376042cfb519578583270a1ac15bbd03d3182a44d329d94d1ba44fbf02d427d0068967cb10734c19f0a69
7
+ data.tar.gz: 48af4ce59340e3f97c5216ed7aacdaa2aac4bf4a0bf7778f3be810f15fca533c8b989e241e98fc2d4b81d31fc871038a3008e6c4a66c98f363ba2d56327ca020
@@ -163,7 +163,14 @@ module Effective
163
163
  @page_title ||= "#{action.to_s.titleize} #{resource}"
164
164
 
165
165
  if request.get?
166
- run_callbacks(:resource_render); return
166
+ run_callbacks(:resource_render)
167
+
168
+ respond_to do |format|
169
+ format.html { }
170
+ format.js { render(template_present?(action) ? action : 'member_action.js', locals: { action: action }) }
171
+ end
172
+
173
+ return
167
174
  end
168
175
 
169
176
  to_assign = (send(resource_params_method_name) rescue {})
@@ -84,7 +84,7 @@ module Effective
84
84
  end
85
85
 
86
86
  # Recursively add any accepts_nested_resources
87
- effective_resource.nested_resources.each do |nested|
87
+ effective_resource.accepts_nested_attributes.each do |nested|
88
88
  if (nested_params = permitted_params_for(nested.klass, namespaces)).present?
89
89
  nested_params.insert(nested_params.rindex { |obj| !obj.kind_of?(Hash)} + 1, :_destroy)
90
90
  permitted_params << { "#{nested.name}_attributes".to_sym => nested_params }
@@ -67,6 +67,11 @@ module Effective
67
67
  klass.reflect_on_all_associations(:has_one).select { |ass| ass.options[:autosave] }
68
68
  end
69
69
 
70
+ def accepts_nested_attributes
71
+ return [] unless klass.respond_to?(:reflect_on_all_associations)
72
+ klass.reflect_on_all_associations.select { |ass| ass.options[:autosave] }
73
+ end
74
+
70
75
  def associated(name)
71
76
  name = (name.to_s.end_with?('_id') ? name.to_s[0...-3] : name).to_sym
72
77
  klass.reflect_on_all_associations.find { |ass| ass.name == name } || effective_addresses(name)
@@ -1,12 +1,9 @@
1
1
  <% resource = (@_effective_resource || Effective::Resource.new(controller_path)) %>
2
2
  <% @resource = instance_variable_get('@' + resource.name) if resource.name %>
3
3
 
4
- <% unless params[:_datatable_action] %>
5
- EffectiveForm.remote_form_payload = "<%= j render_resource_form(@resource, action: action) %>";
6
- <% end %>
7
-
4
+ EffectiveForm.remote_form_payload = "<%= j render_resource_form(@resource, action: action) %>";
8
5
  EffectiveForm.remote_form_flash = <%= raw flash.to_json %>;
9
6
 
10
- <% if @resource.respond_to?(:refresh_datatables) && @resource.refresh_datatables.present? %>
7
+ <% if !request.get? && @resource.respond_to?(:refresh_datatables) && @resource.refresh_datatables.present? %>
11
8
  EffectiveForm.remote_form_refresh_datatables = <%= raw Array(@resource.refresh_datatables).uniq.compact.map(&:to_s) %>;
12
9
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.2.8'.freeze
2
+ VERSION = '1.2.9'.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.2.8
4
+ version: 1.2.9
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: 2019-03-19 00:00:00.000000000 Z
11
+ date: 2019-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails