stackpress
Version:
Incept is a content management framework.
46 lines (45 loc) • 1.61 kB
JavaScript
export default function AdminDetailCreatePageFactory(model) {
return async function AdminDetailCreatePage(req, res, ctx) {
if (res.body || (res.code && res.code !== 200)) {
return;
}
const view = ctx.config.path('view', {});
const brand = ctx.config.path('brand', {});
const language = ctx.config.path('language', {
key: 'locale',
locale: 'en_US',
languages: {}
});
const admin = ctx.config.path('admin', {});
res.data.set('view', {
base: view.base || '/',
props: view.props || {}
});
res.data.set('brand', {
name: brand.name || 'Stackpress',
logo: brand.logo || '/logo.png',
icon: brand.icon || '/icon.png',
favicon: brand.favicon || '/favicon.ico'
});
res.data.set('language', {
key: language.key || 'locale',
locale: language.locale || 'en_US',
languages: language.languages || {}
});
res.data.set('admin', {
name: admin.name || 'Admin',
base: admin.base || '/admin',
menu: admin.menu || []
});
const ids = model.ids.map(column => req.data(column.name)).filter(Boolean);
if (ids.length === model.ids.length) {
const response = await ctx.resolve(`${model.dash}-detail`, req, res);
if (!res.body) {
await ctx.emit('error', req, res);
return;
}
res.setResults(response.results);
}
};
}
;