diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index a9ed0c31c..986358930 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -6,6 +6,7 @@ import { useQuasar } from 'quasar'; import { useState } from 'src/composables/useState'; import { useStateStore } from 'stores/useStateStore'; import { useValidator } from 'src/composables/useValidator'; +import useNotify from 'src/composables/useNotify.js'; import SkeletonForm from 'components/ui/SkeletonForm.vue'; const quasar = useQuasar(); @@ -13,6 +14,7 @@ const state = useState(); const stateStore = useStateStore(); const { t } = useI18n(); const { validate } = useValidator(); +const { notify } = useNotify(); const $props = defineProps({ url: { @@ -31,6 +33,10 @@ const $props = defineProps({ type: String, default: null, }, + urlCreate: { + type: String, + default: null, + }, defaultActions: { type: Boolean, default: true, @@ -39,6 +45,16 @@ const $props = defineProps({ type: Boolean, default: false, }, + formInitialData: { + type: Object, + default: () => {}, + }, + observeFormChanges: { + type: Boolean, + default: true, + description: + 'Esto se usa principalmente para permitir guardar sin hacer cambios (Útil para la feature de clonar ya que en este caso queremos poder guardar de primeras)', + }, }); const emit = defineEmits(['onFetch']); @@ -48,9 +64,17 @@ defineExpose({ }); onMounted(async () => { - if ($props.autoLoad) { + // Podemos enviarle al form la estructura de data inicial sin necesidad de fetchearla + if ($props.formInitialData && !$props.autoLoad) { + state.set($props.model, $props.formInitialData); + } else { await fetch(); } + + // Disparamos el watcher del form después de que se haya cargado la data inicial, si así se desea + if ($props.observeFormChanges) { + startFormWatcher(); + } }); onUnmounted(() => { @@ -58,11 +82,22 @@ onUnmounted(() => { }); const isLoading = ref(false); -const hasChanges = ref(false); +// Si elegimos observar los cambios del form significa que inicialmente las actions estaran deshabilitadas +const hasChanges = ref(!$props.observeFormChanges); const originalData = ref(); const formData = computed(() => state.get($props.model)); const formUrl = computed(() => $props.url); +const startFormWatcher = () => { + watch( + () => formData.value, + (val) => { + if (val) hasChanges.value = true; + }, + { deep: true } + ); +}; + function tMobile(...args) { if (!quasar.platform.is.mobile) return t(...args); } @@ -75,20 +110,26 @@ async function fetch() { state.set($props.model, data); originalData.value = data && JSON.parse(JSON.stringify(data)); - watch(formData.value, () => (hasChanges.value = true)); - emit('onFetch', state.get($props.model)); } async function save() { if (!hasChanges.value) { - return quasar.notify({ - type: 'negative', - message: t('globals.noChanges'), - }); + notify('globals.noChanges', 'negative'); + return; } isLoading.value = true; - await axios.patch($props.urlUpdate || $props.url, formData.value); + + try { + if ($props.urlCreate) { + await axios.post($props.urlCreate, formData.value); + notify('globals.dataCreated', 'positive'); + } else { + await axios.patch($props.urlUpdate || $props.url, formData.value); + } + } catch (err) { + notify('errors.create', 'negative'); + } originalData.value = JSON.parse(JSON.stringify(formData.value)); hasChanges.value = false; @@ -99,8 +140,6 @@ function reset() { state.set($props.model, originalData.value); originalData.value = JSON.parse(JSON.stringify(originalData.value)); - watch(formData.value, () => (hasChanges.value = true)); - emit('onFetch', state.get($props.model)); hasChanges.value = false; } diff --git a/src/i18n/en/index.js b/src/i18n/en/index.js index d92f11789..a78da276b 100644 --- a/src/i18n/en/index.js +++ b/src/i18n/en/index.js @@ -15,6 +15,7 @@ export default { logOut: 'Log out', dataSaved: 'Data saved', dataDeleted: 'Data deleted', + dataCreated: 'Data created', add: 'Add', create: 'Create', save: 'Save', @@ -45,6 +46,7 @@ export default { statusBadGateway: 'It seems that the server has fall down', statusGatewayTimeout: 'Could not contact the server', userConfig: 'Error fetching user config', + create: 'Error during creation', }, login: { title: 'Login', @@ -629,11 +631,6 @@ export default { create: 'Create', summary: 'Summary', }, - list: { - clone: 'Clone', - addEntry: 'Add entry', - preview: 'Preview', - }, summary: { confirmed: 'Confirmed', entryId: 'Entry Id', @@ -656,8 +653,9 @@ export default { }, smartCard: { openCard: 'View card', - openSummary: 'Open summary', + openSummary: 'Preview', viewDescription: 'View description', + clone: 'Clone', }, cardDescriptor: { mainList: 'Main list', diff --git a/src/i18n/es/index.js b/src/i18n/es/index.js index 3a7d09c3c..0f335bf60 100644 --- a/src/i18n/es/index.js +++ b/src/i18n/es/index.js @@ -15,6 +15,7 @@ export default { logOut: 'Cerrar sesión', dataSaved: 'Datos guardados', dataDeleted: 'Datos eliminados', + dataCreated: 'Datos creados', add: 'Añadir', create: 'Crear', save: 'Guardar', @@ -45,6 +46,7 @@ export default { statusBadGateway: 'Parece ser que el servidor ha caído', statusGatewayTimeout: 'No se ha podido contactar con el servidor', userConfig: 'Error al obtener configuración de usuario', + create: 'Error al crear', }, login: { title: 'Inicio de sesión', @@ -631,11 +633,6 @@ export default { create: 'Crear', summary: 'Resumen', }, - list: { - clone: 'Clonar', - addEntry: 'Añadir entrada', - preview: 'Vista previa', - }, summary: { confirmed: 'Confirmado', entryId: 'Id entrada', @@ -660,6 +657,7 @@ export default { openCard: 'Ficha', openSummary: 'Detalles', viewDescription: 'Ver descripción', + clone: 'Clonar', }, cardDescriptor: { mainList: 'Listado principal', diff --git a/src/pages/InvoiceOut/InvoiceOutGlobal.vue b/src/pages/InvoiceOut/InvoiceOutGlobal.vue index c4e853219..5ab66b574 100644 --- a/src/pages/InvoiceOut/InvoiceOutGlobal.vue +++ b/src/pages/InvoiceOut/InvoiceOutGlobal.vue @@ -160,7 +160,7 @@ onUnmounted(() => { .status-text { font-size: 14px; - color: #eeeeee; + color: white; } .text { diff --git a/src/pages/InvoiceOut/InvoiceOutList.vue b/src/pages/InvoiceOut/InvoiceOutList.vue index 2d2fd5093..9f708df00 100644 --- a/src/pages/InvoiceOut/InvoiceOutList.vue +++ b/src/pages/InvoiceOut/InvoiceOutList.vue @@ -148,7 +148,7 @@ const downloadCsv = (rows) => { flat icon="cloud_download" round - v-bind:class="{ dark_icon: !manageCheckboxes }" + :class="{ dark_icon: !manageCheckboxes }" > @@ -178,11 +178,11 @@ const downloadCsv = (rows) => { /> { - { - "en": { - "searchInvoice": "Search issued invoice", - "fileDenied": "Browser denied file download...", - "fileAllowed": "Successful download of CSV file", - "youCanSearchByInvoiceReference": "You can search by invoice reference" - }, - "es": { - "searchInvoice": "Buscar factura emitida", - "fileDenied": "El navegador denegó la descarga de archivos...", - "fileAllowed": "Descarga exitosa de archivo CSV", - "youCanSearchByInvoiceReference": "Puedes buscar por referencia de la factura" - } - } +en: + searchInvoice: Search issued invoice + fileDenied: Browser denied file download... + fileAllowed: Successful download of CSV file + youCanSearchByInvoiceReference: You can search by invoice reference + +es: + searchInvoice: Buscar factura emitida + fileDenied: El navegador denegó la descarga de archivos... + fileAllowed: Descarga exitosa de archivo CSV + youCanSearchByInvoiceReference: Puedes buscar por referencia de la factura diff --git a/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue b/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue index 96b9ac7f4..3935833eb 100644 --- a/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue +++ b/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue @@ -313,7 +313,7 @@ onMounted(async () => { - - { - "en": { - "status": { - "packageInvoicing": "Build packaging tickets", - "invoicing": "Invoicing client", - "stopping": "Stopping process", - "done": "Ended process" - }, - "of": "of" - }, - "es": { - "status":{ - "packageInvoicing": "Generación de tickets de empaque", - "invoicing": "Facturando a cliente", - "stopping": "Deteniendo proceso", - "done": "Proceso detenido", - }, - "of": "de" - } - } - + diff --git a/src/pages/Supplier/SupplierCreate.vue b/src/pages/Supplier/SupplierCreate.vue index e68e7ea8a..3d89264b3 100644 --- a/src/pages/Supplier/SupplierCreate.vue +++ b/src/pages/Supplier/SupplierCreate.vue @@ -1,22 +1,17 @@ - - + +
+ +
+
+ - - - - - -
+ +
diff --git a/src/pages/Travel/TravelCreate.vue b/src/pages/Travel/TravelCreate.vue index b41f7c567..0f6148c7e 100644 --- a/src/pages/Travel/TravelCreate.vue +++ b/src/pages/Travel/TravelCreate.vue @@ -1,18 +1,19 @@ diff --git a/src/pages/Travel/TravelFilter.vue b/src/pages/Travel/TravelFilter.vue index 27948db56..fc7fbfae3 100644 --- a/src/pages/Travel/TravelFilter.vue +++ b/src/pages/Travel/TravelFilter.vue @@ -66,7 +66,6 @@ const decrement = (paramsObj, key) => { { type="number" :label="t('params.scopeDays')" dense - lazy-rules outlined rounded class="input-number" @@ -153,7 +151,6 @@ const decrement = (paramsObj, key) => { { { type="number" :label="t('params.totalEntries')" dense - lazy-rules outlined rounded min="0" @@ -286,32 +281,27 @@ const decrement = (paramsObj, key) => { - { - "en": { - "params": { - "search": "Id/Reference", - "agencyModeFk": "Agency", - "warehouseInFk": "Warehouse In", - "warehouseOutFk": "Warehouse Out", - "scopeDays": "Days onward", - "landedFrom": "Landed from", - "landedTo": "Landed to", - "continent": "Continent out", - "totalEntries": "Total entries" - }, - }, - "es": { - "params":{ - "search": "Id/Referencia", - "agencyModeFk": "Agencia", - "warehouseInFk": "Alm. entrada", - "warehouseOutFk": "Alm. salida", - "scopeDays": "Días adelante", - "landedFrom": "Llegada desde", - "landedTo": "Llegada hasta", - "continent": "Cont. Salida", - "totalEntries": "Ent. totales" - }, - } - } +en: + params: + search: Id/Reference + agencyModeFk: Agency + warehouseInFk: Warehouse In + warehouseOutFk: Warehouse Out + scopeDays: Days onward + landedFrom: Landed from + landedTo: Landed to + continent: Continent out + totalEntries: Total entries +es: + params: + search: Id/Referencia + agencyModeFk: Agencia + warehouseInFk: Alm. entrada + warehouseOutFk: Alm. salida + scopeDays: Días adelante + landedFrom: Llegada desde + landedTo: Llegada hasta + continent: Cont. Salida + totalEntries: Ent. totales + diff --git a/src/pages/Travel/TravelList.vue b/src/pages/Travel/TravelList.vue index 2a4f312a1..f534a0c83 100644 --- a/src/pages/Travel/TravelList.vue +++ b/src/pages/Travel/TravelList.vue @@ -98,25 +98,23 @@ onMounted(async () => {
@@ -140,5 +138,12 @@ onMounted(async () => { +en: + addEntry: Add entry + + +es: + addEntry: Añadir entrada + diff --git a/src/services/suppliers.service.js b/src/services/suppliers.service.js deleted file mode 100644 index fa1023f27..000000000 --- a/src/services/suppliers.service.js +++ /dev/null @@ -1,14 +0,0 @@ -import axios from 'axios'; - -const suppliersService = { - createSupplier: async (formData) => { - try { - return await axios.post('Suppliers/newSupplier', formData); - } catch (err) { - console.error(`Error creating new supplier`, err); - return err.response; - } - }, -}; - -export default suppliersService; diff --git a/src/services/travel.service.js b/src/services/travel.service.js index 606e2eb48..4e6fbc4d8 100644 --- a/src/services/travel.service.js +++ b/src/services/travel.service.js @@ -10,15 +10,6 @@ const travelService = { } }, - createTravel: async (params) => { - try { - return await axios.patch('Travels', params); - } catch (err) { - console.error(`Error creating travel`, err); - return err.response; - } - }, - getTravelEntries: async (param) => { try { return await axios.get(`Travels/${param}/getEntries`); diff --git a/src/stores/travel.js b/src/stores/travel.js index 39be11814..7d1aa8fd5 100644 --- a/src/stores/travel.js +++ b/src/stores/travel.js @@ -17,19 +17,6 @@ export const useTravelStore = defineStore({ const { data } = await travelService.getTravels(); this.travels = data || []; }, - - async createTravel(travelData) { - const params = { - ref: travelData.ref, - agencyModeFk: travelData.agencyModeFk, - warehouseOutFk: travelData.warehouseOutFk, - warehouseInFk: travelData.warehouseInFk, - landed: new Date(travelData.landed), - shipped: new Date(travelData.shipped), - }; - - return await travelService.createTravel(params); - }, }, getters: {},