card 1.93.3 → 1.93.4
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 +4 -4
- data/VERSION +1 -1
- data/db/migrate/20170908114452_increase_text_size_for_delayed_jobs.rb +9 -0
- data/db/migrate_core_cards/data/cards/*header +2 -2
- data/lib/card/format/nest.rb +12 -5
- data/lib/card/format/nest/fetch.rb +1 -2
- data/lib/card/format/render.rb +2 -2
- data/lib/card/model/save_helper.rb +1 -1
- data/lib/card/set/format/haml_views.rb +7 -3
- data/lib/card/subcards.rb +27 -228
- data/lib/card/subcards/add.rb +121 -0
- data/lib/card/subcards/relate.rb +27 -0
- data/lib/card/subcards/remove.rb +42 -0
- data/lib/card/tasks/card/create.rake +35 -132
- data/lib/card/tasks/card/file_card_creator.rb +25 -0
- data/lib/card/tasks/card/file_card_creator/abstract_file_card.rb +44 -0
- data/lib/card/tasks/card/file_card_creator/abstract_file_card/migration_file.rb +49 -0
- data/lib/card/tasks/card/file_card_creator/abstract_file_card/ruby_file.rb +30 -0
- data/lib/card/tasks/card/file_card_creator/abstract_file_card/source_file.rb +36 -0
- data/lib/card/tasks/card/file_card_creator/haml_card.rb +42 -0
- data/lib/card/tasks/card/file_card_creator/output_helper.rb +50 -0
- data/lib/card/tasks/card/file_card_creator/script_card.rb +33 -0
- data/lib/card/tasks/card/file_card_creator/style_card.rb +25 -0
- data/lib/generators/card/template/template_generator.rb +1 -1
- data/mod/account/set/self/account_links.rb +1 -1
- data/mod/basic_formats/set/all/all_csv.rb +63 -0
- data/mod/basic_formats/set/all/json.rb +4 -1
- data/mod/bootstrap/db/migrate_cards/20170719163733_update_bootswatch_themes_to_4_beta.rb +5 -2
- data/mod/carrierwave/set/abstract/attachment.rb +1 -2
- data/mod/core/set/abstract/haml_file.rb +20 -0
- data/mod/core/set/all/chunk.rb +125 -0
- data/mod/core/set/all/collection.rb +2 -351
- data/mod/core/set/all/content.rb +26 -7
- data/mod/core/set/all/extended.rb +45 -0
- data/mod/core/set/all/haml.rb +3 -7
- data/mod/core/set/all/item.rb +92 -0
- data/mod/core/set/all/name.rb +36 -0
- data/mod/core/set/all/subcards.rb +21 -12
- data/mod/core/set/all/tabs.rb +50 -0
- data/mod/core/set/all/trash.rb +4 -0
- data/mod/core/spec/set/all/chunk_spec.rb +45 -0
- data/mod/core/spec/set/all/collection_spec.rb +6 -6
- data/mod/history/set/all/action_view.rb +1 -1
- data/mod/machines/lib/javascript/decko.js.coffee +3 -0
- data/mod/pointer/set/abstract/02_pointer/edit.rb +0 -2
- data/mod/search/set/abstract/search.rb +1 -1
- data/mod/search/set/all/filter.rb +0 -2
- data/mod/search/template/all/filter/_filter_input.haml +1 -1
- data/mod/search/template/all/filter/filter_form.haml +1 -1
- data/mod/standard/set/all/rich_html/editing.rb +1 -1
- data/mod/standard/set/all/rich_html/form.rb +6 -7
- data/mod/standard/set/all/rich_html/menu.rb +2 -3
- data/mod/standard/set/all/rich_html/toolbar.rb +3 -4
- data/mod/standard/set/type/cardtype.rb +1 -1
- data/mod/standard/spec/set/all/rich_html/editing_spec.rb +15 -4
- data/mod/tinymce_editor/db/migrate_cards/{20171113233150_update_tinymce_config.rb → 20171113233151_update_tinymce_config.rb} +1 -0
- metadata +25 -161
- data/.rspec +0 -4
- data/card.gemspec +0 -87
- data/db/seed/test/fixtures/.gitkeep +0 -0
- data/mod/bootstrap/vendor/bootstrap/.babelrc.js +0 -16
- data/mod/bootstrap/vendor/bootstrap/.editorconfig +0 -17
- data/mod/bootstrap/vendor/bootstrap/.eslintignore +0 -3
- data/mod/bootstrap/vendor/bootstrap/.gitattributes +0 -16
- data/mod/bootstrap/vendor/bootstrap/.github/CONTRIBUTING.md +0 -252
- data/mod/bootstrap/vendor/bootstrap/.github/ISSUE_TEMPLATE.md +0 -22
- data/mod/bootstrap/vendor/bootstrap/.gitignore +0 -46
- data/mod/bootstrap/vendor/bootstrap/.hound.yml +0 -19
- data/mod/bootstrap/vendor/bootstrap/.houndignore +0 -4
- data/mod/bootstrap/vendor/bootstrap/.travis.yml +0 -32
- data/mod/bootstrap/vendor/bootstrap/build/.htmllintrc +0 -19
- data/mod/bootstrap/vendor/bootstrap/build/.stylelintrc +0 -248
- data/mod/bootstrap/vendor/bootstrap/docs/4.0/examples/.stylelintrc +0 -12
- data/mod/bootstrap/vendor/bootstrap/js/.eslintrc.json +0 -240
- data/mod/bootstrap/vendor/bootstrap/js/tests/.eslintrc.json +0 -46
- data/mod/bootstrap/vendor/bootswatch/.gitignore +0 -7
- data/mod/bootstrap/vendor/bootswatch/.npmignore +0 -12
- data/mod/bootstrap/vendor/bootswatch/.travis.yml +0 -21
- data/mod/bootstrap/vendor/bootswatch/docs/.nojekyll +0 -0
- data/mod/bootstrap/vendor/bootswatch/docs/2/.travis.yml +0 -15
- data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/bootstrap/.bower.json +0 -20
- data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/bootstrap/.gitignore +0 -37
- data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/bootstrap/.travis.yml +0 -3
- data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/bootstrap/js/.jshintrc +0 -12
- data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/jquery/.bower.json +0 -20
- data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/jquery/.gitignore +0 -1
- data/mod/bootstrap/vendor/bootswatch/docs/2/swatchmaker/.gitignore +0 -1
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap-sass-official/.bower.json +0 -45
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/.bower.json +0 -44
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/grunt/.jshintrc +0 -7
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/js/.jscsrc +0 -42
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/js/.jshintrc +0 -15
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/less/.csscomb.json +0 -304
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/less/.csslintrc +0 -19
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/font-awesome/.bower.json +0 -14
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/font-awesome/.gitignore +0 -32
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/html5shiv/.bower.json +0 -25
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/jquery/.bower.json +0 -38
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/respond/.bower.json +0 -20
- data/mod/bootstrap/vendor/select2/.editorconfig +0 -6
- data/mod/bootstrap/vendor/select2/.github/CONTRIBUTING.md +0 -204
- data/mod/bootstrap/vendor/select2/.github/ISSUE_TEMPLATE.md +0 -46
- data/mod/bootstrap/vendor/select2/.github/PULL_REQUEST_TEMPLATE.md +0 -13
- data/mod/bootstrap/vendor/select2/.gitignore +0 -3
- data/mod/bootstrap/vendor/select2/.jshintignore +0 -4
- data/mod/bootstrap/vendor/select2/.jshintrc +0 -25
- data/mod/bootstrap/vendor/select2/.travis.yml +0 -22
- data/script/fetch_bootswatch_themes.rb +0 -38
- data/spec/config/initializers/core_extensions_spec.rb +0 -47
- data/spec/config/initializers/patches/active_job_spec.rb +0 -7
- data/spec/lib/card/action_spec.rb +0 -15
- data/spec/lib/card/auth_spec.rb +0 -58
- data/spec/lib/card/cache_spec.rb +0 -116
- data/spec/lib/card/chunk_spec.rb +0 -18
- data/spec/lib/card/codename_spec.rb +0 -66
- data/spec/lib/card/content_spec.rb +0 -428
- data/spec/lib/card/diff_spec.rb +0 -208
- data/spec/lib/card/format/nest_spec.rb +0 -13
- data/spec/lib/card/format/render_spec.rb +0 -26
- data/spec/lib/card/format_spec.rb +0 -117
- data/spec/lib/card/i18n_spec.rb +0 -24
- data/spec/lib/card/loader/Modfile +0 -2
- data/spec/lib/card/loader_spec.rb +0 -98
- data/spec/lib/card/migration/import_spec.rb +0 -80
- data/spec/lib/card/mod/loader/mod_dirs.rb +0 -8
- data/spec/lib/card/mod/loader/set_loader_spec.rb +0 -19
- data/spec/lib/card/mod/loader/set_pattern_loader_spec.rb +0 -19
- data/spec/lib/card/name/fields_and_traits_spec.rb +0 -18
- data/spec/lib/card/name_spec.rb +0 -70
- data/spec/lib/card/query/sorting_spec.rb +0 -68
- data/spec/lib/card/query_spec.rb +0 -574
- data/spec/lib/card/reference_spec.rb +0 -212
- data/spec/lib/card/set/event_spec.rb +0 -22
- data/spec/lib/card/set/trait_spec.rb +0 -80
- data/spec/lib/card/set_pattern_spec.rb +0 -59
- data/spec/lib/card/set_spec.rb +0 -89
- data/spec/lib/card/stage_director_spec.rb +0 -482
- data/spec/lib/card/subcards_spec.rb +0 -177
- data/spec/lib/card/success_spec.rb +0 -148
- data/spec/lib/card/view_cache_spec.rb +0 -27
- data/spec/mailers/mailer_spec.rb +0 -62
- data/spec/models/card/create_spec.rb +0 -119
- data/spec/models/card/trash_spec.rb +0 -189
- data/spec/models/card_spec.rb +0 -136
- data/spec/spec_helper.rb +0 -45
- data/spec/support/card_spec_helper.rb +0 -74
- data/spec/support/card_spec_loader.rb +0 -112
- data/spec/support/helper/card_helper.rb +0 -58
- data/spec/support/helper/event_helper.rb +0 -94
- data/spec/support/helper/render_helper.rb +0 -44
- data/spec/support/helper/save_helper.rb +0 -30
- data/spec/support/helper/set_helper.rb +0 -80
- data/spec/support/matchers/card_matchers.rb +0 -160
- data/spec/support/matchers/expectations.rb +0 -5
- data/spec/support/matchers/file_matchers.rb +0 -71
- data/spec/support/matchers/html_matchers.rb +0 -29
- data/spec/support/matchers/negated_matchers.rb +0 -2
- data/spec/support/simplecov_helper.rb +0 -70
- data/spec/support/test_mods/mod1/set/all/test_set.rb +0 -3
- data/spec/support/test_mods/mod2/set_pattern/test_pattern.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ca5a3aee7c51d1ea3f43add1af3d85a71314af8
|
4
|
+
data.tar.gz: 0135ed52dec26c17de6a0d1c3232db8c3c41f9e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f78b2dedc458c623bcd224b80104a2cd9af0b5815b826962cab302bb23f2cc087bb4fcf86ffd338ff1a718ed2a7cb8bb0b937469be0b04ed61d01bd7dba0c0e2
|
7
|
+
data.tar.gz: 5489766302152fc62b3fdcdc25d8f00ebb0449f52cb509a12b6a3bdbe6fd41dd043aadc1abe64f03ad083a7ddc4715eee5770ff14cecb280c6658464c5f25aef
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.4
|
@@ -2,10 +2,10 @@
|
|
2
2
|
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbar-collapse-1" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
3
3
|
<span class="navbar-toggler-icon"></span>
|
4
4
|
</button>
|
5
|
-
<
|
5
|
+
<a class="navbar-brand" href="/">
|
6
6
|
{{*logo|core;size:small}}
|
7
7
|
{{*title|core}}
|
8
|
-
</
|
8
|
+
</a>
|
9
9
|
<div class="collapse navbar-collapse" id="navbar-collapse-1">
|
10
10
|
<div class="navbar-nav mr-auto">
|
11
11
|
{{*main menu|navbar_links}}
|
data/lib/card/format/nest.rb
CHANGED
@@ -6,6 +6,13 @@ class Card
|
|
6
6
|
include Subformat
|
7
7
|
include Mode
|
8
8
|
|
9
|
+
def nest cardish, options={}, override=true, &block
|
10
|
+
return "" if nest_invisible?
|
11
|
+
nested_card = fetch_nested_card cardish, options
|
12
|
+
view, options = interpret_nest_options nested_card, options
|
13
|
+
nest_render nested_card, view, options, override, &block
|
14
|
+
end
|
15
|
+
|
9
16
|
# nested by another card's content
|
10
17
|
# (as opposed to a direct API nest)
|
11
18
|
def content_nest opts={}
|
@@ -15,11 +22,11 @@ class Card
|
|
15
22
|
nest nest_name, opts
|
16
23
|
end
|
17
24
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
view
|
22
|
-
|
25
|
+
# create a path for a nest with respect ot the nest options
|
26
|
+
def nest_path name, nest_opts={}
|
27
|
+
path_opts = { slot: nest_opts.clone }
|
28
|
+
path_opts[:view] = path_opts[:slot].delete :view
|
29
|
+
page_path name, path_opts
|
23
30
|
end
|
24
31
|
|
25
32
|
def interpret_nest_options nested_card, options
|
@@ -9,7 +9,7 @@ class Card
|
|
9
9
|
when Symbol, Integer then Card.fetch cardish
|
10
10
|
when "_", "_self" then card.context_card
|
11
11
|
else
|
12
|
-
opts[:nest_name] = cardish.to_s
|
12
|
+
opts[:nest_name] = Card::Name[cardish].to_s
|
13
13
|
Card.fetch cardish, new: nest_new_args(opts)
|
14
14
|
end
|
15
15
|
end
|
@@ -53,7 +53,6 @@ class Card
|
|
53
53
|
return unless (nestcard_params = subcard_params[nest_name])
|
54
54
|
nestcard_params["content"]
|
55
55
|
end
|
56
|
-
|
57
56
|
end
|
58
57
|
end
|
59
58
|
end
|
data/lib/card/format/render.rb
CHANGED
@@ -44,12 +44,14 @@ class Card
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
def
|
47
|
+
def haml_template_path view=nil, source=nil
|
48
48
|
each_template_path(source) do |template_dir, source_dir|
|
49
49
|
path = try_haml_template_path template_dir, view, source_dir
|
50
50
|
return path if path
|
51
51
|
end
|
52
|
-
|
52
|
+
msg = "can't find haml template"
|
53
|
+
msg += " for #{view}" if view.present?
|
54
|
+
raise Card::Error, msg
|
53
55
|
end
|
54
56
|
|
55
57
|
def each_template_path source
|
@@ -62,7 +64,9 @@ class Card
|
|
62
64
|
end
|
63
65
|
|
64
66
|
def try_haml_template_path template_path, view, source_dir, ext="haml"
|
65
|
-
|
67
|
+
template_path = File.join(template_path, view.to_s) if view.present?
|
68
|
+
template_path += ".#{ext}"
|
69
|
+
path = ::File.expand_path(template_path, source_dir)
|
66
70
|
.sub(%r{(/mod/[^/]+)/set/}, "\\1/#{TEMPLATE_DIR}/")
|
67
71
|
::File.exist?(path) && path
|
68
72
|
end
|
data/lib/card/subcards.rb
CHANGED
@@ -1,14 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
3
|
class Card
|
4
|
-
def subcards
|
5
|
-
@subcards ||= Subcards.new(self)
|
6
|
-
end
|
7
|
-
|
8
|
-
def expire_subcards
|
9
|
-
subcards.clear
|
10
|
-
end
|
11
|
-
|
12
4
|
# API to create/update/delete additional cards together with the main card.
|
13
5
|
# The most common case is for fields but subcards don't have to be descendants.
|
14
6
|
#
|
@@ -19,59 +11,37 @@ class Card
|
|
19
11
|
# Together with "my address" you want to create the subcards
|
20
12
|
# "my address+name", "my address+street", etc.
|
21
13
|
class Subcards
|
14
|
+
require_dependency "card/subcards/add"
|
15
|
+
require_dependency "card/subcards/remove"
|
16
|
+
require_dependency "card/subcards/relate"
|
17
|
+
|
18
|
+
include Add
|
19
|
+
include Remove
|
20
|
+
include Relate
|
21
|
+
|
22
22
|
attr_accessor :context_card, :keys
|
23
23
|
def initialize context_card
|
24
24
|
@context_card = context_card
|
25
25
|
@keys = ::Set.new
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
# @example Add a subcard that is added in the integration phase
|
36
|
-
# (and hence doesn't hold up the transaction for the main card)
|
37
|
-
# add 'spoiler', content: 'John Snow is a Targaryen',
|
38
|
-
# transact_in_stage: :integrate
|
39
|
-
# add card_obj, delayed: true
|
40
|
-
def add name_or_card_or_attr, attr_or_opts={}
|
41
|
-
case name_or_card_or_attr
|
42
|
-
when Card
|
43
|
-
new_by_card name_or_card_or_attr, attr_or_opts
|
44
|
-
when Hash
|
45
|
-
args = name_or_card_or_attr
|
46
|
-
if args[:name]
|
47
|
-
new_by_attributes args.delete(:name), args
|
48
|
-
else
|
49
|
-
multi_add args
|
50
|
-
end
|
51
|
-
else
|
52
|
-
new_by_attributes name_or_card_or_attr, attr_or_opts
|
53
|
-
end
|
28
|
+
def [] name
|
29
|
+
card(name) || field(name)
|
30
|
+
end
|
31
|
+
|
32
|
+
def field name
|
33
|
+
key = field_name_to_key name
|
34
|
+
fetch_subcard key if @keys.include? key
|
54
35
|
end
|
55
36
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
37
|
+
def card name
|
38
|
+
return unless @keys.include? name.to_name.key
|
39
|
+
fetch_subcard name
|
59
40
|
end
|
60
|
-
alias_method :add_field, :add_child
|
61
41
|
|
62
|
-
def
|
63
|
-
|
64
|
-
remove name_or_card
|
65
|
-
else
|
66
|
-
absolute_name = @context_card.name.field_name(name_or_card)
|
67
|
-
if @keys.include? absolute_name.key
|
68
|
-
remove absolute_name
|
69
|
-
else
|
70
|
-
remove @context_card.name.relative_field_name(name_or_card)
|
71
|
-
end
|
72
|
-
end
|
42
|
+
def present?
|
43
|
+
@keys.present?
|
73
44
|
end
|
74
|
-
alias_method :remove_field, :remove_child
|
75
45
|
|
76
46
|
def catch_up_to_stage stage_index
|
77
47
|
each_card do |subcard|
|
@@ -79,46 +49,12 @@ class Card
|
|
79
49
|
end
|
80
50
|
end
|
81
51
|
|
82
|
-
def clear
|
83
|
-
@keys.each do |key|
|
84
|
-
if (subcard = fetch_subcard key)
|
85
|
-
ActManager.delete subcard.director
|
86
|
-
end
|
87
|
-
Card.cache.soft.delete key
|
88
|
-
end
|
89
|
-
@keys = ::Set.new
|
90
|
-
end
|
91
|
-
|
92
|
-
def deep_clear cleared=::Set.new
|
93
|
-
each_card do |card|
|
94
|
-
next if cleared.include? card.id
|
95
|
-
cleared << card.id
|
96
|
-
card.subcards.deep_clear cleared
|
97
|
-
end
|
98
|
-
clear
|
99
|
-
end
|
100
|
-
|
101
|
-
def remove name_or_card
|
102
|
-
key = subcard_key name_or_card
|
103
|
-
return unless @keys.include? key
|
104
|
-
@keys.delete key
|
105
|
-
removed_card = fetch_subcard key
|
106
|
-
removed_card.current_action.delete if removed_card.current_action
|
107
|
-
ActManager.deep_delete removed_card.director
|
108
|
-
Card.cache.soft.delete key
|
109
|
-
removed_card
|
110
|
-
end
|
111
|
-
|
112
52
|
def rename old_name, new_name
|
113
53
|
return unless @keys.include? old_name.to_name.key
|
114
54
|
@keys.delete old_name.to_name.key
|
115
55
|
@keys << new_name.to_name.key
|
116
56
|
end
|
117
57
|
|
118
|
-
def << value
|
119
|
-
add value
|
120
|
-
end
|
121
|
-
|
122
58
|
def method_missing method, *args
|
123
59
|
return unless @keys.respond_to? method
|
124
60
|
@keys.send method, *args
|
@@ -146,163 +82,26 @@ class Card
|
|
146
82
|
end
|
147
83
|
end
|
148
84
|
|
149
|
-
def
|
150
|
-
|
151
|
-
when Hash
|
152
|
-
new_by_attributes name, card_or_attr
|
153
|
-
when Card
|
154
|
-
new_by_card card_or_attr
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
def [] name
|
159
|
-
card(name) || field(name)
|
160
|
-
end
|
161
|
-
|
162
|
-
def field name
|
163
|
-
key = field_name_to_key name
|
164
|
-
fetch_subcard key if @keys.include? key
|
165
|
-
end
|
166
|
-
|
167
|
-
def card name
|
168
|
-
return unless @keys.include? name.to_name.key
|
169
|
-
fetch_subcard name
|
170
|
-
end
|
171
|
-
|
172
|
-
def present?
|
173
|
-
@keys.present?
|
85
|
+
def fetch_subcard key
|
86
|
+
Card.fetch key, local_only: true, new: {}
|
174
87
|
end
|
175
88
|
|
176
89
|
private
|
177
90
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
when Card
|
184
|
-
val.name = absolutize_subcard_name key
|
185
|
-
new_by_card val
|
186
|
-
when nil then next
|
187
|
-
else new_by_attributes key, val
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
def subcard_key name_or_card
|
193
|
-
key = case name_or_card
|
194
|
-
when Card
|
195
|
-
name_or_card.key
|
196
|
-
when Symbol
|
197
|
-
fetch_subcard(name_or_card).key
|
198
|
-
else
|
199
|
-
name_or_card.to_name.key
|
91
|
+
def subcard_key cardish
|
92
|
+
key = case cardish
|
93
|
+
when Card then cardish.key
|
94
|
+
when Symbol then fetch_subcard(cardish).key
|
95
|
+
else cardish.to_name.key
|
200
96
|
end
|
201
97
|
key = absolutize_subcard_name(key).key unless @keys.include?(key)
|
202
98
|
key
|
203
99
|
end
|
204
100
|
|
205
|
-
def fetch_subcard key
|
206
|
-
Card.fetch key, local_only: true, new: {}
|
207
|
-
end
|
208
|
-
|
209
|
-
def field_name_to_key name
|
210
|
-
if @context_card.name =~ /^\+/
|
211
|
-
@context_card.name.relative_field_name(name).key
|
212
|
-
else
|
213
|
-
absolute_key = @context_card.name.field_name(name).key
|
214
|
-
if @keys.include? absolute_key
|
215
|
-
absolute_key
|
216
|
-
else
|
217
|
-
@context_card.name.relative_field_name(name).key
|
218
|
-
end
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
# TODO: this method already exists as card instance method in
|
223
|
-
# tracked_attributes.rb. Find a place for it where its accessible
|
224
|
-
# for both. There is one important difference. The keys are symbols
|
225
|
-
# here instead of strings
|
226
|
-
def extract_subcard_args! name, args
|
227
|
-
subcards = args.delete(:subcards) || {}
|
228
|
-
if (subfields = args.delete(:subfields))
|
229
|
-
subfields.each_pair do |key, value|
|
230
|
-
subcards[name.to_name.field(key)] = value
|
231
|
-
end
|
232
|
-
end
|
233
|
-
args.keys.each do |key|
|
234
|
-
subcards[key] = args.delete(key) if key =~ /^\+/
|
235
|
-
end
|
236
|
-
subcards
|
237
|
-
end
|
238
|
-
|
239
|
-
def new_by_attributes name, attributes={}
|
240
|
-
attributes ||= {}
|
241
|
-
absolute_name = absolutize_subcard_name name
|
242
|
-
if absolute_name.field_of?(@context_card.name) &&
|
243
|
-
(absolute_name.parts.size - @context_card.name.parts.size) > 2
|
244
|
-
left_card = new_by_attributes absolute_name.left
|
245
|
-
new_by_card left_card, transact_in_stage: attributes[:transact_in_stage]
|
246
|
-
left_card.subcards.new_by_attributes absolute_name, attributes
|
247
|
-
else
|
248
|
-
subcard_args = extract_subcard_args! name, attributes
|
249
|
-
t_i_s = attributes.delete(:transact_in_stage)
|
250
|
-
card = Card.assign_or_initialize_by absolute_name.s, attributes, local_only: true
|
251
|
-
subcard = new_by_card card, transact_in_stage: t_i_s
|
252
|
-
card.subcards.add subcard_args
|
253
|
-
subcard
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
101
|
def absolutize_subcard_name name
|
258
102
|
name = Card::Name[name]
|
259
103
|
return name if @context_card.name.parts.first.blank?
|
260
104
|
name.absolute_name @context_card.name
|
261
105
|
end
|
262
|
-
|
263
|
-
def new_by_card card, opts={}
|
264
|
-
card.supercard = @context_card
|
265
|
-
if !card.name.simple? &&
|
266
|
-
card.name.field_of?(@context_card.name)
|
267
|
-
card.superleft = @context_card
|
268
|
-
end
|
269
|
-
@keys << card.key
|
270
|
-
Card.write_to_soft_cache card
|
271
|
-
card.director = @context_card.director.subdirectors.add(card, opts)
|
272
|
-
card
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
def right_id= card_or_id
|
277
|
-
write_card_or_id :right_id, card_or_id
|
278
|
-
end
|
279
|
-
|
280
|
-
def left_id= card_or_id
|
281
|
-
write_card_or_id :left_id, card_or_id
|
282
|
-
end
|
283
|
-
|
284
|
-
def type_id= card_or_id
|
285
|
-
write_card_or_id :type_id, card_or_id
|
286
|
-
end
|
287
|
-
|
288
|
-
def write_card_or_id attribute, card_or_id
|
289
|
-
if card_or_id.is_a? Card
|
290
|
-
card = card_or_id
|
291
|
-
if card.id
|
292
|
-
write_attribute attribute, card.id
|
293
|
-
else
|
294
|
-
add_subcard card
|
295
|
-
card.director.prior_store = true
|
296
|
-
with_id_when_exists(card) do |id|
|
297
|
-
write_attribute attribute, id
|
298
|
-
end
|
299
|
-
end
|
300
|
-
else
|
301
|
-
write_attribute attribute, card_or_id
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
def with_id_when_exists card, &block
|
306
|
-
card.director.call_after_store(&block)
|
307
106
|
end
|
308
107
|
end
|