card-mod-list 0.13.2 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1bb86ee48fd896283c6f8d1100ca96249087e0d80cffb5ce0acf90d6b4e187ba
4
- data.tar.gz: 105487db182f650539a3b0ec9e387cc58c41f720e5e219607abbdc5a8eacc3f4
3
+ metadata.gz: 128513caa820067dcf1ec3e1cd0b389c530cb2be8c6c317aabf8827c2ba6ccb4
4
+ data.tar.gz: 9673c5da3b5838ceabe9a135f7a227204179e1f4e3260c3a44d4eb2ad7d747dd
5
5
  SHA512:
6
- metadata.gz: 165cf0bdfb93b2dd73e9f0b612a3c7964488927a8a2f86d1e59ecf13d3fde29f933bee98f8e9426141e5f140e94cf906a8cba8bfc5dd4890d69c995c38092fa6
7
- data.tar.gz: '073548d105eca9e109c53b60d5a677eb4554bd5eac74504008ba5192bdf2a0a4757e89e9997c6d6ac8d45436db5f23404616533a5b5af6cab84aaa62ac677eaf'
6
+ metadata.gz: 746ad6da3fe5424df83c2db9c244401a93b2d15e703928c9b3b82f433fe906c0a6d3a6581f38e7f40371befeeb4fc2c5ce3f8d6389c71ae4345550de9cdca00e
7
+ data.tar.gz: 4bb16393c851b9f5db6e4f7bcbc488806a9fcf2c27e0ff3cc016dbc3cdc2a5ad43ee4298d250a3c7151930362c7b04901c40feac02ccbc4905dfa0a5aa77ad62
@@ -0,0 +1,15 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ # delete brackets from card content
4
+ class OutWithTheBrackets < Cardio::Migration
5
+ def up
6
+ Card["*getting started links"]&.update_column :type_id, :link_list.card_id
7
+
8
+ list_type_ids = %i[pointer list].map(&:card_id)
9
+ ["[[", "]]"].each do |brackets|
10
+ Card.where(type_id: list_type_ids).in_batches.update_all(
11
+ "db_content = REPLACE(db_content, '#{brackets}', '')"
12
+ )
13
+ end
14
+ end
15
+ end
@@ -14,22 +14,6 @@ def item_to_insert
14
14
  Env.params["insert_item"]
15
15
  end
16
16
 
17
- # If a card's type and content are updated in the same action, the new module
18
- # will override the old module's events and functions. But this event is only
19
- # on pointers -- other type cards do not have this event,
20
- # Therefore if something is changed from a pointer and its content is changed
21
- # in the same action, this event will be run and will treat the content like
22
- # it' still pointer content. The "when" clause helps with that (but is a hack)
23
- event :standardize_items, :prepare_to_validate,
24
- on: :save, changed: :content, when: :still_pointer? do
25
- items_to_content item_strings
26
- end
27
-
28
- def still_pointer?
29
- type_id == PointerID
30
- # Card.new(type_id: type_id).is_a? Abstract::Pointer
31
- end
32
-
33
17
  def changed_item_names
34
18
  dropped_item_names + added_item_names
35
19
  end
@@ -1,5 +1,5 @@
1
1
  %div.filtered-list-editor
2
- %ul.pointer-list.filtered-list-review._pointer-filtered-list.list-group.vertical.nopadding
2
+ %ul.pointer-list.filtered-list-review._pointer-filtered-list.list-group.vertical.p-0
3
3
  - card.item_cards(context: :raw).each do |item_card|
4
4
  %li._filtered-list-item.clearfix{ data: item_card.format.wrap_data(false) }
5
5
  %span._handle.float-left.m-2
@@ -13,9 +13,4 @@
13
13
  %br
14
14
  .clearfix
15
15
  = add_item_modal_link
16
- -# "data-target": "#modal-filtered-list"
17
- -# = modal_slot "filtered-list", "modal-lg"
18
16
 
19
- // note: passing item and filter card because in some cases (eg Project+Metric on wikirate)
20
- // the link was losing set-identifying information (type of left)
21
- // would be preferable to have a more general solution to retain set-identifying info.
@@ -43,7 +43,7 @@ format :html do
43
43
  end
44
44
 
45
45
  def default_filter_card
46
- fcard = card.options_rule_card || Card[:all]
46
+ fcard = card.options_card
47
47
  return fcard if fcard.respond_to? :cql_hash
48
48
 
49
49
  fcard.fetch :referred_to_by, new: {}
@@ -22,7 +22,7 @@ format :html do
22
22
  view :one_line_content do
23
23
  item_view = implicit_item_view
24
24
  item_view = item_view == "name" ? "name" : "link"
25
- wrap_with :div, class: "pointer-list" do
25
+ wrap_with :div, class: "pointer-list one-line-pointer-list" do
26
26
  # limit to first 10 items to optimize
27
27
  pointer_items(view: item_view, limit: 10, offset: 0).join ", "
28
28
  end
@@ -44,10 +44,6 @@ format :html do
44
44
  list_input
45
45
  end
46
46
 
47
- # view :nav_item do
48
- # nav_dropdown
49
- # end
50
-
51
47
  def list_input args={}
52
48
  items = items_for_input args[:item_list]
53
49
  extra_class = "pointer-list-ul"
@@ -29,10 +29,6 @@ def option_cards
29
29
  end
30
30
  end
31
31
 
32
- def options_rule_card
33
- rule_card :content_options
34
- end
35
-
36
32
  def standard_option_names
37
33
  if json_options?
38
34
  options_hash.values.map(&:to_name)
@@ -44,21 +40,30 @@ end
44
40
  def option_names_from_items
45
41
  o_card = options_card
46
42
  limit = o_card.try(:default_limit).to_i
47
- o_card.item_names context: name, limit: limit
43
+ context_name = right_type? ? nil : name
44
+ o_card.item_names context: context_name, limit: limit
48
45
  end
49
46
 
50
47
  def options_card
51
- options_rule_card || Card[:all]
48
+ @options_card ||= rule_card(:content_options) || right_type_options || Card[:all]
52
49
  end
53
50
 
54
51
  def options_card_name
55
- options_rule_card&.name&.url_key || ":all"
52
+ options_card&.name&.url_key
53
+ end
54
+
55
+ private
56
+
57
+ def right_type_options
58
+ Card.fetch [right.name, :type, :by_name] if right_type?
59
+ end
60
+
61
+ def right_type?
62
+ right&.type_id == CardtypeID
56
63
  end
57
64
 
58
65
  format do
59
- def options_card_name
60
- card.options_card_name
61
- end
66
+ delegate :options_card, :options_card_name, to: :card
62
67
  end
63
68
 
64
69
  format :html do
@@ -58,18 +58,6 @@ format :json do
58
58
  params[:max_depth] || 1
59
59
  end
60
60
 
61
- def items_for_export
62
- card.item_cards
63
- end
64
-
65
- def essentials
66
- return {} if depth > max_depth
67
-
68
- card.item_cards.map do |item|
69
- nest item, view: :essentials
70
- end
71
- end
72
-
73
61
  view :links do
74
62
  []
75
63
  end
@@ -8,3 +8,32 @@ end
8
8
  def count
9
9
  item_strings.size
10
10
  end
11
+
12
+ def standardize_content value
13
+ value = item_strings(content: value) unless value.is_a? Array
14
+ super value
15
+ end
16
+
17
+ def each_item_name_with_options _content=nil
18
+ item_names.each { |name| yield name, {} }
19
+ end
20
+
21
+ def swap_names old_name, new_name
22
+ item_strings.map do |string|
23
+ if string.match?(/^[:~]/)
24
+ string
25
+ else
26
+ string.to_name.swap old_name, new_name
27
+ end
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def chunk_class
34
+ Card::Content::Chunk::Link
35
+ end
36
+
37
+ def each_reference_out
38
+ item_names.each { |name| yield name, chunk_class::CODE }
39
+ end
@@ -1,35 +1,13 @@
1
1
  include_set Abstract::Pointer
2
2
 
3
- abstract_basket :item_codenames
4
-
5
- # simplify api
6
- # Self::MyCodePointerSet.add_item :my_item_codename
7
- # instead of
8
- # Self::MyCodePointerSet.add_to_basket :item_codenames, :my_item_codename
9
- module ClassMethods
10
- def add_item codename
11
- valid_codename codename do
12
- add_to_basket :item_codenames, codename
13
- end
14
- end
15
-
16
- def unshift_item codename
17
- valid_codename codename do
18
- unshift_basket :item_codenames, codename
19
- end
20
- end
3
+ def self.included host_class
4
+ basket[host_class.basket_name] = []
5
+ end
21
6
 
22
- def valid_codename codename
23
- if Card::Codename.exist? codename
24
- yield
25
- else
26
- Rails.logger.info "unknown codename '#{codename}' added to code pointer"
27
- end
28
- end
7
+ def item_codenames
8
+ basket[basket_name]
29
9
  end
30
10
 
31
11
  def content
32
- item_codenames.map do |codename|
33
- Card.fetch_name codename
34
- end.compact.to_pointer_content
12
+ item_codenames.map(&:cardname).compact.to_pointer_content
35
13
  end
@@ -19,3 +19,7 @@ end
19
19
  def item_names args={}
20
20
  item_ids(args).map(&:cardname).compact
21
21
  end
22
+
23
+ def export_content
24
+ item_names.join "\n"
25
+ end
@@ -1,3 +1,13 @@
1
+ basket[:list_input_options] = [
2
+ "radio",
3
+ "checkbox",
4
+ "select",
5
+ "multiselect",
6
+ "list",
7
+ "filtered list",
8
+ "autocomplete"
9
+ ]
10
+
1
11
  def supports_content_options?
2
12
  false
3
13
  end
@@ -1,14 +1,5 @@
1
1
  include_set Abstract::Pointer
2
2
 
3
- basket :options
4
- add_to_basket :options, "radio"
5
- add_to_basket :options, "checkbox"
6
- add_to_basket :options, "select"
7
- add_to_basket :options, "multiselect"
8
- add_to_basket :options, "list"
9
- add_to_basket :options, "filtered list"
10
- add_to_basket :options, "autocomplete"
11
-
12
3
  def content
13
- options.to_pointer_content
4
+ basket[:list_input_options].to_pointer_content
14
5
  end
@@ -1,4 +1,4 @@
1
- include_set Abstract::Pointer
1
+ include_set Abstract::Items
2
2
 
3
3
  def raw_item_strings content
4
4
  reference_chunks(content).map(&:referee_name)
@@ -34,7 +34,8 @@ format :html do
34
34
  items = items_for_input args[:item_list]
35
35
  extra_class = "pointer-link-list-ul"
36
36
  ul_classes = classy "pointer-list-editor", extra_class
37
- haml :link_list_input, items: items, ul_classes: ul_classes,
38
- options_card: options_card_name
37
+ haml :link_list_input,
38
+ items: items, ul_classes: ul_classes,
39
+ options_card: :all.card # options_card_name
39
40
  end
40
41
  end
data/set/type/list.rb CHANGED
@@ -1,11 +1,5 @@
1
1
  include_set Abstract::Pointer
2
2
 
3
- def each_reference_out
4
- item_names.each do |name|
5
- yield(name, Card::Content::Chunk::Link::CODE)
6
- end
7
- end
8
-
9
3
  format :html do
10
4
  view :view_list do
11
5
  %i[info_bar bar box closed titled labeled].map do |view|
@@ -8,9 +8,8 @@ def item_options
8
8
  nest_chunks.map(&:raw_options)
9
9
  end
10
10
 
11
- def items_to_content array
12
- items = array.map { |i| standardize_item i }.reject(&:blank?)
13
- self.content = items.join("\n")
11
+ def items_content array
12
+ standardized_items(array).join "\n"
14
13
  end
15
14
 
16
15
  format do
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.13.2
4
+ version: 0.14.1
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: 2021-08-06 00:00:00.000000000 Z
13
+ date: 2022-01-04 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.103.2
21
+ version: 1.104.1
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.103.2
28
+ version: 1.104.1
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.13.2
35
+ version: 0.14.1
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.13.2
42
+ version: 0.14.1
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.13.2
49
+ version: 0.14.1
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.13.2
56
+ version: 0.14.1
57
57
  description: ''
58
58
  email:
59
59
  - info@decko.org
@@ -62,6 +62,7 @@ extensions: []
62
62
  extra_rdoc_files: []
63
63
  files:
64
64
  - db/migrate_core_cards/20160804112340_add_pointer_cards.rb
65
+ - db/migrate_core_cards/20211107155032_out_with_the_brackets.rb
65
66
  - set/abstract/01_pointer.rb
66
67
  - set/abstract/01_pointer/events.rb
67
68
  - set/abstract/01_pointer/html_views.rb
@@ -114,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
115
  - !ruby/object:Gem::Version
115
116
  version: '0'
116
117
  requirements: []
117
- rubygems_version: 3.1.6
118
+ rubygems_version: 3.2.15
118
119
  signing_key:
119
120
  specification_version: 4
120
121
  summary: list of cards