fix: refs #8247 fixed acls and added lost options
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
fdc0a856ad
commit
5259b8200b
|
@ -346,6 +346,7 @@ globals:
|
|||
countryFk: Country
|
||||
companyFk: Company
|
||||
changePass: Change password
|
||||
setPass: Set password
|
||||
deleteConfirmTitle: Delete selected elements
|
||||
changeState: Change state
|
||||
raid: 'Raid {daysInForward} days'
|
||||
|
|
|
@ -348,6 +348,7 @@ globals:
|
|||
countryFk: País
|
||||
companyFk: Empresa
|
||||
changePass: Cambiar contraseña
|
||||
setPass: Establecer contraseña
|
||||
deleteConfirmTitle: Eliminar los elementos seleccionados
|
||||
changeState: Cambiar estado
|
||||
raid: 'Redada {daysInForward} días'
|
||||
|
|
|
@ -6,9 +6,11 @@ import { useVnConfirm } from 'composables/useVnConfirm';
|
|||
import { useRoute } from 'vue-router';
|
||||
import { useAcl } from 'src/composables/useAcl';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { useState } from 'src/composables/useState';
|
||||
import VnConfirm from 'src/components/ui/VnConfirm.vue';
|
||||
import VnChangePassword from 'src/components/common/VnChangePassword.vue';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
const $props = defineProps({
|
||||
hasAccount: {
|
||||
|
@ -21,11 +23,13 @@ const { t } = useI18n();
|
|||
const { hasAccount } = toRefs($props);
|
||||
const { openConfirmationModal } = useVnConfirm();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const state = useState();
|
||||
const user = state.getUser();
|
||||
const { notify } = useQuasar();
|
||||
const account = computed(() => useArrayData('AccountId').store.data[0]);
|
||||
account.value.hasAccount = hasAccount.value;
|
||||
const entityId = computed(() => +route.params.id);
|
||||
|
||||
async function updateStatusAccount(active) {
|
||||
if (active) {
|
||||
await axios.post(`Accounts`, { id: entityId.value });
|
||||
|
@ -36,7 +40,7 @@ async function updateStatusAccount(active) {
|
|||
account.value.hasAccount = active;
|
||||
const status = active ? 'enable' : 'disable';
|
||||
notify({
|
||||
message: t(`account.card.${status}Account.success`),
|
||||
message: t(`account.card.actions.${status}Account.success`),
|
||||
type: 'positive',
|
||||
});
|
||||
}
|
||||
|
@ -49,6 +53,17 @@ async function updateStatusUser(active) {
|
|||
type: 'positive',
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteAccount() {
|
||||
const { data } = await axios.delete(`VnUsers/${entityId.value}`);
|
||||
if (data) {
|
||||
notify({
|
||||
message: t('account.card.actions.delete.success'),
|
||||
type: 'positive',
|
||||
});
|
||||
router.push({ name: 'AccountList' });
|
||||
}
|
||||
}
|
||||
const showSyncDialog = ref(false);
|
||||
const syncPassword = ref(null);
|
||||
const shouldSyncPassword = ref(false);
|
||||
|
@ -63,11 +78,18 @@ async function sync() {
|
|||
type: 'positive',
|
||||
});
|
||||
}
|
||||
const askOldPass = ref(false);
|
||||
const changePassRef = ref();
|
||||
|
||||
const onChangePass = (oldPass) => {
|
||||
askOldPass.value = oldPass;
|
||||
changePassRef.value.show();
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<VnChangePassword
|
||||
ref="changePassRef"
|
||||
:ask-old-pass="true"
|
||||
:ask-old-pass="askOldPass"
|
||||
:submit-fn="
|
||||
async (newPassword, oldPassword) => {
|
||||
await axios.patch(`Accounts/change-password`, {
|
||||
|
@ -110,17 +132,57 @@ async function sync() {
|
|||
</VnConfirm>
|
||||
<QItem
|
||||
v-if="
|
||||
entityId == account.id &&
|
||||
useAcl().hasAny([{ model: 'Account', props: '*', accessType: 'WRITE' }])
|
||||
useAcl().hasAny([
|
||||
{ model: 'VnUser', props: 'higherPrivileges', accessType: 'WRITE' },
|
||||
])
|
||||
"
|
||||
v-ripple
|
||||
clickable
|
||||
@click="$refs.changePassRef.show()"
|
||||
@click="
|
||||
openConfirmationModal(
|
||||
t('account.card.actions.disableAccount.title'),
|
||||
t('account.card.actions.disableAccount.subtitle'),
|
||||
() => deleteAccount()
|
||||
)
|
||||
"
|
||||
>
|
||||
<QItemSection>{{ t('globals.changePass') }}</QItemSection>
|
||||
<QItemSection>{{ t('globals.delete') }}</QItemSection>
|
||||
</QItem>
|
||||
<QItem
|
||||
v-if="account.hasAccount"
|
||||
v-if="
|
||||
useAcl().hasAny([{ model: 'AccountConfig', props: '*', accessType: 'WRITE' }])
|
||||
"
|
||||
v-ripple
|
||||
clickable
|
||||
@click="user.id === account.id ? onChangePass(true) : onChangePass(false)"
|
||||
>
|
||||
<QItemSection v-if="user.id === account.id">
|
||||
{{ t('globals.changePass') }}
|
||||
</QItemSection>
|
||||
<QItemSection v-else>{{ t('globals.setPass') }}</QItemSection>
|
||||
</QItem>
|
||||
<QItem
|
||||
v-if="
|
||||
!account.hasAccount &&
|
||||
useAcl().hasAny([{ model: 'AccountConfig', props: '*', accessType: 'WRITE' }])
|
||||
"
|
||||
v-ripple
|
||||
clickable
|
||||
@click="
|
||||
openConfirmationModal(
|
||||
t('account.card.actions.enableAccount.title'),
|
||||
t('account.card.actions.enableAccount.subtitle'),
|
||||
() => updateStatusAccount(true)
|
||||
)
|
||||
"
|
||||
>
|
||||
<QItemSection>{{ t('account.card.actions.enableAccount.name') }}</QItemSection>
|
||||
</QItem>
|
||||
<QItem
|
||||
v-if="
|
||||
account.hasAccount &&
|
||||
useAcl().hasAny([{ model: 'AccountConfig', props: '*', accessType: 'WRITE' }])
|
||||
"
|
||||
v-ripple
|
||||
clickable
|
||||
@click="
|
||||
|
@ -135,7 +197,12 @@ async function sync() {
|
|||
</QItem>
|
||||
|
||||
<QItem
|
||||
v-if="!account.active"
|
||||
v-if="
|
||||
!account.active &&
|
||||
useAcl().hasAny([
|
||||
{ model: 'VnUser', props: 'higherPrivileges', accessType: 'WRITE' },
|
||||
])
|
||||
"
|
||||
v-ripple
|
||||
clickable
|
||||
@click="
|
||||
|
@ -149,7 +216,12 @@ async function sync() {
|
|||
<QItemSection>{{ t('account.card.actions.activateUser.name') }}</QItemSection>
|
||||
</QItem>
|
||||
<QItem
|
||||
v-if="account.active"
|
||||
v-if="
|
||||
account.active &&
|
||||
useAcl().hasAny([
|
||||
{ model: 'VnUser', props: 'higherPrivileges', accessType: 'WRITE' },
|
||||
])
|
||||
"
|
||||
v-ripple
|
||||
clickable
|
||||
@click="
|
||||
|
@ -162,7 +234,12 @@ async function sync() {
|
|||
>
|
||||
<QItemSection>{{ t('account.card.actions.deactivateUser.name') }}</QItemSection>
|
||||
</QItem>
|
||||
<QItem v-ripple clickable @click="showSyncDialog = true">
|
||||
<QItem
|
||||
v-if="useAcl().hasAny([{ model: 'VnRole', props: '*', accessType: 'WRITE' }])"
|
||||
v-ripple
|
||||
clickable
|
||||
@click="showSyncDialog = true"
|
||||
>
|
||||
<QItemSection>{{ t('account.card.actions.sync.name') }}</QItemSection>
|
||||
</QItem>
|
||||
<QSeparator />
|
||||
|
|
|
@ -58,6 +58,7 @@ lastEntries:
|
|||
pvp: PVP
|
||||
label: Label
|
||||
grouping: Grouping
|
||||
packing: Packing
|
||||
quantity: Quantity
|
||||
cost: Cost
|
||||
kg: Kg.
|
||||
|
|
|
@ -58,6 +58,7 @@ lastEntries:
|
|||
pvp: PVP
|
||||
label: Eti.
|
||||
grouping: Grouping
|
||||
packing: Packing
|
||||
quantity: Cantidad
|
||||
cost: Coste
|
||||
kg: Kg.
|
||||
|
|
Loading…
Reference in New Issue