Merge conflicts fixed

This commit is contained in:
2022-02-04 10:25:46 +01:00
403 changed files with 15524 additions and 2846 deletions

View File

@@ -14,6 +14,7 @@
<scopes></scopes>
<referrer></referrer>
<resources></resources>
<start-date v-if="accompanyingCourse.step === 'CONFIRMED'"></start-date>
<comment v-if="accompanyingCourse.step === 'DRAFT'"></comment>
<confirm v-if="accompanyingCourse.step === 'DRAFT'"></confirm>
@@ -39,6 +40,7 @@ import Referrer from './components/Referrer.vue';
import Resources from './components/Resources.vue';
import Comment from './components/Comment.vue';
import Confirm from './components/Confirm.vue';
import StartDate from './components/StartDate.vue';
export default {
name: 'App',
@@ -56,6 +58,7 @@ export default {
Resources,
Comment,
Confirm,
StartDate
},
computed: {
...mapState([

View File

@@ -15,21 +15,15 @@ const getAccompanyingCourse = (id) => {
});
};
const getUsers = () => {
const url = `/api/1.0/main/user.json`;
return fetchResults(url);
};
const getUsers = () => fetchResults('/api/1.0/main/user.json');
const getReferrersSuggested = (course) => {
const url = `/api/1.0/person/accompanying-course/${course.id}/referrers-suggested.json`;
return fetchResults(url);
}
/*
* Endpoint
*/
const getUserJobs = () => fetchResults('/api/1.0/main/user-job.json');
const getSocialIssues = () => {
const url = `/api/1.0/person/social-work/social-issue.json`;
return fetch(url)
@@ -54,4 +48,5 @@ export {
getAccompanyingCourse,
getUsers,
getReferrersSuggested,
getUserJobs
};

View File

@@ -19,6 +19,9 @@
:options="options"
group-values="locations"
group-label="locationCategories"
:select-label="$t('multiselect.select_label')"
:deselect-label="$t('multiselect.deselect_label')"
:selected-label="$t('multiselect.selected_label')"
@select="updateAdminLocation">
</VueMultiselect>
</div>

View File

@@ -4,7 +4,7 @@
<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" :key="person.id">
<on-the-fly :type="person.type" :id="person.id" :buttonText="person.text" :displayBadge="'true' === 'true'" action="show"></on-the-fly>
<on-the-fly :type="person.type" :id="person.id" :buttonText="person.textAge" :displayBadge="'true' === 'true'" action="show"></on-the-fly>
</span>
</span>
</template>

View File

@@ -59,9 +59,35 @@
</template>
<template v-slot:body>
<p>{{ $t('confirm.sure_description') }}</p>
<div v-if="accompanyingCourse.user === null">
<div v-if="filteredReferrersSuggested.length === 0">
<p class="alert alert-warning">{{ $t('confirm.no_suggested_referrer') }}</p>
</div>
<div v-if="filteredReferrersSuggested.length === 1" class="alert alert-info">
<p>{{ $t('confirm.one_suggested_referrer') }}:</p>
<ul class="list-suggest add-items inline">
<li>
<user-render-box-badge :user="filteredReferrersSuggested[0]"></user-render-box-badge>
</li>
</ul>
<p>{{ $t('confirm.choose_suggested_referrer') }}</p>
<ul class="record_actions">
<li>
<button class="btn btn-save mr-5" @click="chooseSuggestedReferrer">
{{ $t('confirm.choose_button') }}
</button>
</li>
<li>
<button class="btn btn-secondary" @click="doNotChooseSuggestedReferrer">
{{ $t('confirm.do_not_choose_button') }}
</button>
</li>
</ul>
</div>
</div>
</template>
<template v-slot:footer>
<button class="btn btn-danger" @click="confirmCourse">
<button class="btn btn-danger" :disabled="disableConfirm" @click="confirmCourse">
{{ $t('confirm.ok') }}
</button>
</template>
@@ -74,11 +100,13 @@
<script>
import {mapGetters, mapState} from "vuex";
import Modal from 'ChillMainAssets/vuejs/_components/Modal';
import UserRenderBoxBadge from "ChillMainAssets/vuejs/_components/Entity/UserRenderBoxBadge";
export default {
name: "Confirm",
components: {
Modal,
UserRenderBoxBadge
},
data() {
return {
@@ -110,26 +138,38 @@ export default {
scopes: {
msg: 'confirm.set_a_scope',
anchor: '#section-70'
}
}
},
job: {
msg: 'confirm.job_not_valid',
anchor: '#section-80'
},
},
clickedDoNotChooseReferrer: false
}
},
computed: {
...mapState([
'accompanyingCourse'
]),
...mapState({
accompanyingCourse: state => state.accompanyingCourse,
filteredReferrersSuggested: state => state.filteredReferrersSuggested
}),
...mapGetters([
'isParticipationValid',
'isSocialIssueValid',
'isOriginValid',
'isAdminLocationValid',
'isLocationValid',
'isJobValid',
'validationKeys',
'isValidToBeConfirmed'
]),
deleteLink() {
return `/fr/parcours/${this.accompanyingCourse.id}/delete`; //TODO locale
},
disableConfirm() {
return this.clickedDoNotChooseReferrer
? (this.accompanyingCourse.user === null && this.filteredReferrersSuggested.length === 0)
: (this.accompanyingCourse.user === null && this.filteredReferrersSuggested.length === 0) || (this.filteredReferrersSuggested.length === 1);
}
},
methods: {
confirmCourse() {
@@ -141,6 +181,19 @@ export default {
this.$toast.open({message: 'An error occurred'})
}
});
},
chooseSuggestedReferrer() {
this.$store.dispatch('updateReferrer', this.filteredReferrersSuggested[0])
.catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
violations.forEach((violation) => this.$toast.open({message: violation}));
} else {
this.$toast.open({message: 'An error occurred'})
}
});
},
doNotChooseSuggestedReferrer() {
this.clickedDoNotChooseReferrer = true;
}
}
}

View File

@@ -27,7 +27,7 @@
:value="p.person.id"
/>
<label class="form-check-label">
{{ p.person.text }}
<person-text :person="p.person"></person-text>
</label>
</div>
<input type="hidden" name="expand_suggestions" value="true">
@@ -50,9 +50,9 @@
<div v-if="suggestedPersons.length > 0">
<ul class="list-suggest add-items inline">
<li v-for="p in suggestedPersons" :key="p.id" @click="addSuggestedPerson(p)">
<span>{{ p.text }}</span>
</li>
</ul>
<person-text :person="p"></person-text>
</li>
</ul>
</div>
<div>
@@ -76,12 +76,14 @@
import {mapGetters, mapState} from 'vuex';
import ParticipationItem from "./PersonsAssociated/ParticipationItem.vue";
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue';
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
export default {
name: 'PersonsAssociated',
components: {
ParticipationItem,
AddPersons
AddPersons,
PersonText
},
data() {
return {
@@ -110,15 +112,15 @@ export default {
)
// filter persons appearing twice in requestor and resources
.filter(
(e, index, suggested) => {
(e, index, suggested) => {
for (let i = 0; i < suggested.length; i = i+1) {
if (i < index && e.id === suggested[i].id) {
return false
}
if (i < index && e.id === suggested[i].id) {
return false
}
}
return true;
}
}
)
}),
...mapGetters([

View File

@@ -28,7 +28,7 @@
</a>
</li>
<li><on-the-fly :type="participation.person.type" :id="participation.person.id" action="show"></on-the-fly></li>
<li><on-the-fly :type="participation.person.type" :id="participation.person.id" action="edit" @saveFormOnTheFly="saveFormOnTheFly"></on-the-fly></li>
<li><on-the-fly :type="participation.person.type" :id="participation.person.id" action="edit" @saveFormOnTheFly="saveFormOnTheFly" :canCloseModal="canCloseOnTheFlyModal"></on-the-fly></li>
<li>
<button v-if="!participation.endDate"
class="btn btn-sm btn-remove"
@@ -63,6 +63,7 @@ import OnTheFly from 'ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue';
import ButtonLocation from '../ButtonLocation.vue';
import PersonRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/PersonRenderBox.vue';
import Modal from 'ChillMainAssets/vuejs/_components/Modal';
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
export default {
name: 'ParticipationItem',
@@ -88,7 +89,8 @@ export default {
addAge: false,
hLevel: 1
}
}
},
canCloseOnTheFlyModal: false
}
},
computed: {
@@ -110,14 +112,53 @@ export default {
saveFormOnTheFly(payload) {
console.log('saveFormOnTheFly: type', payload.type, ', data', payload.data);
payload.target = 'participation';
this.$store.dispatch('patchOnTheFly', payload)
.catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
violations.forEach((violation) => this.$toast.open({message: violation}));
} else {
this.$toast.open({message: 'An error occurred'})
}
});
let body = { type: payload.type };
if (payload.type === 'person') {
body.firstName = payload.data.firstName;
body.lastName = payload.data.lastName;
if (payload.data.birthdate !== null) { body.birthdate = payload.data.birthdate; }
body.phonenumber = payload.data.phonenumber;
body.mobilenumber = payload.data.mobilenumber;
body.gender = payload.data.gender;
makeFetch('PATCH', `/api/1.0/person/person/${payload.data.id}.json`, body)
.then(response => {
this.$store.dispatch('addPerson', { target: payload.target, body: response })
this.canCloseOnTheFlyModal = true;
})
.catch((error) => {
if (error.name === 'ValidationException') {
for (let v of error.violations) {
this.$toast.open({message: v });
}
} else {
this.$toast.open({message: 'An error occurred'});
}
})
}
else if (payload.type === 'thirdparty') {
body.name = payload.data.text;
body.email = payload.data.email;
body.telephone = payload.data.phonenumber;
body.address = { id: payload.data.address.address_id };
makeFetch('PATCH', `/api/1.0/third-party/third-party/${payload.data.id}.json`, body)
.then(response => {
this.$store.dispatch('addThirdparty', { target: payload.target, body: response })
this.canCloseOnTheFlyModal = true;
})
.catch((error) => {
if (error.name === 'ValidationException') {
for (let v of error.violations) {
this.$toast.open({message: v });
}
} else {
this.$toast.open({message: 'An error occurred'});
}
})
}
}
}
}

View File

@@ -3,6 +3,27 @@
<h2><a id="section-80"></a>{{ $t('referrer.title') }}</h2>
<div>
<label class="col-form-label" for="selectJob">
{{ $t('job.label') }}
</label>
<VueMultiselect
name="selectJob"
label="text"
:custom-label="customJobLabel"
track-by="id"
:multiple="false"
:searchable="true"
:placeholder="$t('job.placeholder')"
v-model="valueJob"
:options="jobs"
:select-label="$t('multiselect.select_label')"
:deselect-label="$t('multiselect.deselect_label')"
:selected-label="$t('multiselect.selected_label')"
@select="updateJob">
</VueMultiselect>
<label class="col-form-label" for="selectReferrer">
{{ $t('referrer.label') }}
</label>
@@ -15,16 +36,16 @@
:searchable="true"
:placeholder="$t('referrer.placeholder')"
v-model="value"
v-bind:options="users"
: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">
<template v-if="filteredReferrersSuggested.length > 0">
<ul class="list-suggest add-items inline">
<li v-for="(u, i) in referrersSuggested" @click="updateReferrer(u)" :key="`referrer-${i}`">
<li v-for="(u, i) in filteredReferrersSuggested" @click="updateReferrer(u)" :key="`referrer-${i}`">
<span>
<user-render-box-badge :user="u"></user-render-box-badge>
</span>
@@ -47,13 +68,17 @@
</ul>
</div>
<div v-if="!isJobValid" class="alert alert-warning to-confirm">
{{ $t('job.not_valid') }}
</div>
</div>
</template>
<script>
import VueMultiselect from 'vue-multiselect';
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
import { mapState } from 'vuex';
import { mapState, mapGetters } from 'vuex';
import UserRenderBoxBadge from "ChillMainAssets/vuejs/_components/Entity/UserRenderBoxBadge";
export default {
@@ -62,23 +87,33 @@ export default {
UserRenderBoxBadge,
VueMultiselect,
},
data() {
return {
jobs: []
}
},
computed: {
...mapState({
value: state => state.accompanyingCourse.user,
users: state => state.users,
referrersSuggested: state => {
return state.referrersSuggested.filter(u => {
if (null === state.accompanyingCourse.user) {
return true;
}
return state.accompanyingCourse.user.id !== u.id;
})
},
valueJob: state => state.accompanyingCourse.job,
users: state => state.users.filter(u => {
if (u.user_job && state.accompanyingCourse.job) {
return u.user_job.id === state.accompanyingCourse.job.id;
} else {
return false;
}
}),
filteredReferrersSuggested: state => state.filteredReferrersSuggested,
}),
...mapGetters([
'isJobValid'
])
},
mounted() {
this.getJobs();
},
methods: {
updateReferrer(value) {
//console.log('value', value);
this.$store.dispatch('updateReferrer', value)
.catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
@@ -88,6 +123,29 @@ export default {
}
});
},
getJobs() {
const url = '/api/1.0/main/user-job.json';
makeFetch('GET', url)
.then(response => {
this.jobs = response.results;
})
.catch((error) => {
this.$toast.open({message: error.txt})
})
},
updateJob(value) {
this.$store.dispatch('updateJob', 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'})
}
});
},
customJobLabel(value) {
return value.label.fr;
},
assignMe() {
const url = `/api/1.0/main/whoami.json`;
makeFetch('GET', url)

View File

@@ -45,7 +45,8 @@
addInfo: true,
hLevel: 3,
isMultiline: true,
isConfidential: false
isConfidential: false,
addAge: true,
}"
>
<template v-slot:record-actions>
@@ -113,7 +114,7 @@
<template v-slot:record-actions>
<ul class="record_actions">
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="show"></on-the-fly></li>
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="edit" @saveFormOnTheFly="saveFormOnTheFly"></on-the-fly></li>
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="edit" @saveFormOnTheFly="saveFormOnTheFly" :canCloseModal="canCloseOnTheFlyModal"></on-the-fly></li>
</ul>
</template>
</person-render-box>
@@ -136,9 +137,10 @@
<div v-if="accompanyingCourse.requestor === null && suggestedEntities.length > 0">
<ul class="list-suggest add-items inline">
<li v-for="p in suggestedEntities" :key="uniqueId(p)" @click="addSuggestedEntity(p)">
<span>{{ p.text }}</span>
</li>
</ul>
<person-text v-if="p.type === 'person'" :person="p"></person-text>
<span v-else>{{ p.text }}</span>
</li>
</ul>
</div>
<div>
@@ -162,6 +164,9 @@ import PersonRenderBox from '../../_components/Entity/PersonRenderBox.vue';
import ThirdPartyRenderBox from 'ChillThirdPartyAssets/vuejs/_components/Entity/ThirdPartyRenderBox.vue';
import Confidential from 'ChillMainAssets/vuejs/_components/Confidential.vue';
import { mapState } from 'vuex';
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
export default {
name: 'Requestor',
@@ -170,7 +175,8 @@ export default {
OnTheFly,
PersonRenderBox,
ThirdPartyRenderBox,
Confidential
Confidential,
PersonText
},
props: ['isAnonymous'],
data() {
@@ -182,7 +188,8 @@ export default {
priority: null,
uniq: true,
}
}
},
canCloseOnTheFlyModal: false
}
},
computed: {
@@ -246,14 +253,52 @@ export default {
saveFormOnTheFly(payload) {
console.log('saveFormOnTheFly: type', payload.type, ', data', payload.data);
payload.target = 'requestor';
this.$store.dispatch('patchOnTheFly', payload)
.catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
violations.forEach((violation) => this.$toast.open({message: violation}));
} else {
this.$toast.open({message: 'An error occurred'})
}
});
let body = { type: payload.type };
if (payload.type === 'person') {
body.firstName = payload.data.firstName;
body.lastName = payload.data.lastName;
if (payload.data.birthdate !== null) { body.birthdate = payload.data.birthdate; }
body.phonenumber = payload.data.phonenumber;
body.mobilenumber = payload.data.mobilenumber;
body.gender = payload.data.gender;
makeFetch('PATCH', `/api/1.0/person/person/${payload.data.id}.json`, body)
.then(response => {
this.$store.dispatch('addPerson', { target: payload.target, body: response })
this.canCloseOnTheFlyModal = true;
})
.catch((error) => {
if (error.name === 'ValidationException') {
for (let v of error.violations) {
this.$toast.open({message: v });
}
} else {
this.$toast.open({message: 'An error occurred'});
}
})
}
else if (payload.type === 'thirdparty') {
body.name = payload.data.text;
body.email = payload.data.email;
body.telephone = payload.data.phonenumber;
body.address = { id: payload.data.address.address_id };
makeFetch('PATCH', `/api/1.0/third-party/third-party/${payload.data.id}.json`, body)
.then(response => {
this.$store.dispatch('addThirdparty', { target: payload.target, body: response })
this.canCloseOnTheFlyModal = true;
})
.catch((error) => {
if (error.name === 'ValidationException') {
for (let v of error.violations) {
this.$toast.open({message: v });
}
} else {
this.$toast.open({message: 'An error occurred'});
}
})
}
},
addSuggestedEntity(e) {
this.$store.dispatch('addRequestor', { result: e, type: e.type })

View File

@@ -22,7 +22,8 @@
<div v-if="suggestedEntities.length > 0">
<ul class="list-suggest add-items inline">
<li v-for="p in suggestedEntities" :key="uniqueId(p)" @click="addSuggestedEntity(p)">
<span>{{ p.text }}</span>
<person-text v-if="p.type === 'person'" :person="p"></person-text>
<span v-else>{{ p.text }}</span>
</li>
</ul>
</div>
@@ -45,12 +46,15 @@
import { mapState } from 'vuex';
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue';
import ResourceItem from './Resources/ResourceItem.vue';
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
export default {
name: 'Resources',
components: {
AddPersons,
ResourceItem
ResourceItem,
PersonText
},
data() {
return {

View File

@@ -34,7 +34,8 @@
:type="resource.resource.type"
:id="resource.resource.id"
action="edit"
@saveFormOnTheFly="saveFormOnTheFly">
@saveFormOnTheFly="saveFormOnTheFly"
:canCloseModal="canCloseOnTheFlyModal">
</on-the-fly>
</li>
<li>
@@ -80,7 +81,8 @@
:type="resource.resource.type"
:id="resource.resource.id"
action="edit"
@saveFormOnTheFly="saveFormOnTheFly">
@saveFormOnTheFly="saveFormOnTheFly"
:canCloseModal="canCloseOnTheFlyModal">
</on-the-fly>
</li>
<li>
@@ -101,6 +103,7 @@ import ButtonLocation from '../ButtonLocation.vue';
import PersonRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/PersonRenderBox.vue';
import ThirdPartyRenderBox from 'ChillThirdPartyAssets/vuejs/_components/Entity/ThirdPartyRenderBox.vue';
import WriteComment from './WriteComment';
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
export default {
name: 'ResourceItem',
@@ -113,6 +116,11 @@ export default {
},
props: ['resource'],
emits: ['remove'],
data() {
return {
canCloseOnTheFlyModal: false
}
},
computed: {
parent() {
return {
@@ -136,14 +144,52 @@ export default {
saveFormOnTheFly(payload) {
console.log('saveFormOnTheFly: type', payload.type, ', data', payload.data);
payload.target = 'resource';
this.$store.dispatch('patchOnTheFly', payload)
.catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
violations.forEach((violation) => this.$toast.open({message: violation}));
} else {
this.$toast.open({message: 'An error occurred'})
}
});
let body = { type: payload.type };
if (payload.type === 'person') {
body.firstName = payload.data.firstName;
body.lastName = payload.data.lastName;
if (payload.data.birthdate !== null) { body.birthdate = payload.data.birthdate; }
body.phonenumber = payload.data.phonenumber;
body.mobilenumber = payload.data.mobilenumber;
body.gender = payload.data.gender;
makeFetch('PATCH', `/api/1.0/person/person/${payload.data.id}.json`, body)
.then(response => {
this.$store.dispatch('addPerson', { target: payload.target, body: response })
this.canCloseOnTheFlyModal = true;
})
.catch((error) => {
if (error.name === 'ValidationException') {
for (let v of error.violations) {
this.$toast.open({message: v });
}
} else {
this.$toast.open({message: 'An error occurred'});
}
})
}
else if (payload.type === 'thirdparty') {
body.name = payload.data.text;
body.email = payload.data.email;
body.telephone = payload.data.phonenumber;
body.address = { id: payload.data.address.address_id };
makeFetch('PATCH', `/api/1.0/third-party/third-party/${payload.data.id}.json`, body)
.then(response => {
this.$store.dispatch('addThirdparty', { target: payload.target, body: response })
this.canCloseOnTheFlyModal = true;
})
.catch((error) => {
if (error.name === 'ValidationException') {
for (let v of error.violations) {
this.$toast.open({message: v });
}
} else {
this.$toast.open({message: 'An error occurred'});
}
})
}
},
updateComment(resource) {
console.log('updateComment', resource);

View File

@@ -7,7 +7,7 @@
-->
<VueMultiselect
name="field"
:close-on-select="false"
:close-on-select="true"
:allow-empty="true"
:show-labels="false"
track-by="id"

View File

@@ -0,0 +1,46 @@
<template>
<div class="vue-component">
<h2><a id="section-110"></a>
{{ $t('startdate.change') }}
</h2>
<div>
<div class="mb-3 row">
<label class="col-form-label col-sm-4">{{ $t('startdate.date') }}</label>
<div class="col-sm-8">
<input class="form-control" type="date" v-model="startDate" @change="updateStartDate" />
</div>
</div>
</div>
</div>
</template>
<script>
import { datetimeToISO, dateToISO, ISOToDate, ISOToDatetime} from 'ChillMainAssets/chill/js/date.js';
import { mapState, mapGetters } from 'vuex';
export default {
name: 'startDate',
methods: {
updateStartDate(event) {
const date = event.target.value;
// console.log(date)
this.$store.dispatch('updateStartDate', date)
.catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
violations.forEach((violation) => this.$toast.open({message: violation}));
} else {
this.$toast.open({message: 'An error occurred'})
}
});
},
},
computed: {
...mapState({
startDate: state => dateToISO(ISOToDatetime(state.accompanyingCourse.openingDate.datetime))
})
}
}
</script>

View File

@@ -13,7 +13,7 @@ const root = window.vueRootComponent;
* Load all App component, for AccompanyingCourse edition page
*/
if (root === 'app') {
initPromise.then(store => {
initPromise(root).then(store => {
const i18n = _createI18n(appMessages);
@@ -37,7 +37,7 @@ if (root === 'app') {
* Load only Banner sub-component, for all others AccompanyingCourse page
*/
if (root === 'banner') {
initPromise.then(store => {
initPromise(root).then(store => {
const i18n = _createI18n(appMessages);

View File

@@ -102,7 +102,7 @@ const appMessages = {
no_address: "Il n'y a pas d'adresse associée au parcours"
},
scopes: {
title: "Services",
title: "Services concernés",
add_at_least_one: "Indiquez au moins un service",
},
referrer: {
@@ -134,11 +134,26 @@ const appMessages = {
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",
job_not_valid: "Indiquez un métier du référent",
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",
delete: "Supprimer le parcours"
delete: "Supprimer le parcours",
no_suggested_referrer: "Il n'y a aucun référent qui puisse être désigné pour ce parcours. Vérifiez la localisation du parcours, les métiers et service indiqués. Si le problème persiste, contactez l'administrateur du logiciel.",
one_suggested_referrer: "Un unique référent peut être suggéré pour ce parcours",
choose_suggested_referrer: "Voulez-vous le désigner directement ?",
choose_button: "Désigner",
do_not_choose_button: "Ne pas désigner"
},
job: {
label: "Métier",
placeholder: "Choisir un métier",
not_valid: "Sélectionnez un métier du référent"
},
startdate: {
change: "Date d'ouverture",
date: "Date d'ouverture",
},
// catch errors
'Error while updating AccompanyingPeriod Course.': "Erreur du serveur lors de la mise à jour du parcours d'accompagnement.",

View File

@@ -8,15 +8,20 @@ import { getAccompanyingCourse,
import { patchPerson } from "ChillPersonAssets/vuejs/_api/OnTheFly";
import { patchThirdparty } from "ChillThirdPartyAssets/vuejs/_api/OnTheFly";
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
import { datetimeToISO, ISOToDate, ISOToDatetime } from 'ChillMainAssets/chill/js/date.js';
const debug = process.env.NODE_ENV !== 'production';
const id = window.accompanyingCourseId;
let scopesPromise = fetchScopes();
let getScopesPromise = (root) => {
if (root === 'app') {
return fetchScopes();
}
}
let accompanyingCoursePromise = getAccompanyingCourse(id);
let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCoursePromise])
.then(([scopes, accompanyingCourse]) => new Promise((resolve, reject) => {
const store = createStore({
@@ -35,6 +40,7 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
scopesAtBackend: accompanyingCourse.scopes.map(scope => scope),
// the users which are available for referrer
referrersSuggested: [],
filteredReferrersSuggested: [],
// all the users available
users: [],
permissions: {}
@@ -55,6 +61,9 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
isLocationValid(state) {
return state.accompanyingCourse.location !== null;
},
isJobValid(state) {
return state.accompanyingCourse.job !== null;
},
isScopeValid(state) {
//console.log('is scope valid', state.accompanyingCourse.scopes.length > 0);
return state.accompanyingCourse.scopes.length > 0;
@@ -63,6 +72,7 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
let keys = [];
if (!getters.isParticipationValid) { keys.push('participation'); }
if (!getters.isLocationValid) { keys.push('location'); }
if (!getters.isJobValid) { keys.push('job'); }
if (!getters.isSocialIssueValid) { keys.push('socialIssue'); }
if (!getters.isOriginValid) { keys.push('origin'); }
if (!getters.isAdminLocationValid) { keys.push('adminLocation'); }
@@ -193,6 +203,9 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
//console.log('value', value);
state.accompanyingCourse.user = value;
},
updateJob(state, value) {
state.accompanyingCourse.job = value;
},
setReferrersSuggested(state, users) {
state.referrersSuggested = users.map(u => {
if (state.accompanyingCourse.user !== null) {
@@ -203,6 +216,22 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
return u;
});
},
setFilteredReferrersSuggested(state) {
state.filteredReferrersSuggested = state.referrersSuggested.filter(u => {
if (u.user_job && state.accompanyingCourse.job && state.accompanyingCourse.user) {
return u.user_job.id === state.accompanyingCourse.job.id && state.accompanyingCourse.user.id !== u.id
} else {
if (null === state.accompanyingCourse.user) {
if (u.user_job && state.accompanyingCourse.job) {
return u.user_job.id === state.accompanyingCourse.job.id
} else {
return true;
}
}
return state.accompanyingCourse.user.id !== u.id;
}
})
},
confirmAccompanyingCourse(state, response) {
//console.log('### mutation: confirmAccompanyingCourse: response', response);
state.accompanyingCourse.step = response.step;
@@ -254,6 +283,10 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
if (scopeIds.includes(scope.id)) {
state.scopesAtBackend = state.scopesAtBackend.filter(s => s.id !== scope.id);
}
},
updateStartDate(state, date) {
console.log('new state date', date)
state.accompanyingCourse.openingDate = date;
}
},
actions: {
@@ -262,6 +295,12 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
commit('removeParticipation', payload);
// fetch DELETE request...
},
addPerson({ commit }, payload) {
commit('updatePerson', { target: payload.target, person: payload.body });
},
addThirdparty({ commit }, payload) {
commit('updateThirdparty', { target: payload.target, thirdparty: payload.body });
},
/**
* Add/close participation
*/
@@ -624,8 +663,8 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
})
},
updateOrigin({ commit }, payload) {
const url = `/api/1.0/person/accompanying-course/${id}.json`
const body = { type: "accompanying_period", origin: { id: payload.id, type: payload.type }}
const url = `/api/1.0/person/accompanying-course/${id}.json`;
const body = { type: "accompanying_period", origin: { id: payload.id, type: payload.type }};
return makeFetch('PATCH', url, body)
.then((response) => {
@@ -637,8 +676,8 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
})
},
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 }}
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) => {
@@ -650,12 +689,42 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
})
},
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 }}
const url = `/api/1.0/person/accompanying-course/${id}.json`;
const body = { type: "accompanying_period", user: { id: payload.id, type: payload.type }};
return makeFetch('PATCH', url, body)
.then((response) => {
commit('updateReferrer', response.user);
commit('setFilteredReferrersSuggested');
})
.catch((error) => {
commit('catchError', error);
throw error;
})
},
updateJob({ commit }, payload) {
const url = `/api/1.0/person/accompanying-course/${id}.json`;
const body = { type: "accompanying_period", job: { id: payload.id, type: payload.type }};
return makeFetch('PATCH', url, body)
.then((response) => {
commit('updateJob', response.job);
commit('setFilteredReferrersSuggested');
})
.catch((error) => {
commit('catchError', error);
throw error;
})
},
updateStartDate({commit}, payload) {
console.log('payload', payload)
const date = ISOToDate(payload);
const url = `/api/1.0/person/accompanying-course/${id}.json`;
const body = { type: "accompanying_period", openingDate: { datetime: datetimeToISO(date) }};
console.log('body', body)
return makeFetch('PATCH', url, body)
.then((response) => {
commit('updateStartDate', response.openingDate);
})
.catch((error) => {
commit('catchError', error);
@@ -665,11 +734,12 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
async fetchReferrersSuggested({ state, commit}) {
let users = await getReferrersSuggested(state.accompanyingCourse);
commit('setReferrersSuggested', users);
commit('setFilteredReferrersSuggested');
if (
null === state.accompanyingCourse.user
&& !state.accompanyingCourse.confidential
&& !state.accompanyingCourse.step === 'DRAFT'
&& users.length === 1
null === state.accompanyingCourse.user
&& !state.accompanyingCourse.confidential
&& !state.accompanyingCourse.step === 'DRAFT'
&& users.length === 1
) {
// set the user if unique
commit('updateReferrer', users[0]);
@@ -750,8 +820,11 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
}
});
store.dispatch('fetchReferrersSuggested');
store.dispatch('fetchUsers');
if (root === 'app') {
store.dispatch('fetchReferrersSuggested');
store.dispatch('fetchUsers');
}
resolve(store);
}));