Account Submodule #412
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import { ref, onUnmounted } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
@ -376,6 +376,10 @@ async function clearFilter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
setLogTree();
|
setLogTree();
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
stateStore.rightDrawer = false;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
|
|
@ -183,5 +183,5 @@ es:
|
||||||
Unsubscribed from alias!: ¡Desuscrito del alias!
|
Unsubscribed from alias!: ¡Desuscrito del alias!
|
||||||
Subscribed to alias!: ¡Suscrito al alias!
|
Subscribed to alias!: ¡Suscrito al alias!
|
||||||
User will be removed from alias: El usuario será borrado del alias
|
User will be removed from alias: El usuario será borrado del alias
|
||||||
¿Seguro que quieres continuar?: Are you sure you want to continue?
|
Are you sure you want to continue?: ¿Seguro que quieres continuar?
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, watch } from 'vue';
|
import { ref, onMounted, watch, computed } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
|
|
||||||
|
@ -16,6 +15,7 @@ const route = useRoute();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
|
|
||||||
|
const initialData = ref({});
|
||||||
const formData = ref({
|
const formData = ref({
|
||||||
forwardTo: null,
|
forwardTo: null,
|
||||||
account: null,
|
account: null,
|
||||||
|
@ -24,6 +24,11 @@ const formData = ref({
|
||||||
const hasAccount = ref(false);
|
const hasAccount = ref(false);
|
||||||
const hasData = ref(false);
|
const hasData = ref(false);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
const hasDataChanged = computed(
|
||||||
|
() =>
|
||||||
|
formData.value.forwardTo !== initialData.value.forwardTo ||
|
||||||
|
initialData.value.hasData !== hasData.value
|
||||||
|
);
|
||||||
|
|
||||||
const fetchAccountExistence = async () => {
|
const fetchAccountExistence = async () => {
|
||||||
try {
|
try {
|
||||||
|
@ -49,6 +54,8 @@ const deleteMailForward = async () => {
|
||||||
try {
|
try {
|
||||||
await axios.delete(`MailForwards/${route.params.id}`);
|
await axios.delete(`MailForwards/${route.params.id}`);
|
||||||
formData.value.forwardTo = null;
|
formData.value.forwardTo = null;
|
||||||
|
initialData.value.forwardTo = null;
|
||||||
|
initialData.value.hasData = hasData.value;
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error deleting mail forward', err);
|
console.error('Error deleting mail forward', err);
|
||||||
|
@ -58,6 +65,8 @@ const deleteMailForward = async () => {
|
||||||
const updateMailForward = async () => {
|
const updateMailForward = async () => {
|
||||||
try {
|
try {
|
||||||
await axios.patch('MailForwards', formData.value);
|
await axios.patch('MailForwards', formData.value);
|
||||||
|
initialData.value = { ...formData.value };
|
||||||
|
initialData.value.hasData = hasData.value;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error creating mail forward', err);
|
console.error('Error creating mail forward', err);
|
||||||
}
|
}
|
||||||
|
@ -70,6 +79,7 @@ const onSubmit = async () => {
|
||||||
|
|
||||||
const setInitialData = async () => {
|
const setInitialData = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
initialData.value.account = route.params.id;
|
||||||
formData.value.account = route.params.id;
|
formData.value.account = route.params.id;
|
||||||
hasAccount.value = await fetchAccountExistence(route.params.id);
|
hasAccount.value = await fetchAccountExistence(route.params.id);
|
||||||
if (!hasAccount.value) {
|
if (!hasAccount.value) {
|
||||||
|
@ -80,7 +90,9 @@ const setInitialData = async () => {
|
||||||
const result = await fetchMailForwards(route.params.id);
|
const result = await fetchMailForwards(route.params.id);
|
||||||
const forwardTo = result ? result.forwardTo : null;
|
const forwardTo = result ? result.forwardTo : null;
|
||||||
formData.value.forwardTo = forwardTo;
|
formData.value.forwardTo = forwardTo;
|
||||||
|
initialData.value.forwardTo = forwardTo;
|
||||||
|
|
||||||
|
initialData.value.hasData = hasAccount.value && !!forwardTo;
|
||||||
hasData.value = hasAccount.value && !!forwardTo;
|
hasData.value = hasAccount.value && !!forwardTo;
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
};
|
};
|
||||||
|
@ -116,6 +128,7 @@ onMounted(async () => await setInitialData());
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="save"
|
icon="save"
|
||||||
@click="onSubmit()"
|
@click="onSubmit()"
|
||||||
|
:disable="!hasDataChanged"
|
||||||
:label="t('globals.save')"
|
:label="t('globals.save')"
|
||||||
/>
|
/>
|
||||||
</QBtnGroup>
|
</QBtnGroup>
|
||||||
|
|
|
@ -20,20 +20,23 @@ const store = arrayData.store;
|
||||||
|
|
||||||
const data = computed(() => {
|
const data = computed(() => {
|
||||||
const dataCopy = store.data;
|
const dataCopy = store.data;
|
||||||
return dataCopy.sort((a, b) => a.inherits?.name.localeCompare(b.inherits?.name));
|
return dataCopy.sort((a, b) => a.role?.name.localeCompare(b.role?.name));
|
||||||
});
|
});
|
||||||
|
|
||||||
const filter = computed(() => ({
|
const filter = computed(() => ({
|
||||||
where: { role: route.params.id },
|
where: {
|
||||||
|
prindicpalType: 'USER',
|
||||||
|
principalId: route.params.id,
|
||||||
|
},
|
||||||
include: {
|
include: {
|
||||||
relation: 'inherits',
|
relation: 'role',
|
||||||
scope: {
|
scope: {
|
||||||
fields: ['id', 'name', 'description'],
|
fields: ['id', 'name', 'description'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const urlPath = computed(() => 'RoleRoles');
|
const urlPath = 'RoleMappings';
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
|
@ -44,8 +47,9 @@ const columns = computed(() => [
|
||||||
watch(
|
watch(
|
||||||
() => route.params.id,
|
() => route.params.id,
|
||||||
() => {
|
() => {
|
||||||
store.url = urlPath.value;
|
store.url = urlPath;
|
||||||
store.filter = filter.value;
|
store.filter = filter.value;
|
||||||
|
store.limit = 0;
|
||||||
fetchSubRoles();
|
fetchSubRoles();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -64,20 +68,21 @@ const redirectToRoleSummary = (id) =>
|
||||||
:data-key="dataKey"
|
:data-key="dataKey"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
:url="urlPath"
|
:url="urlPath"
|
||||||
|
:limit="0"
|
||||||
auto-load
|
auto-load
|
||||||
>
|
>
|
||||||
<template #body>
|
<template #body>
|
||||||
<QTable :rows="data" :columns="columns" hide-header>
|
<QTable :rows="data" :columns="columns" hide-header>
|
||||||
<template #body="{ row }">
|
<template #body="{ row }">
|
||||||
<QTr
|
<QTr
|
||||||
@click="redirectToRoleSummary(row.inherits?.id)"
|
@click="redirectToRoleSummary(row.role?.id)"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
>
|
>
|
||||||
<QTd>
|
<QTd>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<span>{{ row.inherits?.name }}</span>
|
<span>{{ row.role?.name }}</span>
|
||||||
<span class="color-vn-label">{{
|
<span class="color-vn-label">{{
|
||||||
row.inherits?.description
|
row.role?.description
|
||||||
}}</span>
|
}}</span>
|
||||||
</div>
|
</div>
|
||||||
</QTd>
|
</QTd>
|
||||||
|
|
|
@ -19,7 +19,7 @@ account:
|
||||||
card:
|
card:
|
||||||
name: Name
|
name: Name
|
||||||
nickname: User
|
nickname: User
|
||||||
role: Rol
|
role: Role
|
||||||
email: Email
|
email: Email
|
||||||
alias: Alias
|
alias: Alias
|
||||||
lang: Language
|
lang: Language
|
||||||
|
@ -44,7 +44,7 @@ account:
|
||||||
password: Password
|
password: Password
|
||||||
active: Active
|
active: Active
|
||||||
mailForwarding:
|
mailForwarding:
|
||||||
forwardingMail: Dirección de reenvío
|
forwardingMail: Forward email
|
||||||
accountNotEnabled: Account not enabled
|
accountNotEnabled: Account not enabled
|
||||||
enableMailForwarding: Enable mail forwarding
|
enableMailForwarding: Enable mail forwarding
|
||||||
mailInputInfo: All emails will be forwarded to the specified address.
|
mailInputInfo: All emails will be forwarded to the specified address.
|
||||||
|
|
Loading…
Reference in New Issue