feat: add interactive inbox view
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
func (a *App) ListInboxNodes() ([]NodeDTO, error) {
|
||||
if err := a.requireVault(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list, err := a.nodes.ListInboxRoots(false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dtos := toNodeDTOs(list)
|
||||
for i := range dtos {
|
||||
n, err := a.nodes.CountChildren(dtos[i].ID, "case", "client", "project", "folder", "document", "recipe")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dtos[i].HasChildren = n > 0
|
||||
}
|
||||
return dtos, nil
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -16,8 +16,8 @@
|
||||
background: #13131f;
|
||||
}
|
||||
</style>
|
||||
<script type="module" crossorigin src="/assets/main-Cyhj7TEH.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/main-DAyIHTpH.css">
|
||||
<script type="module" crossorigin src="/assets/main-Wpp0QvRu.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/main-xwXesvcm.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestListInboxNodesReturnsOnlyUnassignedRoots(t *testing.T) {
|
||||
app, _ := setupTestApp(t)
|
||||
|
||||
unassigned, err := app.CreateNodeFromTemplate("", "Unassigned Root", "folder.default")
|
||||
if err != nil {
|
||||
t.Fatalf("create unassigned root: %v", err)
|
||||
}
|
||||
inbox, err := app.CreateNodeFromTemplate("", "Inbox Root", "folder.default")
|
||||
if err != nil {
|
||||
t.Fatalf("create inbox root: %v", err)
|
||||
}
|
||||
assigned, err := app.CreateNodeFromTemplate("", "Assigned Root", "folder.default")
|
||||
if err != nil {
|
||||
t.Fatalf("create assigned root: %v", err)
|
||||
}
|
||||
child, err := app.CreateNodeFromTemplate(unassigned.ID, "Nested Child", "folder.default")
|
||||
if err != nil {
|
||||
t.Fatalf("create child: %v", err)
|
||||
}
|
||||
if _, err := app.db.Exec(`UPDATE nodes SET section = 'inbox' WHERE id = ?`, inbox.ID); err != nil {
|
||||
t.Fatalf("mark inbox: %v", err)
|
||||
}
|
||||
if _, err := app.db.Exec(`UPDATE nodes SET section = 'projects' WHERE id = ?`, assigned.ID); err != nil {
|
||||
t.Fatalf("mark assigned: %v", err)
|
||||
}
|
||||
|
||||
list, err := app.ListInboxNodes()
|
||||
if err != nil {
|
||||
t.Fatalf("ListInboxNodes: %v", err)
|
||||
}
|
||||
|
||||
got := map[string]bool{}
|
||||
for _, item := range list {
|
||||
got[item.ID] = true
|
||||
}
|
||||
if !got[unassigned.ID] {
|
||||
t.Fatal("unassigned root missing from inbox")
|
||||
}
|
||||
if !got[inbox.ID] {
|
||||
t.Fatal("section=inbox root missing from inbox")
|
||||
}
|
||||
if got[assigned.ID] {
|
||||
t.Fatal("assigned root should not be in inbox")
|
||||
}
|
||||
if got[child.ID] {
|
||||
t.Fatal("nested child should not be in inbox")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user