summaryrefslogtreecommitdiff
path: root/app/views
diff options
context:
space:
mode:
Diffstat (limited to 'app/views')
-rw-r--r--app/views/pokedex/show.html.erb2
-rw-r--r--app/views/pokedex_entries/index.html.erb20
-rw-r--r--app/views/pokedex_entries/new.html.erb25
-rw-r--r--app/views/runs/show.html.erb80
4 files changed, 91 insertions, 36 deletions
diff --git a/app/views/pokedex/show.html.erb b/app/views/pokedex/show.html.erb
index f920b19..e463d58 100644
--- a/app/views/pokedex/show.html.erb
+++ b/app/views/pokedex/show.html.erb
@@ -8,7 +8,7 @@
border border-orange-900 rounded shadow">
<div class="flex-1 text-display text-center">No. <%= pokemon.pokedex_num %></div>
<div class="flex-grow flex flex-col justify-around">
- <%= image_tag "sprites/pokemon/#{pokemon.pokedex_num}.png" %>
+ <%= image_tag pokemon.sprite_path %>
</div>
<div class="flex-1"><%= pokemon.name %></div>
</div>
diff --git a/app/views/pokedex_entries/index.html.erb b/app/views/pokedex_entries/index.html.erb
new file mode 100644
index 0000000..e31cf2d
--- /dev/null
+++ b/app/views/pokedex_entries/index.html.erb
@@ -0,0 +1,20 @@
+<%= turbo_frame_tag "pokedex_entries" do %>
+ <%= link_to "Record an entry", new_run_pokedex_entry_path(@run) %>
+
+ <div class="space-y-2 p-4 h-[400px] border border-orange-900 overflow-y-scroll">
+ <% @pokedex_entries.each do |entry| %>
+ <div class="flex space-x-2 items-center">
+ <div class="flex justify-around bg-white h-[60px] w-[60px] border border-orange-900
+ rounded shadow">
+ <%= image_tag entry.pokemon.sprite_path(shiny: entry.shiny?) %>
+ </div>
+ <div>
+ <div><%= "Shiny " if entry.shiny? %><%= entry.pokemon.name %></div>
+ <div class="text-sm">Recorded by
+ <%= link_to entry.user.name || "???", user_path(entry.user) %> @ <%= entry.recorded_at %>
+ </div>
+ </div>
+ </div>
+ <% end %>
+ </div>
+<% end %>
diff --git a/app/views/pokedex_entries/new.html.erb b/app/views/pokedex_entries/new.html.erb
new file mode 100644
index 0000000..03bcbc8
--- /dev/null
+++ b/app/views/pokedex_entries/new.html.erb
@@ -0,0 +1,25 @@
+<%= turbo_frame_tag "pokedex_entries" do %>
+ <%= form_with model: [@run, @pokedex_entry], class: "space-y-4" do |form| %>
+ <div>
+ <%= form.label :pokemon_id %>
+ <%= form.collection_select :pokemon_id, Pokemon.order(:pokedex_num), :id,
+ ->(pokemon) { "#{pokemon.pokedex_num} - #{pokemon.name}" }, prompt: "Choose...",
+ required: true %>
+ </div>
+
+ <div>
+ <%= form.label :recorded_at %>
+ <%= form.datetime_local_field :recorded_at, value: Time.zone.now, required: true %>
+ </div>
+
+ <div>
+ <%= form.label :shiny %>
+ <%= form.check_box :shiny %>
+ </div>
+
+ <div class="space-x-2">
+ <%= form.submit "Got 'em!", class: "btn btn-primary" %>
+ <%= link_to "Cancel", run_pokedex_entries_path %>
+ </div>
+ <% end %>
+<% end %>
diff --git a/app/views/runs/show.html.erb b/app/views/runs/show.html.erb
index e080783..cca5029 100644
--- a/app/views/runs/show.html.erb
+++ b/app/views/runs/show.html.erb
@@ -21,44 +21,54 @@
<% end %>
</div>
- <h2 class="text-xl">Checkpoints</h2>
- <div><%= link_to "New checkpoint", new_run_checkpoint_path(@run) %></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") %>
+ <% @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>
- <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>
+ <% end %>
</div>
- <% end %>
+ <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>