effective_resources 1.8.31 → 1.8.35

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: 2cac8ab4956bad6e580c5edfe77d2040d13430b327acff13874f0d447e2cb154
4
- data.tar.gz: 9d2aeb097b2a71715aec44af86b49628549c0083ecd757f742047ae17842207b
3
+ metadata.gz: 889c24801967683844b62d1e659862a39e47bfc99cf184ff77b9ecb9f0dbc16a
4
+ data.tar.gz: a39a146b713bc41482f35df016f3309c8afedef75531c5066479fe8d3ca6100c
5
5
  SHA512:
6
- metadata.gz: c04ecb8170f56016f354a93dd1be925ac08cef0f9dc77b93027457fa30b3382907943083877f47daa6dc000e700be9594a69e52a69fe63a0846a1d988413876c
7
- data.tar.gz: 73e362b25cc6acbc6c9abf0c8e8c87ad1a9b19d4a2d4c4e5f0a21cdc9f4071e8084ec15685fcb29a8d96bd1d9241c36f4d2569c79244247c3df8cd77eca2c333
6
+ metadata.gz: ac2de13588b807efd3fb9c048c0e180701d9b0dff54bf4ff1c44a86eb211b4ab9fc17da5fbea84725ce4c6cdc17fc9d242e749d257dd778209a7127655cc22bc
7
+ data.tar.gz: a7dd80308162e111383edb92c5964e32c7397116b574df8c20460e9571a705985f3b1d8ef6be28b9d743c08a89500fd34f2a830fa37751452db058fc34918c88
@@ -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
- sidebar = content_tag(:div, class: 'nav list-group wizard-sidebar') do
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 'acts_as_sluggable' make sure you have a string field :slug
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
@@ -56,7 +56,11 @@ module Effective
56
56
  when ActiveRecord::Relation
57
57
  input.klass
58
58
  when (ActiveRecord::Reflection::AbstractReflection rescue :nil)
59
- ((input.klass rescue nil).presence || _klass_by_name(input.class_name)) unless input.options[:polymorphic]
59
+ if input.options[:polymorphic]
60
+ _klass_by_name(input.class_name)
61
+ else
62
+ (input.klass rescue nil) || _klass_by_name(input.class_name)
63
+ end
60
64
  when ActiveRecord::Reflection::MacroReflection
61
65
  ((input.klass rescue nil).presence || _klass_by_name(input.class_name)) unless input.options[:polymorphic]
62
66
  when ActionDispatch::Journey::Route
@@ -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
- else
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
- if association.macro == :belongs_to
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
@@ -289,7 +293,10 @@ module Effective
289
293
  # key: the id, or associated_id on my table
290
294
  # keys: the ids themselves as per the target table
291
295
 
292
- if association.macro == :belongs_to
296
+ if association.macro == :belongs_to && association.options[:polymorphic]
297
+ key = sql_column(association.foreign_key)
298
+ keys = relation.pluck((relation.klass.primary_key rescue nil))
299
+ elsif association.macro == :belongs_to
293
300
  key = sql_column(association.foreign_key)
294
301
  keys = relation.pluck(association.klass.primary_key)
295
302
  elsif association.macro == :has_and_belongs_to_many
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.8.31'.freeze
2
+ VERSION = '1.8.35'.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.8.31
4
+ version: 1.8.35
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-09-27 00:00:00.000000000 Z
11
+ date: 2021-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails