bullet_train-fields 1.6.3 → 1.6.5
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: ca44d0df23fb031f046e44ee74f1e0542b7895ff6e9f552e4a75edd0d2ef868a
|
4
|
+
data.tar.gz: cb75d3cac2fb1c0dca8422afcfd76143c6fa4bfc7ae058faa2999dc1aa25cc3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b2d08de8d17226dd7aa27e580555305e8e6cf7a3d6b53bc1f63b9861b6c3f8266873f882821e62234b3b2f3ee57c60871b9e655b871c74b8af1cd1bd0c2c65e
|
7
|
+
data.tar.gz: e1e3035151f57ec704e303fa32fe75757954e81d9132c2c852a53b2aa0096c1ccef921903fea5d0d4251a9c7483e116e829b5268b55b2277a6443563867bbd39
|
@@ -11,6 +11,10 @@ module Fields::SuperSelectSupport
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def create_model_if_new(id)
|
14
|
+
ActiveSupport::Deprecation.warn(
|
15
|
+
"#create_model_if_new is deprecated. " \
|
16
|
+
"Use #ensure_backing_models_on instead. See examples at https://bullettrain.co/docs/field-partials/super-select#accepting-new-entries"
|
17
|
+
)
|
14
18
|
if id.present?
|
15
19
|
unless /^\d+$/.match?(id)
|
16
20
|
id = yield(id).id.to_s
|
@@ -20,10 +24,24 @@ module Fields::SuperSelectSupport
|
|
20
24
|
end
|
21
25
|
|
22
26
|
def create_models_if_new(ids)
|
27
|
+
ActiveSupport::Deprecation.warn(
|
28
|
+
"#create_models_if_new is deprecated. " \
|
29
|
+
"Use #ensure_backing_models_on instead. See examples at https://bullettrain.co/docs/field-partials/super-select#accepting-new-entries"
|
30
|
+
)
|
23
31
|
ids.map do |id|
|
24
32
|
create_model_if_new(id) do
|
25
33
|
yield(id)
|
26
34
|
end
|
27
35
|
end
|
28
36
|
end
|
37
|
+
|
38
|
+
# See examples at https://bullettrain.co/docs/field-partials/super-select#accepting-new-entries
|
39
|
+
def ensure_backing_models_on(collection, id: nil, ids: [id])
|
40
|
+
ids = ids.compact_blank
|
41
|
+
return ids if ids.empty?
|
42
|
+
|
43
|
+
existing_ids = collection.where(id: ids).ids.map(&:to_s)
|
44
|
+
new_ids = ids.without(existing_ids).filter_map { yield(collection, _1)&.id&.to_s }
|
45
|
+
(existing_ids + new_ids).then { id ? _1.first : _1 }
|
46
|
+
end
|
29
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet_train-fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|