mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
vue accompanyingCourse, adding an origin sub-component
This commit is contained in:
parent
d8256b0ac5
commit
2fe1605385
@ -24,10 +24,17 @@ namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Serializer\Annotation\Groups;
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||||
|
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(name="chill_person_accompanying_period_origin")
|
* @ORM\Table(name="chill_person_accompanying_period_origin")
|
||||||
|
* @Serializer\DiscriminatorMap(
|
||||||
|
* typeProperty="type",
|
||||||
|
* mapping={
|
||||||
|
* "origin"=Origin::class
|
||||||
|
* })
|
||||||
*/
|
*/
|
||||||
class Origin
|
class Origin
|
||||||
{
|
{
|
||||||
|
@ -1,17 +1,37 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="vue-component">
|
<div class="vue-component">
|
||||||
<h2><a name="section-05"></a>{{ $t('origin.title') }}</h2>
|
<h2><a name="section-05"></a>{{ $t('origin.title') }}</h2>
|
||||||
|
|
||||||
hop
|
<div class="my-4">
|
||||||
|
<label for="selectOrigin">
|
||||||
|
{{ $t('origin.label') }}
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<VueMultiselect
|
||||||
|
name="selectOrigin"
|
||||||
|
label="text"
|
||||||
|
vbind: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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getOrigins } from '../api';
|
import VueMultiselect from 'vue-multiselect';
|
||||||
|
import { getListOrigins } from '../api';
|
||||||
import { mapState } from 'vuex';
|
import { mapState } from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'OriginDemand',
|
name: 'OriginDemand',
|
||||||
|
components: { VueMultiselect },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
options: []
|
options: []
|
||||||
@ -28,10 +48,25 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
getOptions() {
|
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>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
|
||||||
|
<style lang="css" scoped>
|
||||||
|
label {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<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="selectReferrer">
|
||||||
{{ $t('referrer.label') }}
|
{{ $t('referrer.label') }}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
@ -77,3 +77,5 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
|
||||||
|
@ -28,6 +28,8 @@ const appMessages = {
|
|||||||
},
|
},
|
||||||
origin: {
|
origin: {
|
||||||
title: "Origine de la demande",
|
title: "Origine de la demande",
|
||||||
|
label: "Origine de la demande",
|
||||||
|
placeholder: "Renseignez l'origine de la demande",
|
||||||
},
|
},
|
||||||
persons_associated: {
|
persons_associated: {
|
||||||
title: "Usagers concernés",
|
title: "Usagers concernés",
|
||||||
|
@ -81,6 +81,10 @@ let initPromise = getAccompanyingCourse(id)
|
|||||||
updateSocialIssues(state, value) {
|
updateSocialIssues(state, value) {
|
||||||
state.accompanyingCourse.socialIssues = value;
|
state.accompanyingCourse.socialIssues = value;
|
||||||
},
|
},
|
||||||
|
updateOrigin(state, value) {
|
||||||
|
console.log('value', value);
|
||||||
|
state.accompanyingCourse.origin = value;
|
||||||
|
},
|
||||||
updateReferrer(state, value) {
|
updateReferrer(state, value) {
|
||||||
console.log('value', value);
|
console.log('value', value);
|
||||||
state.accompanyingCourse.user = value;
|
state.accompanyingCourse.user = value;
|
||||||
@ -191,6 +195,13 @@ let initPromise = getAccompanyingCourse(id)
|
|||||||
resolve();
|
resolve();
|
||||||
})).catch((error) => { commit('catchError', error) });
|
})).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) {
|
updateReferrer({ commit }, payload) {
|
||||||
patchAccompanyingCourse(id, { type: "accompanying_period", user: { id: payload.id, type: payload.type } })
|
patchAccompanyingCourse(id, { type: "accompanying_period", user: { id: payload.id, type: payload.type } })
|
||||||
.then(course => new Promise((resolve, reject) => {
|
.then(course => new Promise((resolve, reject) => {
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user