CoreID/app/services/cobalt.service.js

31 lines
876 B
JavaScript
Raw Permalink Normal View History

2020-05-04 01:16:54 +00:00
const { Service } = require('flitter-di')
class CobaltService extends Service {
static get services() {
return [...super.services, 'Vue']
}
2020-05-12 01:26:09 +00:00
listing(req, res, { title = '', columns, data = [], resource = '', actions = [] }) {
2020-05-04 01:16:54 +00:00
return res.page('cobalt:listing', {
2020-05-12 01:26:09 +00:00
...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,
}
}),
2020-05-04 01:16:54 +00:00
...this.Vue.session(req),
})
}
}
module.exports = exports = CobaltService