#6317 create vnCurrency #181

Merged
jorgep merged 16 commits from 6317-createVnCurrency into dev 2024-03-01 07:39:06 +00:00
4 changed files with 8 additions and 13 deletions
Showing only changes of commit c6e9ae2c5f - Show all commits

View File

@ -2,7 +2,6 @@
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { useCapitalize } from 'src/composables/useCapitalize';
import { useValidNumber } from 'src/composables/useValidNumber';
import VnInput from 'src/components/common/VnInput.vue';
const props = defineProps({
@ -19,15 +18,16 @@ const amount = computed({
return props.modelValue;
},
set(val) {
emit('update:modelValue', val.replaceAll(',', '.'));
emit('update:modelValue', val);
},
jorgep marked this conversation as resolved Outdated
Outdated
Review

En angularjs fa aço: front/core/filters/currency.js ns si en vue hi ha algo paregut

En angularjs fa aço: front/core/filters/currency.js ns si en vue hi ha algo paregut

Esto con el type number no es necesario.

Esto con el type number no es necesario.
});
</script>
<template>
<VnInput
v-model="amount"
type="number"
jorgep marked this conversation as resolved Outdated
Outdated
Review

Html(i quasar) te la posibilitat de gastar type="number"
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number

En un component q soles accepta numeros (tambe dixa '.' i ',') seria lo mes apropiat

Html(i quasar) te la posibilitat de gastar type="number" https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number En un component q soles accepta numeros (tambe dixa '.' i ',') seria lo mes apropiat

Si gasto type="number" sale el banner predeterminado de html5 cuando escribes un número con coma, Una posible solución es añadir novalidate en el QForm.

https://www.w3schools.com/tags/att_form_novalidate.asp

Usando step="any" se admiten decimales con coma y punto.

Si gasto type="number" sale el banner predeterminado de html5 cuando escribes un número con coma, Una posible solución es añadir novalidate en el QForm. https://www.w3schools.com/tags/att_form_novalidate.asp Usando step="any" se admiten decimales con coma y punto.
step="any"
:label="useCapitalize(t('amount'))"
:rules="[(val) => useValidNumber(val) || !val]"
is-outlined
>
<template #prepend v-if="icon">
@ -35,11 +35,6 @@ const amount = computed({
</template>
</VnInput>
</template>
<style lang="scss" scoped>
.q-input {
max-height: 44px;
}
</style>
<i18n>
es:
amount: importe

View File

@ -1,3 +0,0 @@
export function useValidNumber(value) {
return /^(\d|\d+(\.)?\d+)$/.test(value);
}

View File

@ -8,6 +8,7 @@ import { useArrayData } from 'src/composables/useArrayData';
import CrudModel from 'src/components/CrudModel.vue';
import FetchData from 'src/components/FetchData.vue';
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
import VnCurrency from 'src/components/common/VnCurrency.vue';
const route = useRoute();
const { t } = useI18n();
@ -158,9 +159,9 @@ async function insert() {
</template>
<template #body-cell-amount="{ row }">
<QTd>
<QInput
<VnCurrency
v-model="row.amount"
jorgep marked this conversation as resolved
Review

Aci si que el has gastat

Aci si que el has gastat
type="number"
:is-outlined="false"
clearable
clear-icon="close"
/>

View File

@ -5,10 +5,12 @@ describe('InvoiceInList', () => {
':nth-child(1) > :nth-child(1) > .justify-between > .flex > .q-chip > .q-chip__content';
const firstDetailBtn = '.q-card:nth-child(1) .q-btn:nth-child(2)';
const summaryHeaders = '.summaryBody .header';
const screen = '.q-page-container > .q-drawer-container > .fullscreen';
beforeEach(() => {
cy.login('developer');
cy.visit(`/#/invoice-in/list`);
cy.get(screen).click();
});
it('should redirect on clicking a invoice', () => {