Include child nodes in menu tree (Noded/frontend#17)
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-10-13 09:58:36 -05:00
parent 604753b3ff
commit 2a5e3419e8
2 changed files with 54 additions and 1 deletions

View File

@@ -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;