effective_resources 1.9.11 → 1.9.15

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: 612fe4c620f16ea85250d0d20afff1cc730bd9608565aa2eae61227c2e16c561
4
- data.tar.gz: 44163d5acae4f3092a7d1c5b1af45f41a6d009035cd5fd3756139105fd99e15d
3
+ metadata.gz: 7dd0112208ea9815fab0543b91b2ab24fd607d561a49b05d1f19ddffa4e6894b
4
+ data.tar.gz: b9fc2f5ac59dc2cb164b4397995b81c8b1c855e045c6934fb2081f4ac9381db0
5
5
  SHA512:
6
- metadata.gz: 01e8d523944f484b841a02d5ccff5ad07b1fd3ddf2f57179a965eed0965125b98e9210589876df52f630195b2eb100a7b921970d364ddf2c0aad59c289e50cec
7
- data.tar.gz: 026427c9bf9876675d9dfaa99e5b63c5aafa93ca62f0aaa224d5d8446b823248ef6d9f083405e8900417517c1a8fcbacbbf6c8ae83a657fdf98f1fa653f8ea16
6
+ metadata.gz: 41562bcb2c1f07e868fcea21088c9b676da9d43b193ad594affde4bc247d47713873f9fb56c63a58ca50b147d0a60905ae476544888e64ce709f22e5cd4dd859
7
+ data.tar.gz: c0e9b28781244c3638f63ca6a6ce89ea811afe31774acb3911f6cc774ad57d61e4b803dde8423c81c39cb620a64be22a75b9a47e613c6da124a0699222763596
@@ -40,6 +40,7 @@ module ActsAsTokened
40
40
  end
41
41
 
42
42
  def to_global_id(**params)
43
+ params[:tenant] = Tenant.current if defined?(Tenant)
43
44
  GlobalID.new(URI::GID.build(app: Rails.application.config.global_id.app, model_name: model_name, model_id: to_param, params: params))
44
45
  end
45
46
 
@@ -21,7 +21,11 @@ module Effective
21
21
  collection ||= (klass.const_get(constant_pluralized) rescue nil) if defined?("#{klass.name}::#{constant_pluralized}")
22
22
  end
23
23
 
24
- { as: :select, polymorphic: true, collection: (collection || []) }.compact
24
+ if collection.present?
25
+ { as: :select, polymorphic: true, collection: (collection || []) }
26
+ else
27
+ { as: :string }
28
+ end
25
29
  when :has_and_belongs_to_many
26
30
  { as: :select }.merge(search_form_field_collection(has_and_belongs_to_many(name)))
27
31
  when :has_many
@@ -98,8 +98,18 @@ module Effective
98
98
  elsif name == :user # Polymorphic user
99
99
  relation.where(search_by_associated_conditions(association, term, fuzzy: fuzzy))
100
100
  else # Maybe from a string field
101
- id ||= Effective::Attribute.new(:integer).parse(term)
102
- relation.where("#{sql_column}_id = ? OR #{sql_column}_type = ?", id, (type || term))
101
+ collection = relation.none
102
+
103
+ relation.unscoped.distinct("#{name}_type").pluck("#{name}_type").each do |klass_name|
104
+ next if klass_name.nil?
105
+
106
+ resource = Effective::Resource.new(klass_name)
107
+ next unless resource.klass.present?
108
+
109
+ collection = collection.or(relation.where("#{name}_id": resource.search_any(term), "#{name}_type": klass_name))
110
+ end
111
+
112
+ collection
103
113
  end
104
114
  when :has_and_belongs_to_many, :has_many, :has_one
105
115
  relation.where(search_by_associated_conditions(association, term, fuzzy: fuzzy))
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.9.11'.freeze
2
+ VERSION = '1.9.15'.freeze
3
3
  end
@@ -52,11 +52,7 @@ module EffectiveResources
52
52
  end
53
53
 
54
54
  def self.transaction(resource = nil, &block)
55
- connection = (resource if resource.respond_to?(:transaction))
56
- connection ||= (resource.class if resource.class.respond_to?(:transaction))
57
- connection ||= '::ApplicationRecord'.safe_constantize
58
- connection ||= 'ActiveRecord::Base'.safe_constantize
59
-
55
+ connection = 'ActiveRecord::Base'.safe_constantize
60
56
  raise('unable to determine transaction class') unless connection.present?
61
57
 
62
58
  connection.transaction { yield }
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.9.11
4
+ version: 1.9.15
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-12-15 00:00:00.000000000 Z
11
+ date: 2022-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails