M2 drag-reorder: notes.position + reorder API + native DnD
- Migration 0008: notes.position (int). Board orders pinned -> position -> updated_at; new notes created at top (max position + 1). POST /api/notes/reorder assigns positions from the given order (owner-scoped). - notes store: position on Note, position-aware sort, optimistic reorder(). - NoteCard reorderable (native HTML5 draggable + dragstart/drop); BoardView moves the dragged note before the drop target and persists. Note: drag on a CSS-columns masonry has imperfect during-drag visuals (columns reflow); order persists correctly. Candidate for a polish pass / layout tweak. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FRgehjoz7Yv8LkUfADxACm
This commit is contained in:
@@ -5,8 +5,12 @@ import type { Note } from "../stores/notes";
|
||||
import Icon from "./Icon.vue";
|
||||
import NoteChecklist from "./NoteChecklist.vue";
|
||||
|
||||
defineProps<{ note: Note }>();
|
||||
const emit = defineEmits<{ (e: "open", note: Note): void }>();
|
||||
defineProps<{ note: Note; reorderable?: boolean }>();
|
||||
const emit = defineEmits<{
|
||||
(e: "open", note: Note): void;
|
||||
(e: "dragstart", note: Note): void;
|
||||
(e: "drop", note: Note): void;
|
||||
}>();
|
||||
const notes = useNotesStore();
|
||||
|
||||
function cardClass(color: NoteColor): string {
|
||||
@@ -18,6 +22,10 @@ function cardClass(color: NoteColor): string {
|
||||
<div
|
||||
class="group relative mb-4 break-inside-avoid rounded-xl border p-3 shadow-sm transition hover:shadow-md"
|
||||
:class="cardClass(note.color)"
|
||||
:draggable="reorderable && !note.trashed"
|
||||
@dragstart="emit('dragstart', note)"
|
||||
@dragover.prevent
|
||||
@drop="emit('drop', note)"
|
||||
>
|
||||
<img
|
||||
v-if="note.attachments.length"
|
||||
|
||||
Reference in New Issue
Block a user