bullet_train-fields 1.6.3 → 1.6.4
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: e05d81fd71bb84dcc8453ed6ab245da56f66c8a7d21c3a623494853fe08f9167
|
4
|
+
data.tar.gz: 8b22fb9961197d36a6e9847a181772dbe6a783dd5e9c085afcf4ee3d8c02468d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f166d7e06da69090b3e98d85e30f0646e8fa2104ff427ac40f6856a287541ee4bfe37227d2bfc110b15d06ac31473eda5e8cb92be9522b52fa4ee034d4d777a
|
7
|
+
data.tar.gz: 5f0f06bc222c60820166839137009c69e66e1937a2a43b899054bbb92709225c3eea372d6d09fa82babf7e857aea64faa39d843e37ea1a5c7fe4536a99f1412b
|
@@ -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.4
|
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-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|