mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
activity: add location of the accompanying course
This commit is contained in:
parent
b808e970ab
commit
1519fcd4dd
@ -36,6 +36,17 @@ const getLocationTypes = () => {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Load Location Types by defaultFor
|
||||
* @param {string} entity - can be "person" or "thirdparty"
|
||||
*/
|
||||
const getLocationTypesByDefaultFor = (entity) => {
|
||||
return getLocationTypes().then(response =>
|
||||
response.results.filter(t => t.defaultFor === entity)[0]
|
||||
);
|
||||
};
|
||||
|
||||
/*
|
||||
* Post a Location
|
||||
*/
|
||||
@ -59,5 +70,6 @@ export {
|
||||
getSocialActionByIssue,
|
||||
getLocations,
|
||||
getLocationTypes,
|
||||
getLocationTypesByDefaultFor,
|
||||
postLocation
|
||||
};
|
||||
|
@ -30,7 +30,7 @@
|
||||
import { mapState, mapGetters } from "vuex";
|
||||
import VueMultiselect from "vue-multiselect";
|
||||
import NewLocation from "./Location/NewLocation.vue";
|
||||
import { getLocations } from "../api.js";
|
||||
import { getLocations, getLocationTypesByDefaultFor } from "../api.js";
|
||||
|
||||
export default {
|
||||
name: "Location",
|
||||
@ -56,15 +56,24 @@ export default {
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.getAccompanyingPeriodLocation();
|
||||
getLocations().then(
|
||||
(response) =>
|
||||
new Promise((resolve) => {
|
||||
console.log("getLocations", response);
|
||||
getLocationTypesByDefaultFor('person').then(
|
||||
t => {
|
||||
const accPeriodLocation = this.activity.accompanyingPeriod.location;
|
||||
const personLocation = {
|
||||
type: 'location',
|
||||
name: 'XXXXXX Domicile de l\'usager du parcours',
|
||||
address: { id: accPeriodLocation.address_id }, //TODO is the id sufficient?
|
||||
locationType: t
|
||||
}
|
||||
this.locations = [
|
||||
...this.getAccompanyingPeriodLocation(),
|
||||
personLocation,
|
||||
...response.results,
|
||||
...this.createConcernedPersonsLocation(),
|
||||
];
|
||||
console.log(this.locations);
|
||||
if (window.default_location_id) {
|
||||
let location = this.locations.filter(
|
||||
(l) => l.id === window.default_location_id
|
||||
@ -72,6 +81,9 @@ export default {
|
||||
this.$store.dispatch("updateLocation", location);
|
||||
}
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
|
||||
})
|
||||
);
|
||||
},
|
||||
@ -81,13 +93,8 @@ export default {
|
||||
value.name ? value.name : ""
|
||||
}`;
|
||||
},
|
||||
getAccompanyingPeriodLocation() {
|
||||
let location = this.activity.accompanyingPeriod.location;
|
||||
return location;
|
||||
},
|
||||
createConcernedPersonsLocation() {
|
||||
let entities = this.suggestedEntities;
|
||||
console.log(entities);
|
||||
return []; // TODO WIP
|
||||
},
|
||||
},
|
||||
|
@ -215,7 +215,6 @@ export default {
|
||||
},
|
||||
getLocationTypesList() {
|
||||
getLocationTypes().then(response => new Promise(resolve => {
|
||||
console.log('getLocationTypes', response);
|
||||
this.locationTypes = response.results.filter(t => t.availableForUsers === true);
|
||||
resolve();
|
||||
}))
|
||||
|
Loading…
x
Reference in New Issue
Block a user