refactor: implement template-driven node tree and human-readable vault layout
Unified Node model: added template_id, fs_path, archived, sort_order fields. Template registry: system templates embedded as JSON (folder/project/client/ document/recipe), with Registry for enabled/disabled/filtered access. SafeDisplayNameToPathSegment: human-readable path segments with Cyrillic support, illegal char replacement, uniqueness via numeric suffixes. Sidebar refactored: system views (Today/Inbox/Activity) separate from workspace tree. Creation menu built dynamically from enabled templates. Create/Rename/Move: physical folder operations with fs_path update, recursive descendant path updates. DB migration 012: adds template_id, fs_path, archived columns. Vault migration command: rebuilds fs_path for existing nodes. Tests: safename, registry, node model, repository integration. Docs: VAULT_LAYOUT.md, TEMPLATES.md, PLAN.md updated. i18n: nav.system, nav.workspace, template.*, common.rename/archive, migrate.* keys added to ru.json and en.json.
This commit is contained in:
+11
-3
@@ -18,7 +18,11 @@ func runNodeCreate(vault, parentID, typ, title string) error {
|
||||
defer db.Close()
|
||||
|
||||
repo := nodes.NewRepository(db)
|
||||
n, err := repo.Create(parentID, typ, title, "")
|
||||
var pid *string
|
||||
if parentID != "" {
|
||||
pid = &parentID
|
||||
}
|
||||
n, err := repo.Create(pid, typ, title, 0, "", "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -65,7 +69,7 @@ func runNodeList(vault, parentID string) error {
|
||||
repo := nodes.NewRepository(db)
|
||||
var list []nodes.Node
|
||||
if parentID == "" {
|
||||
list, err = repo.ListRoots(false, "")
|
||||
list, err = repo.ListRoots(false)
|
||||
} else {
|
||||
list, err = repo.ListChildren(parentID, false)
|
||||
}
|
||||
@@ -87,7 +91,11 @@ func runNodeMove(vault, id, parentID string, sortOrder int) error {
|
||||
defer db.Close()
|
||||
|
||||
repo := nodes.NewRepository(db)
|
||||
if err := repo.Move(id, parentID, sortOrder); err != nil {
|
||||
var pid *string
|
||||
if parentID != "" {
|
||||
pid = &parentID
|
||||
}
|
||||
if err := repo.Move(id, pid, sortOrder); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("moved")
|
||||
|
||||
Reference in New Issue
Block a user