diff --git a/package.json b/package.json index c4f5b828a..1d729b82f 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,7 @@ "validator": "^13.9.0", "vue": "^3.3.4", "vue-i18n": "^9.2.2", - "vue-router": "^4.2.1", - "vue-router-mock": "^0.2.0" + "vue-router": "^4.2.1" }, "devDependencies": { "@intlify/unplugin-vue-i18n": "^0.8.1", diff --git a/src/components/CreateBankEntityForm.vue b/src/components/CreateBankEntityForm.vue new file mode 100644 index 000000000..f4f5fef7d --- /dev/null +++ b/src/components/CreateBankEntityForm.vue @@ -0,0 +1,99 @@ + + + + + +en: + title: New bank entity + subtitle: Please, ensure you put the correct data! + name: Name * + swift: Swift * + country: Country + id: Entity code +es: + title: Nueva entidad bancaria + subtitle: ¡Por favor, asegúrate de poner los datos correctos! + name: Nombre * + swift: Swift * + country: País + id: Código de la entidad + diff --git a/src/components/CreateDepartmentChild.vue b/src/components/CreateDepartmentChild.vue new file mode 100644 index 000000000..8f5b4b874 --- /dev/null +++ b/src/components/CreateDepartmentChild.vue @@ -0,0 +1,100 @@ + + + + + + + +es: + Name: Nombre + New department: Nuevo departamento + diff --git a/src/components/CreateNewCityForm.vue b/src/components/CreateNewCityForm.vue new file mode 100644 index 000000000..ee842e86f --- /dev/null +++ b/src/components/CreateNewCityForm.vue @@ -0,0 +1,72 @@ + + + + + +es: + New city: Nueva ciudad + Please, ensure you put the correct data!: ¡Por favor, asegúrese de poner los datos correctos! + Name: Nombre + Province: Provincia + diff --git a/src/components/CreateNewPostcodeForm.vue b/src/components/CreateNewPostcodeForm.vue new file mode 100644 index 000000000..3504445f8 --- /dev/null +++ b/src/components/CreateNewPostcodeForm.vue @@ -0,0 +1,138 @@ + + + + + +es: + New postcode: Nuevo código postal + Please, ensure you put the correct data!: ¡Por favor, asegúrese de poner los datos correctos! + City: Ciudad + Province: Provincia + Country: País + Postcode: Código postal + diff --git a/src/components/CreateNewProvinceForm.vue b/src/components/CreateNewProvinceForm.vue new file mode 100644 index 000000000..0f88952ea --- /dev/null +++ b/src/components/CreateNewProvinceForm.vue @@ -0,0 +1,72 @@ + + + + + +es: + New province: Nueva provincia + Please, ensure you put the correct data!: ¡Por favor, asegúrese de poner los datos correctos! + Name: Nombre + Autonomy: Autonomía + diff --git a/src/components/FetchData.vue b/src/components/FetchData.vue index f0d908972..137f751db 100644 --- a/src/components/FetchData.vue +++ b/src/components/FetchData.vue @@ -27,6 +27,10 @@ const $props = defineProps({ type: String, default: '', }, + params: { + type: Object, + default: null, + }, }); const emit = defineEmits(['onFetch']); @@ -38,15 +42,15 @@ onMounted(async () => { } }); -async function fetch() { +async function fetch(fetchFilter = {}) { try { - const filter = Object.assign({}, $props.filter); // eslint-disable-line vue/no-dupe-keys + const filter = Object.assign(fetchFilter, $props.filter); // eslint-disable-line vue/no-dupe-keys if ($props.where) filter.where = $props.where; if ($props.sortBy) filter.order = $props.sortBy; if ($props.limit) filter.limit = $props.limit; const { data } = await axios.get($props.url, { - params: { filter: JSON.stringify(filter) }, + params: { filter: JSON.stringify(filter), ...$props.params }, }); emit('onFetch', data); diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index 453b3ffe1..a5560dfc0 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -55,9 +55,13 @@ const $props = defineProps({ 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)', }, + mapper: { + type: Function, + default: null, + }, }); -const emit = defineEmits(['onFetch']); +const emit = defineEmits(['onFetch', 'onDataSaved']); defineExpose({ save, @@ -83,8 +87,9 @@ onUnmounted(() => { const isLoading = ref(false); // Si elegimos observar los cambios del form significa que inicialmente las actions estaran deshabilitadas +const isResetting = ref(false); const hasChanges = ref(!$props.observeFormChanges); -const originalData = ref({...$props.formInitialData}); +const originalData = ref({ ...$props.formInitialData }); const formData = computed(() => state.get($props.model)); const formUrl = computed(() => $props.url); @@ -92,7 +97,8 @@ const startFormWatcher = () => { watch( () => formData.value, (val) => { - if (val) hasChanges.value = true; + hasChanges.value = !isResetting.value && val; + isResetting.value = false; }, { deep: true } ); @@ -114,25 +120,26 @@ async function fetch() { } async function save() { - if (!hasChanges.value) { + if ($props.observeFormChanges && !hasChanges.value) { notify('globals.noChanges', 'negative'); return; } isLoading.value = true; try { + const body = $props.mapper ? $props.mapper(formData.value) : formData.value; if ($props.urlCreate) { - await axios.post($props.urlCreate, formData.value); + await axios.post($props.urlCreate, body); notify('globals.dataCreated', 'positive'); } else { - await axios.patch($props.urlUpdate || $props.url, formData.value); + await axios.patch($props.urlUpdate || $props.url, body); } + emit('onDataSaved', formData.value); + originalData.value = JSON.parse(JSON.stringify(formData.value)); + hasChanges.value = false; } catch (err) { notify('errors.create', 'negative'); } - - originalData.value = JSON.parse(JSON.stringify(formData.value)); - hasChanges.value = false; isLoading.value = false; } @@ -143,6 +150,7 @@ function reset() { emit('onFetch', state.get($props.model)); if ($props.observeFormChanges) { hasChanges.value = false; + isResetting.value = true; } } @@ -168,11 +176,14 @@ watch(formUrl, async () => { }); diff --git a/src/components/common/SendEmailDialog.vue b/src/components/common/SendEmailDialog.vue index 0f574a795..501c48a4d 100644 --- a/src/components/common/SendEmailDialog.vue +++ b/src/components/common/SendEmailDialog.vue @@ -1,7 +1,9 @@ + + + + + + es: + Check the columns you want to see: Marca las columnas que quieres ver + Visible columns: Columnas visibles + diff --git a/src/components/common/VnInput.vue b/src/components/common/VnInput.vue new file mode 100644 index 000000000..cdc6dd865 --- /dev/null +++ b/src/components/common/VnInput.vue @@ -0,0 +1,52 @@ + + + diff --git a/src/components/common/VnInputDate.vue b/src/components/common/VnInputDate.vue index a8e0d4a43..8e0ef2890 100644 --- a/src/components/common/VnInputDate.vue +++ b/src/components/common/VnInputDate.vue @@ -10,7 +10,11 @@ const props = defineProps({ readonly: { type: Boolean, default: false, - } + }, + isOutlined: { + type: Boolean, + default: false, + }, }); const emit = defineEmits(['update:modelValue']); const value = computed({ @@ -36,6 +40,16 @@ const formatDate = (dateString) => { date.getDate() )}`; }; + +const styleAttrs = computed(() => { + return props.isOutlined + ? { + dense: true, + outlined: true, + rounded: true, + } + : {}; +});