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