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

Extended by:
Card::Set::AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb

Instance Method Summary collapse

Instance Method Details

#action_arrow_dir(view_type) ⇒ Object



84
85
86
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 84

def action_arrow_dir view_type
  view_type == :expanded ? :collapse : :expand
end

#action_content(action, view_type) ⇒ Object



49
50
51
52
53
54
55
56
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 49

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



65
66
67
68
69
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 65

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



41
42
43
44
45
46
47
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 41

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



98
99
100
101
102
103
104
105
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 98

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



113
114
115
116
117
118
119
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 113

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



58
59
60
61
62
63
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 58

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



107
108
109
110
111
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 107

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


88
89
90
91
92
93
94
95
96
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 88

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)


71
72
73
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 71

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


75
76
77
78
79
80
81
82
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 75

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