Files
mixtape/zero.Backoffice.UI/old_app/pages/settings/routes.js
T

122 lines
2.7 KiB
JavaScript
Raw Normal View History

2020-10-16 14:02:10 +02:00
const alias = __zero.alias.sections.settings;
const section = __zero.sections.find(x => x.alias === alias);
let settings = [];
let routes = [];
2020-04-13 02:49:11 +02:00
2020-10-16 14:02:10 +02:00
__zero.settingsAreas.forEach(group => group.items.forEach(area =>
{
if (!area.isPlugin)
{
settings.push(area);
}
}));
const addArea = (areaAlias, component, detailComponent, hasCreate, postCreate) =>
{
let area = typeof areaAlias === 'object' ? areaAlias : settings.find(x => x.alias === areaAlias);
2020-12-10 19:57:23 +01:00
if (!area)
{
return;
}
2020-10-16 14:02:10 +02:00
routes.push({
name: area.alias,
path: area.url,
component: component,
meta: {
name: area.name
2020-10-16 14:02:10 +02:00
}
});
if (detailComponent && hasCreate)
{
routes.push({
name: area.alias + '-create',
path: area.url + '/create/:scope?',
2020-10-19 22:47:10 +02:00
props: true,
2020-10-16 14:02:10 +02:00
component: detailComponent,
meta: {
create: true,
name: area.name
2020-10-16 14:02:10 +02:00
}
});
}
if (detailComponent)
{
routes.push({
name: area.alias + '-edit',
path: area.url + '/edit/:id',
2020-10-19 22:47:10 +02:00
props: true,
2020-10-16 14:02:10 +02:00
component: detailComponent,
meta: {
name: area.name
2020-10-16 14:02:10 +02:00
}
});
}
if (typeof postCreate === 'function')
{
postCreate(area);
}
};
2020-04-24 12:46:25 +02:00
if (section)
{
2020-10-16 14:02:10 +02:00
// add overview page
routes.push({
name: section.alias,
path: section.url,
component: () => import('./settings.vue'),
2020-10-16 14:02:10 +02:00
meta: {
name: section.name,
alias: section.alias,
section: section
}
});
// add details
addArea(__zero.alias.settings.applications, () => import('./applications.vue'), () => import('./application.vue'), true);
2020-10-16 14:02:10 +02:00
addArea(__zero.alias.settings.countries, () => import('./countries.vue'), () => import('./country.vue'), true);
2020-10-16 14:02:10 +02:00
addArea(__zero.alias.settings.languages, () => import('./languages.vue'), () => import('./language.vue'), true);
2020-10-16 14:02:10 +02:00
addArea(__zero.alias.settings.translations, () => import('./translations.vue'), () => import('./translations.vue'), true);
2020-10-16 14:02:10 +02:00
addArea(__zero.alias.settings.mails, () => import('./mails.vue'), () => import('./mail.vue'), true);
2020-11-13 12:24:07 +01:00
addArea(__zero.alias.settings.integrations, () => import('./integrations.vue'));
2020-12-10 15:57:59 +01:00
addArea(__zero.alias.settings.users, () => import('./users.vue'), () => import('./user.vue'), true, area =>
2020-04-13 02:49:11 +02:00
{
2020-10-16 14:02:10 +02:00
routes.push({
name: 'roles-create',
path: '/' + section.alias + '/roles/create/:scope?',
2020-10-19 22:47:10 +02:00
props: true,
component: () => import('./role.vue'),
2020-10-16 14:02:10 +02:00
meta: {
create: true,
name: area.name
2020-04-24 12:46:25 +02:00
}
2020-10-16 14:02:10 +02:00
});
2020-04-24 12:46:25 +02:00
2020-10-16 14:02:10 +02:00
routes.push({
name: 'roles-edit',
path: '/' + section.alias + '/roles/edit/:id',
2020-10-19 22:47:10 +02:00
props: true,
component: () => import('./role.vue'),
2020-10-16 14:02:10 +02:00
meta: {
name: area.name
2020-10-16 14:02:10 +02:00
}
});
});
}
2020-10-16 14:02:10 +02:00
export default routes;