card-mod-list 0.17.0 → 0.18.0

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: 2c1f3fb4e25fafbf3292058af388937179d3137dc2218dfeb91f7265f915ef17
4
- data.tar.gz: d74579fe55c4de641ebb00db9fa63a7123f90da10c341be1c4924d6e93b1309c
3
+ metadata.gz: 0d32738491162b1bb9e07c6f985bc32e1ef20dd74212bab7b7242aefd9e31c0d
4
+ data.tar.gz: af8a658609fa58a135e3c1aa68929647d6c9e857a99789bfde2bbd8680cc4050
5
5
  SHA512:
6
- metadata.gz: efab59b282f1b86d857eb33d66f6cf4f8dc471b005273a50bd721e93000445eed6b3f0ebd1ea7cc32d326a17be81eb748e37a038e1a88135887f552f4d8c56bb
7
- data.tar.gz: 8c478da1c0e29074f73f6d5ea5bb7a835ded446985dbfc4f49a3dd7f57ed81faacb4e534ffb80386f63c0293729c178ab34211cf36d68b379cbc397b43940763
6
+ metadata.gz: 30ff29adc1c7c374491909e139a17c2ecdefafa1e868e72f14fcd7cb5c2ae0f183c1f91d26de41c07e87af7ea836296e7657ddc008a9f05dd2393c2a10ce17c4
7
+ data.tar.gz: 0ba4f0295c0c8557b1242a17ffcc152ef3ed8e6b27ff3028a05c2716d9c44bc0917eb167d8252aa48851d46f4519d43688655c9b05ee5d98276305396cbb6eed
@@ -22,17 +22,16 @@ event :validate_item_type, :validate, on: :save, when: :validate_item_type? do
22
22
  end
23
23
  end
24
24
 
25
+ # At present this may never generate an error, because the uniqueness is enforced
26
+ # by `#standardize_items`. It's possible we may want to separate the policy about
27
+ # whether duplicates are allowed and the policy about whether we autocorrect vs.
28
+ # raise an error?
25
29
  event :validate_item_uniqueness, :validate, on: :save, when: :unique_items? do
26
30
  return unless (dupes = duplicate_item_names)&.present?
27
31
 
28
32
  errors.add :content, t(:list_duplicate_items_names, duplicates: dupes.to_sentence)
29
33
  end
30
34
 
31
- # for override
32
- def unique_items?
33
- false
34
- end
35
-
36
35
  def ok_item_types
37
36
  nil
38
37
  end
@@ -1,5 +1,5 @@
1
1
  format :html do
2
- view :core, cache: :never do
2
+ view :core do
3
3
  standard_pointer_core
4
4
  end
5
5
 
@@ -70,10 +70,8 @@ format :html do
70
70
  end
71
71
 
72
72
  def select_input
73
- options = { "-- Select --" => "" }.merge card.options_hash
74
- select_tag("pointer_select-#{unique_id}",
75
- options_for_select(options, card.first_name),
76
- class: "pointer-select form-control")
73
+ select_tag "pointer_select-#{unique_id}", select_input_options,
74
+ class: "pointer-select form-control"
77
75
  end
78
76
 
79
77
  def bar_select_input
@@ -108,6 +106,11 @@ format :html do
108
106
 
109
107
  private
110
108
 
109
+ def select_input_options
110
+ options = { "-- Select --" => "" }.merge card.options_hash
111
+ options_for_select options, card.first_name
112
+ end
113
+
111
114
  # currently only used by :list and :autocomplete. could be generalized?
112
115
  def items_for_input items=nil
113
116
  items ||= card.item_names context: :raw
@@ -1,6 +1,13 @@
1
1
  include_set Abstract::Paging
2
2
  include_set Abstract::Items
3
3
 
4
+ # for override
5
+ # if false, item names that match cardnames will
6
+ # NOT be treated like references to those cards
7
+ def item_references?
8
+ true
9
+ end
10
+
4
11
  def diff_args
5
12
  { diff_format: :pointer }
6
13
  end
@@ -44,5 +51,7 @@ def chunk_class
44
51
  end
45
52
 
46
53
  def each_reference_out
54
+ return unless item_references?
55
+
47
56
  item_names.each { |name| yield name, chunk_class::CODE }
48
57
  end
@@ -10,10 +10,12 @@ def standardize_item cardish
10
10
  end
11
11
 
12
12
  def item_ids args={}
13
- item_strings(args).map do |item|
14
- item = standardize_item item unless item.match?(/^~/)
15
- item.to_s.tr("~", "").to_i
16
- end.compact
13
+ seeding_ids do
14
+ item_strings(args).map do |item|
15
+ item = standardize_item item unless item.match?(/^~/)
16
+ item&.to_s&.tr("~", "")&.to_i
17
+ end.compact
18
+ end
17
19
  end
18
20
 
19
21
  def item_names args={}
@@ -34,5 +36,14 @@ def create_references_out
34
36
  referee_ids = item_ids
35
37
  return if referee_ids.empty?
36
38
 
37
- Reference.mass_insert(referee_ids.map { |rid| [id, rid, "null", "'L'"] })
39
+ values = referee_ids.each_with_object([]) do |rid, vals|
40
+ vals << {
41
+ referer_id: id,
42
+ referee_id: rid,
43
+ referee_key: nil,
44
+ ref_type: "L"
45
+ }
46
+ end
47
+
48
+ Reference.insert_in_slices values
38
49
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: card-mod-list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan McCutchen
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-06-12 00:00:00.000000000 Z
13
+ date: 2024-10-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: card
@@ -18,42 +18,42 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.107.0
21
+ version: 1.108.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 1.107.0
28
+ version: 1.108.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: card-mod-format
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - '='
34
34
  - !ruby/object:Gem::Version
35
- version: 0.17.0
35
+ version: 0.18.0
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - '='
41
41
  - !ruby/object:Gem::Version
42
- version: 0.17.0
42
+ version: 0.18.0
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: card-mod-collection
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - '='
48
48
  - !ruby/object:Gem::Version
49
- version: 0.17.0
49
+ version: 0.18.0
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - '='
55
55
  - !ruby/object:Gem::Version
56
- version: 0.17.0
56
+ version: 0.18.0
57
57
  description: ''
58
58
  email:
59
59
  - info@decko.org
@@ -102,7 +102,7 @@ files:
102
102
  - set/type/pointer.rb
103
103
  homepage: https://decko.org
104
104
  licenses:
105
- - GPL-3.0
105
+ - GPL-3.0-or-later
106
106
  metadata:
107
107
  source_code_uri: https://github.com/decko-commons/decko
108
108
  homepage_uri: https://decko.org
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
128
  requirements: []
129
- rubygems_version: 3.5.10
129
+ rubygems_version: 3.5.7
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: list of cards