mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
location: code refactoring: move saveNewLocation + order of fields
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
v-model="location">
|
||||
</VueMultiselect>
|
||||
|
||||
<new-location @saveNewLocation="saveNewLocation"></new-location>
|
||||
<new-location v-bind:locations="locations"></new-location>
|
||||
</div>
|
||||
</div>
|
||||
</teleport>
|
||||
@@ -30,7 +30,7 @@
|
||||
import { mapState } from "vuex";
|
||||
import VueMultiselect from 'vue-multiselect';
|
||||
import NewLocation from './Location/NewLocation.vue';
|
||||
import { getLocations, postLocation } from '../api.js';
|
||||
import { getLocations } from '../api.js';
|
||||
|
||||
export default {
|
||||
name: "Location",
|
||||
@@ -67,29 +67,6 @@ export default {
|
||||
},
|
||||
customLabel(value) {
|
||||
return `${value.locationType.title.fr} ${value.name}`;
|
||||
},
|
||||
saveNewLocation(selected) {
|
||||
console.log('saveNewLocation', selected);
|
||||
let body = {
|
||||
type: 'location',
|
||||
name: selected.name,
|
||||
address: {
|
||||
id: selected.addressId
|
||||
},
|
||||
locationType: {
|
||||
id: selected.type,
|
||||
type: 'location-type'
|
||||
},
|
||||
phonenumber1: selected.phonenumber1,
|
||||
phonenumber2: selected.phonenumber2,
|
||||
email: selected.email,
|
||||
}
|
||||
postLocation(body).then(location => new Promise(resolve => {
|
||||
console.log('postLocation', location);
|
||||
this.locations.push(location);
|
||||
this.$store.dispatch('updateLocation', location);
|
||||
resolve();
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user