mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'improve_address' into person_renderbox_thirdparty_onthefly
This commit is contained in:
commit
7d2e82d69b
@ -31,8 +31,8 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
//console.log('AddAddress: data context', this.context);
|
||||
//console.log('AddAddress: data options', this.options);
|
||||
console.log('AddAddress: data context', this.context);
|
||||
console.log('AddAddress: data options', this.options);
|
||||
},
|
||||
methods: {
|
||||
displayErrors() {
|
||||
@ -45,7 +45,7 @@ export default {
|
||||
if (this.context.edit) {
|
||||
|
||||
// address is already linked, just finish !
|
||||
this.$refs.addAddress.lastPaneAction();
|
||||
this.$refs.addAddress.afterLastPaneAction({});
|
||||
|
||||
// New created address
|
||||
} else {
|
||||
@ -83,17 +83,17 @@ export default {
|
||||
* Post new created address to targetEntity
|
||||
*/
|
||||
postAddressTo(payload) {
|
||||
console.log('postAddressTo', payload.target);
|
||||
console.log('postAddress', payload.addressId, 'To', payload.target, payload.targetId);
|
||||
switch (payload.target) {
|
||||
case 'household':
|
||||
postAddressToHousehold(payload.targetId, payload.addressId)
|
||||
.then(household => new Promise((resolve, reject) => {
|
||||
console.log('..toHousehold', household);
|
||||
.then(address => new Promise((resolve, reject) => {
|
||||
console.log('..household address', address);
|
||||
this.$refs.addAddress.flag.loading = false;
|
||||
this.$refs.addAddress.flag.success = true;
|
||||
|
||||
// finish
|
||||
this.$refs.addAddress.lastPaneAction();
|
||||
this.$refs.addAddress.afterLastPaneAction({ addressId: address.address_id });
|
||||
|
||||
resolve();
|
||||
}))
|
||||
@ -105,13 +105,13 @@ export default {
|
||||
break;
|
||||
case 'person':
|
||||
postAddressToPerson(payload.targetId, payload.addressId)
|
||||
.then(person => new Promise((resolve, reject) => {
|
||||
console.log('..toPerson', person);
|
||||
.then(address => new Promise((resolve, reject) => {
|
||||
console.log('..person address', address);
|
||||
this.$refs.addAddress.flag.loading = false;
|
||||
this.$refs.addAddress.flag.success = true;
|
||||
|
||||
// finish
|
||||
this.$refs.addAddress.lastPaneAction();
|
||||
this.$refs.addAddress.afterLastPaneAction({ addressId: address.address_id });
|
||||
|
||||
resolve();
|
||||
}))
|
||||
|
@ -104,7 +104,11 @@
|
||||
<button class="btn btn-cancel change-icon" @click="resetPane">
|
||||
{{ $t('action.cancel') }}
|
||||
</button>
|
||||
<button class="btn btn-save" @click="closeEditPane">
|
||||
<button v-if="useDatePane" class="btn btn-misc" @click="closeEditPane">
|
||||
{{ $t('nav.next')}}
|
||||
<i class="fa fa-fw fa-arrow-right"></i>
|
||||
</button>
|
||||
<button v-else class="btn btn-save" @click="closeEditPane">
|
||||
{{ $t('action.save')}}
|
||||
</button>
|
||||
</template>
|
||||
@ -128,7 +132,13 @@
|
||||
</a>
|
||||
</template>
|
||||
<template v-slot:action>
|
||||
<li>
|
||||
<li v-if="useDatePane">
|
||||
<button class="btn btn-misc" @click="closeEditPane">
|
||||
{{ $t('nav.next')}}
|
||||
<i class="fa fa-fw fa-arrow-right"></i>
|
||||
</button>
|
||||
</li>
|
||||
<li v-else>
|
||||
<button class="btn btn-save" @click="closeEditPane">
|
||||
{{ $t('action.save')}}
|
||||
</button>
|
||||
@ -189,7 +199,7 @@
|
||||
|
||||
<template v-slot:action>
|
||||
<li>
|
||||
<button class="btn btn-update" @click="openEditPane">
|
||||
<button class="btn btn-update" @click="closeDatePane">
|
||||
{{ $t('action.edit')}}
|
||||
</button>
|
||||
</li>
|
||||
@ -323,7 +333,7 @@ export default {
|
||||
//console.log('options bindModal.step2', this.options.bindModal.step2);
|
||||
//console.log('options useDate.validFrom', this.options.useDate.validFrom);
|
||||
//console.log('options useDate.validTo', this.options.useDate.validTo);
|
||||
//console.log('useDatePane', this.useDatePane);
|
||||
console.log('useDatePane', this.useDatePane);
|
||||
|
||||
console.log('Mounted now !');
|
||||
if (this.context.edit) {
|
||||
@ -378,13 +388,15 @@ export default {
|
||||
}
|
||||
},
|
||||
closeEditPane() {
|
||||
this.applyChanges();
|
||||
this.flag.editPane = false;
|
||||
console.log('step2: close the Edit Panel');
|
||||
if (!this.context.edit && this.useDatePane) {
|
||||
this.openDatePane();
|
||||
} else {
|
||||
this.openShowPane()
|
||||
this.applyChanges();
|
||||
if (!this.options.forceRedirect) {
|
||||
this.openShowPane();
|
||||
}
|
||||
}
|
||||
},
|
||||
openDatePane() {
|
||||
@ -392,6 +404,7 @@ export default {
|
||||
console.log('step3: open the Date Panel');
|
||||
},
|
||||
closeDatePane() {
|
||||
this.applyChanges();
|
||||
this.flag.datePane = false;
|
||||
console.log('step3: close the Date Panel');
|
||||
},
|
||||
@ -402,13 +415,25 @@ export default {
|
||||
this.flag.datePane = false;
|
||||
this.openShowPane();
|
||||
},
|
||||
lastPaneAction() {
|
||||
|
||||
/*
|
||||
* What happens when submitting last Pane:
|
||||
* - redirect or reset pane,
|
||||
* - change context to editing
|
||||
*/
|
||||
afterLastPaneAction(params) {
|
||||
this.initForm();
|
||||
if (this.options.forceRedirect === true) {
|
||||
console.log("redirect to backUrl");
|
||||
window.location.assign(this.context.backUrl);
|
||||
} else {
|
||||
console.log("don't redirect");
|
||||
this.resetPane();
|
||||
if (!this.context.edit) {
|
||||
this.context.edit = true;
|
||||
this.context.addressId = params.addressId;
|
||||
console.log("context is now edit, with address", params.addressId);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -546,14 +571,14 @@ export default {
|
||||
|
||||
if (!this.context.edit) {
|
||||
this.addNewAddress(newAddress)
|
||||
.then(payload => this.closePaneAndCallbackSubmit(payload));
|
||||
.then(payload => this.addressChangedCallback(payload));
|
||||
|
||||
} else {
|
||||
this.updateAddress({
|
||||
addressId: this.context.addressId,
|
||||
newAddress: newAddress
|
||||
})
|
||||
.then(payload => this.closePaneAndCallbackSubmit(payload));
|
||||
.then(payload => this.addressChangedCallback(payload));
|
||||
}
|
||||
},
|
||||
|
||||
@ -563,7 +588,7 @@ export default {
|
||||
*/
|
||||
addNewAddress(payload)
|
||||
{
|
||||
//console.log('addNewAddress', payload);
|
||||
console.log('addNewAddress', payload);
|
||||
this.flag.loading = true;
|
||||
|
||||
if ('newPostcode' in payload) {
|
||||
@ -583,8 +608,9 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
postNewAddress(payload) {
|
||||
//console.log('postNewAddress', payload);
|
||||
postNewAddress(payload)
|
||||
{
|
||||
console.log('postNewAddress', payload);
|
||||
return postAddress(payload)
|
||||
.then(address => new Promise((resolve, reject) => {
|
||||
this.entity.address = address;
|
||||
@ -654,18 +680,15 @@ export default {
|
||||
/*
|
||||
* Method just add closing pane to the callback method
|
||||
* (get out step1 show pane, submit button)
|
||||
*/
|
||||
closePaneAndCallbackSubmit(payload)
|
||||
{
|
||||
|
||||
this.initForm();
|
||||
this.resetPane();
|
||||
|
||||
//this.initForm();
|
||||
//this.resetPane(); // because parent callback will cast afterLastPaneAction()
|
||||
console.log('will call parent callback method', payload);
|
||||
|
||||
// callback props method from parent
|
||||
this.addressChangedCallback(payload);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -9,10 +9,6 @@
|
||||
{{ errorMsg }}
|
||||
</div>
|
||||
|
||||
<div v-if="flag.success" class="alert alert-success">
|
||||
{{ $t(getSuccessText) }}
|
||||
</div>
|
||||
|
||||
<address-render-box :address="address"></address-render-box>
|
||||
|
||||
<div v-if="showDateFrom" class='address-valid date-since'>
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
<div v-if="errorMsg && errorMsg.length > 0" class="alert alert-danger">{{ errorMsg }}</div>
|
||||
|
||||
<div v-if="flag.success" class="alert alert-success">{{ $t(getSuccessText) }}</div>
|
||||
|
||||
<h4 class="h3">{{ $t('address_suggestions') }}</h4>
|
||||
|
||||
<div class="flex-table AddressSuggestionList">
|
||||
|
@ -16,10 +16,10 @@ containers.forEach((container) => {
|
||||
context: {
|
||||
target: {
|
||||
name: container.dataset.targetName,
|
||||
id: container.dataset.targetId
|
||||
id: parseInt(container.dataset.targetId)
|
||||
},
|
||||
edit: container.dataset.mode === 'edit', //boolean
|
||||
addressId: container.dataset.addressId || null,
|
||||
addressId: parseInt(container.dataset.addressId) || null,
|
||||
backUrl: container.dataset.backUrl || null
|
||||
},
|
||||
options: {
|
||||
|
@ -30,11 +30,11 @@
|
||||
{% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
|
||||
targetEntity: { name: 'person', id: person.id },
|
||||
backUrl: path('chill_person_address_list', { 'person_id': person.id }),
|
||||
useValidFrom: true,
|
||||
openPanesInModal: false,
|
||||
stickyActions: true,
|
||||
} %}
|
||||
{#
|
||||
useValidFrom: true,
|
||||
#}
|
||||
|
||||
{% endblock %}
|
||||
|
@ -10,6 +10,7 @@
|
||||
{% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
|
||||
targetEntity: { name: 'household', id: household.id },
|
||||
backUrl: path('chill_person_household_addresses', { 'household_id': household.id }),
|
||||
forceRedirect: true,
|
||||
stickyActions: true,
|
||||
} %}
|
||||
{#
|
||||
|
@ -18,12 +18,12 @@
|
||||
{% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
|
||||
targetEntity: { name: 'household', id: household.id },
|
||||
backUrl: path('chill_person_household_addresses', { 'household_id': household.id }),
|
||||
forceRedirect: true,
|
||||
mode: 'new',
|
||||
useValidFrom: true,
|
||||
buttonSize: 'btn-lg',
|
||||
buttonText: 'Move household',
|
||||
modalTitle: 'Move household',
|
||||
forceRedirect: true,
|
||||
} %}
|
||||
{#
|
||||
#}
|
||||
|
Loading…
x
Reference in New Issue
Block a user