summaryrefslogtreecommitdiff
path: root/app/views/runs/show.html.erb
blob: cca502999e2ed4aeae6caf75a99e614f99862c9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<div class="space-y-4">
  <div class="space-y-2">
    <h1 class="text-2xl"><%= @run.title %></h1>
    <p class="subtitle"><%= @run.game.title %></p>
    <p>Started by <%= link_to @run.user.name || "???", user_path(@run.user) %>
      <%= time_ago_in_words(@run.created_at) %> ago.</p>
  </div>

  <div class="font-bold">
    This run is currently
    <% if @run.checked_in? %>
      checked in! You can <%= link_to "checkout this run", new_run_checkpoint_path(@run) %>
      to play it yourself, then check it back in when you're done to save your progress.
    <% else %>
      checked out by <%= link_to @run.checked_out_user.name || "???", user_path(@run.checked_out_user) %>.
      <% if @run.last_save_file.attached? %>
        You can
        <%= link_to "download the last save file", rails_blob_path(@run.last_save_file, disposition: "attachment") %>
        to check it out, but you won't be able to check in any progress.
      <% end %>
    <% end %>
  </div>

  <div class="grid grid-cols-1 md:grid-cols-2">
    <div>
      <h2 class="text-xl">Checkpoints</h2>
      <div><%= link_to "New checkpoint", new_run_checkpoint_path(@run) %></div>

      <% @run.checkpoints.order(:created_at).reverse.each do |checkpoint| %>
        <div class="border-l border-orange-900 p-2">
          <div class="flex flex-col">
            <div class="flex space-x-2 text-sm">
              <div>
                <% case checkpoint.kind.to_sym %>
                <% when :comment %>
                  💬
                <% when :checkin %>
                  📬
                <% when :checkout %>
                  📭
                <% else %>
                  <%# Should never happen. %>
                <% end %>
              </div>
              <div class="flex space-x-2">
                <span class="uppercase"><%= checkpoint.kind %></span>
                <% if checkpoint.save_file.attached? %>
                  <%= link_to "Download save file", rails_blob_path(checkpoint.save_file, disposition: "attachment") %>
                <% end %>
              </div>

            </div>
            <div>
            </div>
            <div class="text-sm">
              <%= time_ago_in_words(checkpoint.created_at) %> ago by
              <%= link_to checkpoint.user.name || "???", user_path(checkpoint.user) %>
              <span>@ <%= checkpoint.created_at %></span>
            </div>
            <% if checkpoint.comment %>
              <div class="text-lg"><%= checkpoint.comment %></div>
            <% end %>
          </div>
        </div>
      <% end %>
    </div>
    <div>
      <% if @run.checked_out_user == current_user %>
        <h2 class="text-xl">Pokédex Entries</h2>
        <%= turbo_frame_tag "pokedex_entries", src: run_pokedex_entries_url(@run) %>
      <% end %>
    </div>
  </div>
</div>