@@ -19307,6 +19349,66 @@ function renderRetagGroups(groups, container) {
});
container.innerHTML = html;
+ _attachRetagDelegation(container);
+}
+
+function _attachRetagDelegation(container) {
+ // Single click handler for all retag group interactions
+ container.addEventListener('click', (e) => {
+ const target = e.target;
+
+ // Skip checkbox wrapper clicks — handled by change listener
+ if (target.closest('.retag-group-checkbox')) return;
+
+ // Retag button
+ const retagBtn = target.closest('.retag-group-btn');
+ if (retagBtn) {
+ e.stopPropagation();
+ const groupId = parseInt(retagBtn.dataset.groupId);
+ const header = retagBtn.closest('.retag-group-header');
+ const defaultQuery = header ? header.dataset.defaultQuery || '' : '';
+ openRetagSearch(groupId, defaultQuery);
+ return;
+ }
+
+ // Delete confirm buttons (dynamically injected)
+ const confirmYes = target.closest('.retag-confirm-yes');
+ if (confirmYes) {
+ e.stopPropagation();
+ const card = confirmYes.closest('.retag-group-card');
+ if (card) executeRetagGroupDelete(parseInt(card.dataset.groupId));
+ return;
+ }
+ const confirmNo = target.closest('.retag-confirm-no');
+ if (confirmNo) {
+ e.stopPropagation();
+ const card = confirmNo.closest('.retag-group-card');
+ if (card) cancelRetagDeleteConfirm(parseInt(card.dataset.groupId));
+ return;
+ }
+
+ // Delete button
+ const delBtn = target.closest('.retag-group-delete-btn');
+ if (delBtn) {
+ e.stopPropagation();
+ showRetagDeleteConfirm(parseInt(delBtn.dataset.groupId));
+ return;
+ }
+
+ // Group header click (expand/collapse)
+ const header = target.closest('.retag-group-header');
+ if (header) {
+ toggleRetagGroup(parseInt(header.dataset.groupId));
+ return;
+ }
+ });
+
+ // Separate change handler for checkboxes
+ container.addEventListener('change', (e) => {
+ if (e.target.classList.contains('retag-select-cb')) {
+ updateRetagBatchBar();
+ }
+ });
}
async function toggleRetagGroup(groupId) {
@@ -19581,15 +19683,15 @@ function showRetagDeleteConfirm(groupId) {
if (!area) return;
area.innerHTML = `
Remove?
- Yes
- No
+ Yes
+ No
`;
}
function cancelRetagDeleteConfirm(groupId) {
const area = document.getElementById(`retag-delete-area-${groupId}`);
if (!area) return;
- area.innerHTML = `
× `;
+ area.innerHTML = `
× `;
}
async function executeRetagGroupDelete(groupId) {