diff --git a/js/app.js b/js/app.js index 41d8ac3..75735c8 100644 --- a/js/app.js +++ b/js/app.js @@ -692,7 +692,7 @@ function render() { } else { h += 'đŸ—‘ī¸ ' + timeAgo(e.deleted_at) + '' + '' + - ' ' + + ' ' + '' + ''; } @@ -720,7 +720,7 @@ function gridC(e) { let html = '
'; html += '
'; if (showTrash) { - html += ''; + html += ''; html += ''; } else { html += ''; @@ -745,7 +745,7 @@ function listC(e) { let html = '
'; html += '
'; if (showTrash) { - html += ''; + html += ''; html += ''; } else { html += ''; @@ -770,7 +770,7 @@ function compC(e) { let html = '
'; html += '
'; if (showTrash) { - html += ''; + html += ''; html += ''; } else { html += ''; @@ -806,7 +806,7 @@ function groupedC(list) { html += '
'; html += '
'; if (showTrash) { - html += ''; + html += ''; html += ''; } else { html += ''; @@ -854,7 +854,7 @@ function detailC(list) { } else { html += '
DeletedđŸ—‘ī¸ ' + timeAgo(e.deleted_at) + '
'; html += '
' + - '' + + '' + '' + '
'; } @@ -962,7 +962,8 @@ function setupDrag() { el.ondragend = function(e) { c.querySelectorAll('.drag-dim').forEach(card => card.classList.remove('drag-dim')); draggedId = null; c.querySelectorAll('.drag-over').forEach(x => x.classList.remove('drag-over')); document.getElementById('trashBtn')?.classList.remove('drag-over'); }; el.ondragover = function(e) { e.preventDefault(); e.dataTransfer.dropEffect = 'move'; if (this.dataset.id !== draggedId) this.classList.add('drag-over'); }; el.ondragleave = function(e) { this.classList.remove('drag-over'); }; - el.ondrop = function(e) { e.preventDefault(); e.stopPropagation(); this.classList.remove('drag-over'); const fromId = parseInt(e.dataTransfer.getData('text/plain')); const toId = parseInt(this.dataset.id); if (!fromId || !toId) return; const ids = selectedIds.has(fromId) && selectedIds.size > 1 ? [...selectedIds] : [fromId]; if (ids.length === 1 && ids[0] === toId) return; const base = order.length > 0 ? order : entries.filter(e => e).map(e => e.id); const filtered = base.filter(id => !ids.includes(id)); const idx = filtered.indexOf(toId); idx > -1 ? filtered.splice(idx, 0, ...ids) : filtered.push(...ids); order = filtered; localStorage.setItem('entryOrder', JSON.stringify(order)); const map = new Map(entries.filter(e => e).map(e => [e.id, e])); entries = order.map(id => map.get(id)).filter(e => e); entries.sort((a, b) => (b.favorite || 0) - (a.favorite || 0)); render(); }; + el.ondrop = function(e) { e.preventDefault(); e.stopPropagation(); this.classList.remove('drag-over'); const fromId = parseInt(e.dataTransfer.getData('text/plain')); const toId = parseInt(this.dataset.id); if (!fromId || !toId) return; const ids = selectedIds.has(fromId) && selectedIds.size > 1 ? [...selectedIds] : [fromId]; if (ids.length === 1 && ids[0] === toId) return; const base = order.length > 0 ? order : entries.filter(e => e).map(e => e.id); const filtered = base.filter(id => !ids.includes(id)); const idx = filtered.indexOf(toId); idx > -1 ? filtered.splice(idx, 0, ...ids) : filtered.push(...ids); order = filtered; // Ensure no entries are lost from order +entries.forEach(e => { if (!order.includes(e.id)) order.push(e.id); }); localStorage.setItem('entryOrder', JSON.stringify(order)); const map = new Map(entries.filter(e => e).map(e => [e.id, e])); entries = order.map(id => map.get(id)).filter(e => e); entries.sort((a, b) => (b.favorite || 0) - (a.favorite || 0)); render(); }; }); } @@ -1043,7 +1044,7 @@ function updateBatchBar() { bar.innerHTML = `${selectedIds.size} selected`; if (showTrash) { bar.innerHTML += ` - + `; } else { @@ -1238,8 +1239,11 @@ if (token && curUser) { const id = parseInt(e.dataTransfer.getData('text/plain')); if (!id) return; const ids = selectedIds.has(id) && selectedIds.size > 1 ? [...selectedIds] : [id]; - for (const sid of ids) await delEntry(sid); + for (const sid of ids) await delEntry(sid, true); + toast('đŸ“Ļ Moved ' + ids.length + ' entries to trash'); + playSound('delete'); clearSelection(); + await loadEntries(); }); } })(); @@ -1253,7 +1257,7 @@ document.getElementById('entriesContainer').addEventListener('dragstart', functi document.addEventListener('mousedown', function(e) { if (e.button !== 0 || rectState.active) return; if (e.target?.closest?.('.entry-card,.entry-row,.entry-compact,.table-row-drag,.detail-card,.detail-nav,#batchBar,.custom-modal-overlay.show,.edit-modal.show,.modal-overlay.show,#genModal,#settingsMenu')) return; - if (e.target?.closest?.('button,input,select,.folders-bar,.toolbar,#trashActions,.settings-dropdown,.fab,.view-toggle,.auth-section')) { + if (e.target?.closest?.('button,input,select,.folders-bar,.toolbar,#trashActions,.settings-dropdown,.fab,.auth-section')) { if (selectedIds.size > 0) clearSelection(); return; }