In athlete registration, add an "X" (remove photo) button: - When a photo is present, show an "X" on the thumbnail’s top-right. - On click: → clear the photo (restore placeholder), → clear file input, → set state: photo=null / hasPhoto=false, → if already saved, flag backend removal (e.g., photo_deleted=true). - Accessibility: aria-label="Remove photo". - Keyboard: Enter/Space activates the "X". - Optional confirm: “Remove athlete photo?” [Yes/No]. - Follow Up Deployment
Browse files- index.html +36 -1
index.html
CHANGED
|
@@ -277,8 +277,14 @@
|
|
| 277 |
<div class="md:col-span-2">
|
| 278 |
<label class="block text-sm font-medium mb-1">Foto</label>
|
| 279 |
<input type="file" id="player-photo" accept="image/*" class="w-full p-2 border rounded">
|
| 280 |
-
<div id="photo-preview" class="mt-2 hidden">
|
| 281 |
<img id="preview-image" class="h-20 w-20 rounded-full object-cover border-2 border-gray-300">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
</div>
|
| 283 |
</div>
|
| 284 |
</div>
|
|
@@ -708,6 +714,7 @@
|
|
| 708 |
document.getElementById('player-form').classList.add('hidden');
|
| 709 |
document.getElementById('photo-preview').classList.add('hidden');
|
| 710 |
document.getElementById('player-photo').value = '';
|
|
|
|
| 711 |
});
|
| 712 |
|
| 713 |
// Photo preview handler
|
|
@@ -718,11 +725,37 @@
|
|
| 718 |
reader.onload = function(event) {
|
| 719 |
document.getElementById('preview-image').src = event.target.result;
|
| 720 |
document.getElementById('photo-preview').classList.remove('hidden');
|
|
|
|
| 721 |
}
|
| 722 |
reader.readAsDataURL(file);
|
| 723 |
}
|
| 724 |
});
|
| 725 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 726 |
// Save player
|
| 727 |
document.getElementById('save-player-btn').addEventListener('click', function() {
|
| 728 |
const name = document.getElementById('player-name').value;
|
|
@@ -782,6 +815,8 @@
|
|
| 782 |
document.getElementById('player-team').value = '1';
|
| 783 |
document.getElementById('player-position').value = 'Levantador';
|
| 784 |
document.getElementById('player-photo').value = '';
|
|
|
|
|
|
|
| 785 |
|
| 786 |
saveGameState();
|
| 787 |
});
|
|
|
|
| 277 |
<div class="md:col-span-2">
|
| 278 |
<label class="block text-sm font-medium mb-1">Foto</label>
|
| 279 |
<input type="file" id="player-photo" accept="image/*" class="w-full p-2 border rounded">
|
| 280 |
+
<div id="photo-preview" class="mt-2 relative hidden">
|
| 281 |
<img id="preview-image" class="h-20 w-20 rounded-full object-cover border-2 border-gray-300">
|
| 282 |
+
<button id="remove-photo-btn"
|
| 283 |
+
class="absolute -top-2 -right-2 bg-red-500 text-white rounded-full w-6 h-6 flex items-center justify-center hidden"
|
| 284 |
+
aria-label="Remove photo"
|
| 285 |
+
title="Remove photo">
|
| 286 |
+
<i class="fas fa-times text-xs"></i>
|
| 287 |
+
</button>
|
| 288 |
</div>
|
| 289 |
</div>
|
| 290 |
</div>
|
|
|
|
| 714 |
document.getElementById('player-form').classList.add('hidden');
|
| 715 |
document.getElementById('photo-preview').classList.add('hidden');
|
| 716 |
document.getElementById('player-photo').value = '';
|
| 717 |
+
document.getElementById('remove-photo-btn').classList.add('hidden');
|
| 718 |
});
|
| 719 |
|
| 720 |
// Photo preview handler
|
|
|
|
| 725 |
reader.onload = function(event) {
|
| 726 |
document.getElementById('preview-image').src = event.target.result;
|
| 727 |
document.getElementById('photo-preview').classList.remove('hidden');
|
| 728 |
+
document.getElementById('remove-photo-btn').classList.remove('hidden');
|
| 729 |
}
|
| 730 |
reader.readAsDataURL(file);
|
| 731 |
}
|
| 732 |
});
|
| 733 |
|
| 734 |
+
// Photo removal handler
|
| 735 |
+
document.getElementById('remove-photo-btn').addEventListener('click', function(e) {
|
| 736 |
+
e.preventDefault();
|
| 737 |
+
if (confirm('Remove athlete photo?')) {
|
| 738 |
+
document.getElementById('preview-image').src = '';
|
| 739 |
+
document.getElementById('photo-preview').classList.add('hidden');
|
| 740 |
+
document.getElementById('player-photo').value = '';
|
| 741 |
+
this.classList.add('hidden');
|
| 742 |
+
|
| 743 |
+
// If this is an existing player being edited, flag for backend removal
|
| 744 |
+
if (currentPlayerId) {
|
| 745 |
+
playerToEdit.photo = null;
|
| 746 |
+
playerToEdit.photo_deleted = true;
|
| 747 |
+
}
|
| 748 |
+
}
|
| 749 |
+
});
|
| 750 |
+
|
| 751 |
+
// Make remove button keyboard accessible
|
| 752 |
+
document.getElementById('remove-photo-btn').addEventListener('keydown', function(e) {
|
| 753 |
+
if (e.key === 'Enter' || e.key === ' ') {
|
| 754 |
+
e.preventDefault();
|
| 755 |
+
this.click();
|
| 756 |
+
}
|
| 757 |
+
});
|
| 758 |
+
|
| 759 |
// Save player
|
| 760 |
document.getElementById('save-player-btn').addEventListener('click', function() {
|
| 761 |
const name = document.getElementById('player-name').value;
|
|
|
|
| 815 |
document.getElementById('player-team').value = '1';
|
| 816 |
document.getElementById('player-position').value = 'Levantador';
|
| 817 |
document.getElementById('player-photo').value = '';
|
| 818 |
+
document.getElementById('photo-preview').classList.add('hidden');
|
| 819 |
+
document.getElementById('remove-photo-btn').classList.add('hidden');
|
| 820 |
|
| 821 |
saveGameState();
|
| 822 |
});
|