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
|
* Post a Location
|
||||||
*/
|
*/
|
||||||
@ -59,5 +70,6 @@ export {
|
|||||||
getSocialActionByIssue,
|
getSocialActionByIssue,
|
||||||
getLocations,
|
getLocations,
|
||||||
getLocationTypes,
|
getLocationTypes,
|
||||||
|
getLocationTypesByDefaultFor,
|
||||||
postLocation
|
postLocation
|
||||||
};
|
};
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
import { mapState, mapGetters } from "vuex";
|
import { mapState, mapGetters } from "vuex";
|
||||||
import VueMultiselect from "vue-multiselect";
|
import VueMultiselect from "vue-multiselect";
|
||||||
import NewLocation from "./Location/NewLocation.vue";
|
import NewLocation from "./Location/NewLocation.vue";
|
||||||
import { getLocations } from "../api.js";
|
import { getLocations, getLocationTypesByDefaultFor } from "../api.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Location",
|
name: "Location",
|
||||||
@ -56,15 +56,24 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.getAccompanyingPeriodLocation();
|
||||||
getLocations().then(
|
getLocations().then(
|
||||||
(response) =>
|
(response) =>
|
||||||
new Promise((resolve) => {
|
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.locations = [
|
||||||
...this.getAccompanyingPeriodLocation(),
|
personLocation,
|
||||||
...response.results,
|
...response.results,
|
||||||
...this.createConcernedPersonsLocation(),
|
|
||||||
];
|
];
|
||||||
|
console.log(this.locations);
|
||||||
if (window.default_location_id) {
|
if (window.default_location_id) {
|
||||||
let location = this.locations.filter(
|
let location = this.locations.filter(
|
||||||
(l) => l.id === window.default_location_id
|
(l) => l.id === window.default_location_id
|
||||||
@ -72,6 +81,9 @@ export default {
|
|||||||
this.$store.dispatch("updateLocation", location);
|
this.$store.dispatch("updateLocation", location);
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -81,13 +93,8 @@ export default {
|
|||||||
value.name ? value.name : ""
|
value.name ? value.name : ""
|
||||||
}`;
|
}`;
|
||||||
},
|
},
|
||||||
getAccompanyingPeriodLocation() {
|
|
||||||
let location = this.activity.accompanyingPeriod.location;
|
|
||||||
return location;
|
|
||||||
},
|
|
||||||
createConcernedPersonsLocation() {
|
createConcernedPersonsLocation() {
|
||||||
let entities = this.suggestedEntities;
|
let entities = this.suggestedEntities;
|
||||||
console.log(entities);
|
|
||||||
return []; // TODO WIP
|
return []; // TODO WIP
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -215,7 +215,6 @@ export default {
|
|||||||
},
|
},
|
||||||
getLocationTypesList() {
|
getLocationTypesList() {
|
||||||
getLocationTypes().then(response => new Promise(resolve => {
|
getLocationTypes().then(response => new Promise(resolve => {
|
||||||
console.log('getLocationTypes', response);
|
|
||||||
this.locationTypes = response.results.filter(t => t.availableForUsers === true);
|
this.locationTypes = response.results.filter(t => t.availableForUsers === true);
|
||||||
resolve();
|
resolve();
|
||||||
}))
|
}))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user