Merge branch '51-referent-parcours' into 'master'

parcours référent

See merge request Chill-Projet/chill-bundles!106
This commit is contained in:
Mathieu Jaumotte 2021-07-01 07:48:08 +00:00
commit f7e3be38a7
7 changed files with 145 additions and 49 deletions

View File

@ -282,7 +282,7 @@ class Activity implements HasCenterInterface, HasScopeInterface
return $this->socialIssues; return $this->socialIssues;
} }
public function addSocialIssue(?SocialIssue $socialIssue): self public function addSocialIssue(SocialIssue $socialIssue): self
{ {
if (!$this->socialIssues->contains($socialIssue)) { if (!$this->socialIssues->contains($socialIssue)) {
$this->socialIssues[] = $socialIssue; $this->socialIssues[] = $socialIssue;
@ -303,7 +303,7 @@ class Activity implements HasCenterInterface, HasScopeInterface
return $this->socialActions; return $this->socialActions;
} }
public function addSocialAction(?SocialAction $socialAction): self public function addSocialAction(SocialAction $socialAction): self
{ {
if (!$this->socialActions->contains($socialAction)) { if (!$this->socialActions->contains($socialAction)) {
$this->socialActions[] = $socialAction; $this->socialActions[] = $socialAction;

View File

@ -5,6 +5,7 @@
<h1 v-if="accompanyingCourse.step === 'DRAFT'">{{ $t('course.title.draft') }}</h1> <h1 v-if="accompanyingCourse.step === 'DRAFT'">{{ $t('course.title.draft') }}</h1>
<h1 v-else>{{ $t('course.title.active') }}</h1> <h1 v-else>{{ $t('course.title.active') }}</h1>
<origin-demand></origin-demand>
<persons-associated></persons-associated> <persons-associated></persons-associated>
<requestor></requestor> <requestor></requestor>
<social-issue></social-issue> <social-issue></social-issue>
@ -19,6 +20,7 @@
import { mapState } from 'vuex' import { mapState } from 'vuex'
import Banner from './components/Banner.vue'; import Banner from './components/Banner.vue';
import StickyNav from './components/StickyNav.vue'; import StickyNav from './components/StickyNav.vue';
import OriginDemand from './components/OriginDemand.vue';
import PersonsAssociated from './components/PersonsAssociated.vue'; import PersonsAssociated from './components/PersonsAssociated.vue';
import Requestor from './components/Requestor.vue'; import Requestor from './components/Requestor.vue';
import SocialIssue from './components/SocialIssue.vue'; import SocialIssue from './components/SocialIssue.vue';
@ -32,6 +34,7 @@ export default {
components: { components: {
Banner, Banner,
StickyNav, StickyNav,
OriginDemand,
PersonsAssociated, PersonsAssociated,
Requestor, Requestor,
SocialIssue, SocialIssue,

View File

@ -98,7 +98,7 @@ const postParticipation = (id, payload, method) => {
const postRequestor = (id, payload, method) => { const postRequestor = (id, payload, method) => {
//console.log('payload', payload); //console.log('payload', payload);
const body = (payload)? { type: payload.type, id: payload.id } : {}; const body = (payload)? { type: payload.type, id: payload.id } : {};
console.log('body', body); //console.log('body', body);
const url = `/api/1.0/person/accompanying-course/${id}/requestor.json`; const url = `/api/1.0/person/accompanying-course/${id}/requestor.json`;
return fetch(url, { return fetch(url, {
method: method, method: method,
@ -131,7 +131,7 @@ const postResource = (id, payload, method) => {
default: default:
body['resource'] = { type: payload.type, id: payload.id }; body['resource'] = { type: payload.type, id: payload.id };
} }
console.log('body', body); //console.log('body', body);
const url = `/api/1.0/person/accompanying-course/${id}/resource.json`; const url = `/api/1.0/person/accompanying-course/${id}/resource.json`;
return fetch(url, { return fetch(url, {
method: method, method: method,
@ -165,6 +165,42 @@ const postSocialIssue = (id, body, method) => {
}); });
}; };
const getUsers = () => {
const url = `/api/1.0/main/user.json`;
return fetch(url)
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
};
const whoami = () => {
const url = `/api/1.0/main/whoami.json`;
return fetch(url)
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
};
const getListOrigins = () => {
const url = `/api/1.0/person/accompanying-period/origin.json`;
return fetch(url)
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
}
const getOrigin = (id) => {
const url = `/api/1.0/person/accompanying-period/origin/${id}.json`;
return fetch(url)
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
}
export { export {
getAccompanyingCourse, getAccompanyingCourse,
patchAccompanyingCourse, patchAccompanyingCourse,
@ -173,5 +209,9 @@ export {
postParticipation, postParticipation,
postRequestor, postRequestor,
postResource, postResource,
getUsers,
whoami,
getListOrigins,
getOrigin,
postSocialIssue postSocialIssue
}; };

View File

@ -0,0 +1,37 @@
<template>
<div class="vue-component">
<h2><a name="section-05"></a>{{ $t('origin.title') }}</h2>
hop
</div>
</template>
<script>
import { getOrigins } from '../api';
import { mapState } from 'vuex';
export default {
name: 'OriginDemand',
data() {
return {
options: []
}
},
computed: {
...mapState({
value: state => state.accompanyingCourse.origin,
}),
},
mounted() {
this.getOptions();
},
methods: {
getOptions() {
console.log('loading origins list');
}
}
}
</script>
<style lang="scss" scoped>
</style>

View File

@ -1,42 +1,43 @@
<template> <template>
<div class="vue-component"> <div class="vue-component">
<h2><a name="section-40"></a>{{ $t('referrer.title') }}</h2> <h2><a name="section-40"></a>{{ $t('referrer.title') }}</h2>
<div class="my-4"> <div class="my-4">
<label for="" class=""> <label for="" class="">
{{ $t('referrer.label') }} {{ $t('referrer.label') }}
</label> </label>
<VueMultiselect <VueMultiselect
track-by="id" name="selectReferrer"
label="text" label="text"
:multiple="false" track-by="id"
:searchable="true" v-bind:multiple="false"
:placeholder="$t('referrer.placeholder')" v-bind:searchable="true"
@update:model-value="updateReferrer" v-bind:placeholder="$t('referrer.placeholder')"
:model-value="value" v-model="value"
:options="options"> v-bind:options="options"
</VueMultiselect> @select="updateReferrer">
</VueMultiselect>
<ul class="record_actions">
<li> <ul class="record_actions">
<button <li>
class="sc-button bt-create" <button
type="button" class="sc-button bt-create"
name="button" type="button"
@click="assignMe"> name="button"
{{ $t('referrer.assign_me') }} @click="assignMe">
</button> {{ $t('referrer.assign_me') }}
</li> </button>
</ul> </li>
</ul>
</div>
</div> </div>
</div>
</template> </template>
<script> <script>
import VueMultiselect from 'vue-multiselect'; import VueMultiselect from 'vue-multiselect';
//import { getUsers } from '../api'; import { getUsers, whoami } from '../api';
import { mapState } from 'vuex'; import { mapState } from 'vuex';
export default { export default {
@ -57,20 +58,21 @@ export default {
}, },
methods: { methods: {
getOptions() { getOptions() {
//getUsers().then(response => new Promise((resolve, reject) => { getUsers().then(response => new Promise((resolve, reject) => {
// console.log(response); this.options = response.results;
// resolve(); resolve();
//})).catch(er => this.$store.commit('catchError'), error)); }));
}, },
updateReferrer(value) { updateReferrer(value) {
//this.$store.dispatch('updateReferrer', this.transformValue(value)); //console.log('value', value);
}, this.$store.dispatch('updateReferrer', value);
transformValue(value) {
let payload = value;
return { payload, body, method };
}, },
assignMe() { assignMe() {
console.log('assign me'); //console.log('assign me');
whoami().then(me => new Promise((resolve, reject) => {
this.$store.dispatch('updateReferrer', me);
resolve();
}));
} }
} }
} }

View File

@ -26,6 +26,9 @@ const appMessages = {
regular: "régulier", regular: "régulier",
occasional: "ponctuel" occasional: "ponctuel"
}, },
origin: {
title: "Origine de la demande",
},
persons_associated: { persons_associated: {
title: "Usagers concernés", title: "Usagers concernés",
counter: "Il n'y a pas encore d'usager | 1 usager | {count} usagers", counter: "Il n'y a pas encore d'usager | 1 usager | {count} usagers",

View File

@ -81,6 +81,10 @@ let initPromise = getAccompanyingCourse(id)
updateSocialIssues(state, value) { updateSocialIssues(state, value) {
state.accompanyingCourse.socialIssues = value; state.accompanyingCourse.socialIssues = value;
}, },
updateReferrer(state, value) {
console.log('value', value);
state.accompanyingCourse.user = value;
},
confirmAccompanyingCourse(state, response) { confirmAccompanyingCourse(state, response) {
//console.log('### mutation: confirmAccompanyingCourse: response', response); //console.log('### mutation: confirmAccompanyingCourse: response', response);
state.accompanyingCourse.step = response.step; state.accompanyingCourse.step = response.step;
@ -187,12 +191,19 @@ let initPromise = getAccompanyingCourse(id)
resolve(); resolve();
})).catch((error) => { commit('catchError', error) }); })).catch((error) => { commit('catchError', error) });
}, },
updateReferrer({ commit }, payload) {
patchAccompanyingCourse(id, { type: "accompanying_period", user: { id: payload.id, type: payload.type } })
.then(course => new Promise((resolve, reject) => {
commit('updateReferrer', course.user);
resolve();
})).catch((error) => { commit('catchError', error) });
},
confirmAccompanyingCourse({ commit }) { confirmAccompanyingCourse({ commit }) {
//console.log('## action: confirmAccompanyingCourse'); //console.log('## action: confirmAccompanyingCourse');
confirmAccompanyingCourse(id) confirmAccompanyingCourse(id)
.then(response => new Promise((resolve, reject) => { .then(response => new Promise((resolve, reject) => {
window.location.replace(`/fr/parcours/${id}`); window.location.replace(`/fr/parcours/${id}`);
console.log('fetch resolve'); //console.log('fetch resolve');
commit('confirmAccompanyingCourse', response); commit('confirmAccompanyingCourse', response);
resolve(); resolve();
})).catch((error) => { commit('catchError', error) }); })).catch((error) => { commit('catchError', error) });