card 1.99.1 → 1.99.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/config/initializers/01_core_extensions/array.rb +1 -0
- data/config/initializers/01_core_extensions/persistent_identifiers.rb +1 -1
- data/config/initializers/02_patches/zeitwerk.rb +13 -0
- data/config/initializers/patches.rb +7 -0
- data/config/initializers/recaptcha.rb +1 -2
- data/config/initializers/zeitwerk.rb +5 -0
- data/config/locales/de.yml +1 -1
- data/config/locales/en.yml +1 -1
- data/config/locales/es.yml +1 -1
- data/db/migrate/20110511221913_require_earlier_migrations.rb +0 -3
- data/db/migrate/20141001105348_move_revisions_to_actions.rb +1 -1
- data/db/migrate_core_cards/20140629222005_add_email_cards.rb +5 -5
- data/db/migrate_core_cards/20141120120605_fix_notification_html_message.rb +1 -1
- data/db/migrate_core_cards/20141204061304_watchers_to_following.rb +1 -1
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +2 -2
- data/db/migrate_core_cards/20150317162412_bootstrap_themes.rb +4 -4
- data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +1 -1
- data/db/migrate_core_cards/20190204195039_add_rule_card.rb +1 -1
- data/db/migrate_core_cards/20191008201046_fixture_fix.rb +3 -1
- data/db/migrate_core_cards/20191028135243_add_link_editor_to_tiny_mce_config.rb +8 -0
- data/db/migrate_core_cards/20191115160748_history_cleanup.rb +27 -0
- data/db/migrate_core_cards/20191118145629_codename_fixes.rb +6 -0
- data/db/seed/new/card_actions.yml +874 -874
- data/db/seed/new/card_acts.yml +2 -2
- data/db/seed/new/card_references.yml +2 -2
- data/db/seed/new/cards.yml +1576 -1576
- data/db/seed/new/schema_migrations_core_cards.yml +8 -0
- data/db/seed/test/fixtures/card_actions.yml +1815 -1815
- data/db/seed/test/fixtures/card_acts.yml +499 -499
- data/db/seed/test/fixtures/card_changes.yml +66 -66
- data/db/seed/test/fixtures/card_references.yml +634 -634
- data/db/seed/test/fixtures/cards.yml +2730 -2730
- data/db/seed/test/fixtures/schema_migrations_core_cards.yml +8 -0
- data/db/test_seed.rb +10 -11
- data/lib/card.rb +9 -30
- data/lib/card/act_manager.rb +0 -2
- data/lib/card/auth.rb +0 -5
- data/lib/card/auth/current.rb +32 -59
- data/lib/card/auth/setup.rb +1 -1
- data/lib/card/codename.rb +5 -6
- data/lib/card/content.rb +5 -8
- data/lib/card/content/chunk.rb +0 -78
- data/lib/card/content/chunk/abstract.rb +88 -0
- data/lib/card/content/clean.rb +3 -3
- data/lib/card/content/diff/{lcs.rb → l_c_s.rb} +5 -7
- data/lib/card/content/diff/{processor.rb → l_c_s/processor.rb} +0 -0
- data/lib/card/content/parser.rb +1 -1
- data/lib/card/dirty.rb +25 -31
- data/lib/card/dirty/method_factory.rb +15 -0
- data/lib/card/env.rb +0 -3
- data/lib/card/error.rb +6 -2
- data/lib/card/format.rb +5 -5
- data/lib/card/format/nest/fetch.rb +2 -1
- data/lib/card/mark.rb +1 -0
- data/lib/card/migration.rb +4 -0
- data/lib/card/mod.rb +2 -5
- data/lib/card/mod/dirs.rb +1 -0
- data/lib/card/mod/load_strategy.rb +23 -12
- data/lib/card/mod/loader.rb +13 -13
- data/lib/card/mod/loader/set_loader.rb +7 -1
- data/lib/card/mod/loader/set_pattern_loader.rb +2 -2
- data/lib/card/mod/module_template.rb +1 -5
- data/lib/card/mod_inflector.rb +16 -0
- data/lib/card/model/save_helper.rb +2 -2
- data/lib/card/name.rb +2 -2
- data/lib/card/name/name_variants.rb +19 -0
- data/lib/card/query.rb +4 -2
- data/lib/card/query/card_query/reference_attributes.rb +2 -2
- data/lib/card/query/sql_statement.rb +4 -0
- data/lib/card/set.rb +18 -3
- data/lib/card/set/abstract.rb +6 -0
- data/lib/card/set/event.rb +13 -11
- data/lib/card/set/event/delayed_event.rb +2 -0
- data/lib/card/set/format.rb +3 -3
- data/lib/card/set/helpers.rb +20 -8
- data/lib/card/set/loader.rb +1 -1
- data/lib/card/set/pattern.rb +47 -0
- data/lib/card/{set_pattern.rb → set/pattern/base.rb} +11 -92
- data/lib/card/set/required_field.rb +64 -30
- data/lib/card/set/trait.rb +3 -2
- data/lib/card/set/type.rb +46 -0
- data/lib/card/subcards.rb +0 -4
- data/lib/card/tasks/card.rake +1 -0
- data/lib/card/tasks/card/migrate.rake +1 -1
- data/lib/card/view.rb +2 -7
- data/lib/card/view/cache.rb +3 -0
- data/lib/card/view/cache/stub.rb +5 -0
- data/lib/cardio.rb +73 -46
- data/mod/account/set/abstract/accountable.rb +49 -0
- data/mod/account/set/all/account.rb +3 -3
- data/mod/account/set/right/account.rb +1 -1
- data/mod/account/set/self/signin.rb +2 -2
- data/mod/account/set/type/role.rb +1 -1
- data/mod/account/set/type/signup.rb +2 -2
- data/mod/account/set/type/signup/views.rb +1 -1
- data/mod/account/set/type/user.rb +1 -1
- data/mod/account/spec/set/abstract/accountable_spec.rb +7 -0
- data/mod/account/spec/set/all/account_spec.rb +3 -3
- data/mod/account/spec/set/right/account_spec.rb +1 -1
- data/mod/account/spec/set/type/signup_spec.rb +4 -4
- data/mod/admin/set/self/admin.rb +1 -1
- data/mod/admin/set/self/admin_info.rb +2 -2
- data/mod/admin/set/self/version.rb +1 -1
- data/mod/basic_types/set/type/json.rb +4 -0
- data/mod/basic_types/spec/set/type/html_spec.rb +1 -1
- data/mod/bootstrap/db/migrate_core_cards/data/20181108181219_migrate_classic_skins_to_bootstrap.rb +2 -2
- data/mod/bootstrap/lib/bootstrap/component_loader.rb +1 -1
- data/mod/bootstrap/lib/stylesheets/style_bootstrap_cards.scss +1 -0
- data/mod/bootstrap/set/abstract/bootswatch_theme.rb +1 -1
- data/mod/bootstrap/set/all/bootstrap/tabs.rb +4 -4
- data/mod/bootstrap/set/type/customized_bootswatch_skin.rb +5 -4
- data/mod/carrierwave/config/core_initializers/carrierwave.rb +1 -3
- data/mod/carrierwave/lib/carrier_wave/{cardmount.rb → card_mount.rb} +2 -2
- data/mod/carrierwave/lib/carrier_wave/file_card_uploader.rb +27 -12
- data/mod/carrierwave/set/abstract/attachment.rb +0 -2
- data/mod/carrierwave/set/all/file_utils.rb +5 -1
- data/mod/carrierwave/set/self/admin.rb +1 -1
- data/mod/core/chunk/link.rb +99 -91
- data/mod/core/chunk/nest.rb +2 -2
- data/mod/core/chunk/query_reference.rb +79 -74
- data/mod/core/chunk/view_stub.rb +10 -1
- data/mod/core/format/html_format.rb +1 -1
- data/mod/core/set/abstract/code_file.rb +6 -6
- data/mod/core/set/all/content.rb +1 -1
- data/mod/core/set/all/event_conditions.rb +1 -2
- data/mod/core/set/all/fetch.rb +22 -19
- data/mod/core/set/all/fetch_helper.rb +7 -5
- data/mod/core/set/all/initialize.rb +35 -9
- data/mod/core/set/all/item.rb +16 -6
- data/mod/core/set/all/name.rb +19 -15
- data/mod/core/set/all/pattern.rb +4 -0
- data/mod/core/set/all/permissions.rb +13 -11
- data/mod/core/set/all/rename.rb +1 -0
- data/mod/core/set/all/rules.rb +4 -4
- data/mod/core/set/all/subcards.rb +36 -1
- data/mod/core/set/all/type.rb +1 -1
- data/mod/core/set_pattern/03_type.rb +2 -0
- data/mod/core/spec/chunk/nest_spec.rb +7 -2
- data/mod/core/spec/set/all/fetch_spec.rb +1 -1
- data/mod/core/spec/set/all/permissions_spec.rb +11 -12
- data/mod/core/spec/set/all/rules_spec.rb +3 -3
- data/mod/edit/set/all/bridge.rb +1 -3
- data/mod/edit/set/all/bridge/tab_views.rb +0 -7
- data/mod/edit/set/all/bridge/tab_visibility.rb +5 -7
- data/mod/edit/set/all/form_buttons.rb +1 -1
- data/mod/edit/set/all/form_elements.rb +1 -0
- data/mod/edit/set/all/new.rb +2 -2
- data/mod/edit/spec/set/all/bridge/tab_views_spec.rb +1 -1
- data/mod/edit/spec/set/all/{nest_editor → reference_editor/nest_editor}/nest_parser_spec.rb +1 -1
- data/mod/edit/spec/set/all/{nest_editor_spec.rb → reference_editor/nest_editor_spec.rb} +6 -3
- data/mod/edit/spec/set/all/{nest_image_spec.rb → reference_editor/nest_image_spec.rb} +1 -1
- data/mod/email/set/abstract/test_context.rb +1 -1
- data/mod/email/set/type/email_template/email_config.rb +1 -1
- data/mod/follow/set/all/notify.rb +1 -1
- data/mod/follow/set/all/notify/base_views.rb +1 -1
- data/mod/follow/set/right/account.rb +8 -6
- data/mod/follow/set/right/followers.rb +2 -5
- data/mod/follow/set/right/following.rb +1 -1
- data/mod/follow/spec/set/all/follow_spec.rb +3 -3
- data/mod/follow/spec/set/all/notify_spec.rb +1 -1
- data/mod/follow/spec/set/right/followers_spec.rb +2 -2
- data/mod/history/lib/card/act.rb +3 -1
- data/mod/history/lib/card/action.rb +3 -3
- data/mod/history/lib/card/action/admin.rb +0 -11
- data/mod/history/set/all/history_bridge.rb +1 -1
- data/mod/machines/file/all_script_machine_output/file.js +38415 -69
- data/mod/machines/file/all_style_machine_output/file.css +2 -2
- data/mod/machines/file/script_html5shiv_printshiv_machine_output/file.js +1 -1
- data/mod/machines/lib/javascript/decko/filter.js.coffee +7 -1
- data/mod/machines/lib/javascript/decko/filter_links.js.coffee +13 -2
- data/mod/machines/lib/javascript/decko/link_editor.js.coffee +64 -0
- data/mod/machines/lib/javascript/decko/mod.js.coffee +3 -0
- data/mod/machines/lib/javascript/decko/nest_editor.js.coffee +49 -29
- data/mod/machines/lib/javascript/decko/nest_editor_name.js.coffee +30 -7
- data/mod/machines/lib/javascript/decko/slot.js.coffee +4 -1
- data/mod/machines/lib/stylesheets/style_cards.scss +31 -19
- data/mod/machines/set/abstract/machine/output_cache.rb +1 -1
- data/mod/machines/set/abstract/machine/output_update.rb +1 -1
- data/mod/machines/set/all/reset_machines.rb +2 -2
- data/mod/machines/set/self/script_decko.rb +1 -0
- data/mod/media/set/abstract/media.rb +1 -1
- data/mod/media/set/type/image.rb +1 -1
- data/mod/navbar/set/abstract/account_dropdown.rb +5 -1
- data/mod/navbar/set/right/enabled_roles.rb +1 -1
- data/mod/navbar/set/self/account_links.rb +1 -1
- data/mod/pointer/set/abstract/02_pointer.rb +1 -1
- data/mod/pointer/set/abstract/02_pointer/events.rb +30 -10
- data/mod/pointer/set/abstract/02_pointer/html_views.rb +6 -2
- data/mod/pointer/set/abstract/02_pointer/html_views/autocomplete_input.haml +1 -1
- data/mod/pointer/set/abstract/02_pointer/html_views/filter.rb +1 -1
- data/mod/pointer/set/abstract/02_pointer/item_api.rb +51 -31
- data/mod/pointer/set/abstract/id_pointer.rb +21 -0
- data/mod/pointer/set/type/link_list.rb +1 -1
- data/mod/pointer/set/type/mirror_list.rb +1 -1
- data/mod/pointer/set/type/mirrored_list.rb +2 -2
- data/mod/pointer/spec/set/abstract/paging_params_spec.rb +1 -1
- data/mod/pointer/spec/set/abstract/pointer/item_api_spec.rb +1 -1
- data/mod/recaptcha/set/all/recaptcha.rb +4 -9
- data/mod/rules/set/rule/editor.rb +2 -2
- data/mod/rules/set/type/set/html_views/rule_lists.rb +1 -1
- data/mod/rules/spec/set/type/set_spec.rb +1 -1
- data/mod/search/set/abstract/03_filter/filter_form.haml +1 -1
- data/mod/search/set/abstract/03_filter/filter_form.rb +23 -2
- data/mod/search/set/abstract/03_filter/quick_filters.haml +7 -10
- data/mod/search/template/abstract/search/checkbox_item.haml +5 -6
- data/mod/settings/set/abstract/permission.rb +2 -2
- data/mod/settings/set/right/input_type.rb +3 -3
- data/mod/settings/set/right/structure.rb +1 -1
- data/mod/settings/set/right/style.rb +1 -1
- data/mod/settings/set/type/setting.rb +2 -2
- data/mod/standard/set/all/rich_html/html_views/guide.rb +1 -1
- data/mod/standard/set/all/rich_html/menu.rb +6 -5
- data/mod/standard/set/self/cardtype.rb +1 -1
- data/mod/standard/set/type/cardtype.rb +33 -17
- data/mod/standard/set/type/session.rb +12 -0
- data/mod/standard/spec/set/type/email_template/email_config_spec.rb +1 -2
- data/mod/standard/spec/set/type/email_template_spec.rb +1 -3
- data/mod/tinymce_editor/lib/javascript/script_tinymce_config.js.coffee +3 -2
- data/mod/tinymce_editor/public/assets/tinymce/plugins/nest/plugin.min.js +1 -1
- data/mod/tinymce_editor/set/all/reference_editor.rb +23 -0
- data/mod/tinymce_editor/set/all/reference_editor/_link_editor.haml +18 -0
- data/mod/tinymce_editor/set/all/reference_editor/_nest_editor.haml +17 -0
- data/mod/tinymce_editor/set/all/reference_editor/link_editor.rb +33 -0
- data/mod/tinymce_editor/set/all/reference_editor/link_editor/link_parser.rb +35 -0
- data/mod/tinymce_editor/set/all/reference_editor/nest_editor.rb +174 -0
- data/mod/{edit/set/all → tinymce_editor/set/all/reference_editor}/nest_editor/_help.haml +0 -0
- data/mod/tinymce_editor/set/all/reference_editor/nest_editor/_options.haml +12 -0
- data/mod/{edit/set/all → tinymce_editor/set/all/reference_editor}/nest_editor/_options_select.haml +0 -0
- data/mod/{edit/set/all → tinymce_editor/set/all/reference_editor}/nest_editor/_options_select_row.haml +0 -0
- data/mod/{edit/set/all → tinymce_editor/set/all/reference_editor}/nest_editor/nest_parser.rb +7 -1
- data/mod/tinymce_editor/set/all/reference_editor/nest_image.rb +70 -0
- data/mod/tinymce_editor/set/all/reference_editor/reference_editor.haml +18 -0
- metadata +39 -21
- data/mod/account/set/abstract/accounted.rb +0 -15
- data/mod/edit/set/all/bridge/account_section.rb +0 -16
- data/mod/edit/set/all/nest_editor.rb +0 -122
- data/mod/edit/set/all/nest_editor/_options.haml +0 -12
- data/mod/edit/set/all/nest_editor/nest_editor.haml +0 -31
- data/mod/edit/set/all/nest_image.rb +0 -37
@@ -9,17 +9,17 @@ end
|
|
9
9
|
# @return [Array<String>, String] the name of file(s) to be loaded
|
10
10
|
def source_files
|
11
11
|
case type_id
|
12
|
-
when CoffeeScriptID then "#{codename}.js.coffee"
|
13
|
-
when JavaScriptID then "#{codename}.js"
|
14
|
-
when CssID then "#{codename}.css"
|
15
|
-
when ScssID then "#{codename}.scss"
|
12
|
+
when Card::CoffeeScriptID then "#{codename}.js.coffee"
|
13
|
+
when Card::JavaScriptID then "#{codename}.js"
|
14
|
+
when Card::CssID then "#{codename}.css"
|
15
|
+
when Card::ScssID then "#{codename}.scss"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
def source_dir
|
20
20
|
case type_id
|
21
|
-
when CoffeeScriptID, JavaScriptID then "lib/javascript"
|
22
|
-
when CssID, ScssID then "lib/stylesheets"
|
21
|
+
when Card::CoffeeScriptID, Card::JavaScriptID then "lib/javascript"
|
22
|
+
when Card::CssID, Card::ScssID then "lib/stylesheets"
|
23
23
|
else
|
24
24
|
"lib"
|
25
25
|
end
|
data/mod/core/set/all/content.rb
CHANGED
@@ -24,8 +24,7 @@ end
|
|
24
24
|
|
25
25
|
def on_condition_applies? _event, actions
|
26
26
|
actions = Array(actions).compact
|
27
|
-
|
28
|
-
actions.include? @action
|
27
|
+
actions.empty? ? true : actions.include?(@action)
|
29
28
|
end
|
30
29
|
|
31
30
|
# if changing name/type, the old card has no-longer-applicable set modules, so we create
|
data/mod/core/set/all/fetch.rb
CHANGED
@@ -106,7 +106,7 @@ module ClassMethods
|
|
106
106
|
# @param mark - see #fetch
|
107
107
|
# @return [Integer]
|
108
108
|
def fetch_type_id *mark
|
109
|
-
|
109
|
+
quick_fetch(mark)&.type_id
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
@@ -114,33 +114,37 @@ end
|
|
114
114
|
# INSTANCE METHODS
|
115
115
|
# fetching from the context of a card
|
116
116
|
|
117
|
-
def fetch opts={}
|
118
|
-
|
119
|
-
|
120
|
-
# should this fail as an incorrect api call?
|
121
|
-
traits = Array.wrap traits
|
122
|
-
traits.inject(self) do |card, trait|
|
117
|
+
def fetch traits, opts={}
|
118
|
+
opts[:new][:supercard] = self if opts[:new]
|
119
|
+
Array.wrap(traits).inject(self) do |card, trait|
|
123
120
|
Card.fetch card.name.trait(trait), opts
|
124
121
|
end
|
125
122
|
end
|
126
123
|
|
127
|
-
def renew
|
128
|
-
|
124
|
+
def renew mark, new_opts
|
125
|
+
return self if new_opts.blank?
|
126
|
+
opts = new_opts.clone.merge name: mark
|
127
|
+
copy = dup
|
129
128
|
handle_default_content opts
|
130
|
-
opts
|
131
|
-
|
132
|
-
Card.new opts
|
129
|
+
copy.newish opts
|
130
|
+
copy
|
133
131
|
end
|
134
132
|
|
135
|
-
def
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
133
|
+
def newish opts
|
134
|
+
Card.with_normalized_new_args opts do |norm_opts|
|
135
|
+
handle_type norm_opts do
|
136
|
+
assign_attributes norm_opts
|
137
|
+
self.name = name # trigger superize_name
|
138
|
+
end
|
141
139
|
end
|
142
140
|
end
|
143
141
|
|
142
|
+
def handle_default_content opts
|
143
|
+
return unless (default_content = opts.delete(:default_content)) && db_content.blank?
|
144
|
+
|
145
|
+
opts[:content] ||= default_content
|
146
|
+
end
|
147
|
+
|
144
148
|
def refresh force=false
|
145
149
|
return self unless force || frozen? || readonly?
|
146
150
|
return unless id
|
@@ -148,4 +152,3 @@ def refresh force=false
|
|
148
152
|
fresh_card.include_set_modules
|
149
153
|
fresh_card
|
150
154
|
end
|
151
|
-
|
@@ -119,14 +119,16 @@ module ClassMethods
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def new_card_fetch_results card, mark, opts
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
122
|
+
if (new_opts = opts[:new])
|
123
|
+
card = card.renew mark, new_opts
|
124
|
+
elsif opts[:skip_virtual]
|
125
|
+
return nil
|
126
126
|
end
|
127
127
|
card.assign_name_from_fetched_mark! mark, opts
|
128
128
|
finalize_fetch_results card, opts
|
129
|
-
|
129
|
+
# must include_set_modules before checking `card.known?`,
|
130
|
+
# in case, eg, set modules override #virtual?
|
131
|
+
card if new_opts || card.known?
|
130
132
|
end
|
131
133
|
|
132
134
|
def finalize_fetch_results card, opts
|
@@ -2,36 +2,62 @@ JUNK_INIT_ARGS = %w[missing skip_virtual id].freeze
|
|
2
2
|
|
3
3
|
module ClassMethods
|
4
4
|
def new args={}, _options={}
|
5
|
+
with_normalized_new_args args do |normalized_args|
|
6
|
+
super normalized_args
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def with_normalized_new_args args={}
|
5
11
|
args = (args || {}).stringify_keys
|
12
|
+
delete_junk_args args
|
13
|
+
normalize_type_args args
|
14
|
+
normalize_content_args args
|
15
|
+
yield args
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def delete_junk_args args
|
6
21
|
JUNK_INIT_ARGS.each { |a| args.delete(a) }
|
22
|
+
end
|
23
|
+
|
24
|
+
def normalize_type_args args
|
7
25
|
%w[type type_code].each { |k| args.delete(k) if args[k].blank? }
|
26
|
+
end
|
27
|
+
|
28
|
+
def normalize_content_args args
|
8
29
|
args.delete("content") if args["attach"] # should not be handled here!
|
9
|
-
|
30
|
+
args["db_content"] = args.delete "content" if args["content"]
|
10
31
|
end
|
11
32
|
end
|
12
33
|
|
13
34
|
def initialize args={}
|
14
35
|
args["name"] = initial_name args["name"]
|
15
|
-
args["db_content"] = args.delete "content" if args["content"]
|
16
|
-
@supercard = args.delete "supercard" # must come before name=
|
17
36
|
|
18
|
-
|
19
|
-
|
37
|
+
handle_set_modules args do
|
38
|
+
handle_type args do
|
39
|
+
super args # ActiveRecord #initialize
|
40
|
+
end
|
20
41
|
end
|
21
42
|
self
|
22
43
|
end
|
23
44
|
|
24
|
-
def
|
45
|
+
def handle_set_modules args
|
25
46
|
skip_modules = args.delete "skip_modules"
|
47
|
+
yield
|
48
|
+
include_set_modules unless skip_modules
|
49
|
+
end
|
50
|
+
|
51
|
+
def handle_type args
|
26
52
|
skip_type_lookup = args["skip_type_lookup"]
|
53
|
+
@supercard = args.delete "supercard"
|
54
|
+
|
27
55
|
yield
|
28
56
|
self.type_id = get_type_id_from_structure if !type_id && !skip_type_lookup
|
29
|
-
include_set_modules unless skip_modules
|
30
57
|
end
|
31
58
|
|
32
59
|
def initial_name name
|
33
|
-
|
34
|
-
Card::Name[name].to_s
|
60
|
+
name.is_a?(String) ? name : Card::Name[name].to_s
|
35
61
|
end
|
36
62
|
|
37
63
|
def include_set_modules
|
data/mod/core/set/all/item.rb
CHANGED
@@ -20,29 +20,39 @@ def item_count args={}
|
|
20
20
|
item_names(args).size
|
21
21
|
end
|
22
22
|
|
23
|
+
def items_to_content array
|
24
|
+
items = array.map { |i| standardize_item i }.reject(&:blank?)
|
25
|
+
self.content = items.to_pointer_content
|
26
|
+
end
|
27
|
+
|
28
|
+
def standardize_item item
|
29
|
+
Card::Name[item]
|
30
|
+
end
|
31
|
+
|
23
32
|
def include_item? item
|
24
|
-
|
25
|
-
item_names.map { |name| name.to_name.key }.member? key
|
33
|
+
item_names.include? Card::Name[item]
|
26
34
|
end
|
27
35
|
|
28
36
|
def add_item item
|
29
37
|
return if include_item? item
|
30
|
-
|
38
|
+
items_to_content(items_strings << item)
|
31
39
|
end
|
32
40
|
|
33
41
|
def drop_item item
|
42
|
+
item = Card::Name[item]
|
34
43
|
return unless include_item? item
|
35
|
-
|
36
|
-
self.content = new_names.empty? ? "" : new_names.join("\n")
|
44
|
+
items_to_content(item_names.reject { |i| i == item })
|
37
45
|
end
|
38
46
|
|
39
47
|
def insert_item index, name
|
40
48
|
new_names = item_names
|
41
49
|
new_names.delete name
|
42
50
|
new_names.insert index, name
|
43
|
-
|
51
|
+
items_to_content new_names
|
44
52
|
end
|
45
53
|
|
54
|
+
# I think the following should work as add_item...
|
55
|
+
#
|
46
56
|
def add_id id
|
47
57
|
add_item "~#{id}"
|
48
58
|
end
|
data/mod/core/set/all/name.rb
CHANGED
@@ -55,21 +55,25 @@ end
|
|
55
55
|
def update_subcard_names new_name, name_to_replace=nil
|
56
56
|
return unless @subcards
|
57
57
|
subcards.each do |subcard|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
58
|
+
update_subcard_name subcard, new_name, name_to_replace if subcard.new?
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def update_subcard_name subcard, new_name, name_to_replace
|
63
|
+
name_to_replace ||= name_to_replace_for_subcard subcard, new_name
|
64
|
+
subcard.name = subcard.name.swap name_to_replace, new_name.s
|
65
|
+
subcard.update_subcard_names new_name, name # needed? shouldn't #name= trigger this?
|
66
|
+
end
|
67
|
+
|
68
|
+
def name_to_replace_for_subcard subcard, new_name
|
69
|
+
# if subcard has a relative name like +C
|
70
|
+
# and self is a subcard as well that changed from +B to A+B then
|
71
|
+
# +C should change to A+B+C. #replace doesn't work in this case
|
72
|
+
# because the old name +B is not a part of +C
|
73
|
+
if subcard.name.starts_with_joint? && new_name.parts.first.present?
|
74
|
+
"".to_name
|
75
|
+
else
|
76
|
+
name
|
73
77
|
end
|
74
78
|
end
|
75
79
|
|
data/mod/core/set/all/pattern.rb
CHANGED
@@ -29,8 +29,9 @@ def ok? action
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def ok_with_fetch? action, opts={}
|
32
|
-
|
33
|
-
card
|
32
|
+
trait = opts.delete :trait
|
33
|
+
card = trait.nil? ? self : fetch(trait, opts)
|
34
|
+
card&.ok_without_fetch? action
|
34
35
|
end
|
35
36
|
|
36
37
|
# note: method is chained so that we can return the instance variable @action_ok
|
@@ -179,20 +180,21 @@ event :set_field_read_rules,
|
|
179
180
|
# (because of *type plus right)
|
180
181
|
# skip if name is updated because will already be resaved
|
181
182
|
|
182
|
-
|
183
|
-
|
184
|
-
field.refresh.update_read_rule
|
185
|
-
end
|
183
|
+
each_field_as_bot do |field|
|
184
|
+
field.refresh.update_read_rule
|
186
185
|
end
|
187
186
|
end
|
188
187
|
|
189
|
-
# currently doing a brute force search for every card that may be impacted.
|
190
|
-
# may want to optimize(?)
|
191
188
|
def update_field_read_rules
|
189
|
+
return unless type_id_changed? || read_rule_id_changed?
|
190
|
+
each_field_as_bot do |field|
|
191
|
+
field.update_read_rule if field.rule(:read) == "_left"
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def each_field_as_bot
|
192
196
|
Auth.as_bot do
|
193
|
-
fields.each
|
194
|
-
field.update_read_rule if field.rule(:read) == "_left"
|
195
|
-
end
|
197
|
+
fields.each { |field| yield field }
|
196
198
|
end
|
197
199
|
end
|
198
200
|
|
data/mod/core/set/all/rename.rb
CHANGED
@@ -15,6 +15,7 @@ def suspend_name name
|
|
15
15
|
end
|
16
16
|
|
17
17
|
event :validate_renaming, :validate, on: :update, changed: :name, skip: :allowed do
|
18
|
+
return if name_before_act&.to_name == name # just changing to new variant
|
18
19
|
errors.add :content, tr(:cannot_change_content) if db_content_is_changing?
|
19
20
|
errors.add :type, tr(:cannot_change_type) if type_id_is_changing?
|
20
21
|
end
|
data/mod/core/set/all/rules.rb
CHANGED
@@ -106,7 +106,7 @@ end
|
|
106
106
|
def preference_card_id_lookups setting_code, options={}
|
107
107
|
user_id = options[:user_id] || options[:user]&.id || Auth.current_id
|
108
108
|
return unless user_id
|
109
|
-
["#{setting_code}+#{AllID}", "#{setting_code}+#{user_id}"]
|
109
|
+
["#{setting_code}+#{Card::AllID}", "#{setting_code}+#{user_id}"]
|
110
110
|
end
|
111
111
|
|
112
112
|
def related_sets with_self=false
|
@@ -190,8 +190,8 @@ module ClassMethods
|
|
190
190
|
"#{set_class_code}+#{setting_code}"
|
191
191
|
end
|
192
192
|
user_ids = user_ids_cache[key] || []
|
193
|
-
if user_ids.include? AllID # rule for all -> return all user ids
|
194
|
-
Card.where(type_id: UserID).pluck(:id)
|
193
|
+
if user_ids.include? Card::AllID # rule for all -> return all user ids
|
194
|
+
Card.where(type_id: Card::UserID).pluck(:id)
|
195
195
|
else
|
196
196
|
user_ids
|
197
197
|
end
|
@@ -201,7 +201,7 @@ module ClassMethods
|
|
201
201
|
Card.search(
|
202
202
|
{ right: { codename: setting_code },
|
203
203
|
left: {
|
204
|
-
left: { type_id: SetID }, right: user_name
|
204
|
+
left: { type_id: Card::SetID }, right: user_name
|
205
205
|
},
|
206
206
|
return: :name }, "preference cards for user: #{user_name}"
|
207
207
|
)
|
@@ -70,8 +70,18 @@ def clear_subcards
|
|
70
70
|
subcards.clear
|
71
71
|
end
|
72
72
|
|
73
|
+
# ensures subfield is present
|
74
|
+
# does NOT override subfield content if already present
|
75
|
+
def ensure_subfield field_name, args={}
|
76
|
+
if subfield_present? field_name
|
77
|
+
subfield field_name
|
78
|
+
else
|
79
|
+
add_subfield field_name, args
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
73
83
|
def subfield_present? field_name
|
74
|
-
|
84
|
+
subfield(field_name)&.content&.present?
|
75
85
|
end
|
76
86
|
|
77
87
|
def deep_clear_subcards
|
@@ -99,3 +109,28 @@ event :reject_empty_subcards, :prepare_to_validate do
|
|
99
109
|
director.subdirectors.delete(subcard)
|
100
110
|
end
|
101
111
|
end
|
112
|
+
|
113
|
+
# check when deleting field that left has not also been deleted
|
114
|
+
def trashed_left?
|
115
|
+
l = left
|
116
|
+
!l || l.trash
|
117
|
+
end
|
118
|
+
|
119
|
+
# check when renaming field that it is not actually the same field
|
120
|
+
# (eg on a renamed trunk)
|
121
|
+
def same_field?
|
122
|
+
same_field_trunk? && same_field_tag?
|
123
|
+
end
|
124
|
+
|
125
|
+
private
|
126
|
+
|
127
|
+
# left is same card (even if renamed)
|
128
|
+
def same_field_trunk?
|
129
|
+
l = superleft || Card[left_id]
|
130
|
+
lkey = name.left_name&.key
|
131
|
+
lkey.present? && l&.name&.key == lkey
|
132
|
+
end
|
133
|
+
|
134
|
+
def same_field_tag?
|
135
|
+
name.right_name.key == name_before_act.to_name.right_name.key
|
136
|
+
end
|