0
0
Fork 0

Merge branch 'dev' into fix_itemType-redirection

This commit is contained in:
Alex Moreno 2024-10-28 09:14:21 +00:00
commit ffee9fb27c
12 changed files with 63 additions and 58 deletions

View File

@ -1,6 +1,3 @@
<script setup>
defineProps({ wrap: { type: Boolean, default: false } });
</script>
<template>
<div class="vn-row q-gutter-md q-mb-md">
<slot />

View File

@ -0,0 +1,11 @@
import axios from 'axios';
import { useRole } from './useRole';
export async function useAdvancedSummary(model, id, roles = ['hr']) {
if (useRole().hasAny(roles)) {
const { data } = await axios.get(`${model}/advancedSummary`, {
params: { filter: { where: { id } } },
});
return Array.isArray(data) ? data[0] : data;
}
}

View File

@ -211,6 +211,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
<template #st-actions>
<QBtnGroup push class="q-gutter-x-sm" flat>
<VnBtnSelect
data-cy="change-state"
:disable="!hasSelectedRows"
color="primary"
:label="t('globals.changeState')"

View File

@ -4,7 +4,6 @@ import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue';
import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import VnProgress from 'src/components/common/VnProgressModal.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import TicketAdvanceFilter from './TicketAdvanceFilter.vue';

View File

@ -1,5 +1,5 @@
<script setup>
import { ref } from 'vue';
import { ref, onBeforeMount } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import VnInputDate from 'src/components/common/VnInputDate.vue';
@ -8,32 +8,22 @@ import FormModel from 'src/components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import { useAdvancedSummary } from 'src/composables/useAdvancedSummary';
const route = useRoute();
const { t } = useI18n();
const educationLevels = ref([]);
const countries = ref([]);
const maritalStatus = [
{ code: 'M', name: t('Married') },
{ code: 'S', name: t('Single') },
];
const advancedSummary = ref({});
const workerFilter = {
include: [
{
relation: 'user',
scope: {
fields: ['name', 'emailVerified'],
include: { relation: 'emailUser', scope: { fields: ['email'] } },
},
},
{ relation: 'sip', scope: { fields: ['extension', 'secret'] } },
{ relation: 'department', scope: { include: { relation: 'department' } } },
],
};
onBeforeMount(async () => {
advancedSummary.value =
(await useAdvancedSummary('Workers', +useRoute().params.id)) ?? {};
});
</script>
<template>
<FetchData
:filter="{ fields: ['id', 'name'], order: 'name ASC' }"
@ -48,10 +38,16 @@ const workerFilter = {
auto-load
/>
<FormModel
:filter="workerFilter"
:url="`Workers/${route.params.id}`"
:filter="{ where: { id: +$route.params.id } }"
url="Workers/summary"
:url-update="`Workers/${$route.params.id}`"
auto-load
model="Worker"
@on-fetch="
async (data) => {
Object.assign(data, advancedSummary);
}
"
>
<template #form="{ data }">
<VnRow>
@ -134,7 +130,7 @@ const workerFilter = {
<VnInput v-model="data.fi" :label="t('fi')" />
<VnInputDate :label="t('birth')" v-model="data.birth" />
</VnRow>
<VnRow>
<VnRow wrap>
<QCheckbox
size="sm"
:label="t('isFreelance')"

View File

@ -18,7 +18,7 @@ const { store } = useArrayData('Worker');
const entityId = computed(() => useRoute().params.id);
const filter = computed(() => ({
where: {
gender: store.data?.sex,
gender: store.data?.[0]?.sex,
or: [{ workerFk: null }, { workerFk: entityId.value }],
},
}));
@ -51,6 +51,7 @@ const init = async (data) => {
>
<template #form="{ data }">
<VnSelect
data-cy="locker"
:label="t('Locker')"
v-model="data.id"
:options="lockers"

View File

@ -2,7 +2,6 @@
import { ref, onBeforeMount, computed } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import axios from 'axios';
import { dashIfEmpty, toDate } from 'src/filters';
import VnLv from 'src/components/ui/VnLv.vue';
import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue';
@ -11,7 +10,7 @@ import VnUserLink from 'src/components/ui/VnUserLink.vue';
import VnTitle from 'src/components/common/VnTitle.vue';
import RoleDescriptorProxy from 'src/pages/Account/Role/Card/RoleDescriptorProxy.vue';
import DepartmentDescriptorProxy from 'src/pages/Department/Card/DepartmentDescriptorProxy.vue';
import { useRole } from 'src/composables/useRole';
import { useAdvancedSummary } from 'src/composables/useAdvancedSummary';
const route = useRoute();
const { t } = useI18n();
@ -25,18 +24,11 @@ const $props = defineProps({
const entityId = computed(() => $props.id || route.params.id);
const basicDataUrl = ref(null);
const isHr = computed(() => useRole().hasAny(['hr']));
const advancedSummary = ref();
onBeforeMount(async () => {
if (isHr.value) {
advancedSummary.value = (
await axios.get('Workers/advancedSummary', {
params: { filter: { where: { id: entityId.value } } },
})
).data[0];
advancedSummary.value = await useAdvancedSummary('Workers', entityId.value);
basicDataUrl.value = `#/worker/${entityId.value}/basic-data`;
}
});
</script>
@ -101,21 +93,27 @@ onBeforeMount(async () => {
:label="t('worker.summary.seniority')"
:value="toDate(worker.seniority)"
/>
<VnLv :label="t('worker.summary.fi')" :value="worker.fi" />
<VnLv :label="t('worker.summary.birth')" :value="toDate(worker.birth)" />
<VnLv :label="t('worker.summary.fi')" :value="advancedSummary.fi" />
<VnLv
:label="t('worker.summary.birth')"
:value="toDate(advancedSummary.birth)"
/>
<VnLv
:label="t('worker.summary.isFreelance')"
:value="worker.isFreelance"
:value="advancedSummary.isFreelance"
/>
<VnLv
:label="t('worker.summary.isSsDiscounted')"
:value="worker.isSsDiscounted"
:value="advancedSummary.isSsDiscounted"
/>
<VnLv
:label="t('worker.summary.hasMachineryAuthorized')"
:value="worker.hasMachineryAuthorized"
:value="advancedSummary.hasMachineryAuthorized"
/>
<VnLv
:label="t('worker.summary.isDisable')"
:value="advancedSummary.isDisable"
/>
<VnLv :label="t('worker.summary.isDisable')" :value="worker.isDisable" />
</QCard>
<QCard class="vn-one">
<VnTitle :text="t('worker.summary.userData')" />

View File

@ -87,6 +87,13 @@ export default {
meta: {
title: 'basicData',
icon: 'vn:settings',
acls: [
{
model: 'Worker',
props: 'updateAttributes',
accessType: 'WRITE',
},
],
},
component: () => import('src/pages/Worker/Card/WorkerBasicData.vue'),
},

View File

@ -11,15 +11,13 @@ describe('Ticket expedtion', () => {
it('should change the state', () => {
cy.visit('#/ticket/1/expedition');
cy.intercept('GET', /\/api\/Expeditions\/filter/).as('expeditions');
cy.intercept('POST', /\/api\/Expeditions\/crud/).as('crud');
cy.wait('@expeditions');
cy.intercept('GET', /\/api\/Expeditions\/filter/).as('show');
cy.intercept('POST', /\/api\/ExpeditionStates\/addExpeditionState/).as('add');
cy.wait('@show');
cy.selectRows([1, 2]);
cy.get('#subToolbar [aria-controls]:nth-child(1)').click();
cy.get('.q-menu .q-item').contains('Perdida').click();
cy.wait('@crud');
cy.selectOption('[data-cy="change-state"]', 'Perdida');
cy.wait('@add');
cy.get(`${tableContent} tr:nth-child(-n+2) ${stateTd}`).each(($el) => {
cy.wrap($el).contains('Perdida');

View File

@ -11,7 +11,7 @@ describe('WorkerList', () => {
it('should open the worker summary', () => {
cy.get(inputName).type('jessica{enter}');
cy.get(searchBtn).click();
cy.intercept('GET', /\/api\/Workers\/\d+/).as('worker');
cy.intercept('GET', /\/api\/Workers\/summary+/).as('worker');
cy.wait('@worker').then(() =>
cy.get(descriptorTitle).should('include.text', 'Jessica')
);

View File

@ -1,8 +1,7 @@
describe('WorkerLocker', () => {
const productionId = 49;
const lockerCode = '2F';
const input = '.q-card input';
const thirdOpt = '[role="listbox"] .q-item:nth-child(1)';
const lockerCode = '4F';
const lockerSelect = '[data-cy="locker"]';
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('productionBoss');
@ -10,10 +9,8 @@ describe('WorkerLocker', () => {
});
it('should allocates a locker', () => {
cy.get(input).click();
cy.waitForElement('[role="listbox"]');
cy.get(thirdOpt).click();
cy.selectOption(lockerSelect, lockerCode);
cy.saveCard();
cy.get(input).invoke('val').should('eq', lockerCode);
cy.get(lockerSelect).invoke('val').should('eq', lockerCode);
});
});

View File

@ -82,7 +82,7 @@ Cypress.Commands.add('getValue', (selector) => {
// Fill Inputs
Cypress.Commands.add('selectOption', (selector, option) => {
cy.waitForElement(selector);
cy.get(selector).find('.q-select__dropdown-icon').click();
cy.get(selector).click();
cy.get('.q-menu .q-item').contains(option).click();
});