From a7c0a7fd166de58904c6e6a7e57cd604f4371e22 Mon Sep 17 00:00:00 2001
From: Felix Eckhofer <felix@eckhofer.com>
Date: Sun, 29 Dec 2024 14:21:24 +0100
Subject: [PATCH] Add jump anchors for assignments

---
 app/views/assignments/index.html.erb | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/app/views/assignments/index.html.erb b/app/views/assignments/index.html.erb
index 0b03d07..1276456 100644
--- a/app/views/assignments/index.html.erb
+++ b/app/views/assignments/index.html.erb
@@ -1,9 +1,19 @@
 <% now = Time.now %>
-<div>
+<div class="scroll-smooth">
   <h1 class="text-xl my-4">Assignments for all users</h1>
+  <p>
+    Jump to:
+    <ul class="flex flex-row">
+    <% @assignments.group_by(&:user).each_with_index do |(user, assignments), index| %>
+      <li>
+        <%= link_to user.name, "#" + dom_id(user), class: index == 0 ? "" : "border-l-2 border-gray-300 pl-2 ml-2" %>
+      </li>
+    <% end %>
+    </ul>
+  </p>
   <% @assignments.group_by(&:user).each do |user, assignments| %>
     <div class="my-4">
-      <h4 class="text-xl my-2"><%= link_to user.name, user_assignments_path(user) %> <span class="font-normal"><%= link_to user_assignments_path(user, format: 'ics') do %><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="ml-2 mb-1 size-4 inline-block stroke-slate-400 fill-slate-400"><path fill-rule="evenodd" d="M5.75 2a.75.75 0 01.75.75V4h7V2.75a.75.75 0 011.5 0V4h.25A2.75 2.75 0 0118 6.75v8.5A2.75 2.75 0 0115.25 18H4.75A2.75 2.75 0 012 15.25v-8.5A2.75 2.75 0 014.75 4H5V2.75A.75.75 0 015.75 2zm-1 5.5c-.69 0-1.25.56-1.25 1.25v6.5c0 .69.56 1.25 1.25 1.25h10.5c.69 0 1.25-.56 1.25-1.25v-6.5c0-.69-.56-1.25-1.25-1.25H4.75z" clip-rule="evenodd"></path></svg><% end %></span></h4>
+      <h4 class="text-xl my-2" id="<%= dom_id(user) %>"><%= link_to user.name, user_assignments_path(user) %> <span class="font-normal"><%= link_to user_assignments_path(user, format: 'ics') do %><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="ml-2 mb-1 size-4 inline-block stroke-slate-400 fill-slate-400"><path fill-rule="evenodd" d="M5.75 2a.75.75 0 01.75.75V4h7V2.75a.75.75 0 011.5 0V4h.25A2.75 2.75 0 0118 6.75v8.5A2.75 2.75 0 0115.25 18H4.75A2.75 2.75 0 012 15.25v-8.5A2.75 2.75 0 014.75 4H5V2.75A.75.75 0 015.75 2zm-1 5.5c-.69 0-1.25.56-1.25 1.25v6.5c0 .69.56 1.25 1.25 1.25h10.5c.69 0 1.25-.56 1.25-1.25v-6.5c0-.69-.56-1.25-1.25-1.25H4.75z" clip-rule="evenodd"></path></svg><% end %></span></h4>
         <% assignments.group_by { |a| a.session.starts_at.strftime('%Y-%m-%d') }.each do |date, assignments_on_date| %>
           <h5 class="text-base mt-2 <%= Time.parse(date).end_of_day < now ? "past" : "future" %>"><%= date %></h5>
           <ol class="list-inside">
-- 
GitLab