mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
activity: post new location on-the-fly
This commit is contained in:
parent
1b579f7930
commit
a2f6f2b5cb
@ -104,6 +104,7 @@ export default {
|
||||
if (e.type === 'person' && e.current_household_address !== null){
|
||||
locations.push({
|
||||
type: 'location',
|
||||
onthefly: true,
|
||||
name: e.text,
|
||||
address: { id: e.current_household_address.id },
|
||||
locationType: locationType
|
||||
@ -120,6 +121,7 @@ export default {
|
||||
if (e.type === 'thirdparty' && e.address !== null){
|
||||
locations.push({
|
||||
type: 'location',
|
||||
onthefly: true,
|
||||
name: e.text,
|
||||
address: { id: e.address.id },
|
||||
locationType: locationType
|
||||
@ -134,7 +136,8 @@ export default {
|
||||
const accPeriodLocation = this.activity.accompanyingPeriod.location;
|
||||
return {
|
||||
type: 'location',
|
||||
name: '__AccompanyingCourseLocation__', //TODO not perfect...
|
||||
onthefly: true,
|
||||
name: '__AccompanyingCourseLocation__', //TODO not perfect... shoould show the address
|
||||
address: { id: accPeriodLocation.address_id }, //TODO is the id sufficient?
|
||||
locationType: locationType
|
||||
}
|
||||
|
@ -246,7 +246,6 @@ export default {
|
||||
postLocation(body)
|
||||
.then(
|
||||
location => new Promise(resolve => {
|
||||
console.log('postLocation', location);
|
||||
this.locations.push(location);
|
||||
this.$store.dispatch('updateLocation', location);
|
||||
resolve();
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'es6-promise/auto';
|
||||
import { createStore } from 'vuex';
|
||||
import { postLocation } from './api';
|
||||
|
||||
const debug = process.env.NODE_ENV !== 'production';
|
||||
//console.log('window.activity', window.activity);
|
||||
@ -303,7 +304,19 @@ const store = createStore({
|
||||
let hiddenLocation = document.getElementById(
|
||||
"chill_activitybundle_activity_location"
|
||||
);
|
||||
hiddenLocation.value = value.id;
|
||||
//TODO post the location if new location on-the-fly
|
||||
if (value.onthefly) {
|
||||
postLocation(value)
|
||||
.then(
|
||||
location => hiddenLocation.value = location.id
|
||||
).catch(
|
||||
err => {
|
||||
this.errors.push(err.message);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
hiddenLocation.value = value.id;
|
||||
}
|
||||
commit("updateLocation", value);
|
||||
},
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user