effective_resources 2.16.1 → 2.17.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66b9fac622ba1011fb81e24ca565d714b78028bd464b14b8e199558eb2e795f1
|
4
|
+
data.tar.gz: 72736d311ac7c200758628c5cf4b31b840b2f7e16d482f26771b79b038bb46c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6db9023e73e61521f5265407d753831fc8cc62e0b4d5481692242ccbe4643cb59dfe7b077db2de7ee66b3be4bfdf13492816804c9b76a19ac186266f89e95080
|
7
|
+
data.tar.gz: 6027c08af646b16c6e218c6842c35448aca20420919512ca81b3af573fdbbbe4d9e359a193ba80b37548449a972dccc94064edc305c512f5683b38552de25e31
|
@@ -66,29 +66,42 @@ module Effective
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
|
69
|
+
# Load the limit records + 1. If there are all there, return as: :string
|
70
|
+
# Otherwise return an Array of the processed results ready for a select field
|
71
|
+
# Only hit the database once
|
72
|
+
def search_form_field_collection(association = nil, limit: 100)
|
70
73
|
res = (association.nil? ? self : Effective::Resource.new(association))
|
71
74
|
|
72
|
-
if
|
73
|
-
|
74
|
-
|
75
|
-
if res.klass.unscoped.respond_to?(:datatables_scope)
|
76
|
-
{ collection: res.klass.datatables_scope.map { |obj| [obj.to_s, obj.id] } }
|
77
|
-
elsif res.klass.unscoped.respond_to?(:datatables_filter)
|
78
|
-
collection = res.klass.datatables_filter
|
75
|
+
# Return string if this isnt a relational thing
|
76
|
+
klass = res.klass
|
77
|
+
return { as: :string } unless klass.respond_to?(:unscoped)
|
79
78
|
|
80
|
-
|
81
|
-
|
82
|
-
else
|
83
|
-
{ collection: collection.map { |obj| [obj.to_s, obj.id] } }
|
84
|
-
end
|
79
|
+
# Default scope
|
80
|
+
scope = res.klass.unscoped
|
85
81
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
82
|
+
scope = if scope.respond_to?(:datatables_scope)
|
83
|
+
scope.datatables_scope
|
84
|
+
elsif scope.respond_to?(:datatables_filter)
|
85
|
+
scope.datatables_filter
|
86
|
+
elsif scope.respond_to?(:shallow)
|
87
|
+
scope.shallow
|
88
|
+
elsif scope.respond_to?(:sorted)
|
89
|
+
scope.sorted
|
90
|
+
else
|
91
|
+
scope
|
91
92
|
end
|
93
|
+
|
94
|
+
scope = scope.unarchived if scope.respond_to?(:unarchived)
|
95
|
+
|
96
|
+
# Now that we have the scope figured out let's pull the limit number of records into an Array
|
97
|
+
# If there are more than the limit, return as: :string
|
98
|
+
resources = scope.limit(limit).to_a
|
99
|
+
return { as: :string } unless resources.length < limit
|
100
|
+
|
101
|
+
# Otherwise there are less than the limit, so we can use a collection select
|
102
|
+
{
|
103
|
+
collection: resources.map { |obj| [obj.to_s, obj.id] }
|
104
|
+
}
|
92
105
|
end
|
93
106
|
|
94
107
|
end
|
@@ -22,11 +22,6 @@ module Effective
|
|
22
22
|
klass.unscoped.table
|
23
23
|
end
|
24
24
|
|
25
|
-
def max_id
|
26
|
-
return 999999 unless klass.respond_to?(:unscoped)
|
27
|
-
@max_id ||= klass.unscoped.maximum(klass.primary_key).to_i
|
28
|
-
end
|
29
|
-
|
30
25
|
def sql_column(name)
|
31
26
|
column = column(name)
|
32
27
|
return nil unless table && column
|
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.
|
4
|
+
version: 2.17.1
|
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-11-
|
11
|
+
date: 2023-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|