Activities

LesliView::Items::Activities loads a resource's recent activities and renders them through the shared timeline. It eager-loads each actor, orders the collection newest first, and limits the initial query to 25 records.

<%= render LesliView::Items::Activities.new(
    @ticket,
    i18n_scope: "my_engine.items.activities",
    icons: {
        ticket_created: "add_circle",
        owner_changed: "manage_accounts"
    }
) %>

The resource must expose an Active Record activities association. Each activity must provide actor, activity_code, activity_type, created_at, description, and metadata.

The component converts every record to the timeline contract:

  • operation is the short event title.
  • description explains what changed.
  • actor identifies the user who performed the action.
  • date contains the localized event time.
  • icon contains the event code that icons: maps to a Material Symbol.

Use i18n_scope: to keep each engine's event messages independent, and optionally map event codes to Material Symbols with icons:. Relation events may define set, changed, and removed descriptions; the component selects the correct variant from the activity's from and to metadata. When omitted, the scope defaults to lesli.items.activities for shared messages.

en:
  my_engine:
    items:
      activities_events_owner_changed_operation: Owner changed
      activities_events_owner_changed_set: Assigned to %{to}.
      activities_events_owner_changed_changed: Changed from %{from} to %{to}.
      activities_events_owner_changed_removed: Removed %{from} as owner.

Override the initial query size with limit: when needed. It must be a positive integer:

<%= render LesliView::Items::Activities.new(
    @ticket,
    i18n_scope: "my_engine.items.activities",
    icons: { ticket_created: "add_circle" },
    limit: 50
) %>

This component is intended for Lesli records using the standard activity schema. For already prepared hashes, render Timeline directly.

Component files

lib/lesli_view/items/
    activities.rb
    activities/
        activities.html.erb
        activities.css

Ruby classes retain their public API. Each template and stylesheet lives in the adjacent component directory. The stylesheets use semantic classes and unprefixed @apply, and are imported by source/tailwind/view.css into the existing LesliView stylesheet. Global theme variables remain in LesliAssets.

 Edit this page

Last Update: 2026/11/18