From bb4eb1113b188ad7f1149df715ae2d9fd0411ca7 Mon Sep 17 00:00:00 2001 From: David Gay Date: Thu, 2 Nov 2023 19:05:13 -0400 Subject: Improve run and checkpoint views --- app/views/checkpoints/new.html.erb | 12 +++++++----- app/views/runs/show.html.erb | 39 +++++++++++++++++++++++++++----------- 2 files changed, 35 insertions(+), 16 deletions(-) (limited to 'app') diff --git a/app/views/checkpoints/new.html.erb b/app/views/checkpoints/new.html.erb index b11a9bc..dad7e82 100644 --- a/app/views/checkpoints/new.html.erb +++ b/app/views/checkpoints/new.html.erb @@ -9,10 +9,12 @@ <%= f.text_area :comment %> -
-
<%= f.label :save_file %>
- <%= f.file_field :save_file %> -
+ <% unless @run.checked_in? %> +
+
<%= f.label :save_file %>
+ <%= f.file_field :save_file %> +
+ <% end %>
@@ -24,7 +26,7 @@ <%= f.radio_button :kind, "checkout" %> <%= f.label :kind_checkout, "I'm checking out this save file, lock the run until I check it back in" %>
- <% else %> + <% elsif @run.checked_out_user == current_user %>
<%= f.radio_button :kind, "checkin" %> <%= f.label :kind_checkin, "I'm checking in this save file so another trainer can play it" %> diff --git a/app/views/runs/show.html.erb b/app/views/runs/show.html.erb index 55bef02..e080783 100644 --- a/app/views/runs/show.html.erb +++ b/app/views/runs/show.html.erb @@ -9,7 +9,8 @@
This run is currently <% if @run.checked_in? %> - checked in! You can progress this run <%= link_to "by creating a checkpoint", new_run_checkpoint_path(@run) %>. + 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? %> @@ -21,25 +22,41 @@

Checkpoints

- <%= link_to "New checkpoint", new_run_checkpoint_path(@run) %> +
<%= link_to "New checkpoint", new_run_checkpoint_path(@run) %>
<% @run.checkpoints.order(:created_at).reverse.each do |checkpoint| %>
+
+
+ <% case checkpoint.kind.to_sym %> + <% when :comment %> + 💬 + <% when :checkin %> + 📬 + <% when :checkout %> + 📭 + <% else %> + <%# Should never happen. %> + <% end %> +
+
+ <%= checkpoint.kind %> + <% if checkpoint.save_file.attached? %> + <%= link_to "Download save file", rails_blob_path(checkpoint.save_file, disposition: "attachment") %> + <% end %> +
+ +
- <%= time_ago_in_words(checkpoint.created_at) %> ago by - <%= link_to checkpoint.user.name || "???", user_path(checkpoint.user) %>
- <%= checkpoint.created_at %> - <% if checkpoint.save_file.attached? %> - <%= link_to "Download save file", rails_blob_path(checkpoint.save_file, disposition: "attachment") %> - <% else %> - (No save file attached.) - <% end %> + <%= time_ago_in_words(checkpoint.created_at) %> ago by + <%= link_to checkpoint.user.name || "???", user_path(checkpoint.user) %> + @ <%= checkpoint.created_at %>
<% if checkpoint.comment %> -
<%= checkpoint.comment %>
+
<%= checkpoint.comment %>
<% end %>
-- cgit v1.2.3