mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
address: edit household addresses
This commit is contained in:
parent
67c31e781d
commit
842dfcc69f
@ -150,14 +150,19 @@ class HouseholdController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
public function addressEdit(Request $request, Household $household)
|
public function addressEdit(Request $request, Household $household)
|
||||||
{
|
{
|
||||||
// TODO ACL
|
|
||||||
//$address = $this->findAddressById($household, $address_id); //TODO
|
|
||||||
|
|
||||||
|
// TODO ACL
|
||||||
|
|
||||||
|
$address_id = $request->query->get('address_id');
|
||||||
|
$address = $this->getDoctrine()->getManager()
|
||||||
|
->getRepository(Address::class)
|
||||||
|
->find($address_id)
|
||||||
|
;
|
||||||
|
|
||||||
return $this->render('@ChillPerson/Household/address_edit.html.twig',
|
return $this->render('@ChillPerson/Household/address_edit.html.twig',
|
||||||
[
|
[
|
||||||
'household' => $household,
|
'household' => $household,
|
||||||
//'address' => $address,
|
'address' => $address,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
<div class='household__address-move'>
|
<div class='household__address-move'>
|
||||||
<div class='household__address-move__create'>
|
<div class='household__address-move__create'>
|
||||||
<div>
|
<div>
|
||||||
<h2>{{ $t('create_a_new_address') }}</h2>
|
<h2 v-if="!edit">{{ $t('create_a_new_address') }}</h2>
|
||||||
|
<h2 v-else>{{ $t('edit_a_new_address') }}</h2>
|
||||||
<add-address
|
<add-address
|
||||||
@addNewAddress="addNewAddress">
|
@addNewAddress="addNewAddress">
|
||||||
</add-address>
|
</add-address>
|
||||||
@ -14,7 +15,7 @@
|
|||||||
</show-address>
|
</show-address>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class='household__address-move__valid'>
|
<div v-if="!edit" class='household__address-move__valid'>
|
||||||
<h2>{{ $t('move_date') }}</h2>
|
<h2>{{ $t('move_date') }}</h2>
|
||||||
<input
|
<input
|
||||||
type="date"
|
type="date"
|
||||||
@ -27,16 +28,19 @@
|
|||||||
<div v-if="loading">
|
<div v-if="loading">
|
||||||
{{ $t('loading') }}
|
{{ $t('loading') }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="success">
|
<div v-if="success && !edit">
|
||||||
{{ $t('household_address_move_success') }}
|
{{ $t('household_address_move_success') }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="success && edit">
|
||||||
|
{{ $t('household_address_edit_success') }}
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<ul class="record_actions sticky-form-buttons">
|
<ul class="record_actions sticky-form-buttons">
|
||||||
<li class="cancel">
|
<li class="cancel">
|
||||||
<a :href=backUrl class="sc-button bt-cancel">{{ $t('back_to_the_list') }}</a>
|
<a :href=backUrl class="sc-button bt-cancel">{{ $t('back_to_the_list') }}</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li v-if="!edit">
|
||||||
<button type="submit" class="sc-button bt-update centered" @click="addToHousehold">
|
<button type="submit" class="sc-button bt-update centered" @click="addToHousehold">
|
||||||
{{ $t('add_an_address_to_household') }}
|
{{ $t('add_an_address_to_household') }}
|
||||||
</button>
|
</button>
|
||||||
@ -61,6 +65,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
edit: window.mode === 'edit',
|
edit: window.mode === 'edit',
|
||||||
householdId: window.householdId,
|
householdId: window.householdId,
|
||||||
|
addressId: window.addressId,
|
||||||
backUrl: `/fr/person/household/${householdId}/addresses`, //TODO better way to pass this
|
backUrl: `/fr/person/household/${householdId}/addresses`, //TODO better way to pass this
|
||||||
validFrom: new Date().toISOString().split('T')[0]
|
validFrom: new Date().toISOString().split('T')[0]
|
||||||
}
|
}
|
||||||
@ -113,7 +118,14 @@ export default {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$store.dispatch('addAddress', createdAddress);
|
if (this.edit){
|
||||||
|
this.$store.dispatch('updateAddress', {
|
||||||
|
addressId: this.addressId,
|
||||||
|
newAddress: createdAddress
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.$store.dispatch('addAddress', createdAddress);
|
||||||
|
}
|
||||||
|
|
||||||
modal.showModal = false;
|
modal.showModal = false;
|
||||||
},
|
},
|
||||||
@ -124,8 +136,16 @@ export default {
|
|||||||
body: { validFrom: {datetime: `${this.validFrom}T00:00:00+0100`}},
|
body: { validFrom: {datetime: `${this.validFrom}T00:00:00+0100`}},
|
||||||
backUrl: this.backUrl
|
backUrl: this.backUrl
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
getEditAddress() {
|
||||||
|
this.$store.dispatch('getEditAddress', this.addressId);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
mounted() {
|
||||||
|
if (this.edit) {
|
||||||
|
this.getEditAddress();
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -9,6 +9,7 @@ const appMessages = {
|
|||||||
move_date: 'Date du déménagement',
|
move_date: 'Date du déménagement',
|
||||||
back_to_the_list: 'Retour à la liste',
|
back_to_the_list: 'Retour à la liste',
|
||||||
household_address_move_success: 'La nouvelle adresse du ménage est enregistrée',
|
household_address_move_success: 'La nouvelle adresse du ménage est enregistrée',
|
||||||
|
household_address_edit_success: 'L\'adresse du ménage a été mise à jour',
|
||||||
loading: 'chargement en cours...'
|
loading: 'chargement en cours...'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'es6-promise/auto';
|
import 'es6-promise/auto';
|
||||||
import { createStore } from 'vuex';
|
import { createStore } from 'vuex';
|
||||||
|
|
||||||
import { postAddress, postPostalCode, patchAddress } from 'ChillMainAssets/vuejs/_api/AddAddress';
|
import { postAddress, postPostalCode, patchAddress, getAddress } from 'ChillMainAssets/vuejs/_api/AddAddress';
|
||||||
import { postAddressToHousehold } from '../api';
|
import { postAddressToHousehold } from '../api';
|
||||||
|
|
||||||
const debug = process.env.NODE_ENV !== 'production';
|
const debug = process.env.NODE_ENV !== 'production';
|
||||||
@ -10,6 +10,7 @@ const store = createStore({
|
|||||||
strict: debug,
|
strict: debug,
|
||||||
state: {
|
state: {
|
||||||
newAddress: {},
|
newAddress: {},
|
||||||
|
editAddress: {}, //TODO or should be newAddress?
|
||||||
household: {},
|
household: {},
|
||||||
validFrom: {},
|
validFrom: {},
|
||||||
errorMsg: [],
|
errorMsg: [],
|
||||||
@ -26,6 +27,10 @@ const store = createStore({
|
|||||||
console.log('@M addAddress address', address);
|
console.log('@M addAddress address', address);
|
||||||
state.newAddress = address;
|
state.newAddress = address;
|
||||||
},
|
},
|
||||||
|
updateAddress(state, address) {
|
||||||
|
console.log('@M updateAddress address', address);
|
||||||
|
state.newAddress = address;
|
||||||
|
},
|
||||||
addAddressToHousehold(state, household) {
|
addAddressToHousehold(state, household) {
|
||||||
console.log('@M addAddressToHousehold household', household);
|
console.log('@M addAddressToHousehold household', household);
|
||||||
state.household = household;
|
state.household = household;
|
||||||
@ -34,6 +39,10 @@ const store = createStore({
|
|||||||
console.log('@M addDateToAddress address.validFrom', validFrom);
|
console.log('@M addDateToAddress address.validFrom', validFrom);
|
||||||
state.validFrom = validFrom;
|
state.validFrom = validFrom;
|
||||||
},
|
},
|
||||||
|
getEditAddress(state, address) {
|
||||||
|
console.log('@M getEditAddress address', address);
|
||||||
|
state.editAddress = address;
|
||||||
|
},
|
||||||
setLoading(state, b) {
|
setLoading(state, b) {
|
||||||
state.loading = b;
|
state.loading = b;
|
||||||
},
|
},
|
||||||
@ -101,6 +110,50 @@ const store = createStore({
|
|||||||
commit('setLoading', false);
|
commit('setLoading', false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
updateAddress({ commit }, payload) {
|
||||||
|
console.log('@A updateAddress payload', payload);
|
||||||
|
|
||||||
|
if('newPostalCode' in payload.newAddress){ // TODO change the condition because it writes new postal code in edit mode now: !writeNewPostalCode
|
||||||
|
let postalCodeBody = payload.newAddress.newPostalCode;
|
||||||
|
postalCodeBody = Object.assign(postalCodeBody, {'origin': 3});
|
||||||
|
postPostalCode(postalCodeBody)
|
||||||
|
.then(postalCode => {
|
||||||
|
let body = payload.newAddress;
|
||||||
|
body.postcode = {'id': postalCode.id },
|
||||||
|
patchAddress(payload.addressId, body)
|
||||||
|
.then(address => new Promise((resolve, reject) => {
|
||||||
|
commit('updateAddress', address);
|
||||||
|
commit('setSuccess', true);
|
||||||
|
resolve();
|
||||||
|
}))
|
||||||
|
.catch((error) => {
|
||||||
|
commit('catchError', error);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
patchAddress(payload.addressId, payload.newAddress)
|
||||||
|
.then(address => new Promise((resolve, reject) => {
|
||||||
|
commit('updateAddress', address);
|
||||||
|
commit('setSuccess', true);
|
||||||
|
resolve();
|
||||||
|
}))
|
||||||
|
.catch((error) => {
|
||||||
|
commit('catchError', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getEditAddress({ commit }, payload) {
|
||||||
|
console.log('@A getEditAddress payload', payload);
|
||||||
|
|
||||||
|
getAddress(payload).then(address => new Promise((resolve, reject) => {
|
||||||
|
commit('getEditAddress', address);
|
||||||
|
resolve();
|
||||||
|
}))
|
||||||
|
.catch((error) => {
|
||||||
|
commit('catchError', error);
|
||||||
|
});
|
||||||
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('chill_person_household_address_edit', { 'household_id': household.id, 'address_id' : address.id } ) }}" class="sc-button bt-edit"></a>
|
<a href="{{ path('chill_person_household_address_edit', { 'household_id': household.id, 'address_id' : address.id } ) }}" class="sc-button bt-edit"></a>
|
||||||
</li>
|
</li>
|
||||||
</ul> #}
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="date">
|
<div class="date">
|
||||||
|
@ -349,6 +349,7 @@ Move household: Nouveau déménagement
|
|||||||
Addresses history for household: Historique des adresses
|
Addresses history for household: Historique des adresses
|
||||||
Household accompanying period: Parcours d'accompagnement du ménage
|
Household accompanying period: Parcours d'accompagnement du ménage
|
||||||
Household summary: Résumé du ménage
|
Household summary: Résumé du ménage
|
||||||
|
Edit household address: Modifier l'adresse du ménage
|
||||||
|
|
||||||
# accompanying course work
|
# accompanying course work
|
||||||
Accompanying Course Actions: Actions d'accompagnements
|
Accompanying Course Actions: Actions d'accompagnements
|
||||||
|
Loading…
x
Reference in New Issue
Block a user