card 1.103.2 → 1.103.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/config/environments/production.rb +9 -9
  4. data/db/migrate_core_cards/20130411191151_renaming_for_menu.rb +0 -1
  5. data/db/migrate_core_cards/20140317035504_account_requests_to_signups.rb +0 -2
  6. data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +0 -2
  7. data/db/migrate_core_cards/20190417142612_reorganize_scripts_2.rb +1 -3
  8. data/db/migrate_core_cards/20190502130029_add_shark_and_help_desk_role.rb +1 -1
  9. data/db/migrate_core_cards/20190710090209_homepage_tweaks.rb +3 -7
  10. data/db/migrate_core_cards/20190823220018_cleanup_for_decko_1_0.rb +2 -4
  11. data/db/migrate_core_cards/20190902193208_input_type.rb +3 -8
  12. data/db/migrate_core_cards/20190904174403_token_upgrade.rb +1 -1
  13. data/db/migrate_core_cards/data/1.12_stylesheets/traditional.scss +1 -2
  14. data/db/seed/new/card_actions.yml +2381 -2381
  15. data/db/seed/new/card_acts.yml +3 -3
  16. data/db/seed/new/card_references.yml +1026 -1033
  17. data/db/seed/new/cards.yml +5291 -5293
  18. data/db/seed/test/fixtures/cards.yml +6 -6
  19. data/lib/card/content/chunk.rb +0 -1
  20. data/lib/card/content/diff/summary.rb +14 -18
  21. data/lib/card/content.rb +9 -1
  22. data/lib/card/director/act_direction.rb +5 -3
  23. data/lib/card/director/stages.rb +2 -0
  24. data/lib/card/fetch/results.rb +6 -6
  25. data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card/migration_file.rb +0 -0
  26. data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card/ruby_file.rb +0 -0
  27. data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card/source_file.rb +0 -0
  28. data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card.rb +0 -5
  29. data/lib/card/{tasks/card/file_card_creator → file_card_creator}/haml_card.rb +0 -0
  30. data/lib/card/{tasks/card/file_card_creator → file_card_creator}/output_helper.rb +0 -0
  31. data/lib/card/{tasks/card/file_card_creator → file_card_creator}/script_card.rb +0 -0
  32. data/lib/card/{tasks/card/file_card_creator → file_card_creator}/style_card.rb +0 -0
  33. data/lib/card/{tasks/card/file_card_creator.rb → file_card_creator.rb} +0 -5
  34. data/lib/card/format/content.rb +5 -7
  35. data/lib/card/format/render.rb +10 -10
  36. data/lib/card/format.rb +3 -8
  37. data/lib/card/lexicon.rb +30 -7
  38. data/lib/card/model/save_helper.rb +1 -1
  39. data/lib/card/name/card_class.rb +1 -1
  40. data/lib/card/name.rb +6 -6
  41. data/lib/card/set/card_methods.rb +13 -0
  42. data/lib/card/set/event/skip_and_trigger.rb +8 -0
  43. data/lib/card/set/format/abstract_format/wrapper.rb +1 -1
  44. data/lib/card/set/format/abstract_format.rb +2 -1
  45. data/lib/card/set/format.rb +2 -3
  46. data/lib/card/set/helpers.rb +55 -0
  47. data/lib/card/set/inheritance.rb +1 -1
  48. data/lib/card/set/pattern/all.rb +7 -6
  49. data/lib/card/set/pattern/class_methods.rb +2 -2
  50. data/lib/card/set/pattern.rb +30 -19
  51. data/lib/card/set/registrar.rb +8 -2
  52. data/lib/card/set.rb +14 -7
  53. data/lib/card/view/classy.rb +15 -27
  54. data/lib/card/view/options/voo_api.rb +3 -1
  55. data/lib/card/view.rb +1 -0
  56. data/lib/card.rb +9 -11
  57. data/lib/cardio/generators/deck_helper.rb +0 -4
  58. data/lib/cardio/mod/load_strategy/set_tmp_files.rb +10 -4
  59. data/lib/cardio/mod/load_strategy.rb +3 -4
  60. data/lib/cardio/mod/loader/set_loader.rb +13 -13
  61. data/lib/cardio/mod/loader.rb +1 -1
  62. data/lib/cardio/railtie.rb +6 -2
  63. data/lib/generators/deck/templates/Gemfile.erb +1 -1
  64. data/lib/generators/deck/templates/Rakefile.erb +6 -2
  65. data/lib/generators/deck/templates/simplecov.rb.erb +7 -11
  66. data/lib/{card/tasks → tasks}/card/asset.rake +0 -0
  67. data/lib/{card/tasks → tasks}/card/create.rake +0 -0
  68. data/lib/{card/tasks → tasks}/card/migrate.rake +0 -0
  69. data/lib/{card/tasks → tasks}/card/mod.rake +0 -0
  70. data/lib/{card/tasks → tasks}/card.rake +0 -0
  71. data/mod/admin/set/all/admin.rb +16 -0
  72. data/mod/admin/set/self/admin.rb +2 -6
  73. data/mod/admin/set/self/admin_info.rb +2 -5
  74. data/mod/core/locales/en.yml +4 -5
  75. data/mod/core/set/all/name_events.rb +1 -1
  76. data/mod/core/set/all/reference_events.rb +5 -10
  77. data/mod/core/set/all/trash.rb +2 -3
  78. data/mod/core/spec/set/all/name_events_spec.rb +10 -10
  79. data/mod/core/spec/set/all/trash_spec.rb +1 -1
  80. metadata +20 -19
  81. data/lib/card/set/basket.rb +0 -59
@@ -2,42 +2,53 @@ class Card
2
2
  module Set
3
3
  class Pattern
4
4
  class << self
5
- def reset
6
- nonbase_loadables.each do |set_pattern|
7
- Card::Set.const_remove_if_defined set_pattern.to_s.split("::").last
8
- end
9
- Card.set_patterns = []
10
- @card_keys = nil
5
+ def concrete
6
+ @concrete ||= []
11
7
  end
12
8
 
13
- def loadables
14
- Card.set_patterns.push(Card::Set::Abstract).reverse
9
+ def reset
10
+ reloadables.each do |set_pattern|
11
+ Set.const_remove_if_defined set_pattern.to_s.split("::").last
12
+ end
13
+ @concrete = []
14
+ @card_keys = @codes = @nonbase_codes = @ids = nil
15
15
  end
16
16
 
17
- def nonbase_loadables
18
- l = loadables
19
- l.delete Card::Set::All
20
- l
17
+ def reloadables
18
+ r = concrete.push(Abstract)
19
+ r.delete Set::All
20
+ r
21
21
  end
22
22
 
23
23
  def find pattern_code
24
- Card.set_patterns.find { |sub| sub.pattern_code == pattern_code }
24
+ concrete.find { |sub| sub.pattern_code == pattern_code }
25
25
  end
26
26
 
27
27
  def card_keys
28
28
  @card_keys ||=
29
- Card.set_patterns.each_with_object({}) do |set_pattern, hash|
30
- card_key = Card.quick_fetch(set_pattern.pattern_code).key
31
- hash[card_key] = true
29
+ concrete.each_with_object({}) do |set_pattern, hash|
30
+ hash[set_pattern.pattern_id.cardname.key] = true
32
31
  end
33
32
  end
34
33
 
35
- def nonbase_codes
36
- codes.tap { |list| list.delete :all }
34
+ def grouped_codes with_all: true
35
+ g = [[:abstract], nonbase_codes.reverse]
36
+ g.unshift [:all] if with_all
37
+ g
37
38
  end
38
39
 
40
+ def ids
41
+ @ids ||= concrete.map(&:pattern_id)
42
+ end
43
+
44
+ private
45
+
39
46
  def codes
40
- Card.set_patterns.map(&:pattern_code).push(:abstract).reverse
47
+ @codes ||= concrete.map(&:pattern_code)
48
+ end
49
+
50
+ def nonbase_codes
51
+ @nonbase_codes ||= codes.tap { |list| list.delete :all }
41
52
  end
42
53
  end
43
54
  end
@@ -48,6 +48,14 @@ class Card
48
48
  base_modules.clear
49
49
  end
50
50
 
51
+ def finalize_load
52
+ # basket.freeze
53
+ # basket.each_value(&:freeze)
54
+ clean_empty_modules
55
+ end
56
+
57
+ private
58
+
51
59
  def clean_empty_modules
52
60
  clean_empty_module_from_hash modules[:nonbase]
53
61
  modules[:nonbase_format].each_value do |hash|
@@ -62,8 +70,6 @@ class Card
62
70
  end
63
71
  end
64
72
 
65
- private
66
-
67
73
  # makes sets ready for dynamic loading via #include_set_modules
68
74
  def register_set_of_type set_module, set_type
69
75
  mods = modules[set_type]
data/lib/card/set.rb CHANGED
@@ -48,7 +48,6 @@ class Card
48
48
  module Set
49
49
  include Event::Api
50
50
  include Trait
51
- include Basket
52
51
  include Inheritance
53
52
 
54
53
  include Format
@@ -58,15 +57,23 @@ class Card
58
57
  extend I18nScope
59
58
  extend Registrar
60
59
 
61
- mattr_accessor :modules, :traits
60
+ class << self
61
+ attr_accessor :modules, :traits, :basket
62
62
 
63
- def self.reset_modules
64
- self.modules = { base: [], base_format: {},
65
- nonbase: {}, nonbase_format: {},
66
- abstract: {}, abstract_format: {} }
63
+ def reset
64
+ self.modules = {
65
+ base: [], base_format: {},
66
+ nonbase: {}, nonbase_format: {},
67
+ abstract: {}, abstract_format: {}
68
+ }
69
+
70
+ self.basket = {}
71
+ end
67
72
  end
68
73
 
69
- reset_modules
74
+ delegate :basket, to: Set
75
+
76
+ reset
70
77
 
71
78
  # SET MODULE API
72
79
  #
@@ -24,9 +24,7 @@ class Card
24
24
  # :single_use the same as :nests but is removed after the first use
25
25
  # :global always everywhere
26
26
  def class_up klass, classier, scope=:subviews
27
- klass = klass.to_s
28
-
29
- storage_voo(scope).add_extra_classes klass, classier, scope
27
+ storage_voo(scope).add_extra_classes klass.to_s, classier, scope
30
28
  end
31
29
 
32
30
  def class_down klass, classier
@@ -55,10 +53,8 @@ class Card
55
53
  end
56
54
 
57
55
  def add_extra_classes key, classier, scope
58
- type = class_list_type scope
59
-
60
- class_list(type)[key] =
61
- [class_list(type)[key], classier].flatten.compact.join(" ")
56
+ list = class_list class_list_type(scope)
57
+ list[key] = [list[key], classier].flatten.compact.join " "
62
58
  end
63
59
 
64
60
  # remove classes everywhere where they are visible for the given scope
@@ -83,9 +79,7 @@ class Card
83
79
 
84
80
  def extra_classes klass
85
81
  klass = klass.first if klass.is_a?(Array)
86
- klass = klass.to_s
87
-
88
- deep_extra_classes klass, :self
82
+ deep_extra_classes klass.to_s, :self
89
83
  end
90
84
 
91
85
  # recurse through voos and formats to find all extra classes
@@ -135,33 +129,27 @@ class Card
135
129
  end
136
130
 
137
131
  def class_list type=:private
138
- case type
139
- when :private, :format_private, :public, :single_use
140
- @class_list ||= {}
141
- @class_list[type] ||= {}
142
- else
132
+ unless type.in? %i[private format_private public single_use]
143
133
  raise ArgumentError, "#{type} not a valid class list"
144
134
  end
135
+ @class_list ||= {}
136
+ @class_list[type] ||= {}
145
137
  end
146
138
 
139
+ CLASS_LIST_TYPE = { view: :private,
140
+ format: :format_private,
141
+ subviews: :format_private,
142
+ nests: :public,
143
+ global: :public,
144
+ single_use: :single_use }.freeze
145
+
147
146
  # Translates scopes to the privacy types used to manage the class lists.
148
147
  # A #classy calls looks in the following class_lists:
149
148
  # private - only in the same voo
150
149
  # format_private - the same voo and all parent voos in the same format
151
150
  # public - in all voos in all parent formats
152
151
  def class_list_type scope
153
- case scope
154
- when :view
155
- :private
156
- when :format, :subviews
157
- :format_private
158
- when :nests, :global
159
- :public
160
- when :single_use
161
- :single_use
162
- else
163
- raise ArgumentError, "invalid class_up scope: #{scope}"
164
- end
152
+ CLASS_LIST_TYPE[scope] || raise(ArgumentError, "invalid class_up scope: #{scope}")
165
153
  end
166
154
  end
167
155
  end
@@ -49,7 +49,9 @@ class Card
49
49
  # because they can get changed after. current solution is a compromise.
50
50
  # @return [Hash]
51
51
  def slot_options
52
- normalized_options.merge(view: requested_view).slice(*Options.slot_keys)
52
+ normalized_options.merge(view: requested_view)
53
+ .merge(normalized_visibility_options)
54
+ .slice(*Options.slot_keys)
53
55
  end
54
56
 
55
57
  # ACCESSOR_HELPERS
data/lib/card/view.rb CHANGED
@@ -27,6 +27,7 @@ class Card
27
27
  extend View::Cache::ClassMethods
28
28
 
29
29
  attr_reader :format, :parent, :card
30
+ attr_accessor :interior
30
31
 
31
32
  class << self
32
33
  # @return [Symbol] viewname as Symbol
data/lib/card.rb CHANGED
@@ -123,8 +123,7 @@ class Card < Cardio::Record
123
123
  include Director::CardMethods
124
124
  include Name::All
125
125
  include Content::All
126
- include Set::Event::All
127
- include Set::Pattern::All
126
+ include Set::CardMethods
128
127
  include Cache::All
129
128
  include Director::All
130
129
  include Reference::All
@@ -140,28 +139,27 @@ class Card < Cardio::Record
140
139
  has_many :actions, -> { where(draft: [nil, false]).order :id }
141
140
  has_many :drafts, -> { where(draft: true).order :id }, class_name: :Action
142
141
 
143
- cattr_accessor :set_patterns, :action_specific_attributes, :set_specific_attributes
142
+ cattr_accessor :action_specific_attributes, :set_specific_attributes
143
+ alias_method :card_id, :id
144
144
 
145
145
  class << self
146
146
  delegate :config, :paths, to: Cardio
147
147
  end
148
148
 
149
- self.set_patterns = []
150
149
  self.action_specific_attributes = [
151
150
  :supercard,
152
151
  :superleft,
153
- :action,
154
- :current_action,
152
+ :action, # [Symbol] :create, :update, or :delete
153
+ :current_action, # [Card::Action]
155
154
  :last_action_id_before_edit,
156
155
 
157
- :skip, # skip event(s) for all cards in act
158
- :skip_in_action, # skip event for just this card
159
- :trigger, # trigger event(s) for all cards in act
160
- :trigger_in_action, # trigger event for just this card
156
+ :skip, # [Array] skip event(s) for all cards in act
157
+ :skip_in_action, # [Array] skip event for just this card
158
+ :trigger, # [Array] trigger event(s) for all cards in act
159
+ :trigger_in_action, # [Array] trigger event for just this card
161
160
  :comment, # obviated soon
162
161
 
163
162
  # TODO: refactor following to use skip/trigger
164
- :update_referers, # wrong mechanism for this
165
163
  :update_all_users, # if the above is wrong then this one too
166
164
  :silent_change # and this probably too
167
165
  ]
@@ -67,10 +67,6 @@ module Cardio
67
67
  text
68
68
  end
69
69
 
70
- def simplecov_config
71
- "" # TODO: add simplecov configs here
72
- end
73
-
74
70
  def jasmine_yml prefix
75
71
  inside("javascripts/support") do
76
72
  template "#{prefix}_jasmine.yml.erb", "jasmine.yml"
@@ -21,13 +21,19 @@ module Cardio
21
21
  end
22
22
 
23
23
  def load_tmp_files
24
- mod_dirs.each_tmp(:set) do |set_tmp_dir|
25
- Card::Set::Pattern.codes.each do |pattern|
26
- pattern_dir = "#{set_tmp_dir}/#{pattern}"
27
- Loader.load_dir "#{pattern_dir}/**" if Dir.exist? pattern_dir
24
+ pattern_groups.each do |pattern_group|
25
+ mod_dirs.each_tmp(:set) do |set_tmp_dir|
26
+ load_tmp_files_for_pattern pattern_group, set_tmp_dir
28
27
  end
29
28
  end
30
29
  end
30
+
31
+ def load_tmp_files_for_pattern pattern_group, set_tmp_dir
32
+ pattern_group.each do |pattern|
33
+ pattern_dir = "#{set_tmp_dir}/#{pattern}"
34
+ Loader.load_dir "#{pattern_dir}/**" if Dir.exist? pattern_dir
35
+ end
36
+ end
31
37
  end
32
38
  end
33
39
  end
@@ -14,9 +14,7 @@ module Cardio
14
14
  end
15
15
 
16
16
  def class_for_set_pattern strategy
17
- return PatternTmpFiles if strategy == :tmp_files
18
-
19
- Eval
17
+ strategy == :tmp_files ? PatternTmpFiles : Eval
20
18
  end
21
19
 
22
20
  def tmp_files?
@@ -25,7 +23,8 @@ module Cardio
25
23
  end
26
24
 
27
25
  attr_reader :loader
28
- delegate :template_class, :each_file, :mod_dirs, :parts_from_path, to: :loader
26
+ delegate :template_class, :pattern_groups, :each_file, :mod_dirs, :parts_from_path,
27
+ to: :loader
29
28
 
30
29
  def initialize loader
31
30
  LoadStrategy.current = self.class
@@ -5,10 +5,6 @@ module Cardio
5
5
  # The mods are given by a Mod::Dirs object.
6
6
  # SetLoader can use three different strategies to load the set modules.
7
7
  class SetLoader < Loader
8
- def template_class
9
- SetTemplate
10
- end
11
-
12
8
  def initialize args={}
13
9
  @no_all = args.delete :no_all
14
10
  super load_strategy: args[:load_strategy], mod_dirs: args[:mod_dirs]
@@ -20,22 +16,26 @@ module Cardio
20
16
 
21
17
  def load
22
18
  super
23
- # Card::Set.process_base_modules
24
- Card::Set.clean_empty_modules
19
+ Card::Set.finalize_load
25
20
  end
26
21
 
27
- # does not include abstract
28
- def main_patterns
29
- method = @no_all ? :nonbase_codes : :codes
30
- Card::Set::Pattern.send method
22
+ def template_class
23
+ SetTemplate
31
24
  end
32
25
 
33
26
  def each_file &block
34
- # each_file_with_patterns :abstract, &block
35
- each_file_with_patterns(*main_patterns, &block)
27
+ pattern_groups.each do |pattern_group|
28
+ each_file_with_patterns pattern_group, &block
29
+ end
36
30
  end
37
31
 
38
- def each_file_with_patterns *patterns, &block
32
+ def pattern_groups
33
+ Card::Set::Pattern.grouped_codes with_all: !@no_all
34
+ end
35
+
36
+ private
37
+
38
+ def each_file_with_patterns patterns, &block
39
39
  each_mod_dir :set do |base_dir|
40
40
  patterns.each do |pattern|
41
41
  each_file_in_dir base_dir, pattern.to_s, &block
@@ -22,7 +22,7 @@ module Cardio
22
22
 
23
23
  def reload_sets
24
24
  Card::Set::Pattern.reset
25
- Card::Set.reset_modules
25
+ Card::Set.reset
26
26
  SetPatternLoader.new.load
27
27
  SetLoader.new(no_all: true).load
28
28
  end
@@ -83,16 +83,17 @@ module Cardio
83
83
 
84
84
  c.paths.tap do |p|
85
85
  p["config/environments"].unshift "#{card_root}/config/environments"
86
-
87
86
  p["config/initializers"] << "#{card_root}/config/initializers"
88
87
  p.add "late/initializers", glob: "**/*.rb"
89
88
 
90
- p["lib/tasks"] << "#{card_root}/lib/card/tasks"
89
+ p["lib/tasks"] << "#{card_root}/lib/tasks"
91
90
 
92
91
  p.add "mod", with: "#{card_root}/mod"
93
92
  p["mod"] << "mod"
94
93
  p.add "files"
95
94
 
95
+ p.add "lib/graph_q_l/types/query.rb"
96
+
96
97
  p.add "db", with: "#{card_root}/db"
97
98
  p.add "db/seeds.rb", with: "#{card_root}/db/seeds.rb"
98
99
  p.add "db/migrate", with: "#{card_root}/db/migrate"
@@ -105,9 +106,12 @@ module Cardio
105
106
  c.autoload_paths += Dir["#{mod_path}/lib"]
106
107
  c.watchable_dirs["#{mod_path}/set"] = %i[rb haml]
107
108
 
109
+ p["lib/graph_q_l/types/query.rb"] <<
110
+ "#{mod_path}/lib/graph_q_l/types/query.rb"
108
111
  p["config/initializers"] << "#{mod_path}/init/early"
109
112
  p["late/initializers"] << "#{mod_path}/init/late"
110
113
  p["config/locales"] << "#{mod_path}/locales"
114
+ p["lib/tasks"] << "#{mod_path}/lib/tasks"
111
115
  end
112
116
 
113
117
  p["app/models"] = []
@@ -30,7 +30,7 @@ gem "card-mod-defaults"<%= repo_path_constraint :mod %>
30
30
  # BACKGROUND
31
31
  # A background gem is needed to run tasks like sending notifications in a background
32
32
  # process.
33
- # See https://github.com/decko-commons/decko/tree/master/card-mod-delayed_job
33
+ # See https://github.com/decko-commons/decko/tree/main/card-mod-delayed_job
34
34
  # for additional configuration details.
35
35
  <%= "# " if shark? %>gem "card-mod-delayed_job"<%= repo_path_constraint :mod %>
36
36
 
@@ -1,5 +1,9 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
1
+ # Add your own tasks in files ending in .rake a mod or deck's lib/tasks directory.
2
+ #
3
+ # Deck example: mydeck/lib/tasks/mytasks.rake
4
+ # Mod example mydecko/mod/mymod/lib/tasks/mytasks.rake
5
+ #
6
+ # Tasks in these files will automatically be available to Rake.
3
7
 
4
8
  require File.expand_path("../config/application", __FILE__)
5
9
 
@@ -1,9 +1,11 @@
1
1
 
2
2
  if ENV["<%= 'REPO_' if platypus? %>TMPSETS"] && ENV["COVERAGE"] != "false"
3
3
  SimpleCov.start do
4
- def add_mod_group modname
5
- mod_dir = /(card-mod-)?#{Regexp.escape modname}/
6
- add_group "Mod: #{modname}", %r{(^|card-mod-|mod/|/tmp.*/.*/mod\d{3}-)#{mod_dir}}
4
+ def add_mod_groups dir_pattern
5
+ Dir[dir_pattern].each do |path|
6
+ modname = File.basename path
7
+ add_group "Mod: #{modname}", %r{(mod/|mod\d{3}-)#{modname}}
8
+ end
7
9
  end
8
10
  <% if platypus? %>
9
11
  root "<%= expanded_repo_path %>"
@@ -16,15 +18,9 @@ if ENV["<%= 'REPO_' if platypus? %>TMPSETS"] && ENV["COVERAGE"] != "false"
16
18
  add_group "Cardname", "cardname"
17
19
  add_group "Decko", "decko"
18
20
 
19
- Dir["#{root}/{card/mod/*,card-mod-*}"].each do |path|
20
- match = path.match %r{/card[-/]mod[-/](?<modname>.*)$}
21
- add_mod_group match[:modname]
22
- end
21
+ add_mod_groups "#{root}/{card/,}/mod/*"
23
22
  <% else %>
24
- Dir["mod/*"].each do |path|
25
- modname = path.gsub "mod/", ""
26
- add_mod_group modname
27
- end
23
+ add_mod_groups "mod/*"
28
24
  <% end %>
29
25
  add_filter "/spec/"
30
26
  add_filter "/features/"
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,16 @@
1
+
2
+ basket[:tasks] = []
3
+
4
+ # to add an admin task:
5
+ #
6
+ # basket[:tasks] << {
7
+ # name: NAME,
8
+ # irreversible: TRUE/FALSE,
9
+ # execute_policy: -> { TASK_CODE },
10
+ # stats: {
11
+ # title: TITLE_STRING,
12
+ # count: -> { COUNT_CODE },
13
+ # link_text: LINK_STRING,
14
+ # task:
15
+ # }
16
+ # }
@@ -1,10 +1,6 @@
1
- # collect arrays of the form
2
- # [task symbol, { execute_policy: block, stats_policy: block }]
3
- basket :tasks
4
-
5
1
  def run_task_from_task_basket task
6
2
  task = task.to_sym
7
- task_data = tasks.find { |h| h[:name].to_sym == task.to_sym }
3
+ task_data = basket[:tasks].find { |h| h[:name].to_sym == task.to_sym }
8
4
  if !irreversibles_tasks_allowed? && task_data[:irreversible]
9
5
  not_allowed task_data[:stats][:link_text]
10
6
  elsif task_data
@@ -47,7 +43,7 @@ format :html do
47
43
  stats = card_stats
48
44
  stats += cache_stats
49
45
  stats += memory_stats
50
- card.tasks.each do |task|
46
+ basket[:tasks].each do |task|
51
47
  stats += Array.wrap task[:stats]
52
48
  end
53
49
  table_content = stats.map { |args| stat_row(args) }
@@ -1,12 +1,9 @@
1
- basket :warnings
2
-
1
+ basket[:warnings] = [:no_email_delivery]
3
2
  # For each warning in the basket (eg :my_warning), the core view
4
3
  # will run a test by appending a question mark (eg #my_warning?).
5
4
  # If it fails it will generate a message by appending message
6
5
  # (eg #my_warning_message).
7
6
 
8
- add_to_basket :warnings, :no_email_delivery
9
-
10
7
  def no_email_delivery?
11
8
  Card.config.action_mailer.perform_deliveries == false
12
9
  end
@@ -17,7 +14,7 @@ end
17
14
 
18
15
  format :html do
19
16
  view :core do
20
- warnings = card.warnings.map do |warning|
17
+ warnings = basket[:warnings].map do |warning|
21
18
  card.send("#{warning}?") ? send("#{warning}_message") : nil
22
19
  end
23
20
  warnings.compact!
@@ -21,10 +21,9 @@ en:
21
21
  core_exception_almost_deleted: Narrowly averted deleting current file
22
22
  core_is_incomplete: is incomplete
23
23
  core_only_admins_codename: only admins can set codename
24
- core_rename_and_update: "Rename and Update"
25
24
  core_renaming: "Renaming"
26
25
  core_rename: "Rename"
27
- core_rename_confirm: "Are you sure you want to rename"
28
- core_rename_reference_confirm:
29
- This name is referred to at least %{count} time(s). You may choose to <em>update</em>
30
- those references to use the new name."
26
+ core_rename_confirm: "Are you sure you want to rename?"
27
+
28
+ skip_update_referer_content:
29
+ do not update references to this name
@@ -77,7 +77,7 @@ event :update_lexicon, :finalize, changed: :name, on: :save do
77
77
  end
78
78
 
79
79
  event :cascade_name_changes, :finalize, on: :update, changed: :name do
80
- each_descendant { |d| d.rename_as_descendant update_referers }
80
+ each_descendant { |d| d.rename_as_descendant !skip_update_referers? }
81
81
  end
82
82
 
83
83
  protected
@@ -1,10 +1,5 @@
1
- # test for updating referer content
2
- event :prepare_referer_update, :validate, on: :update, changed: :name do
3
- self.update_referers = ![nil, false, "false"].member?(update_referers)
4
- end
5
-
6
1
  # on rename, update names in cards that refer to self by name (as directed)
7
- event :update_referer_content, :finalize, on: :update, when: :update_referers do
2
+ event :update_referer_content, :finalize, on: :update, changed: :name, skip: :allowed do
8
3
  referers.each do |card|
9
4
  next if card.structure
10
5
 
@@ -19,13 +14,13 @@ end
19
14
  # eg. A links to X+Y. if X+Y is renamed and we're not updating the link in A,
20
15
  # then we need to be sure that A has a partial reference
21
16
  event :update_referer_references_out, :finalize,
22
- changed: :name, on: :update, when: :not_update_referers do
17
+ changed: :name, on: :update, when: :skip_update_referers? do
23
18
  referers.map(&:update_references_out)
24
19
  end
25
20
 
26
21
  # when name changes, update references to card
27
22
  event :refresh_references_in, :finalize, changed: :name, on: :save do
28
- Reference.unmap_referees id if action == :update && !update_referers
23
+ Reference.unmap_referees id if action == :update && skip_update_referers?
29
24
  Reference.map_referees key, id
30
25
  end
31
26
 
@@ -51,8 +46,8 @@ end
51
46
 
52
47
  protected
53
48
 
54
- def not_update_referers
55
- !update_referers
49
+ def skip_update_referers?
50
+ skip_event? :update_referer_content
56
51
  end
57
52
 
58
53
  private
@@ -1,5 +1,4 @@
1
- Self::Admin.add_to_basket(
2
- :tasks,
1
+ basket[:tasks] << {
3
2
  name: :empty_trash,
4
3
  irreversible: true,
5
4
  execute_policy: -> { Card.empty_trash },
@@ -9,7 +8,7 @@ Self::Admin.add_to_basket(
9
8
  link_text: "empty trash",
10
9
  task: "empty_trash"
11
10
  }
12
- )
11
+ }
13
12
 
14
13
  module ClassMethods
15
14
  def empty_trash