0
0
Fork 0

Merge pull request '#7825: Fill the bank field when a new entity is created' (!798) from 7825-FixCreatebankEntity into dev

Reviewed-on: verdnatura/salix-front#798
Reviewed-by: Javier Segarra <jsegarra@verdnatura.es>
This commit is contained in:
Jon Elias 2024-10-15 11:42:38 +00:00
commit 4fb3e0dadf
2 changed files with 13 additions and 3 deletions

View File

@ -31,8 +31,8 @@ const countriesFilter = {
const countriesOptions = ref([]); const countriesOptions = ref([]);
const onDataSaved = (formData, requestResponse) => { const onDataSaved = (...args) => {
emit('onDataSaved', formData, requestResponse); emit('onDataSaved', ...args);
}; };
onMounted(async () => { onMounted(async () => {

View File

@ -29,6 +29,7 @@ const postcodesOptions = ref([]);
const user = useState().getUser(); const user = useState().getUser();
const defaultPayMethod = ref(); const defaultPayMethod = ref();
const bankEntitiesRef = ref();
const columns = computed(() => [ const columns = computed(() => [
{ {
align: 'left', align: 'left',
@ -118,6 +119,12 @@ onBeforeMount(async () => {
).data?.payMethodFk; ).data?.payMethodFk;
}); });
async function handleNewBankEntity(data, resp) {
await bankEntitiesRef.value.fetch();
data.bankEntityFk = resp.id;
bankEntitiesOptions.value.push(resp);
}
function handleLocation(data, location) { function handleLocation(data, location) {
const { town, code, provinceFk, countryFk } = location ?? {}; const { town, code, provinceFk, countryFk } = location ?? {};
data.postcode = code; data.postcode = code;
@ -177,6 +184,7 @@ async function autofillBic(worker) {
auto-load auto-load
/> />
<FetchData <FetchData
ref="bankEntitiesRef"
url="BankEntities" url="BankEntities"
@on-fetch="(data) => (bankEntitiesOptions = data)" @on-fetch="(data) => (bankEntitiesOptions = data)"
auto-load auto-load
@ -344,7 +352,9 @@ async function autofillBic(worker) {
> >
<template #form> <template #form>
<CreateBankEntityForm <CreateBankEntityForm
@on-data-saved="(data) => bankEntitiesOptions.push(data)" @on-data-saved="
(_, resp) => handleNewBankEntity(data, resp)
"
/> />
</template> </template>
<template #option="scope"> <template #option="scope">