mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
activity: add location from concerned person and 3rd parties in the location selector
This commit is contained in:
parent
1519fcd4dd
commit
c1a2112d48
@ -38,10 +38,10 @@ const getLocationTypes = () => {
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Load Location Types by defaultFor
|
* Load Location Type by defaultFor
|
||||||
* @param {string} entity - can be "person" or "thirdparty"
|
* @param {string} entity - can be "person" or "thirdparty"
|
||||||
*/
|
*/
|
||||||
const getLocationTypesByDefaultFor = (entity) => {
|
const getLocationTypeByDefaultFor = (entity) => {
|
||||||
return getLocationTypes().then(response =>
|
return getLocationTypes().then(response =>
|
||||||
response.results.filter(t => t.defaultFor === entity)[0]
|
response.results.filter(t => t.defaultFor === entity)[0]
|
||||||
);
|
);
|
||||||
@ -70,6 +70,6 @@ export {
|
|||||||
getSocialActionByIssue,
|
getSocialActionByIssue,
|
||||||
getLocations,
|
getLocations,
|
||||||
getLocationTypes,
|
getLocationTypes,
|
||||||
getLocationTypesByDefaultFor,
|
getLocationTypeByDefaultFor,
|
||||||
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, getLocationTypesByDefaultFor } from "../api.js";
|
import { getLocations, getLocationTypeByDefaultFor } from "../api.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Location",
|
name: "Location",
|
||||||
@ -56,34 +56,36 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getAccompanyingPeriodLocation();
|
|
||||||
getLocations().then(
|
getLocations().then(
|
||||||
(response) =>
|
(response) =>
|
||||||
new Promise((resolve) => {
|
new Promise((resolve) => {
|
||||||
getLocationTypesByDefaultFor('person').then(
|
getLocationTypeByDefaultFor('person').then(
|
||||||
t => {
|
personLocationType => {
|
||||||
const accPeriodLocation = this.activity.accompanyingPeriod.location;
|
const personLocation = this.makePersonLocation(personLocationType);
|
||||||
const personLocation = {
|
const concernedPersonsLocation =
|
||||||
type: 'location',
|
this.makeConcernedPersonsLocation(personLocationType);
|
||||||
name: 'XXXXXX Domicile de l\'usager du parcours',
|
getLocationTypeByDefaultFor('thirdparty').then(
|
||||||
address: { id: accPeriodLocation.address_id }, //TODO is the id sufficient?
|
thirdpartyLocationType => {
|
||||||
locationType: t
|
const concernedThirdPartiesLocation =
|
||||||
}
|
this.makeConcernedThirdPartiesLocation(thirdpartyLocationType);
|
||||||
this.locations = [
|
this.locations = [
|
||||||
personLocation,
|
personLocation,
|
||||||
...response.results,
|
...concernedPersonsLocation,
|
||||||
];
|
...concernedThirdPartiesLocation,
|
||||||
console.log(this.locations);
|
...response.results,
|
||||||
if (window.default_location_id) {
|
];
|
||||||
let location = this.locations.filter(
|
console.log(this.locations);
|
||||||
(l) => l.id === window.default_location_id
|
if (window.default_location_id) {
|
||||||
);
|
let location = this.locations.filter(
|
||||||
this.$store.dispatch("updateLocation", location);
|
(l) => l.id === window.default_location_id
|
||||||
}
|
);
|
||||||
resolve();
|
this.$store.dispatch("updateLocation", location);
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -93,10 +95,48 @@ export default {
|
|||||||
value.name ? value.name : ""
|
value.name ? value.name : ""
|
||||||
}`;
|
}`;
|
||||||
},
|
},
|
||||||
createConcernedPersonsLocation() {
|
makeConcernedPersonsLocation(locationType) {
|
||||||
let entities = this.suggestedEntities;
|
let locations = [];
|
||||||
return []; // TODO WIP
|
this.suggestedEntities.forEach(
|
||||||
|
(e) => {
|
||||||
|
if (e.type === 'person' && e.current_household_address !== null){
|
||||||
|
locations.push({
|
||||||
|
type: 'location',
|
||||||
|
name: e.text,
|
||||||
|
address: { id: e.current_household_address.id },
|
||||||
|
locationType: locationType
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return locations;
|
||||||
},
|
},
|
||||||
|
makeConcernedThirdPartiesLocation(locationType) {
|
||||||
|
let locations = [];
|
||||||
|
this.suggestedEntities.forEach(
|
||||||
|
(e) => {
|
||||||
|
if (e.type === 'thirdparty' && e.address !== null){
|
||||||
|
locations.push({
|
||||||
|
type: 'location',
|
||||||
|
name: e.text,
|
||||||
|
address: { id: e.address.id },
|
||||||
|
locationType: locationType
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return locations;
|
||||||
|
},
|
||||||
|
makePersonLocation(locationType) {
|
||||||
|
console.log(this.activity)
|
||||||
|
const accPeriodLocation = this.activity.accompanyingPeriod.location;
|
||||||
|
return {
|
||||||
|
type: 'location',
|
||||||
|
name: 'Adresse du parcours', //TODO trans
|
||||||
|
address: { id: accPeriodLocation.address_id }, //TODO is the id sufficient?
|
||||||
|
locationType: locationType
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user