0
0
Fork 0

feat: roleCreate as dialog

This commit is contained in:
Javier Segarra 2024-05-23 13:47:14 +02:00
parent 433564507e
commit 889263bfb8
6 changed files with 54 additions and 39 deletions

View File

@ -20,7 +20,13 @@ const itemComputed = computed(() => {
}); });
</script> </script>
<template> <template>
<QItem active-class="bg-hover" :to="{ name: itemComputed.name }" clickable v-ripple> <QItem
active-class="bg-hover"
class="min-height"
:to="{ name: itemComputed.name }"
clickable
v-ripple
>
<QItemSection avatar v-if="itemComputed.icon"> <QItemSection avatar v-if="itemComputed.icon">
<QIcon :name="itemComputed.icon" /> <QIcon :name="itemComputed.icon" />
</QItemSection> </QItemSection>
@ -33,3 +39,9 @@ const itemComputed = computed(() => {
</QItemSection> </QItemSection>
</QItem> </QItem>
</template> </template>
<style lang="scss" scoped>
.q-item {
min-height: 5vh;
}
</style>

View File

@ -6,14 +6,17 @@ import { toDate } from 'filters/index';
import VnPaginate from 'src/components/ui/VnPaginate.vue'; import VnPaginate from 'src/components/ui/VnPaginate.vue';
import VnLv from 'src/components/ui/VnLv.vue'; import VnLv from 'src/components/ui/VnLv.vue';
import CardList from 'src/components/ui/CardList.vue'; import CardList from 'src/components/ui/CardList.vue';
import VnUserLink from 'src/components/ui/VnUserLink.vue';
import AccountSummary from '../Card/AccountSummary.vue'; import AccountSummary from '../Card/AccountSummary.vue';
import { ref } from 'vue';
import RoleForm from './Card/RoleForm.vue';
const stateStore = useStateStore(); const stateStore = useStateStore();
const router = useRouter(); const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
const redirectToCreateView = () => { const roleCreateDialogRef = ref(null);
router.push({ name: 'RoleCreate' });
const openCreateModal = () => {
roleCreateDialogRef.value.show();
}; };
function getApiUrl() { function getApiUrl() {
return new URL(window.location).origin; return new URL(window.location).origin;
@ -43,12 +46,15 @@ function navigate(event, id) {
v-for="row of rows" v-for="row of rows"
> >
<template #list-items> <template #list-items>
<VnLv :label="t('role.card.name')" :value="row.name"> </VnLv> <div style="flex-direction: column; width: 100%">
<VnLv <VnLv :label="t('role.card.name')" :value="row.name">
:label="t('role.card.description')" </VnLv>
:value="row.description" <VnLv
> :label="t('role.card.description')"
</VnLv> :value="row.description"
>
</VnLv>
</div>
</template> </template>
<template #actions> <template #actions>
<QBtn <QBtn
@ -69,13 +75,18 @@ function navigate(event, id) {
</template> </template>
</VnPaginate> </VnPaginate>
</div> </div>
<QDialog
ref="roleCreateDialogRef"
transition-show="scale"
transition-hide="scale"
>
<RoleForm />
</QDialog>
<QPageSticky :offset="[20, 20]"> <QPageSticky :offset="[20, 20]">
<RouterLink :to="{ name: 'RoleCreate' }"> <QBtn fab icon="add" color="primary" @click="openCreateModal()" />
<QBtn fab icon="add" color="primary" /> <QTooltip>
<QTooltip> {{ t('account.pageTitles.newRole') }}
{{ t('role.pageTitles.roleCreate') }} </QTooltip>
</QTooltip></RouterLink
>
</QPageSticky> </QPageSticky>
</QPage> </QPage>
</template> </template>

View File

@ -1,7 +1,7 @@
<script setup> <script setup>
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import FormModel from 'components/FormModel.vue'; import FormModelPopup from 'components/FormModelPopup.vue';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
@ -15,17 +15,15 @@ const defaultInitialData = {
}; };
</script> </script>
<template> <template>
<VnSubToolbar /> <FormModelPopup
<FormModel :title="t('Create role')"
:url="isNew ? null : `VnRoles/${route.params.id}`" ref="formModelPopupRef"
:url-create="isNew ? 'VnRoles' : null" url-create="VnRoles"
:observe-form-changes="!isNew"
model="VnRole" model="VnRole"
:auto-load="!isNew"
:form-initial-data="defaultInitialData" :form-initial-data="defaultInitialData"
@on-data-saved="onSave" @on-data-saved="onSave"
> >
<template #form="{ data }"> <template #form-inputs="{ data }">
<VnRow class="row q-gutter-md q-mb-md"> <VnRow class="row q-gutter-md q-mb-md">
<div class="col"> <div class="col">
<VnInput v-model="data.name" :label="t('role.card.name')" /> <VnInput v-model="data.name" :label="t('role.card.name')" />
@ -40,5 +38,10 @@ const defaultInitialData = {
</div> </div>
</VnRow> </VnRow>
</template> </template>
</FormModel> </FormModelPopup>
</template> </template>
<i18n>
es:
Create role: Crear role
</i18n>

View File

@ -11,7 +11,7 @@ account:
connections: Connections connections: Connections
inheritedRoles: Inherited Roles inheritedRoles: Inherited Roles
subRoles: Sub Roles subRoles: Sub Roles
roleCreate: New role newRole: New role
privileges: Privileges privileges: Privileges
mailAlias: Mail Alias mailAlias: Mail Alias
mailForwarding: Mail Forwarding mailForwarding: Mail Forwarding

View File

@ -10,7 +10,7 @@ account:
acls: ACLs acls: ACLs
connections: Conexiones connections: Conexiones
inheritedRoles: Roles heredados inheritedRoles: Roles heredados
roleCreate: Nuevo rol newRole: Nuevo rol
subRoles: Subroles subRoles: Subroles
privileges: Privilegios privileges: Privilegios
mailAlias: Alias de correo mailAlias: Alias de correo
@ -46,7 +46,7 @@ role:
pageTitles: pageTitles:
inheritedRoles: Roles heredados inheritedRoles: Roles heredados
subRoles: Subroles subRoles: Subroles
roleCreate: Nuevo rol newRole: Nuevo rol
card: card:
description: Descripción description: Descripción
id: Idd id: Idd

View File

@ -54,17 +54,6 @@ export default {
}, },
component: () => import('src/pages/Account/Role/AccountRoles.vue'), component: () => import('src/pages/Account/Role/AccountRoles.vue'),
}, },
{
name: 'RoleCreate',
path: 'create',
meta: {
title: 'roleCreate',
icon: 'add',
},
component: () => import('src/pages/Account/Role/Card/RoleForm.vue'),
},
{ {
path: 'alias', path: 'alias',
name: 'AccountAlias', name: 'AccountAlias',