feat: node section assignment for sidebar filtering + search fix

Backend:
- Migration 004: add 'section' column to nodes table
  (NULL=inbox, values: clients/projects/recipes/documents/archive)
- Create(parentID, type, title, section) — section stored on root nodes
- ListRoots(includeDeleted, section) — filters by section
  (section='inbox' returns nodes with NULL section)
- GET /api/nodes?section=X filters root nodes by section
- POST /api/nodes accepts 'section' field in body

Frontend:
- Sidebar separates 'НАВИГАЦИЯ' (virtual sections) from 'ДЕЛА' (real nodes)
- Each section loads only its own nodes: GET /api/nodes?section=clients etc.
- Creating from a section sets the section automatically
- Inbox shows only nodes with no section
- selectBySearch(id) closes result dropdown after selection
- All types shown in Russian (Дело, Заметка, Папка, etc.)

Acceptance: go build pass, go test pass (all packages),
  manual: Pro projects section shows only project-nodes,
  clients only client-nodes, inbox only unsectioned nodes.
This commit is contained in:
2026-05-31 01:26:46 +08:00
parent 14ff1a25b9
commit 9ee6df0d3f
11 changed files with 141 additions and 72 deletions
+2 -2
View File
@@ -34,8 +34,8 @@ func NewService(db *storage.DB, vaultRoot string, nodeRepo *nodes.Repository, fi
}
// Create makes a new note node, an empty .md file, and links them.
func (s *Service) Create(parentID, title string) (*nodes.Node, *files.Record, error) {
node, err := s.nodes.Create(parentID, nodes.TypeNote, title)
func (s *Service) Create(parentID, title, section string) (*nodes.Node, *files.Record, error) {
node, err := s.nodes.Create(parentID, nodes.TypeNote, title, section)
if err != nil {
return nil, nil, fmt.Errorf("create node: %w", err)
}
+3 -3
View File
@@ -29,7 +29,7 @@ func setupService(t *testing.T) (*Service, *nodes.Repository, string) {
func TestCreateAndRead(t *testing.T) {
svc, _, vaultRoot := setupService(t)
node, fileRec, err := svc.Create("", "My Note")
node, fileRec, err := svc.Create("", "My Note", "")
if err != nil {
t.Fatalf("Create: %v", err)
}
@@ -60,7 +60,7 @@ func TestCreateAndRead(t *testing.T) {
func TestSaveAndBackup(t *testing.T) {
svc, _, vaultRoot := setupService(t)
node, _, _ := svc.Create("", "Backup Test")
node, _, _ := svc.Create("", "Backup Test", "")
// Save new content.
newContent := "# Updated\n\nThis is the new content."
@@ -88,7 +88,7 @@ func TestSaveAndBackup(t *testing.T) {
func TestDeleteNote(t *testing.T) {
svc, nodeRepo, _ := setupService(t)
node, _, _ := svc.Create("", "To Delete")
node, _, _ := svc.Create("", "To Delete", "")
if err := svc.Delete(node.ID); err != nil {
t.Fatal(err)
}