Merge remote-tracking branch 'origin/master' into 232_resources_comment

This commit is contained in:
2022-01-10 21:50:00 +01:00
118 changed files with 1735 additions and 498 deletions

View File

@@ -8,6 +8,7 @@
<persons-associated></persons-associated>
<course-location></course-location>
<origin-demand></origin-demand>
<admin-location></admin-location>
<requestor v-bind:isAnonymous="accompanyingCourse.requestorAnonymous"></requestor>
<social-issue></social-issue>
<scopes></scopes>
@@ -28,6 +29,7 @@ import { mapGetters, mapState } from 'vuex'
import Banner from './components/Banner.vue';
import StickyNav from './components/StickyNav.vue';
import OriginDemand from './components/OriginDemand.vue';
import AdminLocation from './components/AdminLocation.vue';
import PersonsAssociated from './components/PersonsAssociated.vue';
import Requestor from './components/Requestor.vue';
import SocialIssue from './components/SocialIssue.vue';
@@ -44,6 +46,7 @@ export default {
Banner,
StickyNav,
OriginDemand,
AdminLocation,
PersonsAssociated,
Requestor,
SocialIssue,

View File

@@ -0,0 +1,103 @@
<template>
<div class="vue-component">
<h2><a id="section-40"></a>{{ $t('admin_location.title') }}</h2>
<div class="mb-4">
<label for="selectAdminLocation">
{{ $t('admin_location.title') }}
</label>
<VueMultiselect
name="selectAdminLocation"
label="text"
:custom-label="customLabel"
track-by="id"
:multiple="false"
:searchable="true"
:placeholder="$t('admin_location.placeholder')"
v-model="value"
:options="options"
group-values="locations"
group-label="locationCategories"
@select="updateAdminLocation">
</VueMultiselect>
</div>
<div v-if="!isAdminLocationValid" class="alert alert-warning to-confirm">
{{ $t('admin_location.not_valid') }}
</div>
</div>
</template>
<script>
import VueMultiselect from 'vue-multiselect';
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
import { mapState, mapGetters } from 'vuex';
export default {
name: 'AdminLocation',
components: { VueMultiselect },
data() {
return {
options: []
}
},
computed: {
...mapState({
value: state => state.accompanyingCourse.administrativeLocation,
}),
...mapGetters([
'isAdminLocationValid'
])
},
mounted() {
this.getOptions();
},
methods: {
getOptions() {
const url = `/api/1.0/main/location.json`;
makeFetch('GET', url)
.then(response => {
let options = response.results;
let uniqueLocationTypeId = [...new Set(options.map(o => o.locationType.id))];
let results = [];
for (let id of uniqueLocationTypeId) {
results.push({
locationCategories: options.filter(o => o.locationType.id === id)[0].locationType.title.fr,
locations: options.filter(o => o.locationType.id === id)
})
}
this.options = results;
return response;
})
.catch((error) => {
this.$toast.open({message: error.txt})
})
},
updateAdminLocation(value) {
this.$store.dispatch('updateAdminLocation', value)
.catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
violations.forEach((violation) => this.$toast.open({message: violation}));
} else {
this.$toast.open({message: 'An error occurred'})
}
});
},
customLabel(value) {
return value.locationType
? value.name
? `${value.name} (${value.locationType.title.fr})`
: value.locationType.title.fr
: '';
},
}
}
</script>
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
<style lang="css" scoped>
label {
display: none;
}
</style>

View File

@@ -1,9 +1,9 @@
<template>
<span v-for="h in personsByHousehold()" :class="{ 'household': householdExists(h.id), 'no-household': !householdExists(h.id) }">
<span v-for="h in personsByHousehold()" :class="{ 'household': householdExists(h.id), 'no-household': !householdExists(h.id) }" :key="h.id">
<a v-if="householdExists(h.id)" :href="householdLink(h.id)">
<i class="fa fa-home fa-fw text-light" :title="$t('persons_associated.show_household_number', { id: h.id })"></i>
</a>
<span v-for="person in h.persons" class="me-1">
<span v-for="person in h.persons" class="me-1" :key="person.id">
<on-the-fly :type="person.type" :id="person.id" :buttonText="person.text" :displayBadge="'true' === 'true'" action="show"></on-the-fly>
</span>
</span>

View File

@@ -1,6 +1,6 @@
<template>
<div class="vue-component">
<h2><a id="section-90"></a>{{ $t('comment.title') }}</h2>
<h2><a id="section-100"></a>{{ $t('comment.title') }}</h2>
<!--div class="error flash_message" v-if="errors.length > 0">
{{ errors[0] }}

View File

@@ -1,6 +1,6 @@
<template>
<div class="vue-component">
<h2><a id="section-100"></a>
<h2><a id="section-110"></a>
{{ $t('confirm.title') }}
</h2>
<div>
@@ -24,6 +24,11 @@
{{ $t('confirm.ok') }}
</button>
</li>
<li>
<a class="btn btn-delete" :href="deleteLink">
{{ $t('confirm.delete') }}
</a>
</li>
</ul>
</div>
@@ -37,6 +42,11 @@
{{ $t('confirm.ok') }}
</button>
</li>
<li>
<a class="btn btn-delete" :href="deleteLink">
{{ $t('confirm.delete') }}
</a>
</li>
</ul>
</div>
@@ -89,13 +99,17 @@ export default {
msg: 'confirm.origin_not_valid',
anchor: '#section-30'
},
adminLocation: {
msg: 'confirm.adminLocation_not_valid',
anchor: '#section-40'
},
socialIssue: {
msg: 'confirm.socialIssue_not_valid',
anchor: '#section-50'
anchor: '#section-60'
},
scopes: {
msg: 'confirm.set_a_scope',
anchor: '#section-60'
anchor: '#section-70'
}
}
}
@@ -108,10 +122,14 @@ export default {
'isParticipationValid',
'isSocialIssueValid',
'isOriginValid',
'isAdminLocationValid',
'isLocationValid',
'validationKeys',
'isValidToBeConfirmed'
])
]),
deleteLink() {
return `/fr/parcours/${this.accompanyingCourse.id}/delete`; //TODO locale
},
},
methods: {
confirmCourse() {

View File

@@ -4,7 +4,7 @@
{{ $t('courselocation.title') }}
</h2>
<div v-for="error in displayErrors" class="alert alert-danger my-2">
<div v-for="error in displayErrors" class="alert alert-danger my-2" :key="error">
{{ error }}
</div>

View File

@@ -4,7 +4,7 @@
<div class="mb-4">
<label for="selectOrigin">
{{ $t('origin.label.fr') }}
{{ $t('origin.title') }}
</label>
<VueMultiselect
@@ -17,6 +17,9 @@
:placeholder="$t('origin.placeholder')"
v-model="value"
:options="options"
:select-label="$t('multiselect.select_label')"
:deselect-label="$t('multiselect.deselect_label')"
:selected-label="$t('multiselect.selected_label')"
@select="updateOrigin">
</VueMultiselect>
</div>

View File

@@ -1,6 +1,6 @@
<template>
<div class="vue-component">
<h2><a id="section-70"></a>{{ $t('referrer.title') }}</h2>
<h2><a id="section-80"></a>{{ $t('referrer.title') }}</h2>
<div>
<label class="col-form-label" for="selectReferrer">
@@ -11,17 +11,20 @@
name="selectReferrer"
label="text"
track-by="id"
v-bind:multiple="false"
v-bind:searchable="true"
v-bind:placeholder="$t('referrer.placeholder')"
:multiple="false"
:searchable="true"
:placeholder="$t('referrer.placeholder')"
v-model="value"
v-bind:options="users"
:select-label="$t('multiselect.select_label')"
:deselect-label="$t('multiselect.deselect_label')"
:selected-label="$t('multiselect.selected_label')"
@select="updateReferrer">
</VueMultiselect>
<template v-if="referrersSuggested.length > 0">
<ul class="list-suggest add-items inline">
<li v-for="u in referrersSuggested" @click="updateReferrer(u)">
<li v-for="(u, i) in referrersSuggested" @click="updateReferrer(u)" :key="`referrer-${i}`">
<span>
<user-render-box-badge :user="u"></user-render-box-badge>
</span>

View File

@@ -1,7 +1,7 @@
<template>
<div class="vue-component">
<h2><a id="section-40"></a>{{ $t('requestor.title') }}</h2>
<h2><a id="section-50"></a>{{ $t('requestor.title') }}</h2>
<div v-if="accompanyingCourse.requestor && isAnonymous" class="flex-table">

View File

@@ -1,7 +1,7 @@
<template>
<div class="vue-component">
<h2><a id="section-80"></a>{{ $t('resources.title')}}</h2>
<h2><a id="section-90"></a>{{ $t('resources.title')}}</h2>
<div v-if="resources.length > 0">
<label class="col-form-label">{{ $tc('resources.counter', counter) }}</label>

View File

@@ -1,6 +1,6 @@
<template>
<div class="vue-component">
<h2><a id="section-60"></a>{{ $t('scopes.title') }}</h2>
<h2><a id="section-70"></a>{{ $t('scopes.title') }}</h2>
<div class="mb-4">
<div class="form-check" v-for="s in scopes" :key="s.id">

View File

@@ -1,6 +1,6 @@
<template>
<div class="vue-component">
<h2><a id="section-50"></a>{{ $t('social_issue.title') }}</h2>
<h2><a id="section-60"></a>{{ $t('social_issue.title') }}</h2>
<div class="my-4">
<!--label for="field">{{ $t('social_issue.label') }}</label

View File

@@ -37,6 +37,12 @@ const appMessages = {
placeholder: "Renseignez l'origine de la demande",
not_valid: "Indiquez une origine à la demande",
},
admin_location: {
title: "Localisation administrative",
label: "Localisation administrative",
placeholder: "Renseignez la localisation administrative",
not_valid: "Indiquez une localisation administrative",
},
persons_associated: {
title: "Usagers concernés",
counter: "Il n'y a pas encore d'usagers | 1 usager | {count} usagers",
@@ -127,10 +133,12 @@ const appMessages = {
socialIssue_not_valid: "sélectionnez au minimum une problématique sociale",
location_not_valid: "indiquez au minimum une localisation temporaire du parcours",
origin_not_valid: "Indiquez une origine à la demande",
adminLocation_not_valid: "Indiquez une localisation administrative à la demande",
set_a_scope: "indiquez au moins un service",
sure: "Êtes-vous sûr ?",
sure_description: "Une fois le changement confirmé, il ne sera plus possible de le remettre à l'état de brouillon !",
ok: "Confirmer le parcours"
ok: "Confirmer le parcours",
delete: "Supprimer le parcours"
},
// catch errors
'Error while updating AccompanyingPeriod Course.': "Erreur du serveur lors de la mise à jour du parcours d'accompagnement.",

View File

@@ -49,6 +49,9 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
isOriginValid(state) {
return state.accompanyingCourse.origin !== null;
},
isAdminLocationValid(state) {
return state.accompanyingCourse.administrativeLocation !== null;
},
isLocationValid(state) {
return state.accompanyingCourse.location !== null;
},
@@ -62,6 +65,7 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
if (!getters.isLocationValid) { keys.push('location'); }
if (!getters.isSocialIssueValid) { keys.push('socialIssue'); }
if (!getters.isOriginValid) { keys.push('origin'); }
if (!getters.isAdminLocationValid) { keys.push('adminLocation'); }
if (!getters.isScopeValid) { keys.push('scopes'); }
//console.log('getter keys', keys);
return keys;
@@ -177,6 +181,9 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
//console.log('value', value);
state.accompanyingCourse.origin = value;
},
updateAdminLocation(state, value) {
state.accompanyingCourse.administrativeLocation = value;
},
updateReferrer(state, value) {
//console.log('value', value);
state.accompanyingCourse.user = value;
@@ -624,6 +631,19 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
throw error;
})
},
updateAdminLocation({ commit }, payload) {
const url = `/api/1.0/person/accompanying-course/${id}.json`
const body = { type: "accompanying_period", administrativeLocation: { id: payload.id, type: payload.type }}
return makeFetch('PATCH', url, body)
.then((response) => {
commit('updateAdminLocation', response.administrativeLocation);
})
.catch((error) => {
commit('catchError', error);
throw error;
})
},
updateReferrer({ commit }, payload) {
const url = `/api/1.0/person/accompanying-course/${id}.json`
const body = { type: "accompanying_period", user: { id: payload.id, type: payload.type }}

View File

@@ -7,7 +7,7 @@
<div id="picking">
<p>{{ $t('pick_social_issue_linked_with_action') }}</p>
<div v-for="si in socialIssues">
<div v-for="si in socialIssues" :key="si.id">
<input type="radio" v-bind:value="si.id" name="socialIssue" v-model="socialIssuePicked"><span class="badge bg-chill-l-gray text-dark">{{ si.text }}</span>
</div>
<div class="my-3">

View File

@@ -2,6 +2,7 @@
<ol class="breadcrumb">
<li
v-for="s in steps"
:key="s"
class="breadcrumb-item" :class="{ active: step === s }"
>
{{ $t('household_members_editor.app.steps.'+s) }}

View File

@@ -33,7 +33,7 @@ const fetchHouseholdSuggestionByAccompanyingPeriod = (personId) => {
throw Error ({m: 'Error while fetching household suggestion', status: response.status});
}).then(data => Promise.resolve(data.results))
.catch(e => console.err(e));
.catch(e => console.error(e));
;
};

View File

@@ -9,7 +9,7 @@
<div v-else>
<p>
{{ $t('household_members_editor.concerned.persons_will_be_moved') }}&nbsp;:
<span v-for="c in concerned">
<span v-for="c in concerned" :key="c.person.id">
<person-render-box render="badge" :options="{addLink: false}" :person="c.person"></person-render-box>
<button class="btn" @click="removePerson(c.person)" v-if="c.allowRemove" style="padding-left:0;">
<span class="fa-stack fa-lg" :title="$t('household_members_editor.concerned.remove_concerned')">
@@ -19,6 +19,17 @@
</button>
</span>
</p>
<div class="alert alert-info" v-if="concernedPersonsWithHouseholds.length > 0">
<p>{{ $t('household_members_editor.concerned.persons_with_household') }}</p>
<ul v-for="c in concernedPersonsWithHouseholds" :key="c.person.id">
<li>
{{ c.person.text }}
{{ $t('household_members_editor.concerned.already_belongs_to_household') }}
<a target="_blank" :href="this.makeHouseholdLink(c.person.current_household_id)">{{c.person.current_household_id}}</a>.
</li>
</ul>
</div>
</div>
<ul class="record_actions">
@@ -59,7 +70,7 @@ export default {
},
computed: {
...mapState([
'concerned'
'concerned', 'household'
]),
...mapGetters([
'persons',
@@ -67,6 +78,15 @@ export default {
noPerson () {
return this.$store.getters.persons.length === 0;
},
concernedPersonsWithHouseholds () {
if (this.$store.state.household) {
return this.$store.state.concerned.filter(c =>
c.person.current_household_id !== null && c.person.current_household_id !== this.$store.state.household.id
)
} else {
return [];
}
}
},
data() {
return {
@@ -92,6 +112,9 @@ export default {
console.log('remove person in concerned', person);
this.$store.dispatch('removePerson', person);
},
makeHouseholdLink(id) {
return `/fr/person/household/${id}/summary`
}
}
}
</script>

View File

@@ -8,10 +8,10 @@
</p>
<ul>
<li v-for="(msg, index) in warnings" class="warning">
<li v-for="(msg, i) in warnings" class="warning" :key="i">
{{ $t(msg.m, msg.a) }}
</li>
<li v-for="msg in errors" class="error">
<li v-for="(msg, i) in errors" class="error" :key="i">
{{ msg }}
</li>
</ul>

View File

@@ -39,7 +39,7 @@
aria-labelledby="heading_household_suggestions" data-bs-parent="#householdSuggestions">
<div v-if="showHouseholdSuggestion">
<div class="flex-table householdSuggestionList">
<div v-for="s in getSuggestions" class="item-bloc">
<div v-for="(s, i) in getSuggestions" class="item-bloc" :key="`householdSuggestions-${i}`">
<household-render-box :household="s.household"></household-render-box>
<ul class="record_actions">
<li>

View File

@@ -2,11 +2,11 @@
<current-household></current-household>
<ul class="record_actions">
<li v-if="!hasHouseholdAddress && !isHouseholdForceAddress">
<!-- <li v-if="!hasHouseholdAddress && !isHouseholdForceAddress">
<button class="btn btn-misc" @click="markNoAddress">
{{ $t('household_members_editor.household_address.mark_no_address') }}
</button>
</li>
</li> -->
<li v-if="!hasHouseholdAddress">
<add-address
:context="getAddressContext"

View File

@@ -24,7 +24,8 @@
</button>
</div>
<div
v-for="position in positions"
v-for="(position, i) in positions"
:key="`position-${i}`"
class="position"
>
<button

View File

@@ -1,3 +1,4 @@
import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n';
import { ontheflyMessages } from 'ChillMainAssets/vuejs/OnTheFly/i18n';
import { addressMessages } from 'ChillMainAssets/vuejs/Address/i18n';
@@ -35,7 +36,7 @@ const appMessages = {
create_new_address: "Créer une nouvelle adresse",
},
concerned: {
title: "Usagers déplacés",
title: "Usager(s) à (re)positionner dans un ménage",
persons_will_be_moved: "Les usagers suivants vont être déplacés",
add_at_least_onePerson: "Indiquez au moins un usager à déplacer",
remove_concerned: "Ne plus transférer",
@@ -45,6 +46,8 @@ const appMessages = {
move_to: "Déplacer vers",
persons_leaving: "Usagers quittant leurs ménages",
no_person_in_position: "Aucun usager ne sera ajouté à cette position",
persons_with_household: "Les usagers suivants sont associés à ces ménages:",
already_belongs_to_household: "est associé au ménage"
},
positioning: {
persons_to_positionnate: 'Usagers à positionner',

View File

@@ -224,18 +224,21 @@ const store = createStore({
}
state.concerned.forEach((c, index) => {
let m = {
id: index * -1,
person: c.person,
holder: c.holder,
position: c.position,
};
if (c.position === null) {
m.position = {
ordering: 999999
if (!(h.members.map((m) => m.person.id)).includes(c.person.id)) {
let m = {
id: index * -1,
person: c.person,
holder: c.holder,
position: c.position,
};
if (c.position === null) {
m.position = {
ordering: 999999
}
}
h.new_members.push(m);
}
h.new_members.push(m);
})
console.log('fake household', h);
@@ -307,7 +310,7 @@ const store = createStore({
comment: "",
});
} else {
console.err("person already included");
console.error("person already included");
}
},
markPosition(state, { person_id, position_id}) {
@@ -533,10 +536,14 @@ const store = createStore({
// nothing to do anymore here, bye-bye !
let params = new URLSearchParams(window.location.search);
if (params.has('returnPath')) {
window.location.replace(params.get('returnPath'));
} else {
if (params.has('followAfter')) {
window.location.replace(`/fr/person/household/${household_id}/summary`);
} else {
if (params.has('returnPath')) {
window.location.replace(params.get('returnPath'));
} else {
window.location.replace(`/fr/person/household/${household_id}/summary`);
}
}
} else {
// we assume the answer was 422...

View File

@@ -23,7 +23,7 @@
<div class="my-4 legend">
<h3>{{ $t('visgraph.Legend') }}</h3>
<div class="list-group">
<label class="list-group-item" v-for="layer in legendLayers">
<label class="list-group-item" v-for="(layer, i) in legendLayers" :key="`layer-${i}`">
<input
class="form-check-input me-1"
type="checkbox"

View File

@@ -10,6 +10,13 @@ const getPerson = (id) => {
});
};
const getPersonAltNames = () =>
fetch('/api/1.0/person/config/alt_names.json').then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});;
/*
* POST a new person
*/
@@ -48,6 +55,7 @@ const patchPerson = (id, body) => {
export {
getPerson,
getPersonAltNames,
postPerson,
patchPerson
};

View File

@@ -21,14 +21,19 @@
<div v-else-if="action === 'edit' || action === 'create'">
<div class="form-floating mb-3">
<input class="form-control form-control-lg" id="lastname" v-model="lastName" v-bind:placeholder="$t('person.lastname')" />
<label for="lastname">{{ $t('person.lastname') }}</label>
</div>
<div class="form-floating mb-3">
<input class="form-control form-control-lg" id="firstname" v-model="firstName" v-bind:placeholder="$t('person.firstname')" />
<label for="firstname">{{ $t('person.firstname') }}</label>
</div>
<div class="form-floating mb-3">
<input class="form-control form-control-lg" id="lastname" v-model="lastName" v-bind:placeholder="$t('person.lastname')" />
<label for="lastname">{{ $t('person.lastname') }}</label>
<div v-for="(a) in config.altNames" :key="a.key" class="form-floating mb-3">
<input class="form-control form-control-lg" :id="a.key" @input="onAltNameInput" />
<label :for="a.key">{{ a.labels.fr }}</label>
</div>
<!-- TODO fix placeholder if undefined
@@ -71,11 +76,20 @@
aria-describedby="mobilenumber" />
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="email"><i class="fa fa-fw fa-at"></i></span>
<input class="form-control form-control-lg"
v-model="email"
v-bind:placeholder="$t('person.email')"
v-bind:aria-label="$t('person.email')"
aria-describedby="email" />
</div>
</div>
</template>
<script>
import { getPerson } from '../../_api/OnTheFly';
import { getPerson, getPersonAltNames } from '../../_api/OnTheFly';
import PersonRenderBox from '../Entity/PersonRenderBox.vue';
export default {
@@ -88,13 +102,19 @@ export default {
data() {
return {
person: {
type: 'person'
}
type: 'person',
altNames: []
},
config: {
altNames: []
},
}
},
computed: {
firstName: {
set(value) { this.person.firstName = value; },
set(value) {
this.person.firstName = value;
},
get() { return this.person.firstName; }
},
lastName: {
@@ -125,6 +145,10 @@ export default {
set(value) { this.person.mobilenumber = value; },
get() { return this.person.mobilenumber; }
},
email: {
set(value) { this.person.email = value; },
get() { return this.person.email; }
},
genderClass() {
switch (this.person.gender) {
case 'woman':
@@ -150,6 +174,10 @@ export default {
}
},
mounted() {
getPersonAltNames()
.then(altNames => {
this.config.altNames = altNames;
});
if (this.action !== 'create') {
this.loadData();
}
@@ -162,7 +190,16 @@ export default {
console.log('get person', this.person);
resolve();
}));
}
},
onAltNameInput(event) {
const key = event.target.id;
const label = event.target.value;
let updateAltNames = this.person.altNames.filter((a) => a.key !== key);
updateAltNames.push(
{'key': key, 'label': label}
)
this.person.altNames = updateAltNames;
},
}
}
</script>

View File

@@ -30,6 +30,7 @@ const personMessages = {
phonenumber: "Téléphone",
mobilenumber: "Mobile",
altnames: "Autres noms",
email: "Courriel",
gender: {
title: "Genre",
placeholder: "Choisissez le genre de l'usager",