31 lines
876 B
JavaScript
31 lines
876 B
JavaScript
const { Service } = require('flitter-di')
|
|
|
|
class CobaltService extends Service {
|
|
static get services() {
|
|
return [...super.services, 'Vue']
|
|
}
|
|
|
|
listing(req, res, { title = '', columns, data = [], resource = '', actions = [] }) {
|
|
return res.page('cobalt:listing', {
|
|
...this.Vue.data({ definition: { title, columns, data, resource, actions } }),
|
|
...this.Vue.session(req),
|
|
})
|
|
}
|
|
|
|
form(req, res, { item, plural = undefined, resource, fields }) {
|
|
return res.page('cobalt:form', {
|
|
...this.Vue.data({
|
|
definition: {
|
|
item,
|
|
plural: plural ?? `${item}s`,
|
|
resource,
|
|
fields,
|
|
}
|
|
}),
|
|
...this.Vue.session(req),
|
|
})
|
|
}
|
|
}
|
|
|
|
module.exports = exports = CobaltService
|