card 1.16.15 → 1.17.0
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/recaptcha.rb +21 -4
- data/db/migrate_core_cards/20130823192433_add_style_cards.rb +1 -1
- data/db/migrate_core_cards/20140512155840_add_script_cards.rb +1 -1
- data/db/migrate_core_cards/20140629222005_add_email_cards.rb +2 -2
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +1 -1
- data/db/migrate_core_cards/20150528084659_add_session_cardtype.rb +1 -1
- data/db/migrate_core_cards/20150610180019_add_recaptcha_key_and_admin_info_cards.rb +63 -0
- data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +1 -1
- data/db/migrate_core_cards/20150903130006_attachment_upload_cards.rb +1 -1
- data/db/schema.rb +1 -1
- data/db/seed/new/card_actions.yml +602 -394
- data/db/seed/new/card_acts.yml +595 -1
- data/db/seed/new/card_changes.yml +26282 -10262
- data/db/seed/new/card_references.yml +1252 -1084
- data/db/seed/new/cards.yml +1899 -1423
- data/db/seed/test/fixtures/card_actions.yml +1653 -1413
- data/db/seed/test/fixtures/card_acts.yml +1063 -445
- data/db/seed/test/fixtures/card_changes.yml +29674 -13637
- data/db/seed/test/fixtures/card_references.yml +1976 -1815
- data/db/seed/test/fixtures/cards.yml +3194 -2719
- data/lib/card.rb +14 -13
- data/lib/card/auth.rb +10 -6
- data/lib/card/cache.rb +58 -120
- data/lib/card/cache/persistent.rb +50 -0
- data/lib/card/cache/temporary.rb +38 -0
- data/lib/card/chunk.rb +34 -25
- data/lib/card/content.rb +3 -3
- data/lib/card/env.rb +3 -0
- data/lib/card/format.rb +56 -53
- data/lib/card/migration.rb +6 -2
- data/lib/card/name.rb +9 -1
- data/lib/card/query.rb +1 -1
- data/lib/card/reference.rb +17 -11
- data/lib/card/set.rb +1 -1
- data/lib/card/subcards.rb +6 -6
- data/lib/card/view_cache.rb +45 -28
- data/lib/generators/card/migration/templates/card_migration.erb +1 -2
- data/mod/01_core/chunk/include.rb +71 -48
- data/mod/01_core/chunk/link.rb +6 -3
- data/mod/01_core/chunk/query_reference.rb +38 -29
- data/mod/01_core/chunk/reference.rb +23 -24
- data/mod/01_core/set/all/collection.rb +1 -1
- data/mod/01_core/set/all/fetch.rb +39 -12
- data/mod/01_core/set/all/permissions.rb +2 -4
- data/mod/01_core/set/all/references.rb +50 -75
- data/mod/01_core/set/all/rules.rb +19 -18
- data/mod/01_core/set/all/subcards.rb +1 -1
- data/mod/01_core/set/all/templating.rb +31 -88
- data/mod/01_core/set/all/tracked_attributes.rb +7 -14
- data/mod/01_core/set/all/utils.rb +77 -66
- data/mod/01_core/set_pattern/07_type_plus_right.rb +6 -3
- data/mod/01_core/spec/set/all/fetch_spec.rb +148 -96
- data/mod/01_core/spec/set/all/templating_spec.rb +49 -40
- data/mod/01_core/spec/set/all/trash_spec.rb +1 -1
- data/mod/01_history/set/all/actions.rb +1 -1
- data/mod/02_basic_types/set/all/base.rb +13 -7
- data/mod/02_basic_types/set/all/rss.rb +17 -22
- data/mod/02_basic_types/set/type/plain_text.rb +5 -2
- data/mod/02_basic_types/spec/set/all/base_spec.rb +1 -0
- data/mod/02_basic_types/spec/set/all/rss_spec.rb +7 -6
- data/mod/03_machines/lib/javascript/wagn.js.coffee +22 -9
- data/mod/03_machines/set/right/machine_output.rb +1 -1
- data/mod/04_settings/lib/card/setting.rb +45 -31
- data/mod/04_settings/set/right/structure.rb +47 -1
- data/mod/04_settings/set/self/default_html_view.rb +2 -0
- data/mod/04_settings/set/self/follow_fields.rb +2 -0
- data/mod/04_settings/set/self/recent_settings.rb +1 -1
- data/mod/05_standard/file/favicon/image-icon.png +0 -0
- data/mod/05_standard/file/favicon/image-large.png +0 -0
- data/mod/05_standard/file/favicon/image-medium.png +0 -0
- data/mod/05_standard/file/favicon/image-original.png +0 -0
- data/mod/05_standard/file/favicon/image-small.png +0 -0
- data/mod/05_standard/set/all/links.rb +27 -26
- data/mod/05_standard/set/all/rich_html/editing.rb +1 -1
- data/mod/05_standard/set/all/rich_html/toolbar.rb +1 -1
- data/mod/05_standard/set/rstar/rules.rb +20 -325
- data/mod/05_standard/set/rstar/rules_editor.rb +362 -0
- data/mod/05_standard/set/self/admin_info.rb +82 -0
- data/mod/05_standard/set/self/all.rb +16 -10
- data/mod/05_standard/set/self/head.rb +20 -19
- data/mod/05_standard/set/type/signup.rb +0 -1
- data/mod/05_standard/spec/set/all/account_spec.rb +44 -43
- data/mod/05_standard/spec/set/right/account_spec.rb +4 -2
- data/mod/05_standard/spec/set/type/search_type_spec.rb +8 -0
- data/mod/05_standard/spec/set/type/signup_spec.rb +24 -17
- data/mod/06_bootstrap/set/all/bootstrap/helper.rb +1 -1
- data/spec/lib/card/cache_spec.rb +64 -70
- data/spec/lib/card/content_spec.rb +236 -150
- data/spec/lib/card/reference_spec.rb +22 -38
- data/spec/lib/card/subcards_spec.rb +38 -0
- data/spec/lib/card/view_cache_spec.rb +8 -0
- data/spec/spec_helper.rb +1 -1
- data/tmpsets/set/mod001-01_core/all/collection.rb +77 -74
- data/tmpsets/set/mod001-01_core/all/content.rb +14 -16
- data/tmpsets/set/mod001-01_core/all/fetch.rb +137 -110
- data/tmpsets/set/mod001-01_core/all/name.rb +58 -40
- data/tmpsets/set/mod001-01_core/all/pattern.rb +12 -11
- data/tmpsets/set/mod001-01_core/all/permissions.rb +125 -117
- data/tmpsets/set/mod001-01_core/all/phases.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/references.rb +52 -77
- data/tmpsets/set/mod001-01_core/all/rules.rb +47 -53
- data/tmpsets/set/mod001-01_core/all/templating.rb +31 -87
- data/tmpsets/set/mod001-01_core/all/tracked_attributes.rb +12 -21
- data/tmpsets/set/mod001-01_core/all/trash.rb +4 -1
- data/tmpsets/set/mod001-01_core/all/type.rb +23 -21
- data/tmpsets/set/mod001-01_core/all/utils.rb +80 -64
- data/tmpsets/set/mod002-01_history/all/actions.rb +20 -16
- data/tmpsets/set/mod002-01_history/all/history.rb +18 -13
- data/tmpsets/set/mod003-02_basic_types/all/base.rb +37 -10
- data/tmpsets/set/mod003-02_basic_types/all/rss.rb +17 -22
- data/tmpsets/set/mod003-02_basic_types/type/plain_text.rb +5 -2
- data/tmpsets/set/mod003-02_basic_types/type/pointer.rb +51 -39
- data/tmpsets/set/mod004-03_machines/right/machine_output.rb +10 -6
- data/tmpsets/set/mod005-04_settings/abstract/permission.rb +10 -5
- data/tmpsets/set/mod005-04_settings/right/structure.rb +47 -1
- data/tmpsets/set/mod005-04_settings/self/recent_settings.rb +1 -0
- data/tmpsets/set/mod005-04_settings/type/setting.rb +4 -1
- data/tmpsets/set/mod006-05_email/all/follow.rb +45 -54
- data/tmpsets/set/mod006-05_email/all/notify.rb +88 -73
- data/tmpsets/set/mod006-05_email/right/followers.rb +17 -14
- data/tmpsets/set/mod006-05_email/self/follow_defaults.rb +22 -18
- data/tmpsets/set/mod006-05_email/type/email_template.rb +1 -1
- data/tmpsets/set/mod007-05_standard/abstract/attachment.rb +94 -67
- data/tmpsets/set/mod007-05_standard/all/account.rb +18 -20
- data/tmpsets/set/mod007-05_standard/all/comment.rb +51 -29
- data/tmpsets/set/mod007-05_standard/all/error.rb +129 -99
- data/tmpsets/set/mod007-05_standard/all/links.rb +27 -26
- data/tmpsets/set/mod007-05_standard/all/rich_html/content.rb +115 -103
- data/tmpsets/set/mod007-05_standard/all/rich_html/editing.rb +112 -78
- data/tmpsets/set/mod007-05_standard/all/rich_html/form.rb +123 -81
- data/tmpsets/set/mod007-05_standard/all/rich_html/modal.rb +15 -58
- data/tmpsets/set/mod007-05_standard/all/rich_html/toolbar.rb +2 -2
- data/tmpsets/set/mod007-05_standard/right/account.rb +71 -75
- data/tmpsets/set/mod007-05_standard/right/email.rb +16 -13
- data/tmpsets/set/mod007-05_standard/right/password.rb +20 -12
- data/tmpsets/set/mod007-05_standard/right/status.rb +2 -2
- data/tmpsets/set/mod007-05_standard/right/token.rb +49 -2
- data/tmpsets/set/mod007-05_standard/rstar/rules.rb +20 -325
- data/tmpsets/set/mod007-05_standard/self/all.rb +16 -10
- data/tmpsets/set/mod007-05_standard/self/head.rb +76 -62
- data/tmpsets/set/mod007-05_standard/self/search.rb +45 -22
- data/tmpsets/set/mod007-05_standard/self/signin.rb +14 -12
- data/tmpsets/set/mod007-05_standard/type/cardtype.rb +13 -11
- data/tmpsets/set/mod007-05_standard/type/file.rb +1 -1
- data/tmpsets/set/mod007-05_standard/type/search_type.rb +3 -2
- data/tmpsets/set/mod007-05_standard/type/set.rb +20 -16
- data/tmpsets/set/mod007-05_standard/type/signup.rb +19 -25
- data/tmpsets/set/mod007-05_standard/type/user.rb +1 -1
- data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/helper.rb +1 -1
- data/tmpsets/set_pattern/106-type_plus_right.rb +6 -3
- metadata +11 -2
@@ -5,31 +5,41 @@ format :html do
|
|
5
5
|
###---( TOP_LEVEL (used by menu) NEW / EDIT VIEWS )
|
6
6
|
|
7
7
|
view :new, perms: :create, tags: :unknown_ok do |args|
|
8
|
-
frame_and_form :create, args, 'main-success'=>'REDIRECT' do
|
8
|
+
frame_and_form :create, args, 'main-success' => 'REDIRECT' do
|
9
9
|
[
|
10
|
-
_optional_render(
|
11
|
-
_optional_render(
|
12
|
-
_optional_render(
|
13
|
-
_optional_render(
|
10
|
+
_optional_render(:name_formgroup, args),
|
11
|
+
_optional_render(:type_formgroup, args),
|
12
|
+
_optional_render(:content_formgroup, args),
|
13
|
+
_optional_render(:button_formgroup, args)
|
14
14
|
]
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
18
|
def default_new_args args
|
20
19
|
hidden = args[:hidden] ||= {}
|
21
20
|
hidden[:success] ||= card.rule(:thanks) || '_self'
|
22
|
-
hidden[:card
|
21
|
+
hidden[:card] ||= {}
|
23
22
|
|
24
23
|
args[:optional_help] ||= :show
|
25
24
|
|
26
|
-
|
27
|
-
|
25
|
+
default_new_args_for_name_field_or_title args
|
26
|
+
default_new_args_for_type_field args
|
27
|
+
default_new_args_buttons args
|
28
|
+
end
|
29
|
+
|
30
|
+
def default_new_args_for_name_field_or_title args
|
31
|
+
hidden = args[:hidden]
|
32
|
+
if !params[:name_prompt] && !card.cardname.blank?
|
28
33
|
# name is ready and will show up in title
|
29
34
|
hidden[:card][:name] ||= card.name
|
30
35
|
else
|
31
36
|
# name is not ready; need generic title
|
32
|
-
args[:title] ||=
|
37
|
+
args[:title] ||= if card.type_id == Card.default_type_id
|
38
|
+
'New'
|
39
|
+
else
|
40
|
+
"New #{card.type_name}"
|
41
|
+
end
|
42
|
+
# FIXME: - overrides nest args
|
33
43
|
unless card.rule_card :autoname
|
34
44
|
# prompt for name
|
35
45
|
hidden[:name_prompt] = true unless hidden.has_key? :name_prompt
|
@@ -37,84 +47,95 @@ format :html do
|
|
37
47
|
end
|
38
48
|
end
|
39
49
|
args[:optional_name_formgroup] ||= :hide
|
50
|
+
end
|
40
51
|
|
41
|
-
|
42
|
-
|
43
|
-
if ( !params[:type] and !args[:type] and
|
44
|
-
( main? || card.simple? || card.is_template? ) and
|
45
|
-
Card.new( type_id: card.type_id ).ok? :create #otherwise current type won't be on menu
|
46
|
-
)
|
52
|
+
def default_new_args_for_type_field args
|
53
|
+
if show_type_formgroup?(args)
|
47
54
|
args[:optional_type_formgroup] = :show
|
48
55
|
else
|
49
|
-
hidden[:card][:type_id] ||= card.type_id
|
56
|
+
args[:hidden][:card][:type_id] ||= card.type_id
|
50
57
|
args[:optional_type_formgroup] = :hide
|
51
58
|
end
|
59
|
+
end
|
52
60
|
|
61
|
+
def show_type_formgroup? args
|
62
|
+
!params[:type] && !args[:type] &&
|
63
|
+
(main? || card.simple? || card.is_template?) &&
|
64
|
+
Card.new(type_id: card.type_id).ok?(:create)
|
65
|
+
end
|
53
66
|
|
54
|
-
|
55
|
-
|
56
|
-
else
|
57
|
-
{ class: 'slotter', href: path( view: :missing ) }
|
58
|
-
end
|
59
|
-
|
67
|
+
def default_new_args_buttons args
|
68
|
+
cancel_path = !main? && path(view: :missing)
|
60
69
|
args[:buttons] ||= %{
|
61
|
-
#{
|
62
|
-
#{
|
70
|
+
#{submit_button class: 'create-submit-button'}
|
71
|
+
#{cancel_button class: 'create-cancel-button',
|
72
|
+
href: cancel_path}
|
63
73
|
}
|
64
|
-
|
65
74
|
end
|
66
75
|
|
67
|
-
|
68
|
-
|
69
76
|
view :edit, perms: :update, tags: :unknown_ok do |args|
|
70
77
|
frame_and_form :update, args.merge(optional_toolbar: :show) do
|
71
78
|
[
|
72
|
-
_optional_render(
|
73
|
-
_optional_render(
|
79
|
+
_optional_render(:content_formgroup, args),
|
80
|
+
_optional_render(:button_formgroup, args)
|
74
81
|
]
|
75
82
|
end
|
76
83
|
end
|
77
84
|
|
78
|
-
|
79
85
|
def default_edit_args args
|
80
86
|
args[:optional_help] ||= :show
|
81
87
|
args[:optional_toolbar] ||= :show
|
82
88
|
|
83
89
|
args[:buttons] ||= %{
|
84
|
-
#{
|
85
|
-
#{
|
86
|
-
|
90
|
+
#{submit_button class: 'submit-button'}
|
91
|
+
#{cancel_button href: (args[:cancel_path] || path),
|
92
|
+
class: 'cancel-button',
|
93
|
+
'data-slot-selector' => args[:cancel_slot_selector]}
|
87
94
|
}
|
88
95
|
end
|
89
96
|
|
90
|
-
|
91
97
|
view :edit_name, perms: :update do |args|
|
92
|
-
frame_and_form(
|
98
|
+
frame_and_form(
|
99
|
+
{ action: :update, id: card.id }, args, 'main-success' => 'REDIRECT'
|
100
|
+
) do
|
93
101
|
[
|
94
|
-
_render_name_formgroup(
|
95
|
-
_optional_render(
|
96
|
-
_optional_render(
|
102
|
+
_render_name_formgroup(args),
|
103
|
+
_optional_render(:confirm_rename, args),
|
104
|
+
_optional_render(:button_formgroup, args)
|
97
105
|
]
|
98
106
|
end
|
99
107
|
end
|
100
108
|
|
101
|
-
|
102
109
|
view :confirm_rename do |args|
|
103
110
|
referers = args[:referers]
|
104
|
-
|
111
|
+
descendants = card.descendants
|
112
|
+
msg = "<h5>Are you sure you want to rename <em>#{card.name}</em>?</h5>"
|
113
|
+
if referers.any? || descendants.any?
|
114
|
+
msg << rename_info(referers, descendants)
|
115
|
+
end
|
105
116
|
alert 'warning' do
|
106
|
-
|
107
|
-
<h5>Are you sure you want to rename <em>#{card.name}</em>?</h5>
|
108
|
-
#{ %{ <h6>This change will...</h6> } if referers.any? || dependents.any? }
|
109
|
-
<ul>
|
110
|
-
#{ %{<li>automatically alter #{ dependents.size } related name(s). </li>} if dependents.any? }
|
111
|
-
#{ %{<li>affect at least #{referers.size} reference(s) to "#{card.name}".</li>} if referers.any? }
|
112
|
-
</ul>
|
113
|
-
#{ %{<p>You may choose to <em>update or ignore</em> the references.</p>} if referers.any? }
|
114
|
-
}
|
117
|
+
msg
|
115
118
|
end
|
116
119
|
end
|
117
120
|
|
121
|
+
def rename_info referers, descendants
|
122
|
+
msg = '<h6>This change will...</h6>'
|
123
|
+
msg << '<ul>'
|
124
|
+
if descendants.any?
|
125
|
+
msg << "<li>automatically alter #{descendants.size} related name(s)." \
|
126
|
+
'</li>'
|
127
|
+
end
|
128
|
+
if referers.any?
|
129
|
+
msg << "<li>affect at least #{referers.size} reference(s) to " \
|
130
|
+
"\"#{card.name}\".</li>"
|
131
|
+
end
|
132
|
+
msg << '</ul>'
|
133
|
+
if referers.any?
|
134
|
+
msg << '<p>You may choose to <em>update or ignore</em> the references.' \
|
135
|
+
'</p>'
|
136
|
+
end
|
137
|
+
msg
|
138
|
+
end
|
118
139
|
|
119
140
|
def default_edit_name_args args
|
120
141
|
referers = args[:referers] = card.extended_referencers
|
@@ -126,57 +147,70 @@ format :html do
|
|
126
147
|
card: { update_referencers: false }
|
127
148
|
)
|
128
149
|
args[:optional_toolbar] ||= :show
|
129
|
-
args[:buttons] =
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
150
|
+
args[:buttons] =
|
151
|
+
%{
|
152
|
+
#{submit_button text: 'Rename and Update', disable_with: 'Renaming',
|
153
|
+
class: 'renamer-updater'}
|
154
|
+
#{button_tag 'Rename',
|
155
|
+
data: { disable_with: 'Renaming' },
|
156
|
+
class: 'renamer'}
|
157
|
+
#{cancel_button href: path}
|
158
|
+
}
|
135
159
|
end
|
136
160
|
|
137
|
-
|
138
161
|
view :edit_type, perms: :update do |args|
|
139
162
|
frame_and_form :update, args do
|
140
|
-
|
163
|
+
# 'main-success'=>'REDIRECT: _self', # adding this back in would make
|
164
|
+
# main cards redirect on cardtype changes
|
141
165
|
[
|
142
|
-
_render_type_formgroup(
|
143
|
-
optional_render(
|
166
|
+
_render_type_formgroup(args),
|
167
|
+
optional_render(:button_formgroup, args)
|
144
168
|
]
|
145
169
|
end
|
146
170
|
end
|
147
171
|
|
148
172
|
def default_edit_type_args args
|
149
|
-
args[:variety] = :edit #YUCK!
|
173
|
+
args[:variety] = :edit # YUCK!
|
150
174
|
args[:optional_toolbar] ||= :show
|
151
|
-
args[:hidden] ||= { success: {view: :edit} }
|
175
|
+
args[:hidden] ||= { success: { view: :edit } }
|
152
176
|
args[:buttons] = %{
|
153
|
-
#{
|
154
|
-
#{
|
177
|
+
#{submit_button}
|
178
|
+
#{cancel_button href: path(view: :edit)}
|
155
179
|
}
|
156
180
|
end
|
157
181
|
|
158
182
|
view :edit_rules, tags: :unknown_ok do |args|
|
159
183
|
view = args[:rule_view] || :common_rules
|
160
|
-
slot_args =
|
161
|
-
|
184
|
+
slot_args =
|
185
|
+
{
|
186
|
+
rule_view: view,
|
187
|
+
optional_set_navbar: :show,
|
188
|
+
optional_set_label: :hide,
|
189
|
+
optional_rule_navbar: :hide
|
162
190
|
}
|
163
|
-
_render_related args.merge(
|
191
|
+
_render_related args.merge(
|
192
|
+
related: { card: current_set_card, view: :open, slot: slot_args }
|
193
|
+
)
|
164
194
|
end
|
165
195
|
|
166
196
|
def default_edit_rules_args args
|
167
197
|
args[:optional_toolbar] ||= :show
|
168
198
|
end
|
169
199
|
|
170
|
-
|
200
|
+
# for backwards compatibility
|
201
|
+
view :options, view: :edit_rules, mod: All::RichHtml::Editing::HtmlFormat
|
171
202
|
|
172
203
|
view :edit_structure do |args|
|
173
|
-
slot_args =
|
204
|
+
slot_args =
|
205
|
+
{
|
174
206
|
cancel_slot_selector: '.card-slot.related-view',
|
175
207
|
cancel_path: card.format.path(view: :edit),
|
176
208
|
optional_edit_toolbar: :hide,
|
177
|
-
hidden: {success: {view: :open, 'slot[subframe]'=>true}}
|
209
|
+
hidden: { success: { view: :open, 'slot[subframe]' => true } }
|
178
210
|
}
|
179
|
-
render_related args.merge(
|
211
|
+
render_related args.merge(
|
212
|
+
related: { card: card.structure, view: :edit, slot: slot_args }
|
213
|
+
)
|
180
214
|
end
|
181
215
|
|
182
216
|
def default_edit_structure_args args
|
@@ -197,10 +231,13 @@ format :html do
|
|
197
231
|
view :edit_nest_rules do |args|
|
198
232
|
view = args[:rule_view] || :field_related_rules
|
199
233
|
frame args do
|
200
|
-
#
|
201
|
-
|
202
|
-
|
203
|
-
|
234
|
+
# with_inclusion_mode :edit do
|
235
|
+
nested_fields(args).map do |chunk|
|
236
|
+
nest Card.fetch("#{chunk.referee_name}+*self"),
|
237
|
+
view: :titled, title: chunk.referee_name, rule_view: view,
|
238
|
+
optional_set_label: :hide,
|
239
|
+
optional_rule_navbar: :show
|
240
|
+
end
|
204
241
|
end
|
205
242
|
end
|
206
243
|
|
@@ -210,8 +247,5 @@ format :html do
|
|
210
247
|
end
|
211
248
|
|
212
249
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
250
|
# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/all/rich_html/editing.rb ~~~~~~~~~~~
|
217
251
|
end;end;end;end;end;
|
@@ -5,26 +5,29 @@ format :html do
|
|
5
5
|
def edit_slot args={}
|
6
6
|
# note: @mode should already be :edit here...
|
7
7
|
if args[:structure] || card.structure
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
process_relative_tags optional_toolbar: :hide,
|
14
|
-
structure: args[:structure]
|
15
|
-
end
|
8
|
+
multi_card_edit_slot args
|
9
|
+
else
|
10
|
+
single_card_edit_slot args
|
11
|
+
end
|
12
|
+
end
|
16
13
|
|
14
|
+
def multi_card_edit_slot args
|
15
|
+
if args[:core_edit] # need better name
|
16
|
+
_render_core args
|
17
17
|
else
|
18
|
-
|
19
|
-
|
18
|
+
process_relative_tags optional_toolbar: :hide,
|
19
|
+
structure: args[:structure]
|
20
|
+
end
|
21
|
+
end
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
def single_card_edit_slot args
|
24
|
+
field = content_field form, args
|
25
|
+
if [args[:optional_type_formgroup], args[:optional_name_formgroup]]
|
26
|
+
.member? :show
|
27
|
+
# display content field in formgroup for consistency with other fields
|
28
|
+
formgroup '', field, editor: :content
|
29
|
+
else
|
30
|
+
editor_wrap(:content) { field }
|
28
31
|
end
|
29
32
|
end
|
30
33
|
|
@@ -47,8 +50,8 @@ format :html do
|
|
47
50
|
form_for card, card_form_opts(action, opts) do |form|
|
48
51
|
@form = form
|
49
52
|
%{
|
50
|
-
#{
|
51
|
-
#{
|
53
|
+
#{hidden_tags hidden_args if hidden_args}
|
54
|
+
#{yield form}
|
52
55
|
}
|
53
56
|
end
|
54
57
|
end
|
@@ -64,14 +67,9 @@ format :html do
|
|
64
67
|
end
|
65
68
|
|
66
69
|
def card_form_opts action, html={}
|
67
|
-
url, action =
|
68
|
-
when Symbol ; [ path(action: action) , action ]
|
69
|
-
when Hash ; [ path(action) , action[:action] ]
|
70
|
-
when String ; [ card_path(action) , nil ] #deprecated
|
71
|
-
else ; raise Card::Error, "unsupported card_form action class: #{action.class}"
|
72
|
-
end
|
70
|
+
url, action = url_from_action(action)
|
73
71
|
|
74
|
-
klasses = Array.wrap(
|
72
|
+
klasses = Array.wrap(html[:class])
|
75
73
|
klasses << 'card-form slotter'
|
76
74
|
klasses << 'autosave' if action == :update
|
77
75
|
html[:class] = klasses.join ' '
|
@@ -82,33 +80,51 @@ format :html do
|
|
82
80
|
{ url: url, remote: true, html: html }
|
83
81
|
end
|
84
82
|
|
83
|
+
def url_from_action action
|
84
|
+
case action
|
85
|
+
when Symbol
|
86
|
+
[path(action: action), action]
|
87
|
+
when Hash
|
88
|
+
[path(action), action[:action]]
|
89
|
+
when String # deprecated
|
90
|
+
[card_path(action), nil]
|
91
|
+
else
|
92
|
+
raise Card::Error, "unsupported card_form action class: #{action.class}"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
85
96
|
def editor_wrap type=nil
|
86
|
-
|
97
|
+
html_class = 'editor'
|
98
|
+
html_class << " #{type}-editor" if type
|
99
|
+
content_tag(:div, class: html_class) { yield.html_safe }
|
87
100
|
end
|
88
101
|
|
89
102
|
def formgroup title, content, opts={}
|
90
|
-
|
91
|
-
case opts[:help]
|
92
|
-
when String ; _render_help help_class: 'help-block', help_text: opts[:help]
|
93
|
-
when true ; _render_help help_class: 'help-block'
|
94
|
-
else ; nil
|
95
|
-
end
|
96
|
-
|
97
|
-
div_args = { class: ['form-group', opts[:class]].compact*' ' }
|
98
|
-
div_args[:card_id ] = card.id if card.real?
|
99
|
-
div_args[:card_name] = h card.name if card.name.present?
|
100
|
-
|
101
|
-
wrap_with :div, div_args do
|
103
|
+
wrap_with :div, formgroup_div_args(opts[:class]) do
|
102
104
|
%{
|
103
|
-
<label>#{
|
105
|
+
<label>#{title}</label>
|
104
106
|
<div>
|
105
|
-
#{
|
106
|
-
#{
|
107
|
+
#{editor_wrap(opts[:editor]) { content }}
|
108
|
+
#{formgroup_help_text opts[:help]}
|
107
109
|
</div>
|
108
110
|
}
|
109
111
|
end
|
110
112
|
end
|
111
113
|
|
114
|
+
def formgroup_div_args html_class
|
115
|
+
div_args = { class: ['form-group', html_class].compact.join(' ') }
|
116
|
+
div_args[:card_id] = card.id if card.real?
|
117
|
+
div_args[:card_name] = h card.name if card.name.present?
|
118
|
+
div_args
|
119
|
+
end
|
120
|
+
|
121
|
+
def formgroup_help_text text=nil
|
122
|
+
case text
|
123
|
+
when String then _render_help help_class: 'help-block', help_text: text
|
124
|
+
when true then _render_help help_class: 'help-block'
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
112
128
|
def hidden_tags hash, base=nil
|
113
129
|
# convert hash into a collection of hidden tags
|
114
130
|
result = ''
|
@@ -128,7 +144,7 @@ format :html do
|
|
128
144
|
# FIELDSET VIEWS
|
129
145
|
|
130
146
|
view :name_formgroup do |args|
|
131
|
-
formgroup 'name', raw(
|
147
|
+
formgroup 'name', raw(name_field form), editor: 'name', help: args[:help]
|
132
148
|
end
|
133
149
|
|
134
150
|
view :type_formgroup do |args|
|
@@ -153,26 +169,29 @@ format :html do
|
|
153
169
|
}
|
154
170
|
end
|
155
171
|
|
156
|
-
|
157
172
|
def name_field form=nil, options={}
|
158
173
|
form ||= self.form
|
159
|
-
text_field(
|
160
|
-
|
174
|
+
text_field(:name, {
|
175
|
+
# needed because otherwise gets wrong value if there are updates
|
176
|
+
value: card.name,
|
161
177
|
autocomplete: 'off'
|
162
178
|
}.merge(options))
|
163
179
|
end
|
164
180
|
|
165
181
|
def type_field args={}
|
166
182
|
typelist = Auth.createable_types
|
167
|
-
current_type =
|
168
|
-
|
169
|
-
|
170
|
-
|
183
|
+
current_type =
|
184
|
+
unless args.delete :no_current_type
|
185
|
+
if !card.new_card? && !typelist.include?(card.type_name)
|
186
|
+
# current type should be an option on existing cards,
|
187
|
+
# regardless of create perms
|
188
|
+
typelist.push(card.type_name).sort!
|
171
189
|
end
|
172
|
-
|
190
|
+
card.type_name_or_default
|
173
191
|
end
|
174
192
|
|
175
|
-
options = options_from_collection_for_select typelist, :to_s, :to_s,
|
193
|
+
options = options_from_collection_for_select typelist, :to_s, :to_s,
|
194
|
+
current_type
|
176
195
|
template.select_tag 'card[type]', options, args
|
177
196
|
end
|
178
197
|
|
@@ -180,34 +199,36 @@ format :html do
|
|
180
199
|
@form = form
|
181
200
|
@nested = options[:nested]
|
182
201
|
card.last_action_id_before_edit = card.last_action_id
|
183
|
-
revision_tracking =
|
184
|
-
|
185
|
-
|
186
|
-
|
202
|
+
revision_tracking =
|
203
|
+
if card && !card.new_card? && !options[:skip_rev_id]
|
204
|
+
hidden_field :last_action_id_before_edit, class: 'current_revision_id'
|
205
|
+
# hidden_field_tag 'card[last_action_id_before_edit]',
|
206
|
+
# card.last_action_id, class: 'current_revision_id'
|
207
|
+
end
|
187
208
|
%{
|
188
|
-
#{
|
189
|
-
|
190
|
-
#{ _render_editor options }
|
209
|
+
#{revision_tracking}
|
210
|
+
#{_render_editor options}
|
191
211
|
}
|
192
212
|
end
|
193
213
|
|
214
|
+
# FIELD VIEWS
|
194
215
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
text_area :content, rows: 3, class: 'tinymce-textarea card-content', id: unique_id
|
216
|
+
view :editor do |_args|
|
217
|
+
text_area :content, rows: 3, class: 'tinymce-textarea card-content',
|
218
|
+
id: unique_id
|
199
219
|
end
|
200
220
|
|
201
221
|
view :edit_in_form, perms: :update, tags: :unknown_ok do |args|
|
202
222
|
eform = form_for_multi
|
203
|
-
|
204
|
-
|
223
|
+
content = content_field eform, args.merge(nested: true)
|
224
|
+
if card.new_card?
|
225
|
+
content += raw("\n #{ eform.hidden_field :type_id }")
|
226
|
+
end
|
205
227
|
opts = { editor: 'content', help: true, class: 'card-editor' }
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
formgroup fancy_title( args[:title] ), content, opts
|
228
|
+
if card.cardname.junction?
|
229
|
+
opts[:class] += " RIGHT-#{ card.cardname.tag_name.safe_key }"
|
230
|
+
end
|
231
|
+
formgroup fancy_title(args[:title]), content, opts
|
211
232
|
end
|
212
233
|
|
213
234
|
def process_relative_tags args
|
@@ -215,33 +236,54 @@ format :html do
|
|
215
236
|
nested_card = fetch_nested_card chunk.options
|
216
237
|
nest nested_card, chunk.options.reverse_merge(args)
|
217
238
|
end.join "\n"
|
218
|
-
# _render_raw(args).scan( /\{\{\s*\+[^\}]*\}\}/ ).map do |inc| #fixme - wrong place for regexp!
|
219
|
-
# process_content( inc ).strip
|
220
|
-
# end.join
|
221
239
|
end
|
222
240
|
|
223
241
|
# form helpers
|
224
242
|
|
225
|
-
FIELD_HELPERS =
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
243
|
+
FIELD_HELPERS =
|
244
|
+
%w{
|
245
|
+
hidden_field color_field date_field datetime_field datetime_local_field
|
246
|
+
email_field month_field number_field password_field phone_field
|
247
|
+
range_field search_field telephone_field text_area text_field time_field
|
248
|
+
url_field week_field file_field
|
249
|
+
}
|
230
250
|
|
231
251
|
FIELD_HELPERS.each do |method_name|
|
232
|
-
define_method(method_name) do |name, options
|
252
|
+
define_method(method_name) do |name, options={}|
|
233
253
|
form.send(method_name, name, options)
|
234
254
|
end
|
235
255
|
end
|
236
256
|
|
237
|
-
def check_box method, options={}, checked_value =
|
257
|
+
def check_box method, options={}, checked_value = '1', unchecked_value = '0'
|
238
258
|
form.check_box method, options, checked_value, unchecked_value
|
239
259
|
end
|
240
260
|
|
241
|
-
def radio_button method, tag_value, options
|
261
|
+
def radio_button method, tag_value, options={}
|
242
262
|
form.radio_button method, tag_value, options
|
243
263
|
end
|
244
264
|
|
265
|
+
def submit_button args={}
|
266
|
+
args.reverse_merge!(
|
267
|
+
situation: 'primary',
|
268
|
+
data: {}
|
269
|
+
)
|
270
|
+
text = args.delete(:text) || 'Submit'
|
271
|
+
args[:data][:disable_with] ||= args.delete(:disable_with) || 'Submitting'
|
272
|
+
button_tag text, args
|
273
|
+
end
|
274
|
+
|
275
|
+
# redirect to *previous if no :href is given
|
276
|
+
def cancel_button args={}
|
277
|
+
args.reverse_merge! type: 'button'
|
278
|
+
if args[:href]
|
279
|
+
add_class args, 'slotter'
|
280
|
+
else
|
281
|
+
add_class args, 'redirecter'
|
282
|
+
args[:href] = Card.path_setting('/*previous')
|
283
|
+
end
|
284
|
+
text = args.delete(:text) || 'Cancel'
|
285
|
+
button_tag text, args
|
286
|
+
end
|
245
287
|
end
|
246
288
|
|
247
289
|
|