address: add maxlength, upd default map center and add loader messages in addresses form

This commit is contained in:
nobohan
2021-06-24 16:02:57 +02:00
parent 91c5cd74f7
commit 36eb247995
9 changed files with 91 additions and 10 deletions

View File

@@ -24,6 +24,12 @@
<div v-if="errors.length > 0">
{{ errors }}
</div>
<div v-if="loading">
{{ $t('loading') }}
</div>
<div v-if="success">
{{ $t('household_address_move_success') }}
</div>
</div>
<div>
<ul class="record_actions sticky-form-buttons">
@@ -65,6 +71,12 @@ export default {
},
errors() {
return this.$store.state.errorMsg;
},
loading() {
return this.$store.state.loading;
},
success() {
return this.$store.state.success;
}
},
methods: {

View File

@@ -7,7 +7,9 @@ const appMessages = {
add_an_address_to_household: 'Déménager le ménage',
validFrom: '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',
loading: 'chargement en cours...'
}
};

View File

@@ -12,7 +12,9 @@ const store = createStore({
newAddress: {},
household: {},
validFrom: {},
errorMsg: []
errorMsg: [],
loading: false,
success: false
},
getters: {
},
@@ -31,12 +33,18 @@ const store = createStore({
addDateToAddress(state, validFrom) {
console.log('@M addDateToAddress address.validFrom', validFrom);
state.validFrom = validFrom;
},
setLoading(state, b) {
state.loading = b;
},
setSuccess(state, b) {
state.success = b;
}
},
actions: {
addAddress({ commit }, payload) {
console.log('@A addAddress payload', payload);
commit('setLoading', true);
if('newPostalCode' in payload){
postPostalCode(payload.newPostalCode)
.then(postalCode => {
@@ -46,9 +54,11 @@ const store = createStore({
.then(address => new Promise((resolve, reject) => {
commit('addAddress', address);
resolve();
commit('setLoading', false);
}))
.catch((error) => {
commit('catchError', error);
commit('setLoading', false);
});
})
@@ -57,15 +67,17 @@ const store = createStore({
.then(address => new Promise((resolve, reject) => {
commit('addAddress', address);
resolve();
commit('setLoading', false);
}))
.catch((error) => {
commit('catchError', error);
commit('setLoading', false);
});
}
},
addDateToAddressAndAddressToHousehold({ commit }, payload) {
console.log('@A addDateToAddressAndAddressToHousehold payload', payload);
commit('setLoading', true);
patchAddress(payload.addressId, payload.body)
.then(address => new Promise((resolve, reject) => {
commit('addDateToAddress', address.validFrom);
@@ -74,14 +86,18 @@ const store = createStore({
postAddressToHousehold(payload.householdId, payload.addressId)
.then(household => new Promise((resolve, reject) => {
commit('addAddressToHousehold', household);
commit('setSuccess', true);
commit('setLoading', false);
resolve();
}))
.catch((error) => {
commit('catchError', error);
commit('setLoading', false);
})
))
.catch((error) => {
commit('catchError', error);
commit('setLoading', false);
});
},
}