CoreID/app/services/cobalt.service.js
2020-05-11 20:26:09 -05:00

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