refactor: refs #8422 update document ID error messages and improve notifications in DMS forms
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
This commit is contained in:
parent
f07ce9a0a1
commit
96ed69acd2
|
@ -6,12 +6,14 @@ import { useRoute } from 'vue-router';
|
|||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import FormModelPopup from 'components/FormModelPopup.vue';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
|
||||
import axios from 'axios';
|
||||
|
||||
const emit = defineEmits(['onDataSaved']);
|
||||
|
||||
const { t } = useI18n();
|
||||
const { notify } = useNotify();
|
||||
const route = useRoute();
|
||||
|
||||
const dmsOptions = ref([]);
|
||||
|
@ -19,7 +21,7 @@ const dmsId = ref(null);
|
|||
|
||||
const importDms = async () => {
|
||||
try {
|
||||
if (!dmsId.value) throw new Error(t(`vehicle.error.documentIdEmpty`));
|
||||
if (!dmsId.value) throw new Error(t(`vehicle.errors.documentIdEmpty`));
|
||||
|
||||
const data = {
|
||||
vehicleFk: route.params.id,
|
||||
|
@ -27,10 +29,11 @@ const importDms = async () => {
|
|||
};
|
||||
|
||||
await axios.post('vehicleDms', data);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
dmsId.value = null;
|
||||
emit('onDataSaved');
|
||||
} catch (e) {
|
||||
throw new Error(e.message);
|
||||
notify('vehicle.errors.dmsImported', 'negative');
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -44,7 +47,7 @@ const importDms = async () => {
|
|||
/>
|
||||
<FormModelPopup
|
||||
model="DmsImport"
|
||||
:title="t('vehicle.dms.selectDocId')"
|
||||
:title="t('globals.selectDocumentId')"
|
||||
:form-initial-data="{}"
|
||||
:save-fn="importDms"
|
||||
>
|
||||
|
|
|
@ -49,7 +49,7 @@ const importDms = async () => {
|
|||
<FormModelPopup
|
||||
url-create="genera"
|
||||
model="DmsImport"
|
||||
:title="t('Select document id')"
|
||||
:title="t('globals.selectDocumentId')"
|
||||
:form-initial-data="{}"
|
||||
:save-fn="importDms"
|
||||
>
|
||||
|
@ -70,7 +70,6 @@ const importDms = async () => {
|
|||
|
||||
<i18n>
|
||||
es:
|
||||
Select document id: Introduzca id de gestion documental
|
||||
Document: Documento
|
||||
The document indentifier can't be empty: El número de documento no puede estar vacío
|
||||
</i18n>
|
||||
|
|
|
@ -71,6 +71,7 @@ describe('Vehicle DMS', () => {
|
|||
cy.dataCy(selectors.importBtn).click();
|
||||
cy.fillInForm(data);
|
||||
cy.dataCy(selectors.saveFormBtn).click();
|
||||
cy.checkNotification('Data saved');
|
||||
cy.validateContent(selectors.lastRowReference, '1');
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue