diff options
Diffstat (limited to 'app/helpers')
| -rw-r--r-- | app/helpers/node_actions_helper.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/helpers/node_actions_helper.rb b/app/helpers/node_actions_helper.rb index c829dff7..eb761e3b 100644 --- a/app/helpers/node_actions_helper.rb +++ b/app/helpers/node_actions_helper.rb | |||
| @@ -59,6 +59,32 @@ module NodeActionsHelper | |||
| 59 | end | 59 | end |
| 60 | end | 60 | end |
| 61 | 61 | ||
| 62 | def revision_lifecycle_badges actions | ||
| 63 | return "" if actions.blank? | ||
| 64 | |||
| 65 | badges = actions.map do |action| | ||
| 66 | key = case action.action | ||
| 67 | when "create" then "node_actions.revision_created" | ||
| 68 | when "publish" then action.metadata["via"] == "revision" ? | ||
| 69 | "node_actions.revision_restored" : | ||
| 70 | "node_actions.revision_published" | ||
| 71 | end | ||
| 72 | next unless key | ||
| 73 | |||
| 74 | badge = h(t(key, :date => action.occurred_at.strftime("%Y-%m-%d"), | ||
| 75 | :actor => action.actor_name)) | ||
| 76 | if action.inferred_from | ||
| 77 | badge = safe_join([badge, content_tag(:span, t("node_actions.backfilled"), | ||
| 78 | :class => "node_action_inferred", | ||
| 79 | :title => action.inferred_from)], " ") | ||
| 80 | end | ||
| 81 | badge | ||
| 82 | end.compact | ||
| 83 | |||
| 84 | return "" if badges.empty? | ||
| 85 | safe_join(["— ", safe_join(badges, " · ")]) | ||
| 86 | end | ||
| 87 | |||
| 62 | private | 88 | private |
| 63 | 89 | ||
| 64 | def revision_ref action, key | 90 | def revision_ref action, key |
