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
-
#action_arrow_dir(view_type) ⇒ Object
-
#action_content(action, view_type) ⇒ Object
-
#action_content_toggle(action, view_type) ⇒ Object
-
#action_from_context ⇒ Object
-
#action_legend ⇒ Object
-
#content_changes(action, diff_type, hide_diff = false) ⇒ Object
-
#content_diff(action, view_type) ⇒ Object
-
#content_legend ⇒ Object
-
#revert_actions_link(link_text, path_args, html_args = {}) ⇒ Object
-
#show_action_content_toggle?(action, view_type) ⇒ Boolean
-
#toggle_action_content_link(action, view_type) ⇒ Object
Instance Method Details
#action_arrow_dir(view_type) ⇒ Object
74 75 76 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 74 def action_arrow_dir view_type view_type == :expanded ? :triangle_left : :triangle_right end |
#action_content(action, view_type) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 39 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
55 56 57 58 59 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 55 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_context ⇒ Object
31 32 33 34 35 36 37 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 31 def action_from_context if (action_id = voo.action_id || params[:action_id]) Action.fetch action_id else card.last_action end end |
#action_legend ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 88 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
103 104 105 106 107 108 109 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 103 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
48 49 50 51 52 53 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 48 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_legend ⇒ Object
97 98 99 100 101 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 97 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 |
#revert_actions_link(link_text, path_args, html_args = {}) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 78 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
61 62 63 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 61 def show_action_content_toggle? action, view_type view_type == :expanded || action.summary_diff_omits_content? end |
#toggle_action_content_link(action, view_type) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/actions.rb', line 65 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: "md-24"), class: css_class, path: { action_id: action.id, look_in_trash: true } end |