[plugins]: Allow ordering menu links, fixes #10
This commit is contained in:
parent
1c36399ac0
commit
fe1fae10f5
10
package.json
10
package.json
|
@ -19,13 +19,13 @@
|
|||
"@flaschengeist/users": "^1.0.0-alpha.1",
|
||||
"axios": "^0.21.1",
|
||||
"cordova": "^10.0.0",
|
||||
"pinia": "^2.0.0-beta.3",
|
||||
"quasar": "^2.0.1"
|
||||
"pinia": "2.0.0-beta.5",
|
||||
"quasar": "^2.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@flaschengeist/types": "^1.0.0-alpha.1",
|
||||
"@quasar/app": "^3.0.1",
|
||||
"@quasar/extras": "^1.10.7",
|
||||
"@flaschengeist/types": "^1.0.0-alpha.2",
|
||||
"@quasar/app": "^3.0.3",
|
||||
"@quasar/extras": "^1.10.9",
|
||||
"@types/node": "^12.20.15",
|
||||
"@types/webpack": "^5.28.0",
|
||||
"@types/webpack-env": "^1.16.0",
|
||||
|
|
|
@ -118,11 +118,7 @@ function combineMenuRoutes(
|
|||
target.children = [];
|
||||
}
|
||||
convertRoutes(sourceMainConfig.route, sourceMainConfig.children);
|
||||
if (
|
||||
sourceMainConfig.children &&
|
||||
sourceMainConfig.children.length > 0 &&
|
||||
!sourceMainConfig.route.component
|
||||
)
|
||||
if (sourceMainConfig.children && sourceMainConfig.children.length > 0 && !sourceMainConfig.route.component)
|
||||
Object.assign(sourceMainConfig.route, {
|
||||
component: () => import('src/components/navigation/EmptyParent.vue'),
|
||||
});
|
||||
|
@ -134,20 +130,14 @@ function combineMenuRoutes(
|
|||
return target;
|
||||
}
|
||||
|
||||
function combineRoutes(
|
||||
target: RouteRecordRaw[],
|
||||
source: FG_Plugin.NamedRouteRecordRaw[],
|
||||
mainPath: '/' | '/in'
|
||||
) {
|
||||
function combineRoutes(target: RouteRecordRaw[], source: FG_Plugin.NamedRouteRecordRaw[], mainPath: '/' | '/in') {
|
||||
// Search parent
|
||||
target.forEach((target) => {
|
||||
if (target.path === mainPath) {
|
||||
// Parent found = target
|
||||
source.forEach((sourceRoute) => {
|
||||
// Check if source is already in target
|
||||
const targetRoot = target.children?.find(
|
||||
(targetRoot) => sourceRoute.path === targetRoot.path
|
||||
);
|
||||
const targetRoot = target.children?.find((targetRoot) => sourceRoute.path === targetRoot.path);
|
||||
// Already in target routes, add only children
|
||||
if (targetRoot) {
|
||||
if (targetRoot.children === undefined) targetRoot.children = [];
|
||||
|
@ -155,11 +145,7 @@ function combineRoutes(
|
|||
} else {
|
||||
// Append to target
|
||||
if (target.children === undefined) target.children = [];
|
||||
if (
|
||||
sourceRoute.children &&
|
||||
sourceRoute.children.length > 0 &&
|
||||
sourceRoute.component === undefined
|
||||
)
|
||||
if (sourceRoute.children && sourceRoute.children.length > 0 && sourceRoute.component === undefined)
|
||||
Object.assign(sourceRoute, {
|
||||
component: () => import('src/components/navigation/EmptyParent.vue'),
|
||||
});
|
||||
|
@ -225,11 +211,7 @@ function combineShortcuts(target: FG_Plugin.Shortcut[], source: FG_Plugin.MenuRo
|
|||
* @param plugin Plugin to load
|
||||
* @param router VueRouter instance
|
||||
*/
|
||||
function loadPlugin(
|
||||
loadedPlugins: FG_Plugin.Flaschengeist,
|
||||
plugin: FG_Plugin.Plugin,
|
||||
backend: Backend
|
||||
) {
|
||||
function loadPlugin(loadedPlugins: FG_Plugin.Flaschengeist, plugin: FG_Plugin.Plugin, backend: Backend) {
|
||||
// Check if already loaded
|
||||
if (loadedPlugins.plugins.findIndex((p) => p.name === plugin.name) !== -1) return true;
|
||||
|
||||
|
@ -238,8 +220,7 @@ function loadPlugin(
|
|||
!plugin.requiredModules.every(
|
||||
(required) =>
|
||||
backend.plugins[required[0]] !== undefined &&
|
||||
(required.length == 1 ||
|
||||
true) /* validate the version, semver440 from python is... tricky on node*/
|
||||
(required.length == 1 || true) /* validate the version, semver440 from python is... tricky on node*/
|
||||
)
|
||||
) {
|
||||
console.error(`Plugin ${plugin.name}: Backend modules not satisfied`);
|
||||
|
@ -333,7 +314,13 @@ export default boot(async ({ router, app }) => {
|
|||
}
|
||||
|
||||
// Sort widgets by priority
|
||||
loadedPlugins.widgets.sort((a, b) => b.priority - a.priority);
|
||||
/** @todo Remove priority with first beta */
|
||||
loadedPlugins.widgets.sort((a, b) => <number>(b.order || b.priority) - <number>(a.order || a.priority));
|
||||
/** @todo Can be cleaned up with first beta */
|
||||
loadedPlugins.menuLinks.sort((a, b) => {
|
||||
const diff = a.order && b.order ? b.order - a.order : 0;
|
||||
return diff ? diff : a.title.toString().localeCompare(b.title.toString());
|
||||
});
|
||||
|
||||
// Add loaded routes to router
|
||||
loadedPlugins.routes.forEach((route) => router.addRoute(route));
|
||||
|
|
|
@ -145,8 +145,7 @@ export default defineComponent({
|
|||
Notify.create({
|
||||
group: false,
|
||||
type: 'ongoing',
|
||||
message:
|
||||
'Sollte der Benutzername korrekt und vorhanden sein, erhälst du jetzt eine E-Mail.',
|
||||
message: 'Sollte der Benutzername korrekt und vorhanden sein, erhälst du jetzt eine E-Mail.',
|
||||
timeout: 10000,
|
||||
progress: true,
|
||||
actions: [{ icon: 'mdi-close', color: 'white' }],
|
||||
|
|
|
@ -46,8 +46,7 @@ export default defineComponent({
|
|||
const ival = setInterval(() => {
|
||||
reload.value -= 1;
|
||||
if (reload.value <= 0) {
|
||||
if (router.currentRoute.value.params && 'refresh' in router.currentRoute.value.params)
|
||||
router.go(0);
|
||||
if (router.currentRoute.value.params && 'refresh' in router.currentRoute.value.params) router.go(0);
|
||||
const path = router.currentRoute.value.query.redirect;
|
||||
void router.replace(path ? { path: <string>path } : { name: 'login' });
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue