<%= form_for @timeline, html: { class: 'autosave-form' }, remote: true do |f| %>

<% if @timeline.universe %> <%= link_to @timeline.universe do %> <%= Universe.icon %> <% end %> <% end %> <% if user_signed_in? && current_user == @timeline.user %> <%= link_to edit_timeline_path(@timeline) do %> edit <% end %> <% end %> <%= @timeline.name %>
<%= @timeline.subtitle %>

<%= simple_format @timeline.description %>
<% if @timeline.notes.present? || (@timeline.private_notes.present? && user_signed_in? && current_user == @timeline.user) %> <% end %>
<% end %>
<% @timeline.timeline_events.includes(:timeline_event_entities).each do |event| %>
<%= form_for event, html: { class: 'autosave-form' }, remote: true do |f| %> <%= f.hidden_field :timeline_id %>
<% if event.time_label.present? %>
Time label
<%= simple_format event.time_label %> <% end %>
<%= image_tag 'graphics/timeline-line.webp' %>
<%= simple_format(event.title.presence || 'Untitled event') %> <% if event.description.present? %>
Description
<%= simple_format(event.description) %> <% end %>
<% if event.notes.present? %>
Notes
<%= simple_format(event.notes) %> <% end %>
<% event_entities = event.timeline_event_entities.order('entity_type').preload(:entity).group_by(&:entity_type) %> <% unless event_entities == {} %>
In this event
    <% event_entities.each do |entity_type, entity_list| %> <% entity_list.reject! { |te_entity| te_entity.entity.nil? } %>
  • <% klass = content_class_from_name(entity_type) %>
    <%= klass.icon %> <%= entity_type.pluralize %> <%= entity_list.count %>
    <% entity_list.each do |te_entity| %>
    <%= link_to(te_entity.entity.name.presence || "Untitled #{te_entity.entity_type}", te_entity.entity) %>
    <% end %>
  • <% end %>
<% end %>
<% end %>
<% end %>