card 1.16.14 → 1.16.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/db/migrate_core_cards/20150903130006_attachment_upload_cards.rb +4 -2
  4. data/lib/card/auth.rb +15 -10
  5. data/lib/card/codename.rb +25 -21
  6. data/lib/card/content.rb +100 -68
  7. data/lib/card/format.rb +158 -129
  8. data/lib/card/query.rb +15 -9
  9. data/lib/card/query/attributes.rb +41 -49
  10. data/lib/card/set.rb +15 -12
  11. data/lib/card/set_pattern.rb +4 -5
  12. data/lib/card/spec_helper.rb +54 -16
  13. data/lib/cardio.rb +43 -25
  14. data/mod/01_core/chunk/include.rb +1 -1
  15. data/mod/01_core/set/all/collection.rb +76 -73
  16. data/mod/01_core/set/all/content.rb +0 -4
  17. data/mod/01_core/set/all/fetch.rb +35 -42
  18. data/mod/01_core/set/all/name.rb +17 -7
  19. data/mod/01_core/set/all/pattern.rb +12 -11
  20. data/mod/01_core/set/all/permissions.rb +51 -42
  21. data/mod/01_core/set/all/phases.rb +2 -1
  22. data/mod/01_core/set/all/references.rb +2 -2
  23. data/mod/01_core/set/all/rules.rb +28 -35
  24. data/mod/01_core/set/all/subcards.rb +12 -12
  25. data/mod/01_core/set/all/tracked_attributes.rb +1 -1
  26. data/mod/01_core/set/all/type.rb +11 -11
  27. data/mod/01_core/set/all/utils.rb +6 -1
  28. data/mod/01_core/spec/set/all/fetch_spec.rb +6 -6
  29. data/mod/01_core/spec/set/all/permissions_spec.rb +11 -11
  30. data/mod/01_core/spec/set/all/tracked_attributes_spec.rb +1 -1
  31. data/mod/01_history/lib/card/action.rb +52 -47
  32. data/mod/01_history/set/all/actions.rb +20 -16
  33. data/mod/01_history/set/all/history.rb +18 -13
  34. data/mod/02_basic_types/set/all/base.rb +23 -2
  35. data/mod/02_basic_types/set/type/pointer.rb +45 -36
  36. data/mod/02_basic_types/spec/set/all/base_spec.rb +40 -24
  37. data/mod/02_basic_types/spec/set/type/pointer_spec.rb +87 -0
  38. data/mod/03_machines/set/right/machine_output.rb +10 -6
  39. data/mod/04_settings/set/abstract/permission.rb +10 -5
  40. data/mod/04_settings/set/type/setting.rb +4 -1
  41. data/mod/05_email/set/all/follow.rb +39 -44
  42. data/mod/05_email/set/all/notify.rb +4 -1
  43. data/mod/05_email/set/right/followers.rb +16 -14
  44. data/mod/05_email/set/self/follow_defaults.rb +22 -19
  45. data/mod/05_standard/lib/carrier_wave/cardmount.rb +1 -0
  46. data/mod/05_standard/set/abstract/attachment.rb +85 -58
  47. data/mod/05_standard/set/all/comment.rb +35 -19
  48. data/mod/05_standard/set/all/error.rb +124 -98
  49. data/mod/05_standard/set/all/list_changes.rb +27 -22
  50. data/mod/05_standard/set/all/rich_html/editing.rb +96 -70
  51. data/mod/05_standard/set/all/rich_html/form.rb +123 -81
  52. data/mod/05_standard/set/all/rich_html/modal.rb +15 -58
  53. data/mod/05_standard/set/right/account.rb +2 -2
  54. data/mod/05_standard/set/right/email.rb +3 -2
  55. data/mod/05_standard/set/rstar/rules.rb +3 -3
  56. data/mod/05_standard/set/self/search.rb +45 -22
  57. data/mod/05_standard/set/type/cardtype.rb +13 -11
  58. data/mod/05_standard/set/type/listed_by.rb +3 -2
  59. data/mod/05_standard/set/type/set.rb +17 -13
  60. data/mod/05_standard/set/type/signup.rb +1 -2
  61. data/mod/05_standard/set/type/user.rb +1 -1
  62. data/mod/05_standard/spec/set/all/account_spec.rb +1 -1
  63. data/mod/05_standard/spec/set/all/history_spec.rb +1 -1
  64. data/mod/05_standard/spec/set/type/email_template_spec.rb +140 -134
  65. data/mod/05_standard/spec/set/type/image_spec.rb +2 -1
  66. data/mod/05_standard/spec/set/type/signup_spec.rb +2 -2
  67. data/spec/models/card/trash_spec.rb +1 -1
  68. data/spec/spec_helper.rb +0 -1
  69. metadata +2 -2
@@ -5,81 +5,93 @@ def copy_errors card
5
5
  end
6
6
 
7
7
  format do
8
- view :closed_missing, perms: :none, closed: true do |args|
8
+ view :closed_missing, perms: :none, closed: true do
9
9
  ''
10
10
  end
11
11
 
12
- view :missing, perms: :none do |args|
12
+ view :unsupported_view, perms: :none, tags: :unknown_ok do |args|
13
+ "view (#{args[:unsupported_view]}) not supported for #{error_cardname}"
14
+ end
15
+
16
+ view :missing, perms: :none do
13
17
  ''
14
18
  end
15
19
 
16
- view :not_found, perms: :none, error_code: 404 do |args|
17
- %{ Could not find #{card.name.present? ? %{"#{card.name}"} : 'the card requested'}. }
20
+ view :not_found, perms: :none, error_code: 404 do |_args|
21
+ error_name = card.name.present? ? card.name : 'the card requested'
22
+ %{ Could not find #{error_name}. }
18
23
  end
19
24
 
20
- view :server_error, perms: :none, error_code: 500 do |args|
21
- %{ Wagn Hitch! Server Error. Yuck, sorry about that.\n}+
22
- %{ To tell us more and follow the fix, add a support ticket at http://wagn.org/new/Support_Ticket }
25
+ view :server_error, perms: :none, error_code: 500 do
26
+ %{
27
+ Wagn Hitch! Server Error. Yuck, sorry about that.
28
+ To tell us more and follow the fix,
29
+ add a support ticket at http://wagn.org/new/Support_Ticket
30
+ }
23
31
  end
24
32
 
25
- view :denial, perms: :none, error_code: 403 do |args|
33
+ view :denial, perms: :none, error_code: 403 do
26
34
  focal? ? 'Permission Denied' : ''
27
35
  end
28
36
 
29
- view :bad_address, perms: :none, error_code: 404 do |args|
37
+ view :bad_address, perms: :none, error_code: 404 do
30
38
  %{ 404: Bad Address }
31
39
  end
32
40
 
33
- view :too_deep, perms: :none, closed: true do |args|
41
+ view :too_deep, perms: :none, closed: true do
34
42
  %{ Man, you're too deep. (Too many levels of inclusions at a time) }
35
43
  end
36
44
 
37
- view :too_slow, perms: :none, closed: true do |args|
38
- %{ Timed out! #{ showname } took too long to load. }
45
+ view :too_slow, perms: :none, closed: true do
46
+ %{ Timed out! #{showname} took too long to load. }
39
47
  end
40
48
  end
41
49
 
42
-
43
50
  format :html do
44
51
  def view_for_unknown view, args
45
52
  case
46
- when focal? && ok?( :create ) ; :new
47
- when commentable?( view, args ) ; view
48
- else super
53
+ when focal? && ok?(:create) then :new
54
+ when commentable?(view, args) then view
55
+ else super
49
56
  end
50
57
  end
51
58
 
52
59
  def commentable? view, args
53
- self.class.tagged view, :comment and
54
- show_view? :comment_box, args.merge( default_visibility: :hide ) and #developer or wagneer has overridden default
60
+ return false unless self.class.tagged view, :comment
61
+ visibility_args = args.merge default_visibility: :hide
62
+ return false unless show_view? :comment_box, visibility_args
55
63
  ok? :comment
56
64
  end
57
65
 
58
66
  def rendering_error exception, view
59
- details = if Auth.always_ok?
60
- card_link(error_cardname, class: 'render-error-link') +
61
- alert('warning', dismissible: true, alert_class: "render-error-message errors-view admin-error-message") do
62
- %{
63
- <h3>Error message (visible to admin only)</h3>
64
- <p><strong>#{ exception.message }</strong></p>
65
- <div>#{exception.backtrace * "<br>\n"}</div>
66
- }
67
- end
68
- else
69
- error_cardname
70
- end
71
-
67
+ details = Auth.always_ok? ? backtrace_link(exception) : error_cardname
72
68
  content_tag :span, class: 'render-error alert alert-danger' do
73
- [
74
- 'error rendering',
75
- details,
76
- "(#{view} view)"
77
- ].join "\n"
69
+ ['error rendering', details, "(#{view} view)"].join "\n"
70
+ end
71
+ end
72
+
73
+ def backtrace_link exception
74
+ warning_options = {
75
+ dismissible: true,
76
+ alert_class: 'render-error-message errors-view admin-error-message'
77
+ }
78
+ warning = alert('warning', warning_options) do
79
+ %{
80
+ <h3>Error message (visible to admin only)</h3>
81
+ <p><strong>#{exception.message}</strong></p>
82
+ <div>#{exception.backtrace * "<br>\n"}</div>
83
+ }
78
84
  end
85
+ card_link(error_cardname, class: 'render-error-link') + warning
79
86
  end
80
87
 
81
- def unsupported_view view
82
- "<strong>view <em>#{view}</em> not supported for <em>#{error_cardname}</em></strong>"
88
+ view :unsupported_view, perms: :none, tags: :unknown_ok do |args|
89
+ %{
90
+ <strong>
91
+ view <em>#{args[:unsupported_view]}</em>
92
+ not supported for <em>#{error_cardname}</em>
93
+ </strong>
94
+ }
83
95
  end
84
96
 
85
97
  view :message, perms: :none, tags: :unknown_ok do |args|
@@ -88,46 +100,53 @@ format :html do
88
100
  end
89
101
  end
90
102
 
91
-
92
103
  view :missing do |args|
93
104
  return '' unless card.ok? :create # should this be moved into ok_view?
94
105
 
95
- opts = { remote: true, class: "slotter missing-#{ args[:denied_view] || args[:home_view]}" }
96
- opts[:path_opts] = { type: args[:type] } if args[:type]
106
+ link_opts = {
107
+ remote: true,
108
+ class: "slotter missing-#{args[:denied_view] || args[:home_view]}"
109
+ }
110
+ link_opts[:path_opts] = { type: args[:type] } if args[:type]
97
111
 
98
112
  wrap args do
99
- view_link "Add #{ fancy_title args[:title] }", :new, opts
113
+ view_link "Add #{fancy_title args[:title]}", :new, link_opts
100
114
  end
101
115
  end
102
116
 
103
- view :closed_missing, perms: :none do |args|
104
- %{<span class="faint"> #{ showname } </span>}
117
+ view :closed_missing, perms: :none do
118
+ %{<span class="faint"> #{showname} </span>}
105
119
  end
106
120
 
107
-
108
-
109
121
  view :conflict, error_code: 409 do |args|
110
- wrap args.merge( slot_class: 'error-view' ) do #ENGLISH below
122
+ actor_link = card_link card.last_action.act.actor.cardname
123
+ expanded_act = wrap(args) do
124
+ _render_act_expanded act: card.last_action.act, current_rev_nr: 0
125
+ end
126
+ wrap args.merge(slot_class: 'error-view') do # ENGLISH below
111
127
  alert 'warning' do
112
- %{<strong>Conflict!</strong><span class="new-current-revision-id">#{card.last_action_id}</span>
113
- <div>#{ card_link card.last_action.act.actor.cardname } has also been making changes.</div>
128
+ %{
129
+ <strong>Conflict!</strong>
130
+ <span class="new-current-revision-id">#{card.last_action_id}</span>
131
+ <div>#{actor_link} has also been making changes.</div>
114
132
  <div>Please examine below, resolve above, and re-submit.</div>
115
- #{ wrap do |args|
116
- _render_act_expanded act: card.last_action.act, current_rev_nr: 0
117
- end
118
- }
133
+ #{expanded_act}
119
134
  }
120
135
  end
121
136
  end
122
137
  end
123
138
 
124
139
  view :errors, perms: :none do |args|
125
-
126
140
  if card.errors.any?
127
- title = %{ Problems #{%{ with #{card.name} } unless card.name.blank?} }
128
- frame args.merge(panel_class: "panel panel-warning", title: title, hide: 'menu' ) do
141
+ title = 'Problems'
142
+ title += " with #{card.name}" unless card.name.blank?
143
+ frame_opts = { panel_class: 'panel panel-warning',
144
+ title: title, hide: 'menu' }
145
+ frame args.merge(frame_opts) do
129
146
  card.errors.map do |attrib, msg|
130
- msg = "<strong>#{attrib.to_s.upcase}:</strong> #{msg}" unless attrib == :abort
147
+ unless attrib == :abort
148
+ msg = "<strong>#{attrib.to_s.upcase}:</strong> #{msg}"
149
+ end
131
150
  alert 'warning', dismissible: true, alert_class: 'card-error-msg' do
132
151
  msg
133
152
  end
@@ -136,61 +155,68 @@ format :html do
136
155
  end
137
156
  end
138
157
 
139
- view :not_found do |args| #ug. bad name.
140
- sign_in_or_up_links = if !Auth.signed_in?
141
- %{<div>
142
- #{ card_link :signin, text: 'Sign in' } or
143
- #{ link_to 'Sign up', card_path('new/:signup') } to create it.
144
- </div>}
145
- end
158
+ view :not_found do |args| # ug. bad name.
159
+ sign_in_or_up_links =
160
+ if !Auth.signed_in?
161
+ signin_link = card_link :signin, text: 'Sign in'
162
+ signup_link = link_to 'Sign up', card_path('new/:signup')
163
+ %{<div>#{signin_link} or #{signup_link} to create it.</div>}
164
+ end
146
165
  frame args.merge(title: 'Not Found', optional_menu: :never) do
147
- %{
148
- <h2>Could not find #{card.name.present? ? "<em>#{card.name}</em>" : 'that'}.</h2>
149
- #{sign_in_or_up_links}
150
- }
166
+ card_label = card.name.present? ? "<em>#{card.name}</em>" : 'that'
167
+ %{<h2>Could not find #{card_label}.</h2> #{sign_in_or_up_links}}
151
168
  end
152
169
  end
153
170
 
154
171
  view :denial do |args|
155
- to_task = if task = args[:denied_task]
156
- %{to #{task} this.}
157
- else
158
- 'to do that.'
159
- end
172
+ task = args[:denied_task]
173
+ to_task = task ? "to #{task} this." : 'to do that.'
160
174
  if !focal?
161
- %{<span class="denied"><!-- Sorry, you don't have permission #{to_task} --></span>}
175
+ %{
176
+ <span class="denied">
177
+ <!-- Sorry, you don't have permission #{to_task} -->
178
+ </span>
179
+ }
162
180
  else
163
- frame args do #ENGLISH below
164
- message = case
165
- when task != :read && Card.config.read_only
166
- "We are currently in read-only mode. Please try again later."
167
- when Auth.signed_in?
168
- "You need permission #{to_task}"
169
- else
170
- or_signup = if Card.new(type_id: Card::SignupID).ok? :create
171
- "or #{ link_to 'sign up', card_url('new/:signup') }"
181
+ frame args do # ENGLISH below
182
+ message =
183
+ case
184
+ when task != :read && Card.config.read_only
185
+ 'We are currently in read-only mode. Please try again later.'
186
+ when Auth.signed_in?
187
+ "You need permission #{to_task}"
188
+ else
189
+ signin_link = link_to 'sign in', card_url(':signin')
190
+ or_signup_link =
191
+ if Card.new(type_id: Card::SignupID).ok? :create
192
+ 'or ' + link_to('sign up', card_url('new/:signup'))
193
+ end
194
+ Env.save_interrupted_action(request.env['REQUEST_URI'])
195
+ "Please #{signin_link} #{or_signup_link} #{to_task}"
172
196
  end
173
- Env.save_interrupted_action(request.env['REQUEST_URI'])
174
- "Please #{ link_to 'sign in', card_url(':signin') } #{or_signup} #{to_task}"
175
- end
176
197
 
177
- %{<h1>Sorry!</h1>\n<div>#{ message }</div>}
198
+ %{
199
+ <h1>Sorry!</h1>
200
+ <div>#{message}</div>
201
+ }
178
202
  end
179
203
  end
180
204
  end
181
205
 
182
-
183
- view :server_error do |args|
206
+ view :server_error do
184
207
  %{
185
- <body>
186
- <div class="dialog">
187
- <h1>Wagn Hitch :(</h1>
188
- <p>Server Error. Yuck, sorry about that.</p>
189
- <p><a href="http://www.wagn.org/new/Support_Ticket">Add a support ticket</a>
190
- to tell us more and follow the fix.</p>
191
- </div>
192
- </body>
208
+ <body>
209
+ <div class="dialog">
210
+ <h1>Wagn Hitch :(</h1>
211
+ <p>Server Error. Yuck, sorry about that.</p>
212
+ <p>
213
+ <a href="http://www.wagn.org/new/Support_Ticket">
214
+ Add a support ticket
215
+ </a>
216
+ to tell us more and follow the fix.
217
+ </p>
218
+ </div>
219
+ </body>
193
220
  }
194
221
  end
195
-
196
222
  end
@@ -1,43 +1,48 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
+
4
+ def list_fields
5
+ Card.search({ left: name, type_id: Card::ListID }, 'list fields')
6
+ end
7
+
8
+ def listed_by_fields
9
+ Card.search({ left: name, type_id: Card::ListedByID }, 'listed by fields')
10
+ end
11
+
12
+ def linker_lists
13
+ Card.search({ type_id: Card::ListID, link_to: name },
14
+ "lists that link to #{name}")
15
+ end
16
+
3
17
  event :trunk_cardtype_of_a_list_relation_changed,
4
18
  changed: :type, after: :store, on: :update,
5
19
  when: proc { Codename[:list] } do
6
- type_key_was = (tk = Card.fetch(type_id_was)) && tk.key
7
- if (list_cards = Card.search(left: name, type_id: Card::ListID))
8
- list_cards.each do |card|
9
- card.update_listed_by_cache_for card.item_keys, type_key: type_key_was
10
- card.update_listed_by_cache_for card.item_keys
11
- end
12
- end
13
- if (listed_by_cards = Card.search(left: name, type_id: Card::ListedByID))
14
- listed_by_cards.each(&:update_cached_list)
20
+ type_key_was = (tk = Card.quick_fetch(type_id_was)) && tk.key
21
+
22
+ list_fields.each do |card|
23
+ card.update_listed_by_cache_for card.item_keys, type_key: type_key_was
24
+ card.update_listed_by_cache_for card.item_keys
15
25
  end
26
+ listed_by_fields.each &:update_cached_list
16
27
  end
17
28
 
18
29
  event :trunk_name_of_a_list_relation_changed,
19
30
  changed: :name, after: :store, on: :update,
20
31
  when: proc { Codename[:list] } do
21
- if (list_cards = Card.search(left: name, type_id: Card::ListID))
22
- list_cards.each do |card|
23
- card.update_listed_by_cache_for card.item_keys
24
- end
25
- end
26
- if (listed_by_cards = Card.search(left: name, type_id: Card::ListedByID))
27
- listed_by_cards.each(&:update_cached_list)
32
+ list_fields.each do |card|
33
+ card.update_listed_by_cache_for card.item_keys
28
34
  end
35
+ listed_by_fields.each &:update_cached_list
29
36
  end
30
37
 
31
38
  event :cardtype_of_list_item_changed,
32
39
  changed: :type, before: :approve, on: :save,
33
40
  when: proc { Codename[:list] } do
34
- Card.search(type_id: Card::ListID, link_to: name).each do |card|
41
+ linker_lists.each do |card|
35
42
  if card.item_type_id != type_id
36
- errors.add(
37
- :type,
38
- "can't be changed because #{name} " \
39
- "is referenced by list card #{card.name}"
40
- )
43
+ errors.add(:type,
44
+ "can't be changed because #{name} " \
45
+ "is referenced by list card #{card.name}")
41
46
  end
42
47
  end
43
48
  end
@@ -19,7 +19,13 @@ format :html do
19
19
 
20
20
  args[:optional_help] ||= :show
21
21
 
22
- # name field / title
22
+ default_new_args_for_name_field_or_title args
23
+ default_new_args_for_type_field args
24
+ default_new_args_buttons args
25
+ end
26
+
27
+ def default_new_args_for_name_field_or_title args
28
+ hidden = args[:hidden]
23
29
  if !params[:name_prompt] && !card.cardname.blank?
24
30
  # name is ready and will show up in title
25
31
  hidden[:card][:name] ||= card.name
@@ -38,36 +44,29 @@ format :html do
38
44
  end
39
45
  end
40
46
  args[:optional_name_formgroup] ||= :hide
47
+ end
41
48
 
42
- # type field
43
- if !params[:type] &&
44
- !args[:type] &&
45
- (main? || card.simple? || card.is_template?) &&
46
- Card.new(type_id: card.type_id).ok?(:create)
47
- # otherwise current type won't be on menu
48
-
49
+ def default_new_args_for_type_field args
50
+ if show_type_formgroup?(args)
49
51
  args[:optional_type_formgroup] = :show
50
52
  else
51
- hidden[:card][:type_id] ||= card.type_id
53
+ args[:hidden][:card][:type_id] ||= card.type_id
52
54
  args[:optional_type_formgroup] = :hide
53
55
  end
56
+ end
54
57
 
55
- cancel =
56
- if main?
57
- { class: 'redirecter', href: Card.path_setting('/*previous') }
58
- else
59
- { class: 'slotter', href: path(view: :missing) }
60
- end
58
+ def show_type_formgroup? args
59
+ !params[:type] && !args[:type] &&
60
+ (main? || card.simple? || card.is_template?) &&
61
+ Card.new(type_id: card.type_id).ok?(:create)
62
+ end
61
63
 
64
+ def default_new_args_buttons args
65
+ cancel_path = !main? && path(view: :missing)
62
66
  args[:buttons] ||= %{
63
- #{button_tag 'Submit',
64
- class: 'create-submit-button',
65
- disable_with: 'Submitting',
66
- situation: 'primary'}
67
- #{button_tag 'Cancel',
68
- type: 'button',
69
- class: "create-cancel-button #{cancel[:class]}",
70
- href: cancel[:href]}
67
+ #{submit_button class: 'create-submit-button'}
68
+ #{cancel_button class: 'create-cancel-button',
69
+ href: cancel_path}
71
70
  }
72
71
  end
73
72
 
@@ -80,46 +79,60 @@ format :html do
80
79
  end
81
80
  end
82
81
 
83
-
84
82
  def default_edit_args args
85
83
  args[:optional_help] ||= :show
86
84
  args[:optional_toolbar] ||= :show
87
85
 
88
86
  args[:buttons] ||= %{
89
- #{ button_tag 'Submit', class: 'submit-button', disable_with: 'Submitting', situation: 'primary' }
90
- #{ button_tag 'Cancel', class: 'cancel-button slotter', 'data-slot-selector'=>args[:cancel_slot_selector],
91
- href: (args[:cancel_path] || path), type: 'button' }
87
+ #{submit_button class: 'submit-button'}
88
+ #{cancel_button href: (args[:cancel_path] || path),
89
+ class: 'cancel-button',
90
+ 'data-slot-selector' => args[:cancel_slot_selector]}
92
91
  }
93
92
  end
94
93
 
95
-
96
94
  view :edit_name, perms: :update do |args|
97
- frame_and_form( { action: :update, id: card.id }, args, 'main-success'=>'REDIRECT' ) do
95
+ frame_and_form(
96
+ { action: :update, id: card.id }, args, 'main-success' => 'REDIRECT'
97
+ ) do
98
98
  [
99
- _render_name_formgroup( args ),
100
- _optional_render( :confirm_rename, args ),
101
- _optional_render( :button_formgroup, args )
99
+ _render_name_formgroup(args),
100
+ _optional_render(:confirm_rename, args),
101
+ _optional_render(:button_formgroup, args)
102
102
  ]
103
103
  end
104
104
  end
105
105
 
106
-
107
106
  view :confirm_rename do |args|
108
107
  referers = args[:referers]
109
108
  descendants = card.descendants
109
+ msg = "<h5>Are you sure you want to rename <em>#{card.name}</em>?</h5>"
110
+ if referers.any? || descendants.any?
111
+ msg << rename_info(referers, descendants)
112
+ end
110
113
  alert 'warning' do
111
- %{
112
- <h5>Are you sure you want to rename <em>#{card.name}</em>?</h5>
113
- #{ %{ <h6>This change will...</h6> } if referers.any? || descendants.any? }
114
- <ul>
115
- #{ %{<li>automatically alter #{ descendants.size } related name(s). </li>} if descendants.any? }
116
- #{ %{<li>affect at least #{referers.size} reference(s) to "#{card.name}".</li>} if referers.any? }
117
- </ul>
118
- #{ %{<p>You may choose to <em>update or ignore</em> the references.</p>} if referers.any? }
119
- }
114
+ msg
120
115
  end
121
116
  end
122
117
 
118
+ def rename_info referers, descendants
119
+ msg = '<h6>This change will...</h6>'
120
+ msg << '<ul>'
121
+ if descendants.any?
122
+ msg << "<li>automatically alter #{descendants.size} related name(s)." \
123
+ '</li>'
124
+ end
125
+ if referers.any?
126
+ msg << "<li>affect at least #{referers.size} reference(s) to " \
127
+ "\"#{card.name}\".</li>"
128
+ end
129
+ msg << '</ul>'
130
+ if referers.any?
131
+ msg << '<p>You may choose to <em>update or ignore</em> the references.' \
132
+ '</p>'
133
+ end
134
+ msg
135
+ end
123
136
 
124
137
  def default_edit_name_args args
125
138
  referers = args[:referers] = card.extended_referencers
@@ -131,57 +144,70 @@ format :html do
131
144
  card: { update_referencers: false }
132
145
  )
133
146
  args[:optional_toolbar] ||= :show
134
- args[:buttons] = %{
135
- #{ button_tag 'Rename and Update', disable_with: 'Renaming', class: 'renamer-updater', situation: 'primary' }
136
- #{ button_tag 'Rename', disable_with: 'Renaming', class: 'renamer' }
137
- #{ button_tag 'Cancel', class: 'slotter', type: 'button', href: path }
138
- }
139
-
147
+ args[:buttons] =
148
+ %{
149
+ #{submit_button text: 'Rename and Update', disable_with: 'Renaming',
150
+ class: 'renamer-updater'}
151
+ #{button_tag 'Rename',
152
+ data: { disable_with: 'Renaming' },
153
+ class: 'renamer'}
154
+ #{cancel_button href: path}
155
+ }
140
156
  end
141
157
 
142
-
143
158
  view :edit_type, perms: :update do |args|
144
159
  frame_and_form :update, args do
145
- #'main-success'=>'REDIRECT: _self', # adding this back in would make main cards redirect on cardtype changes
160
+ # 'main-success'=>'REDIRECT: _self', # adding this back in would make
161
+ # main cards redirect on cardtype changes
146
162
  [
147
- _render_type_formgroup( args ),
148
- optional_render( :button_formgroup, args )
163
+ _render_type_formgroup(args),
164
+ optional_render(:button_formgroup, args)
149
165
  ]
150
166
  end
151
167
  end
152
168
 
153
169
  def default_edit_type_args args
154
- args[:variety] = :edit #YUCK!
170
+ args[:variety] = :edit # YUCK!
155
171
  args[:optional_toolbar] ||= :show
156
- args[:hidden] ||= { success: {view: :edit} }
172
+ args[:hidden] ||= { success: { view: :edit } }
157
173
  args[:buttons] = %{
158
- #{ button_tag 'Submit', disable_with: 'Submitting', situation: 'primary' }
159
- #{ button_tag 'Cancel', href: path(view: :edit), type: 'button', class: 'slotter' }
174
+ #{submit_button}
175
+ #{cancel_button href: path(view: :edit)}
160
176
  }
161
177
  end
162
178
 
163
179
  view :edit_rules, tags: :unknown_ok do |args|
164
180
  view = args[:rule_view] || :common_rules
165
- slot_args = {
166
- rule_view: view, optional_set_navbar: :show, optional_set_label: :hide, optional_rule_navbar: :hide
181
+ slot_args =
182
+ {
183
+ rule_view: view,
184
+ optional_set_navbar: :show,
185
+ optional_set_label: :hide,
186
+ optional_rule_navbar: :hide
167
187
  }
168
- _render_related args.merge(related: {card: current_set_card, view: :open, slot: slot_args})
188
+ _render_related args.merge(
189
+ related: { card: current_set_card, view: :open, slot: slot_args }
190
+ )
169
191
  end
170
192
 
171
193
  def default_edit_rules_args args
172
194
  args[:optional_toolbar] ||= :show
173
195
  end
174
196
 
175
- view :options, {view: :edit_rules, mod: All::RichHtml::Editing::HtmlFormat} # for backwards compatibility
197
+ # for backwards compatibility
198
+ view :options, view: :edit_rules, mod: All::RichHtml::Editing::HtmlFormat
176
199
 
177
200
  view :edit_structure do |args|
178
- slot_args = {
201
+ slot_args =
202
+ {
179
203
  cancel_slot_selector: '.card-slot.related-view',
180
204
  cancel_path: card.format.path(view: :edit),
181
205
  optional_edit_toolbar: :hide,
182
- hidden: {success: {view: :open, 'slot[subframe]'=>true}}
206
+ hidden: { success: { view: :open, 'slot[subframe]' => true } }
183
207
  }
184
- render_related args.merge(related: {card: card.structure, view: :edit, slot: slot_args})
208
+ render_related args.merge(
209
+ related: { card: card.structure, view: :edit, slot: slot_args }
210
+ )
185
211
  end
186
212
 
187
213
  def default_edit_structure_args args
@@ -202,10 +228,13 @@ format :html do
202
228
  view :edit_nest_rules do |args|
203
229
  view = args[:rule_view] || :field_related_rules
204
230
  frame args do
205
- # with_inclusion_mode :edit do
206
- nested_fields(args).map do |chunk|
207
- nest Card.fetch("#{chunk.referee_name}+*self"), view: :titled, rule_view: view, optional_set_label: :hide, optional_rule_navbar: :show
208
- end
231
+ # with_inclusion_mode :edit do
232
+ nested_fields(args).map do |chunk|
233
+ nest Card.fetch("#{chunk.referee_name}+*self"),
234
+ view: :titled, rule_view: view,
235
+ optional_set_label: :hide,
236
+ optional_rule_navbar: :show
237
+ end
209
238
  end
210
239
  end
211
240
 
@@ -213,6 +242,3 @@ format :html do
213
242
  args[:optional_toolbar] ||= :show
214
243
  end
215
244
  end
216
-
217
-
218
-