Mathieu Jaumotte 884de5c19e address refactoring: resolve lack of flexibility for many implementations (modal/not, overriding, options, etc. )
address creation/edition is unchanged
many variables are renamed to improve logic and readability
2021-08-04 23:24:52 +02:00

59 lines
1.6 KiB
Vue

<template>
<add-address
v-bind:context="context"
v-bind:key="addAddress.key"
v-bind:options="addAddress.options"
@submitAddress="submitAddress"
ref="addAddress">
</add-address>
</template>
<script>
import AddAddress from './components/AddAddress.vue';
export default {
name: "App",
components: {
AddAddress
},
data() {
return {
context: {
edit: window.mode === 'edit',
personId: window.personId,
addressId: window.addressId,
backUrl: `/fr/person/${window.personId}/address/list`, //TODO better way to pass this
validFrom: new Date().toISOString().split('T')[0]
},
addAddress: {
key: 'person',
options: {
/// Options override default
/// First button text if create or edit address (trans chain, see i18n)
//textButton: { create: 'bim', edit: 'bam' },
/// Modal title text if create or edit address (trans chain, see i18n)
//title: { create: 'boum', edit: 'pan' },
/// Display each step in page or Modal
//bindModal: { step1: false, step2: false } //TODO true-false must not be possible
}
}
}
},
methods: {
submitAddress({ submited, flag }) {
console.log('@@@ CLICK button submitAddress');
console.log('address to post:', submited);
console.log('datas by refs: ', this.$refs.addAddress.entity.address.text);
this.$refs.addAddress.initForm(); // to cast child method
flag.showPane = false;
}
}
}
</script>