diff --git a/CHANGELOG.md b/CHANGELOG.md index 36832794f..e6d1208e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,17 @@ and this project adheres to ## Unreleased +* [asideactivity] creation of aside activity category fixed (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/262) +* [vendee/person] fix typo "situation professionelle" => "situation professionnelle" +* [main] add availableForUsers condition from locationType in the location API endpoint (champs-libres/departement-de-la-vendee/accent-suivi-developpement#248) +* [main] add the current location of the user as API point + add it in the activity location list (champs-libres/departement-de-la-vendee/accent-suivi-developpement#247) +* [activity] improve show/new/edit templates, fix SEE and SEE_DETAILS acl +* [badges] create specific badge for TMS, and make person/thirdparty badges clickable with on-the-fly modal in : + * concerned groups items (activity, calendar) + * accompanyingCourseWork lists + * accompanyingCourse lists +* [acompanyingCourse] add initial comment on Resume page +* [person] create button full width (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/330) ## Test releases @@ -35,6 +46,8 @@ and this project adheres to * [asideactivity] creation of aside activity category fixed (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/262) * [vendee/person] fix typo "situation professionelle" => "situation professionnelle" * [accompanyingcourse_work] Changes in layout/behavior of edit form (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/321) +* [badge-entity] design coherency between pills badge-person and 3 kinds of badge-thirdparty +* [AddPersons] suggestions row are clickable, not only checkbox ### test release 2021-12-06 @@ -51,10 +64,6 @@ and this project adheres to * [visgraph] improve and fix bugs on vis-network relationship graph * [bugfix] posting of birth- and deathdate through api fixed. * [suggestions] improve suggestions lists -* [badge-entity] design coherency between badge-person and 3 kinds of badge-thirdparty -* [AddPersons] suggestions row are clickable, not only checkbox -* [activity] improve show/new/edit templates, fix SEE and SEE_DETAILS acl -* [activity][calendar] concerned groups items are clickable with on-the-fly modal, create specific badge for TMS column ### Test release 2021-11-19 - bis diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/api.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/api.js index 8d4bcac3b..edc0a616c 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/api.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/api.js @@ -17,6 +17,14 @@ const getLocations = () => fetchResults('/api/1.0/main/location.json'); const getLocationTypes = () => fetchResults('/api/1.0/main/location-type.json'); +const getUserCurrentLocation = + () => fetch('/api/1.0/main/user-current-location.json') + .then(response => { + if (response.ok) { return response.json(); } + throw Error('Error with request resource response'); + }); + + /* * Load Location Type by defaultFor * @param {string} entity - can be "person" or "thirdparty" @@ -48,5 +56,6 @@ export { getLocations, getLocationTypes, getLocationTypeByDefaultFor, - postLocation + postLocation, + getUserCurrentLocation }; diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue index 9a4b78334..50eb14799 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue @@ -15,7 +15,7 @@ :searchable="true" :placeholder="$t('activity.choose_location')" :custom-label="customLabel" - :options="locations" + :options="availableLocations" group-values="locations" group-label="locationGroup" v-model="location" @@ -32,7 +32,7 @@ import { mapState, mapGetters } from "vuex"; import VueMultiselect from "vue-multiselect"; import NewLocation from "./Location/NewLocation.vue"; -import { getLocations, getLocationTypeByDefaultFor } from "../api.js"; +import { getLocations, getLocationTypeByDefaultFor, getUserCurrentLocation } from "../api.js"; export default { name: "Location", @@ -40,13 +40,8 @@ export default { NewLocation, VueMultiselect, }, - data() { - return { - locations: [], - }; - }, computed: { - ...mapState(["activity"]), + ...mapState(["activity", "availableLocations"]), ...mapGetters(["suggestedEntities"]), location: { get() { @@ -57,53 +52,6 @@ export default { }, }, }, - mounted() { - getLocations().then( - (results) => { - getLocationTypeByDefaultFor('person').then( - (personLocationType) => { - if (personLocationType) { - const personLocation = this.makeAccompanyingPeriodLocation(personLocationType); - const concernedPersonsLocation = - this.makeConcernedPersonsLocation(personLocationType); - getLocationTypeByDefaultFor('thirdparty').then( - thirdpartyLocationType => { - const concernedThirdPartiesLocation = - this.makeConcernedThirdPartiesLocation(thirdpartyLocationType); - this.locations = [ - { - locationGroup: 'Localisation du parcours', - locations: [personLocation] - }, - { - locationGroup: 'Parties concernées', - locations: [...concernedPersonsLocation, ...concernedThirdPartiesLocation] - }, - { - locationGroup: 'Autres localisations', - locations: results - } - ]; - } - ) - } else { - this.locations = [ - { - locationGroup: 'Localisations', - locations: response.results - } - ]; - } - if (window.default_location_id) { - let location = this.locations.filter( - (l) => l.id === window.default_location_id - ); - this.$store.dispatch("updateLocation", location); - } - } - ) - }) - }, methods: { labelAccompanyingCourseLocation(value) { return `${value.address.text} (${value.locationType.title.fr})` @@ -117,58 +65,6 @@ export default { : value.locationType.title.fr : ''; }, - makeConcernedPersonsLocation(locationType) { - let locations = []; - this.suggestedEntities.forEach( - (e) => { - if (e.type === 'person' && e.current_household_address !== null){ - locations.push({ - type: 'location', - id: -this.suggestedEntities.indexOf(e)*10, - onthefly: true, - name: e.text, - address: { - id: e.current_household_address.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', - id: -this.suggestedEntities.indexOf(e)*10, - onthefly: true, - name: e.text, - address: { id: e.address.address_id }, - locationType: locationType - }); - } - } - ) - return locations; - }, - makeAccompanyingPeriodLocation(locationType) { - const accPeriodLocation = this.activity.accompanyingPeriod.location; - return { - type: 'location', - id: -1, - onthefly: true, - name: '__AccompanyingCourseLocation__', - address: { - id: accPeriodLocation.address_id, - text: `${accPeriodLocation.text} - ${accPeriodLocation.postcode.code} ${accPeriodLocation.postcode.name}` - }, - locationType: locationType - } - } }, }; diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js index 1ca9f9cc2..4bf70b006 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js @@ -1,6 +1,7 @@ import 'es6-promise/auto'; import { createStore } from 'vuex'; import { postLocation } from './api'; +import prepareLocations from './store.locations.js'; const debug = process.env.NODE_ENV !== 'production'; //console.log('window.activity', window.activity); @@ -25,6 +26,7 @@ const store = createStore({ activity: window.activity, socialIssuesOther: [], socialActionsList: [], + availableLocations: [], }, getters: { suggestedEntities(state) { @@ -200,6 +202,9 @@ const store = createStore({ console.log("### mutation: updateLocation", value); state.activity.location = value; }, + addAvailableLocationGroup(state, group) { + state.availableLocations.push(group); + } }, actions: { addIssueSelected({ commit }, issue) { @@ -335,4 +340,6 @@ const store = createStore({ }, }); +prepareLocations(store); + export default store; diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js new file mode 100644 index 000000000..311bdc219 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js @@ -0,0 +1,123 @@ +import {getLocations, getLocationTypeByDefaultFor, getUserCurrentLocation} from "./api"; + +const makeConcernedPersonsLocation = (locationType, store) => { + let locations = []; + store.getters.suggestedEntities.forEach( + (e) => { + if (e.type === 'person' && e.current_household_address !== null){ + locations.push({ + type: 'location', + id: -store.getters.suggestedEntities.indexOf(e)*10, + onthefly: true, + name: e.text, + address: { + id: e.current_household_address.address_id, + }, + locationType: locationType + }); + } + } + ) + return locations; +}; +const makeConcernedThirdPartiesLocation = (locationType, store) => { + let locations = []; + store.getters.suggestedEntities.forEach( + (e) => { + if (e.type === 'thirdparty' && e.address !== null){ + locations.push({ + type: 'location', + id: -store.getters.suggestedEntities.indexOf(e)*10, + onthefly: true, + name: e.text, + address: { id: e.address.address_id }, + locationType: locationType + }); + } + } + ) + return locations; +}; +const makeAccompanyingPeriodLocation = (locationType, store) => { + const accPeriodLocation = store.state.activity.accompanyingPeriod.location; + return { + type: 'location', + id: -1, + onthefly: true, + name: '__AccompanyingCourseLocation__', + address: { + id: accPeriodLocation.address_id, + text: `${accPeriodLocation.text} - ${accPeriodLocation.postcode.code} ${accPeriodLocation.postcode.name}` + }, + locationType: locationType + } +}; + +export default function prepareLocations(store) { + +// find the locations + let allLocations = getLocations().then( + (results) => { + store.commit('addAvailableLocationGroup', { + locationGroup: 'Autres localisations', + locations: results + }); + } + ); + + let currentLocation = getUserCurrentLocation().then( + userCurrentLocation => { + if (null !== userCurrentLocation) { + store.commit('addAvailableLocationGroup', { + locationGroup: 'Ma localisation', + locations: [userCurrentLocation] + }); + } + } + ); + + let partiesLocations = [], partyPromise; + ['person', 'thirdparty'].forEach(kind => { + partyPromise = getLocationTypeByDefaultFor(kind).then( + (kindLocationType) => { + if (kindLocationType) { + let concernedKindLocations; + if (kind === 'person') { + concernedKindLocations = makeConcernedPersonsLocation(kindLocationType, store); + // add location for the parcours into suggestions + const personLocation = makeAccompanyingPeriodLocation(kindLocationType, store); + store.commit('addAvailableLocationGroup', { + locationGroup: 'Localisation du parcours', + locations: [personLocation] + }); + } else { + concernedKindLocations = makeConcernedThirdPartiesLocation(kindLocationType, store); + } + + store.commit('addAvailableLocationGroup', { + locationGroup: kind === 'person' ? 'Usagers concernés' : 'Tiers concernés', + locations: concernedKindLocations, + }); + } + } + ); + partiesLocations.push(partyPromise); + }); + +// when all location are loaded + Promise.all([allLocations, currentLocation, ...partiesLocations]).then(() => { + console.log('current location in activity', store.state.activity.location); + console.log('default loation id', window.default_location_id); + if (window.default_location_id) { + for (let group of store.state.availableLocations) { + console.log(group); + let location = group.locations.find((l) => l.id === window.default_location_id); + console.log(location); + if (location !== undefined) { + store.dispatch('updateLocation', location); + break; + } + } + } + }); +} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig index 8efdd0148..3f49e67cc 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig @@ -127,24 +127,25 @@ {% endif %} + {% if activity.comment.comment is not empty and is_granted('CHILL_ACTIVITY_SEE_DETAILS', activity) %} +
{{ block('title') }}
+{{ 'Write a new comment'|trans }}
+ {{ _self.form_comment('new', form) }} +