location: fix error when creating a new location: a new location could not be added to the availableLocations due to refactoring

This commit is contained in:
nobohan 2022-01-11 16:00:29 +01:00
parent f1c61a2387
commit c7b9a1a3fe
3 changed files with 18 additions and 12 deletions

View File

@ -24,7 +24,7 @@
v-model="location"
>
</VueMultiselect>
<new-location v-bind:locations="locations"></new-location>
<new-location v-bind:availableLocations="availableLocations"></new-location>
</div>
</div>
</teleport>

View File

@ -18,15 +18,6 @@
</template>
<template v-slot:body>
<form>
<div class="form-floating mb-3">
<p v-if="errors.length">
<b>{{ $t('activity.errors') }}</b>
<ul>
<li v-for="error in errors" :key="error">{{ error }}</li>
</ul>
</p>
</div>
<div class="form-floating mb-3">
<select class="form-select form-select-lg" id="type" required v-model="selectType">
<option selected disabled value="">{{ $t('activity.choose_location_type') }}</option>
@ -62,6 +53,12 @@
<input class="form-control form-control-lg" id="email" v-model="inputEmail" placeholder />
<label for="email">{{ $t('activity.location_fields.email') }}</label>
</div>
<div class="alert alert-warning" v-if="errors.length">
<ul>
<li v-for="(e, i) in errors" :key="i">{{ e }}</li>
</ul>
</div>
</form>
</template>
<template v-slot:footer>
@ -89,7 +86,7 @@ export default {
Modal,
AddAddress,
},
props: ['locations'],
props: ['availableLocations'],
data() {
return {
errors: [],
@ -245,8 +242,14 @@ export default {
postLocation(body)
.then(
location => new Promise(resolve => {
this.locations.push(location);
this.$store.dispatch('addAvailableLocationGroup', {
locationGroup: 'Localisations nouvellement créées',
locations: [location]
});
this.$store.dispatch('updateLocation', location);
resolve();
this.modal.showModal = false;
})

View File

@ -240,6 +240,9 @@ const store = createStore({
});
commit("updateActionsSelected", payload);
},
addAvailableLocationGroup({ commit }, payload) {
commit("addAvailableLocationGroup", payload);
},
addPersonsInvolved({ commit }, payload) {
//console.log('### action addPersonsInvolved', payload.result.type);
switch (payload.result.type) {