Include child nodes in menu tree (Noded/frontend#17)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
604753b3ff
commit
2a5e3419e8
@ -24,6 +24,7 @@ class Menu extends Controller {
|
||||
children: nodes,
|
||||
noDelete: true,
|
||||
virtual: true,
|
||||
type: 'branch',
|
||||
})
|
||||
|
||||
// Get view only shared trees
|
||||
@ -36,6 +37,7 @@ class Menu extends Controller {
|
||||
name: tree.Name,
|
||||
children: await this._build_secure_menu_object(tree, req.user),
|
||||
level: await tree.access_level_for(req.user),
|
||||
type: 'page',
|
||||
})
|
||||
}
|
||||
|
||||
@ -49,6 +51,7 @@ class Menu extends Controller {
|
||||
name: tree.Name,
|
||||
children: await this._build_secure_menu_object(tree, req.user),
|
||||
level: await tree.access_level_for(req.user),
|
||||
type: 'page',
|
||||
})
|
||||
}
|
||||
|
||||
@ -62,6 +65,7 @@ class Menu extends Controller {
|
||||
name: tree.Name,
|
||||
children: await this._build_secure_menu_object(tree, req.user),
|
||||
level: await tree.access_level_for(req.user),
|
||||
type: 'page',
|
||||
})
|
||||
}
|
||||
|
||||
@ -71,6 +75,7 @@ class Menu extends Controller {
|
||||
children: [...view_only_nodes, ...update_nodes, ...manage_nodes],
|
||||
noDelete: true,
|
||||
virtual: true,
|
||||
type: 'branch',
|
||||
})
|
||||
|
||||
return res.api(menu)
|
||||
@ -84,7 +89,8 @@ class Menu extends Controller {
|
||||
id: child.UUID,
|
||||
name: child.is_shared() ? child.Name + ' ⁽ˢʰᵃʳᵉᵈ⁾' : child.Name,
|
||||
shared: child.is_shared(),
|
||||
children: await this._build_menu_object(child),
|
||||
children: [...(await child.get_menu_items()), ...(await this._build_menu_object(child))],
|
||||
type: 'page',
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -102,6 +108,7 @@ class Menu extends Controller {
|
||||
name: child.Name,
|
||||
children: await this._build_secure_menu_object(child, user),
|
||||
level: await child.access_level_for(user),
|
||||
type: 'page',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -221,6 +221,52 @@ class Page extends Model {
|
||||
await user.save()
|
||||
}
|
||||
|
||||
async get_menu_items() {
|
||||
// {
|
||||
// id: child.UUID,
|
||||
// name: child.is_shared() ? child.Name + ' ⁽ˢʰᵃʳᵉᵈ⁾' : child.Name,
|
||||
// shared: child.is_shared(),
|
||||
// children: await this._build_menu_object(child),
|
||||
// type: 'page',
|
||||
// }
|
||||
|
||||
// Databases & Code Snips
|
||||
const children = []
|
||||
|
||||
const Database = this.models.get('api:db:Database')
|
||||
const dbs = await Database.find({
|
||||
Active: true,
|
||||
PageId: this.UUID,
|
||||
})
|
||||
|
||||
for ( const db of dbs ) {
|
||||
children.push({
|
||||
id: db.PageId,
|
||||
node_id: db.NodeId,
|
||||
children: [],
|
||||
type: 'db',
|
||||
name: db.Name,
|
||||
})
|
||||
}
|
||||
|
||||
const Codium = this.models.get('api:Codium')
|
||||
const codiums = await Codium.find({
|
||||
PageId: this.UUID,
|
||||
})
|
||||
|
||||
for ( const codium of codiums ) {
|
||||
children.push({
|
||||
id: codium.PageId,
|
||||
node_id: codium.NodeId,
|
||||
children: [],
|
||||
type: 'code',
|
||||
name: codium.code.slice(0, 25) + (codium.code.length > 25 ? '...' : ''),
|
||||
})
|
||||
}
|
||||
|
||||
return children
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = exports = Page;
|
||||
|
Loading…
Reference in New Issue
Block a user