refs #5509 feat: VnDms description

This commit is contained in:
Alex Moreno 2024-02-13 15:01:24 +01:00
parent 1d4179cfa1
commit 4315408452
4 changed files with 88 additions and 59 deletions

View File

@ -27,19 +27,20 @@ const $props = defineProps({
type: Object, type: Object,
default: null, default: null,
}, },
description: {
type: Function,
default: null,
},
}); });
const warehouses = ref(); const warehouses = ref();
const companies = ref(); const companies = ref();
const dmsTypes = ref(); const dmsTypes = ref();
const allowedContentTypes = ref(); const allowedContentTypes = ref();
const inputFileRef = ref();
const dms = ref({}); const dms = ref({});
onMounted(() => defaultData()); onMounted(() => {
defaultData();
if (!$props.formInitialData)
dms.value.description = t($props.model + 'Description', dms.value);
});
function onFileChange(files) { function onFileChange(files) {
dms.value.hasFileAttached = !!files; dms.value.hasFileAttached = !!files;
dms.value.file = files?.name; dms.value.file = files?.name;
@ -78,7 +79,6 @@ function defaultData() {
if ($props.formInitialData) return (dms.value = $props.formInitialData); if ($props.formInitialData) return (dms.value = $props.formInitialData);
return addDefaultData({ return addDefaultData({
reference: route.params.id, reference: route.params.id,
description: $props.description && $props.description(dms.value),
}); });
} }
@ -151,6 +151,7 @@ function addDefaultData(data) {
type="textarea" type="textarea"
/> />
<QFile <QFile
ref="inputFileRef"
:label="t('entry.buys.file')" :label="t('entry.buys.file')"
v-model="dms.files" v-model="dms.files"
:multiple="false" :multiple="false"
@ -159,12 +160,14 @@ function addDefaultData(data) {
class="required" class="required"
:display-value="dms.file" :display-value="dms.file"
> >
<template #prepend> <template #append>
<QIcon name="vn:attach" class="cursor-pointer"> <QIcon
name="vn:attach"
class="cursor-pointer"
@click="inputFileRef.pickFiles()"
>
<QTooltip>{{ t('Select a file') }}</QTooltip> <QTooltip>{{ t('Select a file') }}</QTooltip>
</QIcon> </QIcon>
</template>
<template #append>
<QIcon name="info" class="cursor-pointer"> <QIcon name="info" class="cursor-pointer">
<QTooltip>{{ <QTooltip>{{
t('contentTypesInfo', { allowedContentTypes }) t('contentTypesInfo', { allowedContentTypes })
@ -189,7 +192,10 @@ function addDefaultData(data) {
<i18n> <i18n>
en: en:
contentTypesInfo: Allowed file types {allowedContentTypes} contentTypesInfo: Allowed file types {allowedContentTypes}
EntryDmsDescription: Reference {reference}
es: es:
Generate identifier for original file: Generar identificador para archivo original Generate identifier for original file: Generar identificador para archivo original
contentTypesInfo: Tipos de archivo permitidos {allowedContentTypes} contentTypesInfo: Tipos de archivo permitidos {allowedContentTypes}
EntryDmsDescription: Referencia {reference}
</i18n> </i18n>

View File

@ -2,14 +2,13 @@
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useQuasar, QCheckbox, QBtn, QInput } from 'quasar';
import axios from 'axios';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import VnDms from 'src/components/common/VnDms.vue'; import VnDms from 'src/components/common/VnDms.vue';
import { downloadFile } from 'src/composables/downloadFile';
import VnConfirm from 'components/ui/VnConfirm.vue'; import VnConfirm from 'components/ui/VnConfirm.vue';
import axios from 'axios'; import { downloadFile } from 'src/composables/downloadFile';
import { QCheckbox, QBtn, QInput } from 'quasar';
import { useQuasar } from 'quasar';
const route = useRoute(); const route = useRoute();
const quasar = useQuasar(); const quasar = useQuasar();
@ -35,10 +34,6 @@ const $props = defineProps({
type: String, type: String,
required: true, required: true,
}, },
description: {
type: Function,
required: true,
},
}); });
const dmsFilter = { const dmsFilter = {
@ -144,6 +139,35 @@ const columns = computed(() => [
{ {
field: 'options', field: 'options',
name: 'options', name: 'options',
components: [
{
component: QBtn,
props: () => ({
icon: 'cloud_download',
flat: true,
color: 'primary',
}),
click: (prop) => downloadFile(prop.row.id),
},
{
component: QBtn,
props: () => ({
icon: 'edit',
flat: true,
color: 'primary',
}),
click: (prop) => showFormDialog(prop.row),
},
{
component: QBtn,
props: () => ({
icon: 'delete',
flat: true,
color: 'primary',
}),
click: (prop) => deleteDms(prop.row.id),
},
],
}, },
]); ]);
@ -199,7 +223,7 @@ function parseDms(data) {
class="full-width q-mt-md" class="full-width q-mt-md"
hide-bottom hide-bottom
row-key="clientFk" row-key="clientFk"
:grid="$q.screen.lt.md" :grid="$q.screen.lt.sm"
> >
<template #body-cell="props"> <template #body-cell="props">
<QTd :props="props"> <QTd :props="props">
@ -216,25 +240,14 @@ function parseDms(data) {
</QTr> </QTr>
<div class="flex justify-center" v-if="props.col.name == 'options'"> <div class="flex justify-center" v-if="props.col.name == 'options'">
<QBtn <div v-for="button of props.col.components" :key="button.id">
icon="cloud_download" <component
flat :is="button.component"
color="primary" v-bind="button.props(props)"
@click="downloadFile(props.row.id)" @click="button.click(props)"
/>
<QBtn
icon="edit"
flat
color="primary"
@click="showFormDialog(props.row)"
/>
<QBtn
icon="delete"
flat
color="primary"
@click="deleteDms(props.row.id)"
/> />
</div> </div>
</div>
</QTd> </QTd>
</template> </template>
<template #item="props"> <template #item="props">
@ -244,23 +257,26 @@ function parseDms(data) {
flat flat
@keyup.ctrl.enter.stop="claimDevelopmentForm?.saveChanges()" @keyup.ctrl.enter.stop="claimDevelopmentForm?.saveChanges()"
> >
<QCardSection>
<QCheckbox v-model="props.selected" dense />
</QCardSection>
<QSeparator /> <QSeparator />
<QList dense> <QList dense>
<QItem v-for="col in props.cols" :key="col.name"> <QItem v-for="col in props.cols" :key="col.name">
<QItemSection> <div v-if="col.name != 'options'" class="row">
<component <span class="labelColor">{{ col.label }}:</span>
v-if="col.component" <span>{{ col.value }}</span>
:is="col.component" </div>
v-bind="col.props && col.props(props)" <div v-if="col.name == 'options'" class="row">
<div
v-for="button of col.components"
:key="button.id"
class="row"
> >
<span v-if="col.component == 'span'">{{ <component
`${col.label}:${col.value}` :is="button.component"
}}</span> v-bind="button.props(col)"
</component> @click="button.click(col)"
</QItemSection> />
</div>
</div>
</QItem> </QItem>
</QList> </QList>
</QCard> </QCard>
@ -285,6 +301,9 @@ function parseDms(data) {
display: grid; display: grid;
row-gap: 20px; row-gap: 20px;
} }
.labelColor {
color: var(--vn-label);
}
</style> </style>
<i18n> <i18n>
en: en:

View File

@ -7,14 +7,5 @@ import VnDmsList from 'src/components/common/VnDmsList.vue';
update-model="EntryDms" update-model="EntryDms"
default-dms-code="entry" default-dms-code="entry"
filter="entryFk" filter="entryFk"
:description="
(data) => t('description', { reference: data.reference, id: data.id })
"
/> />
</template> </template>
<i18n>
en:
description: Reference {reference} id {id}
es:
description: Referencia {reference} id {id}
</i18n>

View File

@ -0,0 +1,13 @@
describe('WagonTypeCreate', () => {
const entryId = 1;
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/entry/${entryId}/dms`);
});
it('should create and delete a new wagon type', () => {
cy.addCard()
});
});