refactor: refs #8197 adapt AccountAlias
gitea/salix-front/pipeline/pr-master There was a failure building this commit Details

This commit is contained in:
Alex Moreno 2024-12-16 09:47:46 +01:00
parent 5d744ca456
commit 18fd41b82b
6 changed files with 85 additions and 104 deletions

View File

@ -2,21 +2,12 @@
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { ref, computed } from 'vue'; import { ref, 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 VnCardMain from 'src/components/common/VnCardMain.vue';
import { useStateStore } from 'stores/useStateStore';
const tableRef = ref(); const tableRef = ref();
const { t } = useI18n(); const { t } = useI18n();
const stateStore = useStateStore(); const dataKey = 'AccountAliasList';
const exprBuilder = (param, value) => {
switch (param) {
case 'search':
return /^\d+$/.test(value)
? { id: value }
: { alias: { like: `%${value}%` } };
}
};
const columns = computed(() => [ const columns = computed(() => [
{ {
align: 'left', align: 'left',
@ -40,40 +31,46 @@ const columns = computed(() => [
create: true, create: true,
}, },
]); ]);
const exprBuilder = (param, value) => {
switch (param) {
case 'search':
return /^\d+$/.test(value)
? { id: value }
: { alias: { like: `%${value}%` } };
}
};
</script> </script>
<template> <template>
<template v-if="stateStore.isHeaderMounted()"> <VnCardMain
<Teleport to="#searchbar"> :section="dataKey"
<VnSearchbar :data-key="dataKey"
data-key="AccountAliasList"
url="MailAliases"
:expr-builder="exprBuilder"
:label="t('mailAlias.search')"
:info="t('mailAlias.searchInfo')"
/>
</Teleport>
</template>
<VnTable
ref="tableRef"
data-key="AccountAliasList"
url="MailAliases"
:create="{
urlCreate: 'MailAliases',
title: 'Create MailAlias',
onDataSaved: ({ id }) => tableRef.redirect(id),
formInitialData: {},
}"
order="id DESC"
:columns="columns" :columns="columns"
:disable-option="{ card: true }" prefix="mailAlias"
default-mode="table" :array-data-props="{ url: 'MailAliases', order: 'id DESC', exprBuilder }"
redirect="account/alias" >
:is-editable="true" <template #body>
:use-model="true" <VnTable
/> :data-key="dataKey"
ref="tableRef"
:create="{
urlCreate: 'MailAliases',
title: 'Create MailAlias',
onDataSaved: ({ id }) => tableRef.redirect(id),
formInitialData: {},
}"
:columns="columns"
:disable-option="{ card: true }"
default-mode="table"
redirect="account/alias"
:is-editable="true"
:use-model="true"
:right-search="false"
/>
</template>
</VnCardMain>
</template> </template>
<i18n> <i18n>
es: es:
Id: Id Id: Id

View File

@ -1,6 +1,7 @@
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 aliasCard from './account/aliasCard';
export default { export default {
path: '/account', path: '/account',
@ -12,8 +13,8 @@ export default {
keyBinding: 'u', keyBinding: 'u',
menu: [ menu: [
'AccountList', 'AccountList',
'AccountAliasList',
'AccountRoles', 'AccountRoles',
'AccountAlias',
'AccountAccounts', 'AccountAccounts',
'AccountLdap', 'AccountLdap',
'AccountSamba', 'AccountSamba',
@ -65,13 +66,21 @@ export default {
], ],
}, },
{ {
path: 'alias-list', path: 'alias',
name: 'AccountAliasList', name: 'AccountAlias',
redirect: { name: 'AccountAliasList' },
meta: { meta: {
title: 'alias', title: 'alias',
icon: 'email', icon: 'email',
}, },
component: () => import('src/pages/Account/AccountAliasList.vue'), component: () => import('src/pages/Account/AccountAliasList.vue'),
children: [
{
name: 'AccountAliasList',
path: 'list',
},
aliasCard,
],
}, },
{ {
path: 'acls', path: 'acls',

View File

@ -0,0 +1,36 @@
export default {
name: 'AliasCard',
path: ':id',
component: () => import('src/pages/Account/Alias/Card/AliasCard.vue'),
redirect: { name: 'AliasSummary' },
meta: { menu: ['AliasBasicData', 'AliasUsers'] },
children: [
{
name: 'AliasSummary',
path: 'summary',
meta: {
title: 'summary',
icon: 'launch',
},
component: () => import('src/pages/Account/Alias/Card/AliasSummary.vue'),
},
{
name: 'AliasBasicData',
path: 'basic-data',
meta: {
title: 'basicData',
icon: 'vn:settings',
},
component: () => import('src/pages/Account/Alias/Card/AliasBasicData.vue'),
},
{
name: 'AliasUsers',
path: 'users',
meta: {
title: 'aliasUsers',
icon: 'group',
},
component: () => import('src/pages/Account/Alias/Card/AliasUsers.vue'),
},
],
};

View File

@ -20,7 +20,6 @@ import ItemType from './itemType';
import Zone from './zone'; import Zone from './zone';
import Account from './account'; import Account from './account';
import Monitor from './monitor'; import Monitor from './monitor';
import MailAlias from './mailAlias';
export default [ export default [
Item, Item,
@ -44,6 +43,5 @@ export default [
ItemType, ItemType,
Zone, Zone,
Account, Account,
MailAlias,
Monitor, Monitor,
]; ];

View File

@ -1,57 +0,0 @@
import { RouterView } from 'vue-router';
export default {
path: 'account/alias',
name: 'Alias',
meta: {
title: 'alias',
icon: 'email',
moduleName: 'Alias',
},
component: RouterView,
redirect: { name: 'AccountAliasList' },
menus: {
main: [],
card: ['AliasBasicData', 'AliasUsers'],
},
children: [
{
name: 'AliasCard',
path: ':id',
component: () => import('src/pages/Account/Alias/Card/AliasCard.vue'),
redirect: { name: 'AliasSummary' },
children: [
{
name: 'AliasSummary',
path: 'summary',
meta: {
title: 'summary',
icon: 'launch',
},
component: () =>
import('src/pages/Account/Alias/Card/AliasSummary.vue'),
},
{
name: 'AliasBasicData',
path: 'basic-data',
meta: {
title: 'basicData',
icon: 'vn:settings',
},
component: () =>
import('src/pages/Account/Alias/Card/AliasBasicData.vue'),
},
{
name: 'AliasUsers',
path: 'users',
meta: {
title: 'aliasUsers',
icon: 'group',
},
component: () =>
import('src/pages/Account/Alias/Card/AliasUsers.vue'),
},
],
},
],
};

View File

@ -20,7 +20,6 @@ import agency from 'src/router/modules/agency';
import zone from 'src/router/modules/zone'; import zone from 'src/router/modules/zone';
import account from './modules/account'; import account from './modules/account';
import monitor from 'src/router/modules/monitor'; import monitor from 'src/router/modules/monitor';
import mailAlias from './modules/mailAlias';
const routes = [ const routes = [
{ {
@ -94,7 +93,6 @@ const routes = [
ItemType, ItemType,
zone, zone,
account, account,
mailAlias,
{ {
path: '/:catchAll(.*)*', path: '/:catchAll(.*)*',
name: 'NotFound', name: 'NotFound',