effective_resources 2.9.0 → 2.9.2

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: 10642ec990cb0ad6b2426415a997aead2f5d53bcdb8a932b3f276af5e9485af9
4
- data.tar.gz: a971535ad4974d3931be497db3595f91e1baac7483f718e3197778e84674e525
3
+ metadata.gz: 39969863270d4e8a60c93f0dd10f138a93936fa84958005d25ad1a6c2ab747dd
4
+ data.tar.gz: 3836b95d6616e55f9bcd9d0e1c859bf17e87ac0d78dcbd89a2cfd5fbb84fd32c
5
5
  SHA512:
6
- metadata.gz: c8ee4692a6b49d21cfe3d591233f9991355cb1d4d3697d5317fceb7186eb9011db71edef3dc8b6ddedc8ba97d3d28b7c7cf80bf753c18a31b344c8cbc7393db1
7
- data.tar.gz: 7cfa99b30169c1bb0bc316dafdc29bad35996b678affea7f21e9ab6fe469bdf4dd6a3fe013d028b8e8fb4cd4281aa809640477db683e3cb0d987bc40d62375b5
6
+ metadata.gz: 7c5b1e1c914d649b9c56004066d21d2d3125a68246dc15c95934850f3e2ae68c4d6eb07e1d55c6d163c2de42bdab06340d26dbd3561273078496aa3a41b80e84
7
+ data.tar.gz: c7e7eb23d4363b1977147d7e26ff2481dadf83ecd7326616f95392df404fff13d9434ac40f8091e41d6d07199b0f9d62f1c6a21bba3252366f5484a90adb32e7
@@ -185,8 +185,10 @@ module Effective
185
185
  respond_to do |format|
186
186
  format.html { }
187
187
  format.js do
188
+ html_template = action if template_present?(action, format: :html)
188
189
  template = template_present?(action) ? action : 'member_action'
189
- render(template, formats: :js, locals: { action: action })
190
+
191
+ render(template, formats: :js, locals: { action: action, html_template: html_template })
190
192
  end
191
193
  end
192
194
 
@@ -103,9 +103,10 @@ module Effective
103
103
  flash[:danger] ||= danger
104
104
  end
105
105
 
106
- def template_present?(action)
106
+ def template_present?(action, format: nil)
107
+ format = Array(format).presence
107
108
  formats = [(request.format.symbol.to_s.sub('json', 'js').presence || 'html').to_sym]
108
- lookup_context.template_exists?(action, _prefixes, formats: formats)
109
+ lookup_context.template_exists?(action, _prefixes, formats: (format || formats))
109
110
  end
110
111
 
111
112
  end
@@ -189,13 +189,15 @@ module EffectiveResourcesHelper
189
189
  safe = atts.delete(:safe)
190
190
  atts = { :namespace => (effective_resource.namespace.to_sym if effective_resource.namespace), effective_resource.name.to_sym => resource }.compact.merge(atts)
191
191
 
192
- if lookup_context.template_exists?(effective_resource.name, controller._prefixes, :partial)
193
- return render(effective_resource.name, atts)
192
+ partial = (action.present? ? action.to_s : effective_resource.name)
193
+
194
+ if lookup_context.template_exists?(partial, controller._prefixes, :partial)
195
+ return render(partial, atts)
194
196
  end
195
197
 
196
198
  effective_resource.view_paths.each do |view_path|
197
- if lookup_context.template_exists?(effective_resource.name, [view_path], :partial)
198
- return render(view_path + '/' + effective_resource.name, atts)
199
+ if lookup_context.template_exists?(partial, [view_path], :partial)
200
+ return render(view_path + '/' + partial, atts)
199
201
  end
200
202
  end
201
203
 
@@ -146,10 +146,16 @@ module ActsAsWizard
146
146
  has_completed_step?(required_steps.last)
147
147
  end
148
148
 
149
- def reset_wizard_steps!
149
+ def reset_all_wizard_steps!
150
150
  update!(wizard_steps: {})
151
151
  end
152
152
 
153
+ def complete_all_wizard_steps!
154
+ now = Time.zone.now
155
+ required_steps.each { |step| wizard_steps[step] ||= now }
156
+ save!
157
+ end
158
+
153
159
  def without_current_step(&block)
154
160
  existing = current_step
155
161
 
@@ -15,9 +15,15 @@ class SizeValidator < ActiveModel::EachValidator
15
15
  max_size = options.try(:[], :less_than) || 2.megabytes
16
16
  message = options.try(:[], :message) || "is too large, please upload a file smaller than #{max_size / 1.megabyte}MB"
17
17
 
18
- if value.blob.byte_size > max_size
19
- record.errors.add(attribute, message)
18
+ blobs = value.try(:blobs) || value.try(:blob) || raise('unable to find blobs')
19
+
20
+ Array(blobs).each do |blob|
21
+ if blob.byte_size > max_size
22
+ record.errors.add(attribute, message)
23
+ break
24
+ end
20
25
  end
21
26
 
27
+ true
22
28
  end
23
29
  end
@@ -1,7 +1,12 @@
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_form(@resource, action: action, safe: true) %>";
4
+ <% if html_template.present? %>
5
+ EffectiveForm.remote_form_payload = "<%= j(render_resource_partial(@resource, action: action)) %>";
6
+ <% else %>
7
+ EffectiveForm.remote_form_payload = "<%= j(render_resource_form(@resource, action: action, safe: true).presence || render_resource_partial(@resource)) %>";
8
+ <% end %>
9
+
5
10
  EffectiveForm.remote_form_commit = "<%= params[:commit] %>";
6
11
  EffectiveForm.remote_form_flash = <%= raw flash.to_json %>;
7
12
 
@@ -46,10 +46,8 @@ module EffectiveResources
46
46
  app.config.to_prepare do
47
47
  if defined?(CanCan::Ability)
48
48
  CanCan::Ability.module_eval do
49
- CRUD_ACTIONS = [:index, :new, :create, :edit, :update, :show, :destroy]
50
-
51
49
  def crud
52
- CRUD_ACTIONS
50
+ [:index, :new, :create, :edit, :update, :show, :destroy]
53
51
  end
54
52
  end
55
53
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '2.9.0'.freeze
2
+ VERSION = '2.9.2'.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: 2.9.0
4
+ version: 2.9.2
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: 2023-08-16 00:00:00.000000000 Z
11
+ date: 2023-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails