Add drag-and-drop reordering for note tabs, and a user-facing guide
Tabs can now be dragged to reorder within a group and to move between sections in one gesture: dropping on a tab's left/right half inserts before/after it and adopts that tab's section, while a dedicated zone past the last group ungroups and appends at the end. A blue indicator line shows the drop position while dragging. core/notes.reorder() takes the full new page-id order computed client-side (NotePanel.vue has the reactive list already) rather than recomputing positions server-side, validates it against the current page-id set, sets the moved page's section, then renumbers position. POST /api/notes/reorder exposes it. Also adds docs/notes-guide.md, an end-user walkthrough of the shared notes panel (pages, sections, drag-and-drop, AI interaction) — the existing docs were all developer-facing specs with no operating instructions for the feature itself. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -104,6 +104,27 @@ def set_section(db: DBSession, page_id: int, section: str | None) -> NotePage |
|
||||
return page
|
||||
|
||||
|
||||
def reorder(db: DBSession, page_id: int, section: str | None, order: list[int]) -> bool:
|
||||
"""タブのドラッグ&ドロップによる並べ替えを反映する。
|
||||
|
||||
order にはドラッグ後の全ページIDを新しい順序で渡す(フロント側で計算する)。
|
||||
page_id のページには先に section を設定し、その後 order の順に position を振り直す。
|
||||
こうすることで、別セクションのタブの前後にドロップした場合はそのセクションへの
|
||||
移動を兼ね、同じセクション内でのドロップなら単純な並べ替えになる。
|
||||
|
||||
order が現在の全ページIDの集合と一致しない場合は何もせず False を返す。
|
||||
"""
|
||||
pages = {p.id: p for p in db.query(NotePage).all()}
|
||||
if page_id not in pages or set(order) != set(pages.keys()):
|
||||
return False
|
||||
|
||||
pages[page_id].section = (section or "").strip() or None
|
||||
for i, pid in enumerate(order):
|
||||
pages[pid].position = i
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
|
||||
def rename_section(db: DBSession, old_name: str, new_name: str | None) -> int:
|
||||
"""あるセクションに属する全ページのセクション名を一括で変更する。new_name が空ならグループ解除になる。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user