Module: Card::Set::All::History::Actions::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
card/tmpsets/set/mod013-card-mod-history/all/history/actions.rb,
card/tmpsets/set/mod012-card-mod-history/all/history/actions.rb

Instance Method Summary collapse

Instance Method Details

#action_arrow_dir(view_type) ⇒ Object



95
96
97
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/actions.rb', line 95

def action_arrow_dir view_type
  view_type == :expanded ? :triangle_left : :triangle_right
end

#action_content(action, view_type) ⇒ Object



60
61
62
63
64
65
66
67
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/actions.rb', line 60

def action_content action, view_type
  return "" unless action.present?

  wrap do
    [action_content_toggle(action, view_type),
     content_diff(action, view_type)]
  end
end

#action_content_toggle(action, view_type) ⇒ Object



76
77
78
79
80
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/actions.rb', line 76

def action_content_toggle action, view_type
  return unless show_action_content_toggle?(action, view_type)

  toggle_action_content_link action, view_type
end

#action_from_contextObject



52
53
54
55
56
57
58
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/actions.rb', line 52

def action_from_context
  if (action_id = voo.action_id || params[:action_id])
    Action.fetch action_id
  else
    card.last_action
  end
end

#action_legendObject



109
110
111
112
113
114
115
116
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/actions.rb', line 109

def action_legend
  types = %i[create update delete]
  legend = types.map do |action_type|
    "#{action_icon(action_type)} #{action_type}d"
  end
  legend << _render_draft_legend if voo.show?(:draft_legend)
  "<small>Actions: #{legend.join ' | '}</small>"
end

#content_changes(action, diff_type, hide_diff = false) ⇒ Object



124
125
126
127
128
129
130
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/actions.rb', line 124

def content_changes action, diff_type, hide_diff=false
  if hide_diff
    action.raw_view
  else
    action.content_diff diff_type
  end
end

#content_diff(action, view_type) ⇒ Object



69
70
71
72
73
74
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/actions.rb', line 69

def content_diff action, view_type
  diff = action.new_content? && content_changes(action, view_type)
  return "<i>empty</i>" unless diff.present?

  diff
end

#content_legendObject



118
119
120
121
122
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/actions.rb', line 118

def content_legend
  legend = [Card::Content::Diff.render_added_chunk("Additions"),
            Card::Content::Diff.render_deleted_chunk("Subtractions")]
  "<small>Content changes: #{legend.join ' | '}</small>"
end


99
100
101
102
103
104
105
106
107
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/actions.rb', line 99

def revert_actions_link link_text, path_args, html_args={}
  return unless card.ok? :update

  path_args.reverse_merge! action: :update, look_in_trash: true, assign: true,
                           card: { skip: :validate_renaming }
  html_args.reverse_merge! remote: true, method: :post, rel: "nofollow", path: path_args
  add_class html_args, "slotter"
  link_to link_text, html_args
end

#show_action_content_toggle?(action, view_type) ⇒ Boolean

Returns:

  • (Boolean)


82
83
84
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/actions.rb', line 82

def show_action_content_toggle? action, view_type
  view_type == :expanded || action.summary_diff_omits_content?
end


86
87
88
89
90
91
92
93
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/actions.rb', line 86

def toggle_action_content_link action, view_type
  other_view_type = view_type == :expanded ? :summary : :expanded
  css_class = "revision-#{action.card_act_id} float-right"
  link_to_view "action_#{other_view_type}",
               icon_tag(action_arrow_dir(view_type), class: "md-24"),
               class: css_class,
               path: { action_id: action.id, look_in_trash: true }
end