diff options
Diffstat (limited to 'views/admin')
| -rw-r--r-- | views/admin/album.erb | 26 |
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> |
