effective_resources 1.8.30 → 1.8.34
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/app/controllers/concerns/effective/wizard_controller/save.rb +9 -1
- data/app/controllers/concerns/effective/wizard_controller.rb +14 -0
- data/app/helpers/effective_resources_wizard_helper.rb +4 -2
- data/app/models/concerns/acts_as_slugged.rb +1 -1
- data/app/models/concerns/acts_as_wizard.rb +2 -0
- data/app/models/effective/resources/init.rb +2 -0
- data/app/models/effective/resources/relation.rb +8 -4
- 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: 3a3ce02ada5c7878e2c6fab4642ba84c4ba7dbb7fb5986c7f8bc135ea8e3258c
|
4
|
+
data.tar.gz: 375b538d786b4730626c5b7fb64a522ec04c789b750b25b2d4235f4617398e46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65954757632e43d089f173c0e09e421c8c6528d4aa7da4fe70c7b2f24ce0f4ee90646ec8908a778e356846643cfe9d8b924dc7af2fb800a1b4040b8876a05889
|
7
|
+
data.tar.gz: a1c6e51cba33a5489746a1d0954d547f4065fc75c69a87adaae35faca338c51ba91b36788c34729af74394b5d29ceeb9532b1d6acd7b8ffae06bf1ff29374f2b
|
data/README.md
CHANGED
@@ -352,6 +352,8 @@ Here's `views/things/start.html.haml`:
|
|
352
352
|
|
353
353
|
You can also call `render_wizard_sidebar(resource)` without the block syntax.
|
354
354
|
|
355
|
+
If you add `f.hidden_field(:skip_to_step, value: 'stepc')` you can control the next step.
|
356
|
+
|
355
357
|
## Testing
|
356
358
|
|
357
359
|
Run tests by:
|
@@ -9,7 +9,7 @@ module Effective
|
|
9
9
|
if save_resource(resource, action)
|
10
10
|
flash[:success] ||= options.delete(:success) || resource_flash(:success, resource, action)
|
11
11
|
|
12
|
-
@skip_to ||= resource
|
12
|
+
@skip_to ||= skip_to_step(resource)
|
13
13
|
@redirect_to ||= resource_wizard_path(resource, @skip_to) if was_new_record
|
14
14
|
|
15
15
|
redirect_to(@redirect_to || wizard_path(@skip_to))
|
@@ -19,6 +19,14 @@ module Effective
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
private
|
23
|
+
|
24
|
+
def skip_to_step(resource)
|
25
|
+
resource.skip_to_step ||
|
26
|
+
resource.required_steps.find { |s| s == next_step } ||
|
27
|
+
resource.first_uncompleted_step
|
28
|
+
end
|
29
|
+
|
22
30
|
end
|
23
31
|
end
|
24
32
|
end
|
@@ -62,5 +62,19 @@ module Effective
|
|
62
62
|
wizard_path(step, resource_name_id => param)
|
63
63
|
end
|
64
64
|
|
65
|
+
private
|
66
|
+
|
67
|
+
def current_step_before?(nav_step)
|
68
|
+
index = wizard_steps.index(nav_step) || raise("step #{nav_step} not found in wizard_steps")
|
69
|
+
current = wizard_steps.index(step) || raise("current step not found in wizard_steps")
|
70
|
+
current < index
|
71
|
+
end
|
72
|
+
|
73
|
+
def current_step_after?(nav_step)
|
74
|
+
index = wizard_steps.index(nav_step) || raise("step #{nav_step} not found in wizard_steps")
|
75
|
+
current = wizard_steps.index(step) || raise("current step not found in wizard_steps")
|
76
|
+
current > index
|
77
|
+
end
|
78
|
+
|
65
79
|
end
|
66
80
|
end
|
@@ -2,8 +2,10 @@
|
|
2
2
|
|
3
3
|
module EffectiveResourcesWizardHelper
|
4
4
|
|
5
|
-
def render_wizard_sidebar(resource, numbers: true, &block)
|
6
|
-
|
5
|
+
def render_wizard_sidebar(resource, numbers: true, horizontal: false, &block)
|
6
|
+
klasses = ['wizard-sidebar', 'list-group', ('list-group-horizontal' if horizontal)].compact.join(' ')
|
7
|
+
|
8
|
+
sidebar = content_tag(:div, class: klasses) do
|
7
9
|
resource.required_steps.map.with_index do |nav_step, index|
|
8
10
|
render_wizard_sidebar_item(resource, nav_step, (index + 1 if numbers))
|
9
11
|
end.join.html_safe
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# This module automatically generates slugs based on the :to_s field using a before_validation filter
|
4
4
|
#
|
5
|
-
# Mark your model with '
|
5
|
+
# Mark your model with 'acts_as_slugged' make sure you have a string field :slug
|
6
6
|
|
7
7
|
module ActsAsSlugged
|
8
8
|
extend ActiveSupport::Concern
|
@@ -55,6 +55,8 @@ module Effective
|
|
55
55
|
input
|
56
56
|
when ActiveRecord::Relation
|
57
57
|
input.klass
|
58
|
+
when (ActiveRecord::Reflection::BelongsToReflection rescue :nil)
|
59
|
+
_klass_by_name(input.class_name)
|
58
60
|
when (ActiveRecord::Reflection::AbstractReflection rescue :nil)
|
59
61
|
((input.klass rescue nil).presence || _klass_by_name(input.class_name)) unless input.options[:polymorphic]
|
60
62
|
when ActiveRecord::Reflection::MacroReflection
|
@@ -91,9 +91,11 @@ module Effective
|
|
91
91
|
|
92
92
|
if term == 'nil'
|
93
93
|
relation.where(is_null("#{sql_column}_id")).where(is_null("#{sql_column}_type"))
|
94
|
-
elsif type.present? && id.present?
|
94
|
+
elsif type.present? && id.present? # This was from a polymorphic select
|
95
95
|
relation.where("#{sql_column}_id = ?", id).where("#{sql_column}_type = ?", type)
|
96
|
-
|
96
|
+
elsif name == :user # Polymorphic user
|
97
|
+
relation.where(search_by_associated_conditions(association, term, fuzzy: fuzzy))
|
98
|
+
else # Maybe from a string field
|
97
99
|
id ||= Effective::Attribute.new(:integer).parse(term)
|
98
100
|
relation.where("#{sql_column}_id = ? OR #{sql_column}_type = ?", id, (type || term))
|
99
101
|
end
|
@@ -213,8 +215,10 @@ module Effective
|
|
213
215
|
|
214
216
|
# key: the id, or associated_id on my table
|
215
217
|
# keys: the ids themselves as per the target table
|
216
|
-
|
217
|
-
|
218
|
+
if association.macro == :belongs_to && association.options[:polymorphic]
|
219
|
+
key = sql_column(association.foreign_key)
|
220
|
+
keys = relation.pluck((relation.klass.primary_key rescue nil))
|
221
|
+
elsif association.macro == :belongs_to
|
218
222
|
key = sql_column(association.foreign_key)
|
219
223
|
keys = relation.pluck(association.klass.primary_key)
|
220
224
|
elsif association.macro == :has_and_belongs_to_many
|
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.8.
|
4
|
+
version: 1.8.34
|
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: 2021-
|
11
|
+
date: 2021-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|