summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorKen D'Ambrosio <ken@jots.org>2026-05-14 04:14:31 +0000
committerKen D'Ambrosio <ken@jots.org>2026-05-14 04:14:31 +0000
commit9cebd2e909793e12f7b9e5125d4fba671b5b660d (patch)
treeb3c0187e8c5e701074d6c7e05c86773dfc86e592 /views
parent7950acb21b22e7bc6f10c50e1427850de2834b24 (diff)
Add per-photo delete checkbox to admin edit form
Checking Delete and saving permanently removes the file and its thumbnail; a JS confirm dialog gates the submit. Deleted files are stripped from params before save_edits so they don't linger in album.json. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'views')
-rw-r--r--views/admin/album.erb26
1 files changed, 22 insertions, 4 deletions
diff --git a/views/admin/album.erb b/views/admin/album.erb
index 49ec4ca..f28d515 100644
--- a/views/admin/album.erb
+++ b/views/admin/album.erb
@@ -63,6 +63,7 @@
<th>Caption</th>
<th>Visible</th>
<th>Cover</th>
+ <th>Delete</th>
</tr>
</thead>
<tbody>
@@ -80,6 +81,9 @@
<td class="cover-cell">
<input type="radio" name="album_cover_file" value="<%= name %>" class="cover-radio"<%= ' checked' if @data['cover'] == name %>>
</td>
+ <td class="delete-cell">
+ <input type="checkbox" name="file_delete[<%= name %>]" value="1" class="delete-check">
+ </td>
</tr>
<% end %>
</tbody>
@@ -96,10 +100,24 @@
(function () {
const randomCb = document.getElementById('cover-random');
const radios = () => document.querySelectorAll('.cover-radio');
- if (!randomCb) return;
- radios().forEach(r => r.addEventListener('change', () => { randomCb.checked = false; }));
- randomCb.addEventListener('change', function () {
- if (this.checked) radios().forEach(r => { r.checked = false; });
+ if (randomCb) {
+ radios().forEach(r => r.addEventListener('change', () => { randomCb.checked = false; }));
+ randomCb.addEventListener('change', function () {
+ if (this.checked) radios().forEach(r => { r.checked = false; });
+ });
+ }
+
+ document.querySelectorAll('.delete-check').forEach(cb => {
+ cb.addEventListener('change', function () {
+ this.closest('tr').classList.toggle('delete-marked', this.checked);
+ });
+ });
+
+ document.querySelector('form').addEventListener('submit', function (e) {
+ const count = document.querySelectorAll('.delete-check:checked').length;
+ if (count > 0 && !confirm(`Permanently delete ${count} photo${count !== 1 ? 's' : ''}? This cannot be undone.`)) {
+ e.preventDefault();
+ }
});
})();
</script>