forked from verdnatura/salix-front
Resolve conflicts
This commit is contained in:
commit
c881fe6577
|
@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Added
|
||||
|
||||
### Fixed
|
||||
|
||||
- (General) => Se vuelven a mostrar los parámetros en la url al aplicar un filtro
|
||||
|
||||
## [2414.01] - 2024-04-04
|
||||
|
||||
### Added
|
||||
|
|
|
@ -101,8 +101,7 @@ onMounted(async () => {
|
|||
});
|
||||
|
||||
onBeforeRouteLeave((to, from, next) => {
|
||||
if (!hasChanges.value) next();
|
||||
|
||||
if (hasChanges.value)
|
||||
quasar.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
|
@ -111,6 +110,7 @@ onBeforeRouteLeave((to, from, next) => {
|
|||
promise: () => next(),
|
||||
},
|
||||
});
|
||||
else next();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
|
|
|
@ -5,7 +5,7 @@ import { useCapitalize } from 'src/composables/useCapitalize';
|
|||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: { type: String, default: '' },
|
||||
modelValue: { type: [String, Number], default: '' },
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
|
|
|
@ -198,11 +198,13 @@ function addDefaultData(data) {
|
|||
en:
|
||||
contentTypesInfo: Allowed file types {allowedContentTypes}
|
||||
EntryDmsDescription: Reference {reference}
|
||||
WorkersDescription: Working of employee id {reference}
|
||||
SupplierDmsDescription: Reference {reference}
|
||||
es:
|
||||
Generate identifier for original file: Generar identificador para archivo original
|
||||
contentTypesInfo: Tipos de archivo permitidos {allowedContentTypes}
|
||||
EntryDmsDescription: Referencia {reference}
|
||||
WorkersDescription: Laboral del empleado {reference}
|
||||
SupplierDmsDescription: Referencia {reference}
|
||||
|
||||
</i18n>
|
||||
|
|
|
@ -5,9 +5,11 @@ import { useRoute } from 'vue-router';
|
|||
import { useQuasar, QCheckbox, QBtn, QInput } from 'quasar';
|
||||
import axios from 'axios';
|
||||
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||
import VnDms from 'src/components/common/VnDms.vue';
|
||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||
import VnUserLink from '../ui/VnUserLink.vue';
|
||||
import { downloadFile } from 'src/composables/downloadFile';
|
||||
|
||||
const route = useRoute();
|
||||
|
@ -26,6 +28,15 @@ const $props = defineProps({
|
|||
type: String,
|
||||
default: null,
|
||||
},
|
||||
deleteModel: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
downloadModel: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: null,
|
||||
},
|
||||
defaultDmsCode: {
|
||||
type: String,
|
||||
required: true,
|
||||
|
@ -74,7 +85,7 @@ const dmsFilter = {
|
|||
],
|
||||
},
|
||||
},
|
||||
order: ['dmsFk DESC'],
|
||||
where: { [$props.filter]: route.params.id },
|
||||
};
|
||||
|
||||
const columns = computed(() => [
|
||||
|
@ -94,12 +105,12 @@ const columns = computed(() => [
|
|||
props: (prop) => ({
|
||||
readonly: true,
|
||||
borderless: true,
|
||||
'model-value': prop.row.dmsType.name,
|
||||
'model-value': prop.row.dmsType?.name,
|
||||
}),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'order',
|
||||
field: 'hardCopyNumber',
|
||||
label: t('globals.order'),
|
||||
name: 'order',
|
||||
component: 'span',
|
||||
|
@ -117,6 +128,7 @@ const columns = computed(() => [
|
|||
label: t('globals.description'),
|
||||
name: 'description',
|
||||
component: 'span',
|
||||
props: (prop) => ({ value: prop.value?.toUpperCase() }),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -136,21 +148,53 @@ const columns = computed(() => [
|
|||
name: 'file',
|
||||
component: 'span',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'worker',
|
||||
label: t('globals.worker'),
|
||||
name: 'worker',
|
||||
component: VnUserLink,
|
||||
props: (prop) => ({
|
||||
name: prop.row.worker?.user?.name.toLowerCase(),
|
||||
workerId: prop.row.worker?.id,
|
||||
}),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'created',
|
||||
label: t('globals.created'),
|
||||
name: 'created',
|
||||
component: VnInputDate,
|
||||
props: (prop) => ({
|
||||
disable: true,
|
||||
'model-value': prop.row.created,
|
||||
}),
|
||||
},
|
||||
{
|
||||
field: 'options',
|
||||
name: 'options',
|
||||
components: [
|
||||
{
|
||||
component: QBtn,
|
||||
name: 'download',
|
||||
isDocuware: true,
|
||||
props: () => ({
|
||||
icon: 'cloud_download',
|
||||
flat: true,
|
||||
color: 'primary',
|
||||
}),
|
||||
click: (prop) => downloadFile(prop.row.id),
|
||||
click: (prop) =>
|
||||
downloadFile(
|
||||
prop.row.id,
|
||||
$props.downloadModel,
|
||||
null,
|
||||
prop.row.download
|
||||
),
|
||||
},
|
||||
{
|
||||
component: QBtn,
|
||||
name: 'edit',
|
||||
external: false,
|
||||
props: () => ({
|
||||
icon: 'edit',
|
||||
flat: true,
|
||||
|
@ -160,6 +204,8 @@ const columns = computed(() => [
|
|||
},
|
||||
{
|
||||
component: QBtn,
|
||||
name: 'delete',
|
||||
external: false,
|
||||
props: () => ({
|
||||
icon: 'delete',
|
||||
flat: true,
|
||||
|
@ -167,12 +213,24 @@ const columns = computed(() => [
|
|||
}),
|
||||
click: (prop) => deleteDms(prop.row.id),
|
||||
},
|
||||
{
|
||||
component: QBtn,
|
||||
name: 'open',
|
||||
external: true,
|
||||
props: () => ({
|
||||
icon: 'open_in_new',
|
||||
flat: true,
|
||||
color: 'primary',
|
||||
}),
|
||||
click: (prop) => open(prop.row.url),
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
function setData(data) {
|
||||
const newData = data.map((value) => value.dms);
|
||||
const newData = data.map((value) => value.dms || value);
|
||||
newData.sort((a, b) => new Date(b.created) - new Date(a.created));
|
||||
rows.value = newData;
|
||||
}
|
||||
|
||||
|
@ -186,7 +244,7 @@ function deleteDms(dmsFk) {
|
|||
},
|
||||
})
|
||||
.onOk(async () => {
|
||||
await axios.post(`${$props.model}/${dmsFk}/removeFile`);
|
||||
await axios.post(`${$props.deleteModel ?? $props.model}/${dmsFk}/removeFile`);
|
||||
const index = rows.value.findIndex((row) => row.id == dmsFk);
|
||||
rows.value.splice(index, 1);
|
||||
});
|
||||
|
@ -206,16 +264,27 @@ function parseDms(data) {
|
|||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
async function open(url) {
|
||||
window.open(url).focus();
|
||||
}
|
||||
|
||||
function shouldRenderButton(button, isExternal = false) {
|
||||
if (button.name == 'download') return true;
|
||||
return button.external === isExternal;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
<VnPaginate
|
||||
ref="dmsRef"
|
||||
:data-key="$props.model"
|
||||
:url="$props.model"
|
||||
:filter="dmsFilter"
|
||||
:where="{ [$props.filter]: route.params.id }"
|
||||
:order="['dmsFk DESC']"
|
||||
:auto-load="true"
|
||||
@on-fetch="setData"
|
||||
auto-load
|
||||
/>
|
||||
>
|
||||
<template #body>
|
||||
<QTable
|
||||
:columns="columns"
|
||||
:rows="rows"
|
||||
|
@ -240,9 +309,12 @@ function parseDms(data) {
|
|||
</component>
|
||||
</QTr>
|
||||
|
||||
<div class="flex justify-center" v-if="props.col.name == 'options'">
|
||||
<div class="row no-wrap" v-if="props.col.name == 'options'">
|
||||
<div v-for="button of props.col.components" :key="button.id">
|
||||
<component
|
||||
v-if="
|
||||
shouldRenderButton(button, props.row.isDocuware)
|
||||
"
|
||||
:is="button.component"
|
||||
v-bind="button.props(props)"
|
||||
@click="button.click(props)"
|
||||
|
@ -272,6 +344,12 @@ function parseDms(data) {
|
|||
class="row"
|
||||
>
|
||||
<component
|
||||
v-if="
|
||||
shouldRenderButton(
|
||||
button.name,
|
||||
props.row.isDocuware
|
||||
)
|
||||
"
|
||||
:is="button.component"
|
||||
v-bind="button.props(col)"
|
||||
@click="button.click(col)"
|
||||
|
@ -284,6 +362,8 @@ function parseDms(data) {
|
|||
</div>
|
||||
</template>
|
||||
</QTable>
|
||||
</template>
|
||||
</VnPaginate>
|
||||
<QDialog v-model="formDialog.show">
|
||||
<VnDms
|
||||
:model="updateModel ?? model"
|
||||
|
|
|
@ -110,7 +110,7 @@ async function paginate() {
|
|||
if (!arrayData.hasMoreData.value) {
|
||||
if (store.userParamsChanged) arrayData.hasMoreData.value = true;
|
||||
store.userParamsChanged = false;
|
||||
isLoading.value = false;
|
||||
endPagination();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -120,12 +120,14 @@ async function paginate() {
|
|||
pagination.value.sortBy = sortBy;
|
||||
pagination.value.descending = descending;
|
||||
|
||||
isLoading.value = false;
|
||||
endPagination();
|
||||
}
|
||||
|
||||
function endPagination() {
|
||||
isLoading.value = false;
|
||||
emit('onFetch', store.data);
|
||||
emit('onPaginate');
|
||||
}
|
||||
|
||||
async function onLoad(index, done) {
|
||||
if (!store.data) {
|
||||
return done();
|
||||
|
@ -188,6 +190,12 @@ async function onLoad(index, done) {
|
|||
<QSpinner color="orange" size="md" />
|
||||
</div>
|
||||
</QInfiniteScroll>
|
||||
<div
|
||||
v-if="!isLoading && arrayData.hasMoreData"
|
||||
class="w-full flex justify-center q-mt-md"
|
||||
>
|
||||
<QBtn color="primary" :label="t('Load more data')" @click="paginate()" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@ -204,4 +212,5 @@ async function onLoad(index, done) {
|
|||
es:
|
||||
No data to display: Sin datos que mostrar
|
||||
No results found: No se han encontrado resultados
|
||||
Load more data: Cargar más resultados
|
||||
</i18n>
|
||||
|
|
|
@ -76,7 +76,7 @@ const removeNode = (node) => {
|
|||
notify(t('department.departmentRemoved'), 'positive');
|
||||
await fetchNodeLeaves(parentFk);
|
||||
} catch (err) {
|
||||
console.log('Error removing department');
|
||||
console.error('Error removing department');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { useSession } from 'src/composables/useSession';
|
||||
import { getUrl } from './getUrl';
|
||||
|
||||
const {getTokenMultimedia} = useSession();
|
||||
const { getTokenMultimedia } = useSession();
|
||||
const token = getTokenMultimedia();
|
||||
|
||||
export async function downloadFile(dmsId) {
|
||||
export async function downloadFile(id, model = 'dms', urlPath = '/downloadFile', url) {
|
||||
let appUrl = await getUrl('', 'lilium');
|
||||
appUrl = appUrl.replace('/#/', '');
|
||||
window.open(`${appUrl}/api/dms/${dmsId}/downloadFile?access_token=${token}`);
|
||||
window.open(url ?? `${appUrl}/api/${model}/${id}${urlPath}?access_token=${token}`);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { onMounted, ref, computed } from 'vue';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import { useRoute } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import { useArrayDataStore } from 'stores/useArrayDataStore';
|
||||
import { buildFilter } from 'filters/filterPanel';
|
||||
|
@ -15,7 +15,6 @@ export function useArrayData(key, userOptions) {
|
|||
|
||||
const store = arrayDataStore.get(key);
|
||||
const hasMoreData = ref(false);
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
let canceller = null;
|
||||
|
||||
|
@ -98,14 +97,14 @@ export function useArrayData(key, userOptions) {
|
|||
|
||||
const { limit } = filter;
|
||||
|
||||
hasMoreData.value = response.data.length === limit;
|
||||
hasMoreData.value = response.data.length >= limit;
|
||||
|
||||
if (append) {
|
||||
if (!store.data) store.data = [];
|
||||
for (const row of response.data) store.data.push(row);
|
||||
} else {
|
||||
store.data = response.data;
|
||||
if (!document.querySelectorAll('[role="dialog"]'))
|
||||
if (!document.querySelectorAll('[role="dialog"]').length)
|
||||
updateRouter && updateStateParams();
|
||||
}
|
||||
|
||||
|
@ -188,11 +187,15 @@ export function useArrayData(key, userOptions) {
|
|||
if (store.userParams && Object.keys(store.userParams).length !== 0)
|
||||
query.params = JSON.stringify(store.userParams);
|
||||
|
||||
if (router)
|
||||
router.replace({
|
||||
path: route.path,
|
||||
query: query,
|
||||
});
|
||||
const url = new URL(window.location.href);
|
||||
const { hash: currentHash } = url;
|
||||
const [currentRoute] = currentHash.split('?');
|
||||
|
||||
const params = new URLSearchParams();
|
||||
for (const param in query) params.append(param, query[param]);
|
||||
|
||||
url.hash = currentRoute + '?' + params.toString();
|
||||
window.history.pushState({}, '', url.hash);
|
||||
}
|
||||
|
||||
const totalRows = computed(() => (store.data && store.data.length) || 0);
|
||||
|
|
|
@ -91,6 +91,8 @@ export default {
|
|||
log: 'Logs',
|
||||
parkingList: 'Parkings list',
|
||||
},
|
||||
created: 'Created',
|
||||
worker: 'Worker',
|
||||
},
|
||||
errors: {
|
||||
statusUnauthorized: 'Access denied',
|
||||
|
@ -865,6 +867,7 @@ export default {
|
|||
notes: 'Notes',
|
||||
pda: 'PDA',
|
||||
calendar: 'Calendar',
|
||||
dms: 'My documentation',
|
||||
notifications: 'Notifications',
|
||||
pbx: 'Private Branch Exchange',
|
||||
log: 'Log',
|
||||
|
|
|
@ -91,6 +91,8 @@ export default {
|
|||
log: 'Historial',
|
||||
parkingList: 'Listado de parkings',
|
||||
},
|
||||
created: 'Fecha creación',
|
||||
worker: 'Trabajador',
|
||||
},
|
||||
errors: {
|
||||
statusUnauthorized: 'Acceso denegado',
|
||||
|
@ -864,6 +866,7 @@ export default {
|
|||
notes: 'Notas',
|
||||
pda: 'PDA',
|
||||
calendar: 'Calendario',
|
||||
dms: 'Mi documentación',
|
||||
notifications: 'Notificaciones',
|
||||
pbx: 'Centralita',
|
||||
log: 'Historial',
|
||||
|
|
|
@ -63,7 +63,7 @@ const removeDepartment = () => {
|
|||
router.push({ name: 'WorkerDepartment' });
|
||||
notify('department.departmentRemoved', 'positive');
|
||||
} catch (err) {
|
||||
console.log('Error removing department');
|
||||
console.error('Error removing department');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -32,6 +32,13 @@ const invoiceInFormRef = ref();
|
|||
const expensesRef = ref();
|
||||
const newExpenseRef = ref();
|
||||
|
||||
defineProps({
|
||||
actionIcon: {
|
||||
type: String,
|
||||
default: 'add',
|
||||
},
|
||||
});
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
name: 'expense',
|
||||
|
@ -207,17 +214,16 @@ async function addExpense() {
|
|||
@click.stop="value = null"
|
||||
class="cursor-pointer"
|
||||
/>
|
||||
<QBtn
|
||||
padding="xs"
|
||||
round
|
||||
flat
|
||||
icon="add_circle"
|
||||
@click.stop="newExpenseRef.show()"
|
||||
<QIcon
|
||||
@click.stop.prevent="newExpenseRef.show()"
|
||||
:name="actionIcon"
|
||||
size="xs"
|
||||
class="default-icon"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('Create expense') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
</QIcon>
|
||||
</template>
|
||||
</VnSelectFilter>
|
||||
</QTd>
|
||||
|
@ -470,6 +476,11 @@ async function addExpense() {
|
|||
.q-item {
|
||||
min-height: 0;
|
||||
}
|
||||
.default-icon {
|
||||
cursor: pointer;
|
||||
border-radius: 50px;
|
||||
background-color: $primary;
|
||||
}
|
||||
</style>
|
||||
<i18n>
|
||||
es:
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<script setup>
|
||||
import VnDmsList from 'src/components/common/VnDmsList.vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
const route = useRoute();
|
||||
</script>
|
||||
<template>
|
||||
<VnDmsList
|
||||
:model="`WorkerDms/${route.params.id}/filter`"
|
||||
update-model="Workers"
|
||||
delete-model="WorkerDms"
|
||||
download-model="WorkerDms"
|
||||
default-dms-code="hhrrData"
|
||||
filter="worker"
|
||||
/>
|
||||
</template>
|
|
@ -20,6 +20,7 @@ export default {
|
|||
'WorkerPBX',
|
||||
'WorkerLog',
|
||||
'WorkerCalendar',
|
||||
'WorkerDms',
|
||||
],
|
||||
departmentCard: ['BasicData'],
|
||||
},
|
||||
|
@ -128,6 +129,15 @@ export default {
|
|||
},
|
||||
component: () => import('src/pages/Worker/Card/WorkerPBX.vue'),
|
||||
},
|
||||
{
|
||||
name: 'WorkerDms',
|
||||
path: 'dms',
|
||||
meta: {
|
||||
title: 'dms',
|
||||
icon: 'cloud_upload',
|
||||
},
|
||||
component: () => import('src/pages/Worker/Card/WorkerDms.vue'),
|
||||
},
|
||||
{
|
||||
name: 'WorkerLog',
|
||||
path: 'log',
|
||||
|
|
|
@ -36,7 +36,7 @@ describe('VnSearchBar', () => {
|
|||
const checkCardListAndUrl = (expectedLength) => {
|
||||
cy.get(cardList).then(($cardList) => {
|
||||
expect($cardList.find('.q-card').length).to.equal(expectedLength);
|
||||
cy.url().then((currentUrl) => expect(currentUrl).to.equal(url));
|
||||
cy.url().then((currentUrl) => expect(currentUrl).to.contain(url));
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
import { describe, expect, it, beforeAll } from 'vitest';
|
||||
import { axios } from 'app/test/vitest/helper';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
|
||||
describe('useArrayData', () => {
|
||||
let arrayData;
|
||||
beforeAll(() => {
|
||||
axios.get.mockResolvedValue({ data: [] });
|
||||
arrayData = useArrayData('InvoiceIn', { url: 'invoice-in/list' });
|
||||
Object.defineProperty(window.location, 'href', {
|
||||
writable: true,
|
||||
value: 'localhost:9000/invoice-in/list',
|
||||
});
|
||||
|
||||
// Mock the window.history.pushState method within useArrayData
|
||||
window.history.pushState = (data, title, url) => (window.location.href = url);
|
||||
|
||||
// Mock the URL constructor within useArrayData
|
||||
global.URL = class URL {
|
||||
constructor(url) {
|
||||
this.hash = url.split('localhost:9000/')[1];
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
it('should add the params to the url', async () => {
|
||||
arrayData.store.userParams = { supplierFk: 2 };
|
||||
arrayData.updateStateParams();
|
||||
expect(window.location.href).contain('params=%7B%22supplierFk%22%3A2%7D');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue