* add read only tree table and value help
* rm tree table in catalogservice
* Update cat-service.cds
* i18n and object page
* hana workaround, local messaging and rm virtual
* move hierarchy to fiori
* Update admin-service.cds
* Update common.cds
* fix after moving to fiori
* fix UI filter
* file-based-messaging in hybrid
* review fixes
* Update services.cds
* make bookshop Books fiori.draft.enabled
* add simplest handler for sqlite
* adapt test and link in csvs
* .
* Reverting to human-readable UUIDs :)
* Less obstrusive workaround
* typo
* Update fiori/app/common.cds
* Update fiori/app/common.cds
* Workaround for stupid GUID check in Fiori client
* ...
* Simplified mock support for recursive hierarchies in SQLite :)
* missing comma
* Rudimentary tree support for Genres on SQLite
* ?.
* fixed copy error
* using subselect to determine leafs
* Revert "using subselect to determine leafs"
This reverts commit f01ddaea1f.
* Using scalar subselect for DrillState
* .
---------
Co-authored-by: D070615 <[email protected]>
Co-authored-by: D045778 <[email protected]>
Co-authored-by: Daniel Hutzel <[email protected]>
33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
const cds = require('@sap/cds/lib')
|
|
if (cds.requires.db?.kind === 'sqlite') {
|
|
cds.on ('serving:AdminService', srv => srv.prepend(() => {
|
|
const {Genres} = srv.entities
|
|
// Register a simplistic handler for hierarchical queries
|
|
srv.on('READ', Genres, (req,next) => {
|
|
const q = req.query
|
|
// Expand query on a single row
|
|
if (q.SELECT.recurse?.where?.[0].ref[0] === 'Distance') {
|
|
q.SELECT.where[0] = 'parent_ID'
|
|
// Initial query
|
|
} else if (!q.SELECT.search && !is_count(q)) {
|
|
q.SELECT.where ??= [ 'parent_ID is null' ]
|
|
}
|
|
// Use scalar subselect for DrillState
|
|
q.SELECT.from.as = 'g'
|
|
q.SELECT.columns = q.SELECT.columns.map (c => {
|
|
if (c.ref == 'DrillState') return { xpr:[`
|
|
CASE WHEN ( SELECT count(1) from ${Genres} where parent_ID = g.ID ) > 0
|
|
THEN 'collapsed' ELSE 'leaf' END`
|
|
], as: 'DrillState' }
|
|
else return c
|
|
})
|
|
// Suppress error message: Feature "recurse" queries not supported.
|
|
delete q.SELECT.__proto__.recurse
|
|
delete q.SELECT.recurse
|
|
return next()
|
|
})
|
|
}))
|
|
}
|
|
|
|
const is_count = q => q.SELECT.columns?.length === 1 && q.SELECT.columns[0].func === 'count'
|