From a942b4e83d8c3c71020fdc6ae93954ddfa2ea338 Mon Sep 17 00:00:00 2001 From: Ken D'Ambrosio Date: Tue, 9 Jun 2026 14:09:19 +0000 Subject: Fix New Person flow: redirect to new cluster, show hero face, detect duplicate names After moving a face to "New Person", the user is now taken directly to that cluster's detail page. If it's a single unnamed cluster, the face is shown prominently at the top. Typing an existing name on the name form triggers a confirm dialog: OK merges into the existing person's cluster, Cancel saves as a new separate person with the same name. Co-Authored-By: Claude Sonnet 4.6 --- views/admin/person_detail.erb | 56 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) (limited to 'views/admin') diff --git a/views/admin/person_detail.erb b/views/admin/person_detail.erb index 77f27b7..7a1ea0a 100644 --- a/views/admin/person_detail.erb +++ b/views/admin/person_detail.erb @@ -26,11 +26,32 @@ <% unless @is_pool %> <%# ── Name ──────────────────────────────────────────────────────────────── %>
-
- + <% if @count == 1 && !@name %> + <% m = @members.first; rel = m['rel']; box = m['box'] %> + <% parts = rel.split('/'); fname = parts.last; dir_rel = parts[0..-2].join('/') %> + <% album_url = dir_rel.empty? ? '/browse/' : "/browse/#{ERB::Util.html_escape(dir_rel)}" %> +
+
+ + + +
+

Hover to see full photo · Click to open in album

+
+ <% end %> + +
+
<%# ── Merge entire cluster ──────────────────────────────────────────────── %> @@ -131,6 +152,35 @@ preview.style.top = y + 'px'; } + // Duplicate name check + var existingNames = <%= @existing_names_json || '[]' %>; + var nameForm = document.getElementById('name-form'); + var nameInput = document.getElementById('name-input'); + if (nameForm && nameInput) { + var forceNew = false; + nameForm.addEventListener('submit', function (e) { + if (forceNew) return; + var val = nameInput.value.trim(); + if (!val) return; + var match = existingNames.find(function (p) { + return p.name.toLowerCase() === val.toLowerCase(); + }); + if (match) { + e.preventDefault(); + var msg = '"' + match.name + '" already exists.\n\n' + + 'OK — add this photo to ' + match.name + "'s cluster\n" + + 'Cancel — create a new separate person named "' + val + '"'; + if (confirm(msg)) { + document.getElementById('merge-into-uuid').value = match.uuid; + document.getElementById('merge-into-form').submit(); + } else { + forceNew = true; + nameForm.submit(); + } + } + }); + } + document.querySelectorAll('.face-detail-thumb').forEach(function (el) { el.querySelector('img').style.cursor = 'zoom-in'; el.addEventListener('mouseenter', function (e) { -- cgit v1.2.3