feat: refs #8197 better leftMenu and VnCardMain improvements
gitea/salix-front/pipeline/pr-master There was a failure building this commit
Details
gitea/salix-front/pipeline/pr-master There was a failure building this commit
Details
This commit is contained in:
parent
1b1aa8e488
commit
5d744ca456
|
@ -92,13 +92,11 @@ function findMatches(search, item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addChildren(module, route, parent) {
|
function addChildren(module, route, parent) {
|
||||||
if (route.menus) {
|
if (!route?.meta?.menu) return;
|
||||||
const mainMenus = route.menus[props.source];
|
const matches = findMatches(route.meta.menu, route);
|
||||||
const matches = findMatches(mainMenus, route);
|
|
||||||
|
|
||||||
for (const child of matches) {
|
for (const child of matches) {
|
||||||
navigation.addMenuItem(module, child, parent);
|
navigation.addMenuItem(module, child, parent);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,15 +118,14 @@ function getRoutes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.source === 'card') {
|
if (props.source === 'card') {
|
||||||
const currentRoute = route.matched[1];
|
let menuRoute;
|
||||||
const currentModule = toLowerCamel(currentRoute.name);
|
let index = route.matched.length - 1;
|
||||||
const moduleDef = routes.find(
|
|
||||||
(route) => toLowerCamel(route.name) === currentModule
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!moduleDef) return;
|
while (!menuRoute && index > 0) {
|
||||||
|
if (route.matched[index]?.meta?.menu) menuRoute = route.matched[index];
|
||||||
addChildren(currentModule, moduleDef, items.value);
|
index--;
|
||||||
|
}
|
||||||
|
addChildren('', menuRoute, items.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ let root = ref(null);
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
matched.value = currentRoute.value.matched.filter(
|
matched.value = currentRoute.value.matched.filter(
|
||||||
(matched) => Object.keys(matched.meta).length
|
(matched) => !!matched?.meta?.title || !!matched?.meta?.icon
|
||||||
);
|
);
|
||||||
breadcrumbs.value.length = 0;
|
breadcrumbs.value.length = 0;
|
||||||
if (!matched.value[0]) return;
|
if (!matched.value[0]) return;
|
||||||
|
|
|
@ -2,25 +2,78 @@
|
||||||
import LeftMenu from '../LeftMenu.vue';
|
import LeftMenu from '../LeftMenu.vue';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import RightMenu from './RightMenu.vue';
|
import RightMenu from './RightMenu.vue';
|
||||||
|
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||||
|
import VnTableFilter from '../VnTable/VnTableFilter.vue';
|
||||||
|
import { onBeforeMount } from 'vue';
|
||||||
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
|
|
||||||
defineProps({
|
const $props = defineProps({
|
||||||
section: {
|
section: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
dataKey: {
|
||||||
|
type: String,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
searchBar: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
prefix: {
|
||||||
|
type: String,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
rightFilter: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
columns: {
|
||||||
|
type: Array,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
arrayDataProps: {
|
||||||
|
type: Object,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeMount(() => {
|
||||||
|
if ($props.dataKey)
|
||||||
|
useArrayData($props.dataKey, {
|
||||||
|
searchUrl: 'table',
|
||||||
|
...$props.arrayDataProps,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<slot name="searchbar" />
|
<slot name="searchbar">
|
||||||
|
<VnSearchbar
|
||||||
|
v-if="searchBar"
|
||||||
|
v-bind="arrayDataProps"
|
||||||
|
:data-key="dataKey"
|
||||||
|
:label="$t(`${prefix}.search`)"
|
||||||
|
:info="$t(`${prefix}.searchInfo`)"
|
||||||
|
/>
|
||||||
|
</slot>
|
||||||
|
|
||||||
<Teleport to="#left-panel" v-if="stateStore.isHeaderMounted()">
|
<Teleport to="#left-panel" v-if="stateStore.isHeaderMounted()">
|
||||||
<LeftMenu v-if="section == $route.name" />
|
<LeftMenu v-if="section == $route.name" />
|
||||||
</Teleport>
|
</Teleport>
|
||||||
<slot name="body" v-if="section == $route.name" />
|
|
||||||
<RouterView v-else />
|
|
||||||
<RightMenu>
|
<RightMenu>
|
||||||
<template #right-panel v-if="$slots['rightMenu']">
|
<template #right-panel v-if="$slots['rightMenu'] || rightFilter">
|
||||||
<slot name="rightMenu" />
|
<slot name="rightMenu">
|
||||||
|
<VnTableFilter
|
||||||
|
v-if="rightFilter && columns"
|
||||||
|
:data-key="dataKey"
|
||||||
|
:columns="columns"
|
||||||
|
/>
|
||||||
|
</slot>
|
||||||
</template>
|
</template>
|
||||||
</RightMenu>
|
</RightMenu>
|
||||||
|
|
||||||
|
<slot name="body" v-if="section == $route.name" />
|
||||||
|
<RouterView v-else />
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,22 +1,17 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { ref, computed, onBeforeMount } from 'vue';
|
import { computed } from 'vue';
|
||||||
import VnTable from 'components/VnTable/VnTable.vue';
|
import VnTable from 'components/VnTable/VnTable.vue';
|
||||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
|
||||||
import AccountSummary from './Card/AccountSummary.vue';
|
import AccountSummary from './Card/AccountSummary.vue';
|
||||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||||
import VnCardMain from 'src/components/common/VnCardMain.vue';
|
import VnCardMain from 'src/components/common/VnCardMain.vue';
|
||||||
import VnTableFilter from 'src/components/VnTable/VnTableFilter.vue';
|
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { viewSummary } = useSummaryDialog();
|
const { viewSummary } = useSummaryDialog();
|
||||||
const tableRef = ref();
|
|
||||||
const filter = {
|
const filter = {
|
||||||
include: { relation: 'role', scope: { fields: ['id', 'name'] } },
|
include: { relation: 'role', scope: { fields: ['id', 'name'] } },
|
||||||
};
|
};
|
||||||
const dataKey = 'AccountList';
|
const dataKey = 'AccountList';
|
||||||
const url = 'VnUsers/preview';
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
@ -87,15 +82,6 @@ const columns = computed(() => [
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
onBeforeMount(() => {
|
|
||||||
useArrayData(dataKey, {
|
|
||||||
url,
|
|
||||||
userFilter: filter,
|
|
||||||
order: 'id DESC',
|
|
||||||
exprBuilder,
|
|
||||||
searchUrl: 'table',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
function exprBuilder(param, value) {
|
function exprBuilder(param, value) {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case 'search':
|
case 'search':
|
||||||
|
@ -117,17 +103,20 @@ function exprBuilder(param, value) {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnCardMain :section="dataKey">
|
<VnCardMain
|
||||||
<template #searchbar>
|
:section="dataKey"
|
||||||
<VnSearchbar
|
:data-key="dataKey"
|
||||||
:data-key="dataKey"
|
:columns="columns"
|
||||||
:label="t('account.search')"
|
prefix="account"
|
||||||
:info="t('account.searchInfo')"
|
:array-data-props="{
|
||||||
/>
|
url: 'VnUsers/preview',
|
||||||
</template>
|
userFilter: filter,
|
||||||
|
order: 'id DESC',
|
||||||
|
exprBuilder,
|
||||||
|
}"
|
||||||
|
>
|
||||||
<template #body>
|
<template #body>
|
||||||
<VnTable
|
<VnTable
|
||||||
ref="tableRef"
|
|
||||||
:data-key="dataKey"
|
:data-key="dataKey"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
default-mode="table"
|
default-mode="table"
|
||||||
|
@ -136,9 +125,6 @@ function exprBuilder(param, value) {
|
||||||
:right-search="false"
|
:right-search="false"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #rightMenu>
|
|
||||||
<VnTableFilter :data-key="dataKey" :columns="columns" />
|
|
||||||
</template>
|
|
||||||
</VnCardMain>
|
</VnCardMain>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { useI18n } from 'vue-i18n';
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import VnTable from 'components/VnTable/VnTable.vue';
|
import VnTable from 'components/VnTable/VnTable.vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
|
||||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||||
import RoleSummary from './Card/RoleSummary.vue';
|
import RoleSummary from './Card/RoleSummary.vue';
|
||||||
import VnCardMain from 'src/components/common/VnCardMain.vue';
|
import VnCardMain from 'src/components/common/VnCardMain.vue';
|
||||||
|
@ -86,21 +85,17 @@ const exprBuilder = (param, value) => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnCardMain :section="dataKey">
|
<VnCardMain
|
||||||
<template #searchbar>
|
:section="dataKey"
|
||||||
<VnSearchbar
|
:data-key="dataKey"
|
||||||
:url="url"
|
:columns="columns"
|
||||||
:data-key="dataKey"
|
prefix="role"
|
||||||
:expr-builder="exprBuilder"
|
:array-data-props="{ url, exprBuilder, order: 'id ASC' }"
|
||||||
:label="t('role.searchRoles')"
|
>
|
||||||
:info="t('role.searchInfo')"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template #body>
|
<template #body>
|
||||||
<VnTable
|
<VnTable
|
||||||
ref="tableRef"
|
ref="tableRef"
|
||||||
:data-key="dataKey"
|
:data-key="dataKey"
|
||||||
:url="url"
|
|
||||||
:create="{
|
:create="{
|
||||||
urlCreate: 'VnRoles',
|
urlCreate: 'VnRoles',
|
||||||
title: t('Create rol'),
|
title: t('Create rol'),
|
||||||
|
@ -109,7 +104,6 @@ const exprBuilder = (param, value) => {
|
||||||
editorFk: entityId,
|
editorFk: entityId,
|
||||||
},
|
},
|
||||||
}"
|
}"
|
||||||
order="id ASC"
|
|
||||||
:disable-option="{ card: true }"
|
:disable-option="{ card: true }"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
default-mode="table"
|
default-mode="table"
|
||||||
|
|
|
@ -66,7 +66,7 @@ account:
|
||||||
mailInputInfo: All emails will be forwarded to the specified address.
|
mailInputInfo: All emails will be forwarded to the specified address.
|
||||||
role:
|
role:
|
||||||
newRole: New role
|
newRole: New role
|
||||||
searchRoles: Search role
|
search: Search role
|
||||||
searchInfo: Search role by id or name
|
searchInfo: Search role by id or name
|
||||||
description: Description
|
description: Description
|
||||||
id: Id
|
id: Id
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { RouterView } from 'vue-router';
|
import { RouterView } from 'vue-router';
|
||||||
import accountCard from './account/accountCard';
|
import accountCard from './account/accountCard';
|
||||||
import roleCard from './account/roleCard';
|
import roleCard from './account/roleCard';
|
||||||
import getSections from 'src/utils/getSections';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
path: '/account',
|
path: '/account',
|
||||||
|
@ -11,11 +10,7 @@ export default {
|
||||||
icon: 'face',
|
icon: 'face',
|
||||||
moduleName: 'Account',
|
moduleName: 'Account',
|
||||||
keyBinding: 'u',
|
keyBinding: 'u',
|
||||||
},
|
menu: [
|
||||||
component: RouterView,
|
|
||||||
redirect: { name: 'AccountMain' },
|
|
||||||
menus: {
|
|
||||||
main: [
|
|
||||||
'AccountList',
|
'AccountList',
|
||||||
'AccountAliasList',
|
'AccountAliasList',
|
||||||
'AccountRoles',
|
'AccountRoles',
|
||||||
|
@ -25,8 +20,9 @@ export default {
|
||||||
'AccountAcls',
|
'AccountAcls',
|
||||||
'AccountConnections',
|
'AccountConnections',
|
||||||
],
|
],
|
||||||
card: getSections(accountCard.children),
|
|
||||||
},
|
},
|
||||||
|
component: RouterView,
|
||||||
|
redirect: { name: 'AccountMain' },
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
|
|
|
@ -3,6 +3,16 @@ export default {
|
||||||
path: ':id',
|
path: ':id',
|
||||||
redirect: { name: 'AccountSummary' },
|
redirect: { name: 'AccountSummary' },
|
||||||
component: () => import('src/pages/Account/Card/AccountCard.vue'),
|
component: () => import('src/pages/Account/Card/AccountCard.vue'),
|
||||||
|
meta: {
|
||||||
|
menu: [
|
||||||
|
'AccountBasicData',
|
||||||
|
'AccountInheritedRoles',
|
||||||
|
'AccountMailForwarding',
|
||||||
|
'AccountMailAlias',
|
||||||
|
'AccountPrivileges',
|
||||||
|
'AccountLog',
|
||||||
|
],
|
||||||
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
name: 'AccountSummary',
|
name: 'AccountSummary',
|
||||||
|
|
|
@ -3,6 +3,9 @@ export default {
|
||||||
path: ':id',
|
path: ':id',
|
||||||
component: () => import('src/pages/Account/Role/Card/RoleCard.vue'),
|
component: () => import('src/pages/Account/Role/Card/RoleCard.vue'),
|
||||||
redirect: { name: 'RoleSummary' },
|
redirect: { name: 'RoleSummary' },
|
||||||
|
meta: {
|
||||||
|
menu: ['RoleBasicData', 'SubRoles', 'InheritedRoles', 'RoleLog'],
|
||||||
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
name: 'RoleSummary',
|
name: 'RoleSummary',
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
export default (sections) => {
|
|
||||||
const names = [];
|
|
||||||
for (const section of sections) {
|
|
||||||
if (section.path == 'summary') continue;
|
|
||||||
names.push(section.name);
|
|
||||||
}
|
|
||||||
return names;
|
|
||||||
};
|
|
Loading…
Reference in New Issue