card 1.20.0 → 1.20.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/card.gemspec +1 -1
  4. data/lib/card.rb +7 -3
  5. data/lib/card/act_manager/stage_director.rb +22 -10
  6. data/lib/card/cache/persistent.rb +15 -9
  7. data/lib/card/format/nest.rb +12 -5
  8. data/lib/card/format/nest/fetch.rb +2 -1
  9. data/lib/card/format/render.rb +5 -2
  10. data/lib/card/set/event.rb +7 -1
  11. data/lib/card/subcards.rb +3 -3
  12. data/lib/card/view/cache.rb +1 -1
  13. data/lib/card/view/fetch.rb +17 -5
  14. data/lib/card/view/options.rb +52 -26
  15. data/lib/cardio.rb +2 -1
  16. data/mod/account/spec/set/right/account_spec.rb +17 -3
  17. data/mod/admin/set/self/admin.rb +0 -2
  18. data/mod/admin/spec/set/self/admin_spec.rb +14 -11
  19. data/mod/bootstrap/set/all/bootstrap/helper.rb +27 -29
  20. data/mod/carrierwave/set/type/file.rb +1 -1
  21. data/mod/carrierwave/set/type/image.rb +18 -6
  22. data/mod/core/set/all/collection.rb +33 -7
  23. data/mod/core/set/all/fetch.rb +16 -3
  24. data/mod/core/set/all/permissions.rb +6 -12
  25. data/mod/core/set/all/trash.rb +3 -1
  26. data/mod/core/spec/set/all/collection_spec.rb +9 -8
  27. data/mod/email/set/all/notify.rb +27 -17
  28. data/mod/email/set/right/follow.rb +49 -36
  29. data/mod/email/set/type/email_template.rb +25 -69
  30. data/mod/email/set/type/email_template/email_config.rb +63 -0
  31. data/mod/email/set/type_plus_right/user/follow.rb +3 -3
  32. data/mod/machines/lib/stylesheets/style_cards.scss +292 -0
  33. data/mod/pointer/set/abstract/01_pointer.rb +8 -8
  34. data/mod/pointer/set/abstract/01_pointer/edit.rb +6 -2
  35. data/mod/prosemirror_editor/lib/javascript/script_prosemirror.js +12283 -11605
  36. data/mod/prosemirror_editor/lib/javascript/script_prosemirror_config.js.coffee +1 -1
  37. data/mod/standard/set/abstract/01_search_params.rb +1 -1
  38. data/mod/standard/set/abstract/search/paging.rb +4 -4
  39. data/mod/standard/set/all/comment.rb +67 -47
  40. data/mod/standard/set/all/links.rb +2 -2
  41. data/mod/standard/set/all/rich_html/content.rb +1 -1
  42. data/mod/standard/set/all/rich_html/editing.rb +3 -2
  43. data/mod/standard/set/all/rich_html/form.rb +21 -12
  44. data/mod/standard/set/all/rich_html/header.rb +9 -0
  45. data/mod/standard/set/all/rich_html/menu.rb +16 -12
  46. data/mod/standard/set/all/rich_html/toolbar.rb +140 -130
  47. data/mod/standard/set/all/rich_html/wrapper.rb +11 -1
  48. data/mod/standard/set/rstar/rules_editor.rb +2 -34
  49. data/mod/standard/set/self/search.rb +1 -1
  50. data/mod/standard/set/type/set.rb +4 -4
  51. data/mod/standard/spec/set/type/email_template/email_config_spec.rb +218 -0
  52. data/mod/standard/spec/set/type/email_template_spec.rb +3 -185
  53. data/spec/lib/card/cache_spec.rb +0 -1
  54. data/spec/lib/card/format/render_spec.rb +19 -0
  55. data/spec/lib/card/stage_director_spec.rb +1 -1
  56. data/tmpsets/set/mod001-core/all/actify.rb +5 -6
  57. data/tmpsets/set/mod001-core/all/fetch.rb +14 -12
  58. data/tmpsets/set/mod001-core/all/name.rb +1 -1
  59. data/tmpsets/set/mod001-core/all/permissions.rb +12 -22
  60. data/tmpsets/set/mod001-core/all/tracked_attributes.rb +76 -0
  61. data/tmpsets/set/mod001-core/all/utils.rb +40 -3
  62. data/tmpsets/set/mod002-history/all/history.rb +1 -2
  63. data/tmpsets/set/mod008-solid_cache/abstract/solid_cache.rb +1 -1
  64. data/tmpsets/set/mod013-carrierwave/abstract/attachment.rb +282 -0
  65. data/tmpsets/set/mod013-carrierwave/type/file.rb +155 -0
  66. data/tmpsets/set/mod013-carrierwave/type/image.rb +96 -0
  67. data/tmpsets/set/mod014-admin/self/admin.rb +113 -0
  68. data/tmpsets/set/mod014-admin/self/admin_info.rb +110 -0
  69. data/tmpsets/set/mod014-admin/self/version.rb +15 -0
  70. data/tmpsets/set/mod015-developer/all/event_viz.rb +59 -0
  71. data/tmpsets/set/mod015-developer/all/view_viz.rb +30 -0
  72. data/tmpsets/set/mod015-developer/right/debug.rb +96 -0
  73. metadata +15 -2
@@ -26,6 +26,6 @@ $.extend wagn,
26
26
  createProseMirror(el_id, conf)
27
27
 
28
28
  prosemirrorContent = (id) ->
29
- content = getProseMirror(id).getContent("html")
29
+ content = getProseMirrorContent(id)
30
30
  return '' if content == '<p></p>'
31
31
  content
@@ -24,7 +24,7 @@ end
24
24
 
25
25
  format :html do
26
26
  def default_limit
27
- 20
27
+ Cardio.config.paging_limit || 20
28
28
  end
29
29
  end
30
30
 
@@ -43,19 +43,19 @@ format :html do
43
43
 
44
44
  def page_link text, page, options
45
45
  return text unless page
46
- paging_path_args[:offset] = page * limit
47
46
  options.merge! class: "card-paging-link slotter",
48
47
  remote: true,
49
- path: paging_path_args
48
+ path: paging_path_args(offset: page * limit)
50
49
  link_to raw(text), options
51
50
  end
52
51
 
53
52
  def paging_path_args local_args={}
54
53
  @paging_path_args ||= {
55
54
  limit: limit,
56
- view: voo.home_view,
55
+ view: paging_view,
57
56
  slot: voo.slot_options
58
- }.merge(extra_paging_path_args).merge local_args
57
+ }.merge(extra_paging_path_args)
58
+ @paging_path_args.merge local_args
59
59
  end
60
60
 
61
61
  def paging_view
@@ -1,60 +1,80 @@
1
- event :add_comment, :prepare_to_store,
2
- on: :save, when: proc { |c| c.comment } do
3
- cleaned_comment =
4
- comment.split(/\n/).map do |line|
5
- "<p>#{line.strip.empty? ? '&nbsp;' : line}</p>"
6
- end * "\n"
7
-
8
- signature =
1
+ def commenting?
2
+ comment && @action != :delete
3
+ end
4
+
5
+ event :add_comment, :prepare_to_store, on: :save, when: :comment do
6
+ Env.session[:comment_author] = comment_author if Env.session
7
+ self.content =
8
+ [content, format.comment_with_signature].compact.join "\n<hr\>\n"
9
+ end
10
+
11
+ attr_writer :comment_author
12
+
13
+ def comment_author
14
+ @comment_author ||=
15
+ Env.session[:comment_author] || Env.params[:comment_author] || "Anonymous"
16
+ end
17
+
18
+ def clean_comment
19
+ comment.split(/\n/).map do |line|
20
+ "<p>#{line.strip.empty? ? '&nbsp;' : line}</p>"
21
+ end * "\n"
22
+ end
23
+
24
+ format do
25
+ def comment_with_signature
26
+ card.clean_comment + "\n" + comment_signature
27
+ end
28
+
29
+ def comment_signature
30
+ wrap_with :div, class: "w-comment-author" do
31
+ "#{comment_author}.....#{Time.zone.now}"
32
+ end
33
+ end
34
+
35
+ def comment_author
9
36
  if Auth.signed_in?
10
37
  "[[#{Auth.current.name}]]"
11
38
  else
12
- Env.session[:comment_author] = comment_author if Env.session
13
- "#{comment_author} (Not signed in)"
39
+ "#{card.comment_author} (Not signed in)"
14
40
  end
41
+ end
15
42
 
16
- self.content = %(
17
- #{content}
18
- #{'<hr>' unless content.blank?}
19
- #{cleaned_comment}
20
- <div class="w-comment-author">--#{signature}.....#{Time.zone.now}</div>
21
- )
22
- end
23
-
24
- format do
25
43
  view :comment_box,
26
44
  denial: :blank, tags: :unknown_ok,
27
- perms: ->(r) { r.card.ok? :comment } do |_args|
28
- <<-HTML
29
- <div class="comment-box nodblclick">#{comment_form}</div>
30
- HTML
31
- end
32
-
33
- def comment_form
34
- card_form :update do
35
- %(
36
- #{hidden_field_tag('card[name]', card.name) if card.new_card?
37
- # FIXME: wish we had more generalized solution for names.
38
- # without this, nonexistent cards will often take left's linkname.
39
- # (needs test)
40
- }
41
- #{text_area :comment, rows: 3}
42
- #{comment_buttons}
43
- )
45
+ perms: ->(r) { r.card.ok? :comment } do
46
+ wrap_with :div, class: "comment-box nodblclick" do
47
+ action = card.new_card? ? :create : :update
48
+ card_form action do
49
+ [hidden_comment_fields, comment_box, comment_buttons]
50
+ end
44
51
  end
45
52
  end
46
53
 
54
+ def hidden_comment_fields
55
+ return unless card.new_card?
56
+ hidden_field_tag "card[name]", card.name
57
+ # FIXME: wish we had more generalized solution for names.
58
+ # without this, nonexistent cards will often take left's linkname.
59
+ # (needs test)
60
+ end
61
+
62
+ def comment_box
63
+ text_area :comment, rows: 3
64
+ end
65
+
47
66
  def comment_buttons
48
- <<-HTML
49
- <div class="comment-buttons">
50
- #{unless Auth.signed_in?
51
- card.comment_author = session[:comment_author] ||
52
- params[:comment_author] || 'Anonymous' # ENGLISH
53
- %(<label>My Name is:</label> #{text_field :comment_author})
54
- end}
55
- #{submit_button text: 'Comment', type: :submit,
56
- disable_with: 'Commenting'}
57
- </div>
58
- HTML
67
+ wrap_with :div, class: "comment-buttons" do
68
+ [comment_author_label, comment_submit_button]
69
+ end
70
+ end
71
+
72
+ def comment_author_label
73
+ return if Auth.signed_in?
74
+ %(<label>My Name is:</label> #{text_field :comment_author})
75
+ end
76
+
77
+ def comment_submit_button
78
+ submit_button text: "Comment", type: :submit, disable_with: "Commenting"
59
79
  end
60
80
  end
@@ -2,7 +2,7 @@ RESOURCE_TYPE_REGEXP = /^([a-zA-Z][\-+\.a-zA-Z\d]*):/
2
2
 
3
3
  format :html do
4
4
  def link_to text=nil, opts={}
5
- opts[:href] = path opts.delete(:path)
5
+ opts[:href] ||= path opts.delete(:path)
6
6
  text = raw(text || opts[:href])
7
7
  interpret_data_opts_to_link_to opts
8
8
  wrap_with :a, text, opts
@@ -113,7 +113,7 @@ format do
113
113
  return unless opts[:action] == :new
114
114
  opts.delete :action
115
115
  return unless opts[:mark]
116
- "new/#{path_mark opts}"
116
+ "new/#{path_mark opts}#{path_query opts}"
117
117
  end
118
118
 
119
119
  def standard_path opts
@@ -150,7 +150,7 @@ format :html do
150
150
  # subformat(rcard)._render_title(args)
151
151
  # end
152
152
 
153
- view :related do |args|
153
+ view :related, cache: :never do |args|
154
154
  related_card, options = related_card_and_options args
155
155
  return unless related_card
156
156
  voo.show :toolbar, :menu, :help
@@ -130,8 +130,7 @@ format :html do
130
130
  _render_related args.merge(
131
131
  related: {
132
132
  card: current_set_card,
133
- view: :open,
134
- slot: { rule_view: (args[:rule_view] || :common_rules) }
133
+ view: :open
135
134
  }
136
135
  )
137
136
  end
@@ -163,6 +162,8 @@ format :html do
163
162
  end
164
163
 
165
164
  view :edit_nest_rules, cache: :never do |args|
165
+ return ""
166
+ # FIXME - view can recurse. temporarily turned off
166
167
  voo.show :toolbar
167
168
  view = args[:rule_view] || :field_related_rules
168
169
  frame do
@@ -63,7 +63,7 @@ format :html do
63
63
 
64
64
  def card_form action, opts={}
65
65
  @form_root = true
66
- url, action = card_form_url action
66
+ url, action = card_form_url_and_action action
67
67
  html_opts = card_form_html_opts action, opts
68
68
  form_for card, url: url, html: html_opts, remote: true do |form|
69
69
  @form = form
@@ -88,7 +88,7 @@ format :html do
88
88
  opts
89
89
  end
90
90
 
91
- def card_form_url action
91
+ def card_form_url_and_action action
92
92
  case action
93
93
  when Symbol then [path(action: action), action]
94
94
  when Hash then [path(action), action[:action]]
@@ -195,22 +195,31 @@ format :html do
195
195
 
196
196
  def type_field_current_value args, typelist
197
197
  return if args.delete :no_current_type
198
- if !card.new_card? && !typelist.include?(card.type_name)
199
- # current type should be an option on existing cards,
200
- # regardless of create perms
201
- typelist.push(card.type_name).sort!
202
- end
203
- card.type_name_or_default
204
- end
198
+ if !card.new_card? && !typelist.include?(card.type_name)
199
+ # current type should be an option on existing cards,
200
+ # regardless of create perms
201
+ typelist.push(card.type_name).sort!
202
+ end
203
+ card.type_name_or_default
204
+ end
205
205
 
206
206
  def content_field skip_rev_id=false
207
- [content_field_revision_tracking(skip_rev_id), _render_editor].compact.join
207
+ with_nest_mode :normal do
208
+ # by changing nest mode to normal, we ensure that editors (eg image
209
+ # previews) can render core views.
210
+ output [content_field_revision_tracking(skip_rev_id), _render_editor]
211
+ end
208
212
  end
209
213
 
214
+ # SAMPLE editor view for override
215
+ # view :editor do
216
+ # text_area :content, rows: 5, class: "card-content"
217
+ # end
218
+
210
219
  def content_field_revision_tracking skip_rev_id
211
220
  card.last_action_id_before_edit = card.last_action_id
212
221
  return if !card || card.new_card? || skip_rev_id
213
- hidden_field :last_action_id_before_edit, class: "current_revision_id"
222
+ hidden_field :last_action_id_before_edit, class: "current_revision_id"
214
223
  end
215
224
 
216
225
  # FIELD VIEWS
@@ -222,7 +231,7 @@ format :html do
222
231
  editor: "content", help: true, class: classy("card-editor") do
223
232
  [content_field, (form.hidden_field(:type_id) if card.new_card?)]
224
233
  end
225
- end
234
+ end
226
235
 
227
236
  def add_junction_class
228
237
  return unless card.cardname.junction?
@@ -6,6 +6,15 @@ format :html do
6
6
  class_list[key] = classier.to_s
7
7
  end
8
8
 
9
+ # don't use in the given block the additional class that
10
+ # was added to `klass`
11
+ def without_upped_class klass
12
+ tmp_class = class_list.delete klass
13
+ result = yield tmp_class
14
+ class_list[klass] = tmp_class
15
+ result
16
+ end
17
+
9
18
  def class_list
10
19
  @class_list ||= {}
11
20
  end
@@ -16,7 +16,7 @@ format :html do
16
16
 
17
17
  wrap_with :div, class: "vertical-card-menu card-menu #{css_class}" do
18
18
  wrap_with :div, class: "btn-group slotter card-slot pull-right" do
19
- link_to_view(:vertical_menu, menu_icon, path: menu_path_opts).html_safe
19
+ link_to_view :vertical_menu, menu_icon, path: menu_path_opts
20
20
  end
21
21
  end
22
22
  end
@@ -32,17 +32,17 @@ format :html do
32
32
  glyphicon "cog"
33
33
  end
34
34
 
35
- view :vertical_menu, tags: :unknown_ok do
35
+ view :vertical_menu, cache: :never, tags: :unknown_ok do
36
36
  wrap_with :ul, class: "btn-group pull-right slotter" do
37
37
  [vertical_menu_toggle, vertical_menu_item_list]
38
38
  end
39
39
  end
40
40
 
41
41
  def vertical_menu_toggle
42
- wrap_with :span, "<a href='#'>#{menu_icon}</a>".html_safe,
43
- class: "open-menu dropdown-toggle",
44
- "data-toggle" => "dropdown",
45
- "aria-expanded" => "false"
42
+ wrap_with :span, "<a href='#'>#{menu_icon}</a>",
43
+ class: "open-menu dropdown-toggle",
44
+ "data-toggle" => "dropdown",
45
+ "aria-expanded" => "false"
46
46
  end
47
47
 
48
48
  def vertical_menu_item_list
@@ -53,7 +53,7 @@ format :html do
53
53
  end
54
54
  end
55
55
 
56
- view :horizontal_menu do
56
+ view :horizontal_menu, cache: :never do
57
57
  wrap_with :div, class: "btn-group slotter pull-right card-menu "\
58
58
  "horizontal-card-menu hidden-xs" do
59
59
  menu_item_list(class: "btn btn-default").join("\n").html_safe
@@ -72,7 +72,8 @@ format :html do
72
72
  end
73
73
 
74
74
  def menu_discuss_link opts
75
- menu_item "discuss", "comment", opts.merge(related: Card[:discussion].key)
75
+ menu_item "discuss", "comment",
76
+ opts.merge(related: :discussion.cardname.key)
76
77
  end
77
78
 
78
79
  def menu_follow_link opts
@@ -84,13 +85,13 @@ format :html do
84
85
  end
85
86
 
86
87
  def menu_rules_link opts
87
- menu_item "rules", "wrench", opts.merge(view: :options)
88
+ menu_item "rules", "wrench", opts.merge(view: :edit_rules)
88
89
  end
89
90
 
90
91
  def menu_account_link opts
91
92
  menu_item "account", "user", opts.merge(
92
93
  view: :related,
93
- path: { related: { name: "+*account", view: :edit } }
94
+ path: { related: { name: "+#{:account.cardname.key}", view: :edit } }
94
95
  )
95
96
  end
96
97
 
@@ -142,8 +143,11 @@ format :html do
142
143
 
143
144
  def menu_discussion_card
144
145
  return if card.new_card?
145
- disc_tagname = Card.quick_fetch(:discussion).cardname
146
- return if card.junction? && card.cardname.tag_name.key == disc_tagname.key
146
+ return if discussion_card?
147
147
  card.fetch trait: :discussion, skip_modules: true, new: {}
148
148
  end
149
+
150
+ def discussion_card?
151
+ card.junction? && card.cardname.tag_name.key == :discussion.cardname.key
152
+ end
149
153
  end
@@ -1,68 +1,106 @@
1
1
  format :html do
2
+
3
+ TOOLBAR_TITLE = {
4
+ edit: "content", edit_name: "name", edit_type: "type",
5
+ edit_structure: "structure", edit_nests: "nests", history: "history",
6
+ common_rules: "common", recent_rules: "recent", grouped_rules: "all",
7
+ edit_nest_rules: "nests"
8
+ }.freeze
9
+
2
10
  def toolbar_pinned?
3
11
  (tp = Card[:toolbar_pinned]) && tp.content == "true"
4
12
  end
5
13
 
6
- view :toolbar do |args|
7
- collapsed = close_link(args.merge(class: "pull-right visible-xs"))
14
+ view :toolbar, cache: :never do
15
+ tool_navbar do
16
+ [
17
+ expanded_close_link,
18
+ toolbar_split_buttons,
19
+ toolbar_simple_buttons
20
+ ]
21
+ end
22
+ end
23
+
24
+ def default_toolbar_args args
25
+ if params[:related]
26
+ @related_card, _opts = related_card_and_options args.clone
27
+ end
28
+ @rule_view = params[:rule_view]
29
+ end
30
+
31
+ # def default_toolbar_args args
32
+ # args[:nested_fields] = nested_fields
33
+ # args[:active_toolbar_button] ||= active_toolbar_button @slot_view, args
34
+ # end
35
+
36
+ def expanded_close_link
37
+ close_link "hidden-xs navbar-right"
38
+ end
39
+
40
+ def collapsed_close_link
41
+ close_link "pull-right visible-xs"
42
+ end
43
+
44
+ def tool_navbar
8
45
  navbar "toolbar-#{card.cardname.safe_key}-#{voo.home_view}",
9
46
  toggle_align: :left, class: "slotter toolbar",
10
47
  navbar_type: "inverse",
11
- collapsed_content: collapsed do
48
+ collapsed_content: collapsed_close_link do
49
+ yield
50
+ end
51
+ end
52
+
53
+ def toolbar_split_buttons
54
+ wrap_with :form, class: "navbar-form navbar-left" do
12
55
  [
13
- close_link(args.merge(class: "hidden-xs navbar-right")),
14
- (wrap_with(:form, class: "navbar-form navbar-left") do
15
- [
16
- (account_split_button(args) if card.accountable?),
17
- activity_split_button(args),
18
- rules_split_button(args),
19
- edit_split_button(args)
20
- ]
21
- end),
22
- (wrap_with(:form, class: "navbar-form navbar-right") do
23
- wrap_with :div, class: "form-group" do
24
- _optional_render(:toolbar_buttons, args, :show)
25
- end
26
- end)
56
+ (account_split_button if card.accountable?),
57
+ activity_split_button,
58
+ rules_split_button,
59
+ edit_split_button
27
60
  ]
28
61
  end
29
62
  end
30
63
 
31
- def default_toolbar_args args
32
- args[:nested_fields] = nested_fields
33
- args[:active_toolbar_button] ||= active_toolbar_button @slot_view, args
34
- end
35
-
36
- def active_toolbar_button active_view, args
37
- case active_view
38
- when :follow, :editors, :history
39
- "activity"
40
- when :edit_rules, :edit_nest_rules
41
- "rules"
42
- when :edit, :edit_name, :edit_type, :edit_structure, :edit_nests
43
- "edit"
44
- when :related
45
- if args[:related_card] && (tag = args[:related_card].tag)
46
- case tag.codename
47
- when "discussion", "editors"
48
- "engage"
49
- when "account", "roles", "edited", "created", "follow"
50
- "account"
51
- when "structure"
52
- "edit"
53
- else
54
- "rules"
55
- end
64
+ def toolbar_simple_buttons
65
+ wrap_with :form, class: "navbar-form navbar-right" do
66
+ wrap_with :div, class: "form-group" do
67
+ _optional_render :toolbar_buttons
56
68
  end
57
69
  end
58
70
  end
59
71
 
60
- TOOLBAR_TITLE = {
61
- edit: "content", edit_name: "name", edit_type: "type",
62
- edit_structure: "structure", edit_nests: "nests", history: "history",
63
- common_rules: "common", recent_rules: "recent", grouped_rules: "all",
64
- edit_nest_rules: "nests"
65
- }.freeze
72
+ # TODO: decentralize and let views choose which menu they are in.
73
+ # (Also, should only be represented once. Currently we must configure
74
+ # this relationship twice)
75
+ def active_toolbar_button
76
+ @active_toolbar_button ||=
77
+ case voo.root.ok_view
78
+ when :follow, :editors, :history then "activity"
79
+ when :edit_rules, :edit_nest_rules then "rules"
80
+ when :edit, :edit_name, :edit_type,
81
+ :edit_structure, :edit_nests then "edit"
82
+ when :related then active_related_toolbar_button
83
+ end
84
+ end
85
+
86
+ def active_related_toolbar_button
87
+ return unless (codename = related_codename @related_card)
88
+ case codename
89
+ when :discussion, :editors then "activity"
90
+ when :account, :roles, :edited, :created, :follow then "account"
91
+ when :structure then "edit"
92
+ else "rules"
93
+ end
94
+ end
95
+
96
+ def active_toolbar_item
97
+ @active_toolbar_item ||=
98
+ case
99
+ when @rule_view then @rule_view.to_sym
100
+ when voo.root.ok_view != :related then voo.root.ok_view
101
+ when @related_card then related_codename @related_card
102
+ end
103
+ end
66
104
 
67
105
  def toolbar_view_title view
68
106
  if view == :edit_rules
@@ -72,31 +110,30 @@ format :html do
72
110
  end
73
111
  end
74
112
 
75
- def activity_split_button args
76
- discuss = smart_link_to "discuss", related: Card[:discussion].key
77
- editors = smart_link_to "editors", related: Card[:editors].key
78
- toolbar_split_button "activity", { view: :history }, args do
113
+ def activity_split_button
114
+ toolbar_split_button "activity", view: :history do
79
115
  {
80
- history: (_render_history_link if card.history?),
81
- discuss: discuss,
82
- follow: _render_follow_link(args),
83
- editors: editors
116
+ history: (_render_history_link if card.history?),
117
+ discussion: link_to_related(:discussion, "discuss"),
118
+ follow: _render_follow_link,
119
+ editors: link_to_related(:editors, "editors")
84
120
  }
85
121
  end
86
122
  end
87
123
 
88
- def rules_split_button args
124
+ def rules_split_button
89
125
  button_hash = {
90
126
  common_rules: edit_rules_link("common", :common_rules),
91
127
  grouped_rules: edit_rules_link("by group", :grouped_rules),
92
128
  all_rules: edit_rules_link("by name", :all_rules)
93
129
  }
94
130
  recently_edited_rules_link button_hash
95
- nest_rules_link button_hash, args[:nested_fields]
96
- toolbar_split_button("rules", { view: :edit_rules }, args) { button_hash }
131
+ nest_rules_link button_hash
132
+ toolbar_split_button("rules", view: :edit_rules) { button_hash }
97
133
  end
98
134
 
99
- def nest_rules_link button_hash, nested_fields
135
+ def nest_rules_link button_hash
136
+ return # FIXME: remove when reinstating edit_nest_rules
100
137
  return unless nested_fields.present?
101
138
  button_hash[:separator] = separator
102
139
  button_hash[:edit_nest_rules] = edit_nest_rules_link "nests"
@@ -108,20 +145,20 @@ format :html do
108
145
  end
109
146
 
110
147
  def edit_nest_rules_link text
111
- smart_link_to text, view: :edit_nest_rules,
112
- path: { slot: { rule_view: :field_related_rules } }
148
+ link_to_view :edit_nest_rules, text,
149
+ path: { rule_view: :field_related_rules }
113
150
  end
114
151
 
115
152
  def edit_rules_link text, rule_view
116
- smart_link_to text, view: :edit_rules,
117
- path: { slot: { rule_view: rule_view } }
153
+ link_to_view :edit_rules, text,
154
+ path: { rule_view: rule_view }
118
155
  end
119
156
 
120
- def edit_split_button args
121
- toolbar_split_button "edit", { view: :edit }, args do
157
+ def edit_split_button
158
+ toolbar_split_button "edit", view: :edit do
122
159
  {
123
- edit: _render_edit_link(args),
124
- edit_nests: (_render_edit_nests_link if nests_editable?(args)),
160
+ edit: _render_edit_link,
161
+ edit_nests: (_render_edit_nests_link if nests_editable?),
125
162
  structure: (_render_edit_structure_link if structure_editable?),
126
163
  edit_name: _render_edit_name_link,
127
164
  edit_type: _render_edit_type_link
@@ -129,55 +166,42 @@ format :html do
129
166
  end
130
167
  end
131
168
 
132
- def nests_editable? args
133
- !card.structure && args[:nested_fields].present?
169
+ def nests_editable?
170
+ !card.structure && nested_fields.present?
134
171
  end
135
172
 
136
- def account_split_button args
137
- details = "#{card.name}+#{Card[:account].key}"
138
- toolbar_split_button "account", { related: Card[:account].key }, args do
173
+ def account_split_button
174
+ toolbar_split_button "account", related: :account do
139
175
  {
140
- account: smart_link_to(
141
- "details", view: :related,
142
- paths: { related: { name: details, view: :edit } }
143
- ),
144
- roles: smart_link_to("roles", related: Card[:roles].key),
145
- created: smart_link_to("created", related: Card[:created].key),
146
- edited: smart_link_to("edited", related: Card[:edited].key),
147
- follow: smart_link_to("follow", related: Card[:follow].key)
176
+ account: link_to_related(:account, "details", path: { view: :edit }),
177
+ roles: link_to_related(:roles, "roles"),
178
+ created: link_to_related(:created, "created"),
179
+ edited: link_to_related(:edited, "edited"),
180
+ follow: link_to_related(:follow, "follow")
148
181
  }
149
182
  end
150
183
  end
151
184
 
152
- def toolbar_split_button name, button_path_opts, args
153
- status = args[:active_toolbar_button] == name ? "active" : ""
154
- button = button_link name, path: button_path_opts, class: status
155
- active_item =
156
- if @slot_view == :related
157
- if args[:rule_view]
158
- args[:rule_view].to_sym
159
- elsif args[:related_card] && (r = args[:related_card].right) &&
160
- (cn = r.codename)
161
- cn.to_sym
162
- end
163
- else
164
- @slot_view
165
- end
166
- split_button button, args.merge(active_item: active_item) do
167
- yield
168
- end
185
+ def toolbar_split_button name, button_link_opts
186
+ status = active_toolbar_button == name ? "active" : ""
187
+ button_link = button_link name, button_link_opts.merge(class: status)
188
+ split_button(button_link, active_toolbar_item) { yield }
169
189
  end
170
190
 
171
- def close_link args
172
- path_opts = args[:subslot] ? { slot: { subframe: true } } : {}
173
-
174
- link = link_to_view :home, glyphicon("remove"),
175
- path: path_opts, title: "cancel",
176
- class: "btn-toolbar-control btn btn-primary"
177
- css_class = ["nav navbar-nav", args[:class]].compact.join "\n"
191
+ def related_codename related_card
192
+ return nil unless related_card
193
+ tag_card = Card.quick_fetch related_card.cardname.right
194
+ tag_card && tag_card.codename.to_sym
195
+ end
178
196
 
179
- wrap_with :div, class: css_class do
180
- [toolbar_pin_button, link]
197
+ def close_link extra_class
198
+ wrap_with :div, class: css_classes("nav navbar-nav", extra_class) do
199
+ [
200
+ toolbar_pin_button,
201
+ link_to_view(voo.home_view, glyphicon("remove"),
202
+ title: "cancel",
203
+ class: "btn-toolbar-control btn btn-primary")
204
+ ]
181
205
  end
182
206
  end
183
207
 
@@ -189,22 +213,23 @@ format :html do
189
213
  "#{'in' unless toolbar_pinned?}active"
190
214
  end
191
215
 
192
- view :toolbar_buttons do |args|
193
- show_or_hide_delete = card.ok?(:delete) ? :show : :hide
216
+ view :toolbar_buttons, cache: :never do
194
217
  wrap_with(:div, class: "btn-group") do
195
218
  [
196
- _optional_render(:delete_button, args, show_or_hide_delete),
197
- _optional_render(:refresh_button, args, :show),
198
- _optional_render(:related_button, args, :show)
219
+ _optional_render(:delete_button,
220
+ optional: (card.ok?(:delete) ? :show : :hide)),
221
+ _optional_render(:refresh_button),
222
+ _optional_render(:related_button)
199
223
  ]
200
224
  end
201
225
  end
202
226
 
203
- view :related_button do |_args|
227
+ view :related_button do
204
228
  dropdown_button "", icon: "education", class: "related" do
205
229
  [
206
230
  ["children", "baby-formula", "*children"],
207
- ["mates", "bed", "*mates"],
231
+ # ["mates", "bed", "*mates"],
232
+ # FIXME: optimize and restore
208
233
  ["references out", "log-out", "*refers_to"],
209
234
  ["references in", "log-in", "*referred_to_by"]
210
235
  ].map do |title, icon, tag|
@@ -233,17 +258,6 @@ format :html do
233
258
  opts[:class] = [opts[:class], "btn btn-primary"].compact * " "
234
259
  opts[:title] ||= text
235
260
  smart_link_to link_text, opts
236
-
237
- # if (cardname = opts.delete(:page))
238
- # link_to_card cardname, link_text, class: klass
239
- # elsif (viewname = tag_args.delete(:view))
240
- # _opts = opts[:path] || { slot: { show: :toolbar } }
241
- # link_to_view viewname, link_text, path: path_opts, format_opts
242
- # else
243
- # path_opts = opts.delete(:path) || {}
244
- # path_opts[:action] = opts.delete(:action) if opts[:action]
245
- # link_to path_opts, link_text, opts[:format]
246
- # end
247
261
  end
248
262
 
249
263
  def toolbar_button_text text, symbol, hide
@@ -272,14 +286,10 @@ format :html do
272
286
 
273
287
  view "#{viewname}_link" do
274
288
  voo.title ||= viewtitle
275
- toolbar_view_link viewname
289
+ link_to_view viewname, voo.title
276
290
  end
277
291
  end
278
292
 
279
- def toolbar_view_link view
280
- link_to_view view, voo.title
281
- end
282
-
283
293
  def recently_edited_settings?
284
294
  (rs = Card[:recent_settings]) && rs.item_names.present?
285
295
  end