kalender und fixes
This commit is contained in:
1 parent
940d9bbde4
commit
416ca9e854
14 files changed
+376
-71
No files matched your search
@@ -1,7 +1,7 @@
|
||||
// ── Search ──
|
||||
|
||||
import { $, esc, escRe, fuzzyMatch, countSubstring, highlight } from './util.js';
|
||||
import { state, parseTags, tagChipHtml } from './state.js';
|
||||
import { $, esc, escRe, api, fuzzyMatch, countSubstring, highlight } from './util.js';
|
||||
import { state, parseTags, tagChipHtml, getChildren } from './state.js';
|
||||
import { renderMd, stripMd } from './markdown.js';
|
||||
|
||||
const overlay = $('search');
|
||||
@@ -170,9 +170,12 @@ function hitHtml(card, idx, words) {
|
||||
} else { snippet = esc(plain.substring(0, 120)) + (plain.length > 120 ? '...' : ''); }
|
||||
|
||||
const htags = parseTags(card);
|
||||
return `<div class="search-hit flex items-start gap-3 px-4 py-2.5 cursor-pointer transition-colors hover:bg-t-raised" data-idx="${idx}">
|
||||
const children = getChildren(card.id);
|
||||
const isGroup = children.length > 0;
|
||||
const canDrag = !isGroup && !card.parent_id;
|
||||
return `<div class="search-hit flex items-start gap-3 px-4 py-2.5 cursor-pointer transition-colors hover:bg-t-raised" data-idx="${idx}" data-card-id="${card.id}" ${canDrag ? 'draggable="true"' : ''}>
|
||||
<span class="w-2 h-2 rounded-full shrink-0 mt-1.5" style="background:${card.color}"></span>
|
||||
<div class="min-w-0 flex-1"><div class="text-xs text-t-bright font-pixel leading-relaxed truncate">${title}</div>
|
||||
<div class="min-w-0 flex-1"><div class="text-xs text-t-bright font-pixel leading-relaxed truncate flex items-center gap-2">${title}${isGroup ? `<span style="font-size:9px;padding:1px 5px;border-radius:3px;background:${card.color};color:#000;" class="font-pixel">${children.length + 1}</span>` : ''}</div>
|
||||
<div class="text-[11px] text-t-muted leading-relaxed mt-0.5 line-clamp-2">${snippet}</div>
|
||||
${htags.length ? `<div class="flex flex-wrap gap-1 mt-1">${htags.slice(0, 3).map(t => `<span class="tag-chip" style="font-size:8px;padding:0 4px;">#${esc(t)}</span>`).join('')}</div>` : ''}</div></div>`;
|
||||
}
|
||||
@@ -185,6 +188,42 @@ function bindHits() {
|
||||
else { active = i; updateActive(); }
|
||||
});
|
||||
el.addEventListener('dblclick', () => { const i = parseInt(el.dataset.idx); if (hits[i]) window._openDetail(hits[i].id); });
|
||||
|
||||
// Drag: only non-group, non-child cards
|
||||
if (el.draggable) {
|
||||
el.addEventListener('dragstart', e => {
|
||||
e.dataTransfer.setData('text/plain', el.dataset.cardId);
|
||||
e.dataTransfer.effectAllowed = 'move';
|
||||
el.style.opacity = '0.4';
|
||||
});
|
||||
el.addEventListener('dragend', () => { el.style.opacity = ''; });
|
||||
}
|
||||
|
||||
// Drop target: any card can receive (to form group)
|
||||
el.addEventListener('dragover', e => {
|
||||
const dragId = e.dataTransfer.types.includes('text/plain') ? true : false;
|
||||
if (!dragId) return;
|
||||
if (el.dataset.cardId === e.dataTransfer.getData('text/plain')) return;
|
||||
e.preventDefault();
|
||||
e.dataTransfer.dropEffect = 'move';
|
||||
el.style.background = 'var(--t-raised)';
|
||||
el.style.borderLeft = `3px solid var(--t-accent)`;
|
||||
});
|
||||
el.addEventListener('dragleave', () => {
|
||||
el.style.background = '';
|
||||
el.style.borderLeft = '';
|
||||
});
|
||||
el.addEventListener('drop', async e => {
|
||||
el.style.background = '';
|
||||
el.style.borderLeft = '';
|
||||
const dragId = e.dataTransfer.getData('text/plain');
|
||||
const targetId = el.dataset.cardId;
|
||||
if (!dragId || !targetId || dragId === targetId) return;
|
||||
e.preventDefault();
|
||||
await api(`api/cards/${dragId}`, { method: 'PATCH', body: { parent_id: targetId } });
|
||||
await window._reloadAll();
|
||||
search(input.value);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user