feat: refs #8225 added worker and zone modules
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jon Elias 2025-01-10 10:27:03 +01:00
parent 69bcab0ec4
commit ac1515e107
4 changed files with 83 additions and 45 deletions

View File

@ -6,11 +6,10 @@ import CardDescriptor from 'src/components/ui/CardDescriptor.vue';
import VnLv from 'src/components/ui/VnLv.vue'; import VnLv from 'src/components/ui/VnLv.vue';
import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue'; import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue';
import VnChangePassword from 'src/components/common/VnChangePassword.vue'; import VnChangePassword from 'src/components/common/VnChangePassword.vue';
import { useState } from 'src/composables/useState';
import axios from 'axios'; import axios from 'axios';
import VnImg from 'src/components/ui/VnImg.vue'; import VnImg from 'src/components/ui/VnImg.vue';
import EditPictureForm from 'components/EditPictureForm.vue'; import EditPictureForm from 'components/EditPictureForm.vue';
import DepartmentDescriptorProxy from 'src/pages/Department/Card/DepartmentDescriptorProxy.vue'; import WorkerDescriptorMenu from './WorkerDescriptorMenu.vue';
const $props = defineProps({ const $props = defineProps({
id: { id: {
@ -28,8 +27,6 @@ const image = ref(null);
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
const state = useState();
const user = state.getUser();
const showEditPhotoForm = ref(false); const showEditPhotoForm = ref(false);
const toggleEditPictureForm = () => { const toggleEditPictureForm = () => {
showEditPhotoForm.value = !showEditPhotoForm.value; showEditPhotoForm.value = !showEditPhotoForm.value;
@ -45,18 +42,6 @@ const getIsExcluded = async () => {
workerExcluded.value = data.exists; workerExcluded.value = data.exists;
}; };
const handleExcluded = async () => {
if (workerExcluded.value)
await axios.delete(`WorkerDisableExcludeds/${entityId.value}`);
else
await axios.post(`WorkerDisableExcludeds`, {
workerFk: entityId.value,
dated: new Date(),
});
workerExcluded.value = !workerExcluded.value;
};
const handlePhotoUpdated = (evt = false) => { const handlePhotoUpdated = (evt = false) => {
image.value.reload(evt); image.value.reload(evt);
}; };
@ -72,25 +57,11 @@ const handlePhotoUpdated = (evt = false) => {
@on-fetch="getIsExcluded" @on-fetch="getIsExcluded"
> >
<template #menu="{ entity }"> <template #menu="{ entity }">
<QItem v-ripple clickable @click="handleExcluded"> <WorkerDescriptorMenu
<QItemSection> :worker="entity"
{{ :is-excluded="workerExcluded"
workerExcluded @show-dialog="$refs.changePassRef.show"
? t('Click to allow the user to be disabled') />
: t('Click to exclude the user from getting disabled')
}}
</QItemSection>
</QItem>
<QItem
v-if="!entity.user.emailVerified && user.id != entity.id"
v-ripple
clickable
@click="$refs.changePassRef.show"
>
<QItemSection>
{{ t('globals.changePass') }}
</QItemSection>
</QItem>
</template> </template>
<template #before> <template #before>
<div class="relative-position"> <div class="relative-position">
@ -144,14 +115,10 @@ const handlePhotoUpdated = (evt = false) => {
:value="entity.user?.emailUser?.email" :value="entity.user?.emailUser?.email"
copy copy
/> />
<VnLv :label="t('worker.list.department')"> <VnLv
<template #value> :label="t('worker.list.department')"
<span class="link" v-text="entity.department?.department?.name" /> :value="entity.department ? entity.department.department.name : null"
<DepartmentDescriptorProxy
:id="entity.department?.department?.id"
/> />
</template>
</VnLv>
<VnLv :value="entity.phone"> <VnLv :value="entity.phone">
<template #label> <template #label>
{{ t('globals.phone') }} {{ t('globals.phone') }}
@ -211,8 +178,6 @@ const handlePhotoUpdated = (evt = false) => {
<i18n> <i18n>
es: es:
Go to client: Ir a cliente
Go to user: Ir al usuario
Click to allow the user to be disabled: Marcar para deshabilitar Click to allow the user to be disabled: Marcar para deshabilitar
Click to exclude the user from getting disabled: Marcar para no deshabilitar Click to exclude the user from getting disabled: Marcar para no deshabilitar
</i18n> </i18n>

View File

@ -0,0 +1,65 @@
<script setup>
import { computed, ref, toRefs } from 'vue';
import axios from 'axios';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { useState } from 'src/composables/useState';
const $props = defineProps({
worker: {
type: Object,
required: true,
},
isExcluded: {
type: Boolean,
required: true,
},
});
const route = useRoute();
const { t } = useI18n();
const state = useState();
const user = state.getUser();
const { worker } = toRefs($props);
const workerExcluded = ref($props.isExcluded);
const entityId = computed(() => {
return $props.worker.id || route.params.id;
});
const emit = defineEmits(['show-dialog']);
const handleExcluded = async () => {
if (workerExcluded.value)
await axios.delete(`WorkerDisableExcludeds/${entityId.value}`);
else
await axios.post(`WorkerDisableExcludeds`, {
workerFk: entityId.value,
dated: new Date(),
});
workerExcluded.value = !workerExcluded.value;
};
const showChangePasswordDialog = () => {
emit('show-dialog', true);
};
</script>
<template>
<QItem v-ripple clickable @click="handleExcluded">
<QItemSection>
{{
workerExcluded
? t('Click to allow the user to be disabled')
: t('Click to exclude the user from getting disabled')
}}
</QItemSection>
</QItem>
<QItem
v-if="!worker.user.emailVerified && user.id == worker.id"
v-ripple
clickable
@click="showChangePasswordDialog"
>
<QItemSection>
{{ t('globals.changePass') }}
</QItemSection>
</QItem>
</template>

View File

@ -11,6 +11,7 @@ import VnTitle from 'src/components/common/VnTitle.vue';
import RoleDescriptorProxy from 'src/pages/Account/Role/Card/RoleDescriptorProxy.vue'; import RoleDescriptorProxy from 'src/pages/Account/Role/Card/RoleDescriptorProxy.vue';
import DepartmentDescriptorProxy from 'src/pages/Department/Card/DepartmentDescriptorProxy.vue'; import DepartmentDescriptorProxy from 'src/pages/Department/Card/DepartmentDescriptorProxy.vue';
import { useAdvancedSummary } from 'src/composables/useAdvancedSummary'; import { useAdvancedSummary } from 'src/composables/useAdvancedSummary';
import WorkerDescriptorMenu from './WorkerDescriptorMenu.vue';
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
@ -42,6 +43,9 @@ onBeforeMount(async () => {
<template #header="{ entity }"> <template #header="{ entity }">
<div>{{ entity.id }} - {{ entity.firstName }} {{ entity.lastName }}</div> <div>{{ entity.id }} - {{ entity.firstName }} {{ entity.lastName }}</div>
</template> </template>
<template #menu="{ entity }">
<WorkerDescriptorMenu :worker="entity" :is-excluded="workerExcluded" />
</template>
<template #body="{ entity: worker }"> <template #body="{ entity: worker }">
<QCard class="vn-one"> <QCard class="vn-one">
<VnTitle :url="basicDataUrl" :text="t('globals.summary.basicData')" /> <VnTitle :url="basicDataUrl" :text="t('globals.summary.basicData')" />

View File

@ -11,6 +11,7 @@ import { getUrl } from 'src/composables/getUrl';
import { toCurrency } from 'filters/index'; import { toCurrency } from 'filters/index';
import { toTimeFormat } from 'src/filters/date'; import { toTimeFormat } from 'src/filters/date';
import axios from 'axios'; import axios from 'axios';
import ZoneDescriptorMenuItems from './ZoneDescriptorMenuItems.vue';
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
@ -79,6 +80,9 @@ onMounted(async () => {
<template #header="{ entity }"> <template #header="{ entity }">
<div>#{{ entity.id }} - {{ entity.name }}</div> <div>#{{ entity.id }} - {{ entity.name }}</div>
</template> </template>
<template #menu="{ entity }">
<ZoneDescriptorMenuItems :zone="entity" />
</template>
<template #body="{ entity: zone }"> <template #body="{ entity: zone }">
<QCard class="vn-one"> <QCard class="vn-one">
<VnTitle :url="zoneUrl + `basic-data`" :text="t('summary.basicData')" /> <VnTitle :url="zoneUrl + `basic-data`" :text="t('summary.basicData')" />