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

This commit is contained in:
Jorge Penadés 2024-07-02 14:04:19 +00:00
commit 96a3298280
9 changed files with 77 additions and 30 deletions

View File

@ -1,6 +1,6 @@
{
"name": "salix-front",
"version": "24.28.1",
"version": "24.30.1",
"description": "Salix frontend",
"productName": "Salix",
"author": "Verdnatura",

View File

@ -59,6 +59,10 @@ const $props = defineProps({
type: Boolean,
default: false,
},
hasSubtoolbar: {
type: Boolean,
default: true,
},
});
const { t } = useI18n();
const stateStore = useStateStore();
@ -175,11 +179,14 @@ function columnName(col) {
}
function getColAlign(col) {
return 'text-' + (col.align ?? 'left')
return 'text-' + (col.align ?? 'left');
}
const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']);
defineExpose({
reload,
redirect: redirectFn,
selected,
});
</script>
<template>
@ -225,11 +232,18 @@ defineExpose({
:search-url="searchUrl"
:disable-infinite-scroll="mode == TABLE_MODE"
@save-changes="reload"
:has-subtoolbar="isEditable"
:has-subtoolbar="$attrs['hasSubtoolbar'] ?? isEditable"
>
<template
v-for="(_, slotName) in $slots"
#[slotName]="slotData"
:key="slotName"
>
<slot :name="slotName" v-bind="slotData ?? {}" :key="slotName" />
</template>
<template #body="{ rows }">
<QTable
v-bind="$attrs['QTable']"
v-bind="$attrs['q-table']"
class="vnTable"
:columns="splittedColumns.columns"
:rows="rows"
@ -246,6 +260,7 @@ defineExpose({
CrudModelRef.vnPaginateRef.paginate()
"
@row-click="(_, row) => rowClickFunction(row)"
@update:selected="emit('update:selected', $event)"
>
<template #top-left>
<slot name="top-left"></slot>
@ -310,6 +325,7 @@ defineExpose({
class="no-margin q-px-xs"
:class="getColAlign(col)"
>
<slot :name="`column-${col.name}`" :col="col" :row="row">
<VnTableColumn
:column="col"
:row="row"
@ -317,6 +333,7 @@ defineExpose({
v-model="row[col.name]"
component-prop="columnField"
/>
</slot>
</QTd>
</template>
<template #body-cell-tableActions="{ col, row }">
@ -411,6 +428,11 @@ defineExpose({
@click="
stopEventPropagation($event)
"
>
<slot
:name="`column-${col.name}`"
:col="col"
:row="row"
>
<VnTableColumn
:column="col"
@ -420,6 +442,7 @@ defineExpose({
component-prop="columnField"
:show-label="true"
/>
</slot>
</span>
</template>
</VnLv>
@ -477,6 +500,7 @@ defineExpose({
default="input"
v-model="data[column.name]"
:show-label="true"
component-prop="columnCreate"
/>
<slot name="more-create-dialog" :data="data" />
</div>

View File

@ -93,7 +93,12 @@ const inputRules = [
name="close"
size="xs"
v-if="hover && value && !$attrs.disabled && $props.clearable"
@click="value = null"
@click="
() => {
value = null;
emit('remove');
}
"
></QIcon>
<QIcon v-if="info" name="info">
<QTooltip max-width="350px">

View File

@ -61,6 +61,10 @@ const $props = defineProps({
type: Boolean,
default: false,
},
useLike: {
type: Boolean,
default: true,
},
});
const { t } = useI18n();
@ -114,11 +118,14 @@ async function fetchFilter(val) {
if (!$props.url || !dataRef.value) return;
const { fields, sortBy, limit } = $props;
let key = optionLabel.value;
let key = optionFilter.value ?? optionLabel.value;
if (new RegExp(/\d/g).test(val)) key = optionFilter.value ?? optionValue.value;
if (new RegExp(/\d/g).test(val)) key = optionValue.value;
const where = { ...{ [key]: { like: `%${val}%` } }, ...$props.where };
const defaultWhere = $props.useLike
? { [key]: { like: `%${val}%` } }
: { [key]: val };
const where = { ...defaultWhere, ...$props.where };
const fetchOptions = { where, order: sortBy, limit };
if (fields) fetchOptions.fields = fields;
return dataRef.value.fetch(fetchOptions);

View File

@ -58,7 +58,14 @@ const $props = defineProps({
},
});
const emit = defineEmits(['refresh', 'clear', 'search', 'init', 'remove']);
const emit = defineEmits([
'update:modelValue',
'refresh',
'clear',
'search',
'init',
'remove',
]);
const arrayData = useArrayData($props.dataKey, {
exprBuilder: $props.exprBuilder,
@ -92,6 +99,11 @@ watch(
(val) => setUserParams(val)
);
watch(
() => $props.modelValue,
(val) => (userParams.value = val ?? {})
);
const isLoading = ref(false);
async function search(evt) {
if (evt && $props.disableSubmitEvent) return;
@ -148,6 +160,7 @@ async function clearFilters() {
isLoading.value = false;
emit('clear');
emit('update:modelValue', userParams.value);
}
const tagsList = computed(() => {
@ -171,6 +184,7 @@ async function remove(key) {
userParams.value[key] = undefined;
search();
emit('remove', key);
emit('update:modelValue', userParams.value);
}
function formatValue(value) {

View File

@ -65,6 +65,8 @@ const columns = computed(() => [
url: 'Workers/activeWithInheritedRole',
fields: ['id', 'name'],
where: { role: 'salesPerson' },
optionFilter: 'firstName',
useLike: false,
},
create: true,
columnField: {

View File

@ -5,12 +5,11 @@ describe('InvoiceInList', () => {
':nth-child(1) > :nth-child(1) > .justify-between > .flex > .q-chip > .q-chip__content';
const firstDetailBtn = '.q-card:nth-child(1) .q-btn:nth-child(2)';
const summaryHeaders = '.summaryBody .header-link';
const screen = '.q-page-container > .q-drawer-container > .fullscreen';
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/invoice-in/list`);
cy.get(screen).click();
});
it('should redirect on clicking a invoice', () => {

View File

@ -8,9 +8,9 @@ describe('ParkingList', () => {
const summaryHeader = '.summaryBody .header';
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/parking/list`);
cy.closeSideMenu();
});
it('should redirect on clicking a parking', () => {

View File

@ -221,10 +221,6 @@ Cypress.Commands.add('openLeftMenu', (element) => {
if (element) cy.waitForElement(element);
cy.get('.q-toolbar > .q-btn--round.q-btn--dense > .q-btn__content > .q-icon').click();
});
Cypress.Commands.add('closeSideMenu', (element) => {
if (element) cy.waitForElement(element);
cy.get('.fullscreen.q-drawer__backdrop:not(.hidden)').click();
});
Cypress.Commands.add('clearSearchbar', (element) => {
if (element) cy.waitForElement(element);