Merge branch 'dev' into fix-workerSections
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jon Elias 2025-02-26 11:28:51 +00:00
commit 87d25c55b4
23 changed files with 239 additions and 162 deletions

2
Jenkinsfile vendored
View File

@ -122,7 +122,7 @@ pipeline {
}
post {
always {
sh "docker-compose ${env.COMPOSE_PARAMS} down"
sh "docker-compose ${env.COMPOSE_PARAMS} down -v"
junit(
testResults: 'junit/e2e.xml',
allowEmptyResults: true

View File

@ -31,6 +31,7 @@ export default defineConfig({
requestTimeout: 10000,
responseTimeout: 30000,
pageLoadTimeout: 60000,
defaultBrowser: 'chromium',
fixturesFolder: 'test/cypress/fixtures',
screenshotsFolder: 'test/cypress/screenshots',
supportFile: 'test/cypress/support/index.js',
@ -38,17 +39,10 @@ export default defineConfig({
downloadsFolder: 'test/cypress/downloads',
video: false,
specPattern: 'test/cypress/integration/**/*.spec.js',
experimentalRunAllSpecs: false,
watchForFileChanges: false,
reporter: 'cypress-mochawesome-reporter',
reporterOptions: {
charts: true,
reportPageTitle: 'Cypress Inline Reporter',
reportFilename: '[status]_[datetime]-report',
embeddedScreenshots: true,
reportDir: 'test/cypress/reports',
inlineAssets: true,
},
experimentalRunAllSpecs: true,
watchForFileChanges: true,
reporter,
reporterOptions,
component: {
componentFolder: 'src',
testFiles: '**/*.spec.js',

View File

@ -91,7 +91,6 @@ const components = {
event: updateEvent,
attrs: {
...defaultAttrs,
style: 'min-width: 150px',
},
forceAttrs,
},

View File

@ -31,6 +31,7 @@ import VnLv from 'components/ui/VnLv.vue';
import VnTableOrder from 'src/components/VnTable/VnOrder.vue';
import VnTableFilter from './VnTableFilter.vue';
import { getColAlign } from 'src/composables/getColAlign';
import RightMenu from '../common/RightMenu.vue';
const arrayData = useArrayData(useAttrs()['data-key']);
const $props = defineProps({
@ -50,10 +51,6 @@ const $props = defineProps({
type: Boolean,
default: true,
},
rightSearchIcon: {
type: Boolean,
default: true,
},
rowClick: {
type: [Function, Boolean],
default: null,
@ -165,7 +162,6 @@ const app = inject('app');
const editingRow = ref(null);
const editingField = ref(null);
const isTableMode = computed(() => mode.value == TABLE_MODE);
const showRightIcon = computed(() => $props.rightSearch || $props.rightSearchIcon);
const selectRegex = /select/;
const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']);
const tableModes = [
@ -414,20 +410,13 @@ async function renderInput(rowId, field, clickedElement) {
eventHandlers: {
'update:modelValue': async (value) => {
if (isSelect && value) {
row[column.name] = value[column.attrs?.optionValue ?? 'id'];
row[column?.name + 'TextValue'] =
value[column.attrs?.optionLabel ?? 'name'];
await column?.cellEvent?.['update:modelValue']?.(
value,
oldValue,
row,
);
await updateSelectValue(value, column, row, oldValue);
} else row[column.name] = value;
await column?.cellEvent?.['update:modelValue']?.(value, oldValue, row);
},
keyup: async (event) => {
if (event.key === 'Enter')
await destroyInput(rowIndex, field, clickedElement);
await destroyInput(rowId, field, clickedElement);
},
keydown: async (event) => {
switch (event.key) {
@ -458,6 +447,17 @@ async function renderInput(rowId, field, clickedElement) {
node.el?.querySelector('span > div > div').focus();
}
async function updateSelectValue(value, column, row, oldValue) {
row[column.name] = value[column.attrs?.optionValue ?? 'id'];
row[column?.name + 'VnTableTextValue'] = value[column.attrs?.optionLabel ?? 'name'];
if (column?.attrs?.find?.label)
row[column?.attrs?.find?.label] = value[column.attrs?.optionLabel ?? 'name'];
await column?.cellEvent?.['update:modelValue']?.(value, oldValue, row);
}
async function destroyInput(rowIndex, field, clickedElement) {
if (!clickedElement)
clickedElement = document.querySelector(
@ -520,9 +520,9 @@ function getToggleIcon(value) {
}
function formatColumnValue(col, row, dashIfEmpty) {
if (col?.format || row[col?.name + 'TextValue']) {
if (selectRegex.test(col?.component) && row[col?.name + 'TextValue']) {
return dashIfEmpty(row[col?.name + 'TextValue']);
if (col?.format || row[col?.name + 'VnTableTextValue']) {
if (selectRegex.test(col?.component) && row[col?.name + 'VnTableTextValue']) {
return dashIfEmpty(row[col?.name + 'VnTableTextValue']);
} else {
return col.format(row, dashIfEmpty);
}
@ -555,19 +555,33 @@ function formatColumnValue(col, row, dashIfEmpty) {
}
return dashIfEmpty(row[col?.name]);
}
function cardClick(_, row) {
if ($props.redirect) router.push({ path: `/${$props.redirect}/${row.id}` });
}
function removeTextValue(data, getChanges) {
let changes = data.updates;
if (!changes) return data;
for (const change of changes) {
for (const key in change.data) {
if (key.endsWith('VnTableTextValue')) {
delete change.data[key];
}
}
}
data.updates = changes.filter((change) => Object.keys(change.data).length > 0);
if ($attrs?.beforeSaveFn) data = $attrs.beforeSaveFn(data, getChanges);
return data;
}
</script>
<template>
<QDrawer
v-if="$props.rightSearch"
v-model="stateStore.rightDrawer"
side="right"
:width="256"
:overlay="$props.overlay"
>
<QScrollArea class="fit">
<RightMenu v-if="$props.rightSearch">
<template #right-panel>
<VnTableFilter
:data-key="$attrs['data-key']"
:columns="columns"
@ -581,8 +595,8 @@ function cardClick(_, row) {
<slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
</template>
</VnTableFilter>
</QScrollArea>
</QDrawer>
</template>
</RightMenu>
<CrudModel
v-bind="$attrs"
:class="$attrs['class'] ?? 'q-px-md'"
@ -591,6 +605,7 @@ function cardClick(_, row) {
@on-fetch="(...args) => emit('onFetch', ...args)"
:search-url="searchUrl"
:disable-infinite-scroll="isTableMode"
:before-save-fn="removeTextValue"
@save-changes="reload"
:has-sub-toolbar="$props.hasSubToolbar ?? isEditable"
:auto-load="hasParams || $attrs['auto-load']"
@ -635,6 +650,7 @@ function cardClick(_, row) {
:skip="columnsVisibilitySkipped"
/>
<QBtnToggle
v-if="!tableModes.some((mode) => mode.disable)"
v-model="mode"
toggle-color="primary"
class="bg-vn-section-color"

View File

@ -76,6 +76,15 @@ onBeforeMount(async () => {
);
});
const routeName = computed(() => {
const DESCRIPTOR_PROXY = 'DescriptorProxy';
let name = $props.dataKey;
if ($props.dataKey.includes(DESCRIPTOR_PROXY)) {
name = name.split(DESCRIPTOR_PROXY)[0];
}
return `${name}Summary`;
});
async function getData() {
store.url = $props.url;
store.filter = $props.filter ?? {};
@ -154,9 +163,7 @@ const toModule = computed(() =>
{{ t('components.smartCard.openSummary') }}
</QTooltip>
</QBtn>
<RouterLink
:to="{ name: `${dataKey}Summary`, params: { id: entity.id } }"
>
<RouterLink :to="{ name: routeName, params: { id: entity.id } }">
<QBtn
class="link"
color="white"

View File

@ -153,6 +153,7 @@ globals:
maxTemperature: Max
minTemperature: Min
changePass: Change password
setPass: Set password
deleteConfirmTitle: Delete selected elements
changeState: Change state
raid: 'Raid {daysInForward} days'

View File

@ -157,6 +157,7 @@ globals:
maxTemperature: Máx
minTemperature: Mín
changePass: Cambiar contraseña
setPass: Establecer contraseña
deleteConfirmTitle: Eliminar los elementos seleccionados
changeState: Cambiar estado
raid: 'Redada {daysInForward} días'

View File

@ -25,12 +25,13 @@ const $props = defineProps({
const { t } = useI18n();
const { hasAccount } = toRefs($props);
const { openConfirmationModal } = useVnConfirm();
const arrayData = useArrayData('Account');
const route = useRoute();
const router = useRouter();
const state = useState();
const user = state.getUser();
const { notify } = useQuasar();
const account = computed(() => useArrayData('Account').store.data[0]);
const account = computed(() => arrayData.store.data);
account.value.hasAccount = hasAccount.value;
const entityId = computed(() => +route.params.id);
const hasitManagementAccess = ref();
@ -39,7 +40,7 @@ const isHimself = computed(() => user.value.id === account.value.id);
const url = computed(() =>
isHimself.value
? 'Accounts/change-password'
: `Accounts/${entityId.value}/setPassword`
: `Accounts/${entityId.value}/setPassword`,
);
async function updateStatusAccount(active) {
@ -153,6 +154,7 @@ onMounted(() => {
t('account.card.actions.disableAccount.title'),
t('account.card.actions.disableAccount.subtitle'),
() => deleteAccount(),
() => deleteAccount(),
)
"
>
@ -172,6 +174,7 @@ onMounted(() => {
t('account.card.actions.enableAccount.title'),
t('account.card.actions.enableAccount.subtitle'),
() => updateStatusAccount(true),
() => updateStatusAccount(true),
)
"
>
@ -186,6 +189,7 @@ onMounted(() => {
t('account.card.actions.disableAccount.title'),
t('account.card.actions.disableAccount.subtitle'),
() => updateStatusAccount(false),
() => updateStatusAccount(false),
)
"
>
@ -201,6 +205,7 @@ onMounted(() => {
t('account.card.actions.activateUser.title'),
t('account.card.actions.activateUser.title'),
() => updateStatusUser(true),
() => updateStatusUser(true),
)
"
>
@ -215,6 +220,7 @@ onMounted(() => {
t('account.card.actions.deactivateUser.title'),
t('account.card.actions.deactivateUser.title'),
() => updateStatusUser(false),
() => updateStatusUser(false),
)
"
>

View File

@ -639,7 +639,7 @@ onMounted(() => {
'flex-wrap': 'wrap',
gap: '16px',
position: 'relative',
height: '450px',
height: '500px',
},
columnGridStyle: {
'max-width': '50%',
@ -650,7 +650,7 @@ onMounted(() => {
:is-editable="editableMode"
:without-header="!editableMode"
:with-filters="editableMode"
:right-search="true"
:right-search="editableMode"
:right-search-icon="true"
:row-click="false"
:columns="columns"

View File

@ -274,7 +274,7 @@ onBeforeMount(async () => {
:array-data-props="{
url: 'Entries/filter',
order: 'landed DESC',
userFilter: EntryFilter,
userFilter: entryQueryFilter,
}"
>
<template #advanced-menu>

View File

@ -3,7 +3,7 @@ import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import { useQuasar } from 'quasar';
import { dashIfEmpty, toDate, toHour } from 'src/filters';
import { toDate, toHour } from 'src/filters';
import { useRouter } from 'vue-router';
import { usePrintService } from 'src/composables/usePrintService';

View File

@ -45,8 +45,6 @@ const filter = {
:label="t('parking.sector')"
:value="entity.sector?.description"
/>
<VnLv :label="t('parking.row')" :value="entity.row" />
<VnLv :label="t('parking.column')" :value="entity.column" />
</QCard>
</template>
</CardSummary>

View File

@ -1,19 +1,15 @@
<script setup>
import { onMounted, onUnmounted } from 'vue';
import { useRouter } from 'vue-router';
import { computed, onMounted, onUnmounted } from 'vue';
import { useI18n } from 'vue-i18n';
import { useStateStore } from 'stores/useStateStore';
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import VnPaginate from 'components/ui/VnPaginate.vue';
import CardList from 'components/ui/CardList.vue';
import VnLv from 'components/ui/VnLv.vue';
import ParkingFilter from './ParkingFilter.vue';
import ParkingSummary from './Card/ParkingSummary.vue';
import exprBuilder from './ParkingExprBuilder.js';
import VnTable from 'components/VnTable/VnTable.vue';
import VnSection from 'src/components/common/VnSection.vue';
import ParkingFilter from './ParkingFilter.vue';
import exprBuilder from './ParkingExprBuilder.js';
import ParkingSummary from './Card/ParkingSummary.vue';
const stateStore = useStateStore();
const { push } = useRouter();
const { t } = useI18n();
const { viewSummary } = useSummaryDialog();
const dataKey = 'ParkingList';
@ -24,7 +20,48 @@ onUnmounted(() => (stateStore.rightDrawer = false));
const filter = {
fields: ['id', 'sectorFk', 'code', 'pickingOrder'],
};
const columns = computed(() => [
{
align: 'left',
name: 'code',
label: t('globals.code'),
isId: true,
isTitle: true,
columnFilter: false,
sortable: true,
},
{
align: 'left',
name: 'sector',
label: t('parking.sector'),
format: (val) => val.sector.description ?? '',
sortable: true,
cardVisible: true,
},
{
align: 'left',
name: 'pickingOrder',
label: t('parking.pickingOrder'),
sortable: true,
cardVisible: true,
},
{
align: 'right',
label: '',
name: 'tableActions',
actions: [
{
title: t('components.smartCard.viewSummary'),
icon: 'preview',
action: (row) => viewSummary(row.id, ParkingSummary),
isPrimary: true,
},
],
},
]);
</script>
<template>
<VnSection
:data-key="dataKey"
@ -40,41 +77,24 @@ const filter = {
<ParkingFilter data-key="ParkingList" />
</template>
<template #body>
<QPage class="column items-center q-pa-md">
<div class="vn-card-list">
<VnPaginate :data-key="dataKey">
<template #body="{ rows }">
<CardList
v-for="row of rows"
:key="row.id"
:id="row.id"
:title="row.code"
@click="
push({ path: `/shelving/parking/${row.id}/summary` })
"
>
<template #list-items>
<VnLv
label="Sector"
:value="row.sector?.description"
/>
<VnLv
:label="t('parking.pickingOrder')"
:value="row.pickingOrder"
/>
</template>
<template #actions>
<QBtn
:label="t('components.smartCard.openSummary')"
@click.stop="viewSummary(row.id, ParkingSummary)"
color="primary"
/>
</template>
</CardList>
</template>
</VnPaginate>
</div>
</QPage>
<VnTable
:data-key="dataKey"
:columns="columns"
is-editable="false"
:right-search="false"
:use-model="true"
:disable-option="{ table: true }"
redirect="shelving/parking"
default-mode="card"
>
<template #actions="{ row }">
<QBtn
:label="t('components.smartCard.openSummary')"
@click.stop="viewSummary(row.id, ParkingSummary)"
color="primary"
/>
</template>
</VnTable>
</template>
</VnSection>
</template>

View File

@ -17,6 +17,12 @@ const maritalStatus = [
{ code: 'M', name: t('Married') },
{ code: 'S', name: t('Single') },
];
async function setAdvancedSummary(data) {
const advanced = (await useAdvancedSummary('Workers', data.id)) ?? {};
Object.assign(form.value.formData, advanced);
await nextTick();
if (form.value) form.value.hasChanges = false;
}
</script>
<template>
<FetchData
@ -36,13 +42,7 @@ const maritalStatus = [
:url-update="`Workers/${$route.params.id}`"
auto-load
model="Worker"
@on-fetch="
async (data) => {
Object.assign(data, (await useAdvancedSummary('Workers', data.id)) ?? {});
await $nextTick();
if (form) form.hasChanges = false;
}
"
@on-fetch="setAdvancedSummary"
>
<template #form="{ data }">
<VnRow>

View File

@ -12,6 +12,11 @@ const $props = defineProps({
<template>
<QPopupProxy>
<WorkerDescriptor v-if="$props.id" :id="$props.id" :summary="WorkerSummary" />
<WorkerDescriptor
v-if="$props.id"
:id="$props.id"
:summary="WorkerSummary"
data-key="WorkerDescriptorProxy"
/>
</QPopupProxy>
</template>

View File

@ -0,0 +1,24 @@
describe('ClaimNotes', () => {
const descriptorOptions = '[data-cy="descriptor-more-opts-menu"] > .q-list';
const url = '/#/account/1/summary';
it('should see all the account options', () => {
cy.login('itManagement');
cy.visit(url);
cy.dataCy('descriptor-more-opts').click();
cy.get(descriptorOptions)
.find('.q-item')
.its('length')
.then((count) => {
cy.log('Número de opciones:', count);
expect(count).to.equal(5);
});
});
it('should not see any option', () => {
cy.login('salesPerson');
cy.visit(url);
cy.dataCy('descriptor-more-opts').click();
cy.get(descriptorOptions).should('not.be.visible');
});
});

View File

@ -1,5 +1,5 @@
/// <reference types="cypress" />
describe('Client list', () => {
describe.skip('Client list', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');

View File

@ -1,23 +0,0 @@
/// <reference types="cypress" />
describe('ParkingBasicData', () => {
const codeInput = 'form .q-card .q-input input';
const sectorSelect = 'form .q-card .q-select input';
const sectorOpt = '.q-menu .q-item';
beforeEach(() => {
cy.login('developer');
cy.visit(`/#/shelving/parking/1/basic-data`);
});
it('should edit the code and sector', () => {
cy.get(sectorSelect).type('Second');
cy.get(sectorOpt).click();
cy.get(codeInput).eq(0).clear();
cy.get(codeInput).eq(0).type('900-001');
cy.saveCard();
cy.get(sectorSelect).should('have.value', 'Second sector');
cy.get(codeInput).should('have.value', '900-001');
});
});

View File

@ -1,33 +0,0 @@
/// <reference types="cypress" />
describe('ParkingList', () => {
const searchbar = '#searchbar input';
const firstCard = '.q-card:nth-child(1)';
const firstChipId =
':nth-child(1) > :nth-child(1) > .justify-between > .flex > .q-chip > .q-chip__content';
const firstDetailBtn =
':nth-child(1) > :nth-child(1) > .card-list-body > .actions > .q-btn';
const summaryHeader = '.summaryBody .header';
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/shelving/parking/list`);
});
it('should redirect on clicking a parking', () => {
cy.get(searchbar).type('{enter}');
cy.get(firstChipId)
.invoke('text')
.then((content) => {
const id = content.substring(4);
cy.get(firstCard).click();
cy.url().should('include', `/parking/${id}/summary`);
});
});
it('should open the details', () => {
cy.get(searchbar).type('{enter}');
cy.get(firstDetailBtn).click();
cy.get(summaryHeader).contains('Basic data');
});
});

View File

@ -0,0 +1,32 @@
/// <reference types="cypress" />
describe('ParkingBasicData', () => {
const codeInput = 'form .q-card .q-input input';
const sectorSelect = 'form .q-card .q-select input';
const sectorOpt = '.q-menu .q-item';
beforeEach(() => {
cy.login('developer');
cy.visit(`/#/shelving/parking/1/basic-data`);
});
it('should give an error if the code aldready exists', () => {
cy.get(codeInput).eq(0).should('have.value', '700-01').clear();
cy.get(codeInput).eq(0).type('700-02');
cy.saveCard();
cy.get('.q-notification__message').should('have.text', 'The code already exists');
});
it('should edit the code and sector', () => {
cy.get(sectorSelect).type('First');
cy.get(sectorOpt).click();
cy.get(codeInput).eq(0).clear();
cy.get(codeInput).eq(0).type('700-01');
cy.dataCy('Picking order_input').clear().type(80230);
cy.saveCard();
cy.get('.q-notification__message').should('have.text', 'Data saved');
cy.get(sectorSelect).should('have.value', 'First sector');
cy.get(codeInput).should('have.value', '700-01');
cy.dataCy('Picking order_input').should('have.value', 80230);
});
});

View File

@ -0,0 +1,30 @@
/// <reference types="cypress" />
describe('ParkingList', () => {
const searchbar = '#searchbar input';
const firstCard = ':nth-child(1) > .q-card > .no-margin > .q-py-none';
const summaryHeader = '.summaryBody .header';
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/shelving/parking/list`);
});
it('should redirect on clicking a parking', () => {
cy.get(searchbar).type('{enter}');
cy.get(firstCard).click();
cy.get(summaryHeader).contains('Basic data');
});
it('should filter and redirect if there is only one result', () => {
cy.dataCy('Code_input').type('1{enter}');
cy.dataCy('Sector_select').type('Normal{enter}');
cy.get(summaryHeader).contains('Basic data');
});
it('should filter and redirect to summary if only one result', () => {
cy.dataCy('Code_input').type('A{enter}');
cy.dataCy('Sector_select').type('First Sector{enter}');
cy.url().should('match', /\/shelving\/parking\/\d+\/summary/);
});
});

View File

@ -1,4 +1,4 @@
describe('WorkerCreate', () => {
describe.skip('WorkerCreate', () => {
const externalRadio = '.q-radio:nth-child(2)';
const developerBossId = 120;
const payMethodCross =

View File

@ -112,7 +112,7 @@ function selectItem(selector, option, ariaControl, hasWrite = true) {
.find((item) => item.innerText.includes(option));
if (matchingItem) return cy.wrap(matchingItem).click();
if (hasWrite) cy.get(selector).clear().type(option, { delay: 0 });
if (hasWrite) cy.get(selector).clear().type(option);
return selectItem(selector, option, ariaControl, false);
});
}