Merge branch 'parcours/origin-de-la-demande' into 'master'

parcours - origin de la demande

See merge request Chill-Projet/chill-bundles!107
This commit is contained in:
Mathieu Jaumotte 2021-07-01 08:37:46 +00:00
commit 270c0accc5
11 changed files with 246 additions and 115 deletions

View File

@ -65,7 +65,7 @@ export default {
addPersons: {
key: 'activity',
options: {
type: ['person', 'thirdparty'], // TODO add 'user'
type: ['person', 'thirdparty', 'user'], // TODO add 'user'
priority: null,
uniq: false,
}

View File

@ -24,10 +24,17 @@ namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
/**
* @ORM\Entity
* @ORM\Table(name="chill_person_accompanying_period_origin")
* @Serializer\DiscriminatorMap(
* typeProperty="type",
* mapping={
* "origin"=Origin::class
* })
*/
class Origin
{

View File

@ -5,8 +5,8 @@
<h1 v-if="accompanyingCourse.step === 'DRAFT'">{{ $t('course.title.draft') }}</h1>
<h1 v-else>{{ $t('course.title.active') }}</h1>
<origin-demand></origin-demand>
<persons-associated></persons-associated>
<origin-demand></origin-demand>
<requestor></requestor>
<social-issue></social-issue>
<referrer></referrer>
@ -68,11 +68,11 @@ export default {
}
a[name^="section"] {
position: absolute;
top: -3.5em; // reference for stickNav
top: -2.5em; // reference for stickNav
}
}
padding: 0.8em 0em;
margin: 2em 0;
padding: 0em 0em;
margin: 1em 0;
border: 1px dotted #718596ab;
border-radius: 5px;
border-left: 1px dotted #718596ab;

View File

@ -192,15 +192,6 @@ const getListOrigins = () => {
});
}
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 {
getAccompanyingCourse,
patchAccompanyingCourse,
@ -212,6 +203,5 @@ export {
getUsers,
whoami,
getListOrigins,
getOrigin,
postSocialIssue
};

View File

@ -1,17 +1,37 @@
<template>
<div class="vue-component">
<h2><a name="section-05"></a>{{ $t('origin.title') }}</h2>
<h2><a name="section-15"></a>{{ $t('origin.title') }}</h2>
<div class="my-4">
<label for="selectOrigin">
{{ $t('origin.label') }}
</label>
hop
<VueMultiselect
name="selectOrigin"
label="text"
v-bind:custom-label="transText"
track-by="id"
v-bind:multiple="false"
v-bind:searchable="true"
v-bind:placeholder="$t('origin.placeholder')"
v-model="value"
v-bind:options="options"
@select="updateOrigin">
</VueMultiselect>
</div>
</div>
</template>
<script>
import { getOrigins } from '../api';
import VueMultiselect from 'vue-multiselect';
import { getListOrigins } from '../api';
import { mapState } from 'vuex';
export default {
name: 'OriginDemand',
components: { VueMultiselect },
data() {
return {
options: []
@ -27,11 +47,26 @@ export default {
},
methods: {
getOptions() {
console.log('loading origins list');
}
//console.log('loading origins list');
getListOrigins().then(response => new Promise((resolve, reject) => {
this.options = response.results;
resolve();
}));
},
updateOrigin(value) {
//console.log('value', value);
this.$store.dispatch('updateOrigin', value);
},
transText ({ text }) {
return text.fr //TODO multilang
},
}
}
</script>
<style lang="scss" scoped>
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
<style lang="css" scoped>
label {
display: none;
}
</style>

View File

@ -3,7 +3,7 @@
<h2><a name="section-40"></a>{{ $t('referrer.title') }}</h2>
<div class="my-4">
<label for="" class="">
<label for="selectReferrer">
{{ $t('referrer.label') }}
</label>
@ -77,3 +77,5 @@ export default {
}
}
</script>
<style src="vue-multiselect/dist/vue-multiselect.css"></style>

View File

@ -28,6 +28,8 @@ const appMessages = {
},
origin: {
title: "Origine de la demande",
label: "Origine de la demande",
placeholder: "Renseignez l'origine de la demande",
},
persons_associated: {
title: "Usagers concernés",

View File

@ -81,8 +81,12 @@ let initPromise = getAccompanyingCourse(id)
updateSocialIssues(state, value) {
state.accompanyingCourse.socialIssues = value;
},
updateOrigin(state, value) {
//console.log('value', value);
state.accompanyingCourse.origin = value;
},
updateReferrer(state, value) {
console.log('value', value);
//console.log('value', value);
state.accompanyingCourse.user = value;
},
confirmAccompanyingCourse(state, response) {
@ -191,6 +195,13 @@ let initPromise = getAccompanyingCourse(id)
resolve();
})).catch((error) => { commit('catchError', error) });
},
updateOrigin({ commit }, payload) {
patchAccompanyingCourse(id, { type: "accompanying_period", origin: { id: payload.id, type: payload.type } })
.then(course => new Promise((resolve, reject) => {
commit('updateOrigin', course.origin);
resolve();
})).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) => {

View File

@ -273,7 +273,6 @@
</div>
</div>
<<<<<<< HEAD
{% endif %}
{% if r.thirdParty %}

View File

@ -0,0 +1,46 @@
<?php
/*
*
* Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Chill\PersonBundle\Serializer\Normalizer;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
/**
*
* @internal we keep this normalizer, because the property 'text' may be replace by a rendering in the future
*/
class AccompanyingPeriodOriginNormalizer implements NormalizerInterface
{
public function normalize($origin, string $format = null, array $context = array())
{
/** @var Origin $origin */
return [
'type' => 'origin',
'id' => $origin->getId(),
'label' => $origin->getLabel(),
'text' => $origin->getLabel()
];
}
public function supportsNormalization($data, string $format = null): bool
{
return $data instanceof Origin;
}
}

View File

@ -296,6 +296,7 @@ paths:
$ref: "#/components/schemas/Person"
403:
description: "Unauthorized"
/1.0/person/person.json:
post:
tags:
@ -358,39 +359,6 @@ paths:
/1.0/person/social-work/social-issue.json:
get:
tags:
- social-issue
summary: Return a list of social work
responses:
200:
description: "ok"
/1.0/person/social-work/social-issue/{id}.json:
get:
tags:
- social-issue
summary: Return a social issue by id
parameters:
- name: id
in: path
required: true
description: The social issue's id
schema:
type: integer
format: integer
minimum: 1
responses:
200:
description: "ok"
content:
application/json:
schema:
$ref: '#/components/schemas/SocialIssue'
404:
description: "not found"
401:
description: "Unauthorized"
/1.0/person/accompanying-course/{id}.json:
get:
tags:
@ -457,6 +425,7 @@ paths:
description: "OK"
422:
description: "object with validation errors"
/1.0/person/accompanying-course/{id}/requestor.json:
post:
tags:
@ -908,6 +877,61 @@ paths:
422:
description: "object with validation errors"
/1.0/person/accompanying-course/work/{id}.json:
get:
tags:
- accompanying-course-work
summary: edit an existing accompanying course work
parameters:
- name: id
in: path
required: true
description: The accompanying course social work's id
schema:
type: integer
format: integer
minimum: 1
responses:
401:
description: "Unauthorized"
404:
description: "Not found"
200:
description: "OK"
400:
description: "Bad Request"
put:
tags:
- accompanying-course-work
summary: edit an existing accompanying course work
parameters:
- name: id
in: path
required: true
description: The accompanying course social work's id
schema:
type: integer
format: integer
minimum: 1
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AccompanyingCourseWork'
responses:
401:
description: "Unauthorized"
404:
description: "Not found"
200:
description: "OK"
422:
description: "Unprocessable entity (validation errors)"
400:
description: "Bad Request"
/1.0/person/accompanying-course/{id}/confirm.json:
post:
tags:
@ -932,6 +956,43 @@ paths:
400:
description: "transition cannot be applyed"
/1.0/person/accompanying-period/origin.json:
get:
tags:
- person
summary: Return a list of all origins
responses:
200:
description: "ok"
/1.0/person/accompanying-period/origin/{id}.json:
get:
tags:
- person
summary: Return an origin by id
parameters:
- name: id
in: path
required: true
description: The origin id
schema:
type: integer
format: integer
minimum: 1
responses:
200:
description: "ok"
400:
description: "Bad Request"
401:
description: "Unauthorized"
404:
description: "Not found"
/1.0/person/household.json:
get:
tags:
@ -1120,61 +1181,6 @@ paths:
/1.0/person/accompanying-course/work/{id}.json:
get:
tags:
- accompanying-course-work
summary: edit an existing accompanying course work
parameters:
- name: id
in: path
required: true
description: The accompanying course social work's id
schema:
type: integer
format: integer
minimum: 1
responses:
401:
description: "Unauthorized"
404:
description: "Not found"
200:
description: "OK"
400:
description: "Bad Request"
put:
tags:
- accompanying-course-work
summary: edit an existing accompanying course work
parameters:
- name: id
in: path
required: true
description: The accompanying course social work's id
schema:
type: integer
format: integer
minimum: 1
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AccompanyingCourseWork'
responses:
401:
description: "Unauthorized"
404:
description: "Not found"
200:
description: "OK"
422:
description: "Unprocessable entity (validation errors)"
400:
description: "Bad Request"
/1.0/person/social/social-action.json:
get:
tags:
@ -1209,7 +1215,6 @@ paths:
400:
description: "Bad Request"
/1.0/person/social/social-action/by-social-issue/{id}.json:
get:
tags:
@ -1234,6 +1239,42 @@ paths:
description: "Bad Request"
/1.0/person/social-work/social-issue.json:
get:
tags:
- social-issue
summary: Return a list of social work
responses:
200:
description: "ok"
/1.0/person/social-work/social-issue/{id}.json:
get:
tags:
- social-issue
summary: Return a social issue by id
parameters:
- name: id
in: path
required: true
description: The social issue's id
schema:
type: integer
format: integer
minimum: 1
responses:
200:
description: "ok"
content:
application/json:
schema:
$ref: '#/components/schemas/SocialIssue'
404:
description: "not found"
401:
description: "Unauthorized"
/1.0/person/social-work/result.json:
get:
tags:
@ -1268,7 +1309,6 @@ paths:
400:
description: "Bad Request"
/1.0/person/social-work/result/by-goal/{id}.json:
get:
tags:
@ -1349,7 +1389,6 @@ paths:
400:
description: "Bad Request"
/1.0/person/social-work/goal/by-social-action/{id}.json:
get:
tags: