effective_resources 2.9.0 → 2.9.2
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/actions.rb +3 -1
- data/app/controllers/concerns/effective/crud_controller/respond.rb +3 -2
- data/app/helpers/effective_resources_helper.rb +6 -4
- data/app/models/concerns/acts_as_wizard.rb +7 -1
- data/app/validators/size_validator.rb +8 -2
- data/app/views/application/member_action.js.erb +6 -1
- data/lib/effective_resources/engine.rb +1 -3
- 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: 39969863270d4e8a60c93f0dd10f138a93936fa84958005d25ad1a6c2ab747dd
|
4
|
+
data.tar.gz: 3836b95d6616e55f9bcd9d0e1c859bf17e87ac0d78dcbd89a2cfd5fbb84fd32c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
193
|
-
|
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?(
|
198
|
-
return render(view_path + '/' +
|
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
|
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
|
-
|
19
|
-
|
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
|
-
|
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
|
-
|
50
|
+
[:index, :new, :create, :edit, :update, :show, :destroy]
|
53
51
|
end
|
54
52
|
end
|
55
53
|
|
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.
|
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-
|
11
|
+
date: 2023-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|