mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
corrections + details
This commit is contained in:
parent
63fbf4b249
commit
e178183cef
@ -28,6 +28,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
/*
|
||||||
|
* Address component is a uniq component for many contexts.
|
||||||
|
* Allow to create/attach/edit an address to
|
||||||
|
* - a person (new or edit address),
|
||||||
|
* - a household (move or edit address)
|
||||||
|
*
|
||||||
|
* */
|
||||||
import AddAddress from './components/AddAddress.vue';
|
import AddAddress from './components/AddAddress.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -362,8 +362,8 @@ export default {
|
|||||||
* apply some transformations before asyncing with backend
|
* apply some transformations before asyncing with backend
|
||||||
* from entity.selected to entity.address
|
* from entity.selected to entity.address
|
||||||
*/
|
*/
|
||||||
applyChanges() {
|
applyChanges()
|
||||||
|
{
|
||||||
let newAddress = {
|
let newAddress = {
|
||||||
'isNoAddress': this.entity.selected.isNoAddress,
|
'isNoAddress': this.entity.selected.isNoAddress,
|
||||||
'street': this.entity.selected.isNoAddress ? '' : this.entity.selected.address.street,
|
'street': this.entity.selected.isNoAddress ? '' : this.entity.selected.address.street,
|
||||||
@ -403,6 +403,52 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Async POST transactions,
|
||||||
|
* creating new address, and receive backend datas when promise is resolved
|
||||||
|
*/
|
||||||
|
addAddress(payload)
|
||||||
|
{
|
||||||
|
this.flag.loading = true;
|
||||||
|
if ('newPostcode' in payload) {
|
||||||
|
|
||||||
|
let postcodeBody = payload.newPostcode;
|
||||||
|
if (this.context.entity.type === 'person') {
|
||||||
|
postcodeBody = Object.assign(postcodeBody, {'origin': 3});
|
||||||
|
}
|
||||||
|
|
||||||
|
postPostalCode(postcodeBody)
|
||||||
|
.then(postalCode => {
|
||||||
|
let body = payload;
|
||||||
|
body.postcode = {'id': postalCode.id },
|
||||||
|
postAddress(body)
|
||||||
|
.then(address => new Promise((resolve, reject) => {
|
||||||
|
this.entity.address = address;
|
||||||
|
this.flag.loading = false;
|
||||||
|
this.flag.success = true;
|
||||||
|
resolve();
|
||||||
|
}))
|
||||||
|
.catch((error) => {
|
||||||
|
this.errorMsg.push(error);
|
||||||
|
this.flag.loading = false;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
postAddress(payload)
|
||||||
|
.then(address => new Promise((resolve, reject) => {
|
||||||
|
this.entity.address = address;
|
||||||
|
this.flag.loading = false;
|
||||||
|
this.flag.success = true;
|
||||||
|
resolve();
|
||||||
|
}))
|
||||||
|
.catch((error) => {
|
||||||
|
this.errorMsg.push(error);
|
||||||
|
this.flag.loading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Async PATCH transactions,
|
* Async PATCH transactions,
|
||||||
* then update existing address with backend datas when promise is resolved
|
* then update existing address with backend datas when promise is resolved
|
||||||
@ -423,6 +469,7 @@ export default {
|
|||||||
.then(address => new Promise((resolve, reject) => {
|
.then(address => new Promise((resolve, reject) => {
|
||||||
this.entity.address = address;
|
this.entity.address = address;
|
||||||
this.flag.loading = false;
|
this.flag.loading = false;
|
||||||
|
this.flag.success = true;
|
||||||
resolve();
|
resolve();
|
||||||
}))
|
}))
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
@ -436,6 +483,7 @@ export default {
|
|||||||
.then(address => new Promise((resolve, reject) => {
|
.then(address => new Promise((resolve, reject) => {
|
||||||
this.entity.address = address;
|
this.entity.address = address;
|
||||||
this.flag.loading = false;
|
this.flag.loading = false;
|
||||||
|
this.flag.success = true;
|
||||||
resolve();
|
resolve();
|
||||||
}))
|
}))
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
@ -445,47 +493,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
|
||||||
* Async POST transactions,
|
|
||||||
* creating new address, and receive backend datas when promise is resolved
|
|
||||||
*/
|
|
||||||
addAddress(payload)
|
|
||||||
{
|
|
||||||
this.flag.loading = true;
|
|
||||||
if('newPostcode' in payload){
|
|
||||||
let postcodeBody = payload.newPostcode;
|
|
||||||
postcodeBody = Object.assign(postcodeBody, {'origin': 3});
|
|
||||||
|
|
||||||
postPostalCode(postcodeBody)
|
|
||||||
.then(postalCode => {
|
|
||||||
let body = payload;
|
|
||||||
body.postcode = {'id': postalCode.id},
|
|
||||||
postAddress(body)
|
|
||||||
.then(address => new Promise((resolve, reject) => {
|
|
||||||
this.entity.address = address;
|
|
||||||
resolve();
|
|
||||||
this.flag.loading = false;
|
|
||||||
}))
|
|
||||||
.catch((error) => {
|
|
||||||
this.errorMsg.push(error);
|
|
||||||
this.flag.loading = false;
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
} else {
|
|
||||||
postAddress(payload)
|
|
||||||
.then(address => new Promise((resolve, reject) => {
|
|
||||||
this.entity.address = address;
|
|
||||||
resolve();
|
|
||||||
this.flag.loading = false;
|
|
||||||
}))
|
|
||||||
.catch((error) => {
|
|
||||||
this.errorMsg.push(error);
|
|
||||||
this.flag.loading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When submit address (step1 show pane)
|
* When submit address (step1 show pane)
|
||||||
*/
|
*/
|
||||||
@ -528,12 +535,11 @@ export default {
|
|||||||
postAddressToPerson(payload.entityId, payload.addressId)
|
postAddressToPerson(payload.entityId, payload.addressId)
|
||||||
.then(person => new Promise((resolve, reject) => {
|
.then(person => new Promise((resolve, reject) => {
|
||||||
|
|
||||||
console.log('commit addAddressToPerson !!!', person);
|
console.log('TODO commit addAddressToPerson !!!', person);
|
||||||
//this.$props.result = person;
|
//this.$props.result = person;
|
||||||
|
|
||||||
this.flag.loading = false;
|
this.flag.loading = false;
|
||||||
this.flag.success = true;
|
this.flag.success = true;
|
||||||
|
|
||||||
if (this.options.redirectToBackUrl) {
|
if (this.options.redirectToBackUrl) {
|
||||||
window.location.assign(payload.backUrl);
|
window.location.assign(payload.backUrl);
|
||||||
}
|
}
|
||||||
@ -563,11 +569,10 @@ export default {
|
|||||||
postAddressToHousehold(payload.entityId, payload.addressId)
|
postAddressToHousehold(payload.entityId, payload.addressId)
|
||||||
.then(household => new Promise((resolve, reject) => {
|
.then(household => new Promise((resolve, reject) => {
|
||||||
|
|
||||||
console.log('commit addAddressToHousehold', household);
|
console.log('TODO commit addAddressToHousehold', household);
|
||||||
|
|
||||||
this.flag.success = true;
|
|
||||||
this.flag.loading = false;
|
this.flag.loading = false;
|
||||||
|
this.flag.success = true;
|
||||||
if (this.options.redirectToBackUrl) {
|
if (this.options.redirectToBackUrl) {
|
||||||
window.location.assign(payload.backUrl);
|
window.location.assign(payload.backUrl);
|
||||||
}
|
}
|
||||||
|
@ -68,13 +68,13 @@
|
|||||||
aria-describedby="validFrom"
|
aria-describedby="validFrom"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<!--div v-if="errorMsg.length > 0">
|
|
||||||
{{ errors }}
|
|
||||||
</div-->
|
|
||||||
<div v-if="flag.loading">
|
<div v-if="flag.loading">
|
||||||
{{ $t('loading') }}
|
{{ $t('loading') }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="flag.success">
|
<div v-if="errorMsg.length > 0" class="alert alert-danger">
|
||||||
|
{{ errors }}
|
||||||
|
</div>
|
||||||
|
<div v-if="flag.success" class="alert alert-success">
|
||||||
{{ $t('person_address_creation_success') }}
|
{{ $t('person_address_creation_success') }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
{# include vue_address component #}
|
{# include vue_address component #}
|
||||||
{% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
|
{% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
|
||||||
address_id: person.lastAddress.id,
|
|
||||||
mode: 'new',
|
mode: 'new',
|
||||||
buttonSize: 'btn-lg',
|
buttonSize: 'btn-lg',
|
||||||
buttonText: 'Add an address',
|
buttonText: 'Add an address',
|
||||||
|
@ -15,10 +15,13 @@
|
|||||||
<li style="margin: auto;">
|
<li style="margin: auto;">
|
||||||
|
|
||||||
{# include vue_address component #}
|
{# include vue_address component #}
|
||||||
<a class="btn btn-lg btn-create"
|
{% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
|
||||||
href="{{ chill_path_add_return_path('chill_person_household_address_move', { 'household_id': household.id }) }}">
|
mode: 'new',
|
||||||
{{ 'Move household'|trans }}
|
backUrl: chill_path_add_return_path('chill_person_household_address_move', { 'household_id': household.id }),
|
||||||
</a>
|
buttonSize: 'btn-lg',
|
||||||
|
buttonText: 'Move household',
|
||||||
|
modalTitle: 'Move household',
|
||||||
|
} %}
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user