From cfb814470864785565f33e4bebd2aca7e67c16ae Mon Sep 17 00:00:00 2001 From: Ken D'Ambrosio Date: Fri, 12 Jun 2026 14:01:48 +0000 Subject: Move bulk selection to admin cluster detail page (correct page) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bulk selection panel now lives on /admin/people/:uuid — the face crop grid page — which is what was actually requested. A sticky left panel shows the cluster name, the name form, a selection counter, and bulk action controls. Clicking a face crop toggles selection; clicking the photo link still opens the album. Bulk actions: move selected faces to a named person, move to pool, or blacklist. The per-face individual dropdowns are replaced by the panel. Merge-entire-cluster and Blacklist-cluster moved to collapsible/button in the panel too. Co-Authored-By: Claude Sonnet 4.6 --- app.rb | 40 ++++++ public/css/style.css | 32 +++-- views/admin/person_detail.erb | 327 +++++++++++++++++++++++------------------- 3 files changed, 243 insertions(+), 156 deletions(-) diff --git a/app.rb b/app.rb index ece8b18..9f02422 100644 --- a/app.rb +++ b/app.rb @@ -1007,6 +1007,46 @@ post '/admin/people/:uuid/delete' do redirect '/admin/people' end +post '/admin/people/:uuid/bulk_move' do + require_admin! + src = params[:uuid] + action = params['bulk_action'].to_s.strip + entries = Array(params['entries[]']).map { |e| JSON.parse(e) rescue nil }.compact + + halt 400 if entries.empty? + + data = load_people_data + people = data['people'] || {} + halt 404 unless people.key?(src) + + to_move = entries.filter_map do |e| + rel = e['rel']; box = e['box'].map(&:to_i) + people[src]['members'].find { |m| m['rel'] == rel && m['box'].map(&:to_i) == box } + end + + people[src]['members'] -= to_move + + case action + when 'blacklist' + data['blacklist'] ||= [] + data['blacklist'].concat(to_move) + when 'pool' + people['__pool__'] ||= { 'name' => '__pool__', 'slug' => nil, 'members' => [] } + people['__pool__']['members'].concat(to_move) + when /\A[0-9a-f-]{36}\z/ + halt 404 unless people.key?(action) + people[action]['members'].concat(to_move) + else + halt 400 + end + + people.delete(src) if people[src]['members'].empty? + data['people'] = people + atomic_write(PEOPLE_PATH, JSON.pretty_generate(data)) + + people[src] ? redirect("/admin/people/#{src}") : redirect('/admin/people') +end + post '/admin/people/:uuid/merge' do require_admin! src = params[:uuid] diff --git a/public/css/style.css b/public/css/style.css index 93345ad..a549143 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -548,30 +548,34 @@ tr.delete-marked td { background: rgba(192,57,43,.08); } .person-name { padding: 7px 10px 2px; font-size: .9rem; font-weight: 500; color: var(--text); } .person-count { padding: 0 10px 8px; font-size: .75rem; color: var(--text-dim); } -/* ── Person page bulk selection ────────────────────────────────────────── */ +/* ── Shared bulk-action panel (person detail + person page) ────────────── */ +.person-detail-wrap, .person-page-wrap { display: flex; align-items: flex-start; gap: 0; } .bulk-panel { - width: 220px; flex-shrink: 0; position: sticky; top: 16px; + width: 230px; flex-shrink: 0; position: sticky; top: 16px; max-height: calc(100vh - 32px); + overflow-y: auto; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-right: 20px; } -.bulk-panel-title { font-size: .95rem; font-weight: 600; margin: 0 0 8px; } +.bulk-panel-title { font-size: .95rem; font-weight: 600; margin: 0 0 4px; } .bulk-panel-hint { font-size: .82rem; color: var(--text-dim); margin: 0; } -.bulk-selected-count { font-size: .9rem; margin: 0; } .bulk-sep { border: none; border-top: 1px solid var(--border); margin: 12px 0; } .bulk-label { display: block; font-size: .8rem; color: var(--text-dim); margin-bottom: 4px; } .bulk-select, .bulk-input { width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: 5px 8px; - font-size: .82rem; margin-bottom: 8px; box-sizing: border-box; + font-size: .82rem; margin-bottom: 6px; box-sizing: border-box; } .bulk-select:focus, .bulk-input:focus { border-color: var(--accent); outline: none; } .bulk-action-btn { width: 100%; text-align: center; } +.person-detail-main, .person-page-main { flex: 1; min-width: 0; } -/* Selectable photo cards */ -.selectable-card { cursor: pointer; position: relative; } -.selectable-card .thumb-wrap { position: relative; } +/* Selectable cards (photo grid and face grid) */ +.selectable-card, +.selectable-face { cursor: pointer; position: relative; } +.selectable-card .thumb-wrap, +.selectable-face .face-detail-thumb { position: relative; } .select-checkbox { position: absolute; top: 6px; left: 6px; width: 20px; height: 20px; border-radius: 4px; @@ -581,8 +585,10 @@ tr.delete-marked td { background: rgba(192,57,43,.08); } opacity: 0; transition: opacity .12s; pointer-events: none; } -.selectable-card:hover .select-checkbox { opacity: 1; } -.selectable-card.selected .select-checkbox { +.selectable-card:hover .select-checkbox, +.selectable-face:hover .select-checkbox { opacity: 1; } +.selectable-card.selected .select-checkbox, +.selectable-face.selected .select-checkbox { opacity: 1; background: var(--accent); border-color: var(--accent); } .selectable-card.selected .select-checkbox::after { @@ -591,8 +597,10 @@ tr.delete-marked td { background: rgba(192,57,43,.08); } border: 2px solid #fff; border-top: none; border-left: none; transform: rotate(45deg) translate(-1px, -1px); } -.selectable-card.selected .thumb-wrap img { opacity: .75; } -.selectable-card.selected { outline: 2px solid var(--accent); outline-offset: -2px; } +.selectable-card.selected .thumb-wrap img, +.selectable-face.selected .face-detail-thumb img { opacity: .75; } +.selectable-card.selected, +.selectable-face.selected { outline: 2px solid var(--accent); outline-offset: -2px; } /* ── Admin upload ──────────────────────────────────────────────────────── */ .admin-upload { margin-top: 32px; } diff --git a/views/admin/person_detail.erb b/views/admin/person_detail.erb index 7a1ea0a..fbce8af 100644 --- a/views/admin/person_detail.erb +++ b/views/admin/person_detail.erb @@ -1,158 +1,208 @@ -
-
- ← All Clusters - <% if @name && !@is_pool %> - Public Page ↗ - <% end %> -
+
-

<%= ERB::Util.html_escape(@title) %>

-

<%= @count %> photo<%= @count == 1 ? '' : 's' %> in this cluster

+ <%# ── Left action panel ──────────────────────────────────────────────────── %> + + + <%# ── Face grid ──────────────────────────────────────────────────────────── %> +
+
+ <% @members.each do |m| %> + <% 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)}" %> + <% entry_json = ERB::Util.html_escape({rel: rel, box: box}.to_json) %> +
+
+ + + + +
- <% if @is_pool || !@named_others.empty? %> -
- - - -
- <% end %> -
- <% end %> + <% end %> +
-
+ +<%# .person-detail-wrap %>
-- cgit v1.2.3