vue accompanyingcourse_work: prepare evaluations, + translations chains + styles border

This commit is contained in:
Mathieu Jaumotte 2021-08-09 16:22:28 +02:00 committed by Marc Ducobu
parent 44e85361e6
commit 3156706c2b
5 changed files with 149 additions and 66 deletions

View File

@ -1,29 +1,34 @@
<template> <template>
<div id="workEditor"> <div id="workEditor">
<div id="title"> <div id="title">
<label class="action_title_label">{{ $t('action_title') }}</label> <label class="action_title_label">{{ $t('action_title') }}</label>
<p class="action_title">{{ work.socialAction.text }}</p> <p class="action_title">{{ work.socialAction.text }}</p>
</div> </div>
<div id="startDate"> <div id="startDate">
<label>{{ $t('startDate') }}</label> <label>{{ $t('startDate') }}</label>
<input type="date" v-model="startDate" /> <input type="date" v-model="startDate" />
</div> </div>
<div id="endDate"> <div id="endDate">
<label>{{ $t('endDate') }}</label> <label>{{ $t('endDate') }}</label>
<input type="date" v-model="endDate" /> <input type="date" v-model="endDate" />
</div> </div>
<div id="comment"> <div id="comment">
<label>Commentaire</label> <label>{{ $t('comments') }}</label>
<ckeditor <ckeditor
:editor="editor" :editor="editor"
v-model="note" v-model="note"
tag-name="textarea" tag-name="textarea"
></ckeditor> ></ckeditor>
</div> </div>
<div id="objectives" class="objectives_list"> <div id="objectives" class="objectives_list">
<div class="title" aria="hidden"> <div class="title" aria="hidden">
<div><h3>Motifs - objectifs - dispositifs</h3></div> <div><h3>{{ $t('goals_title') }}</h3></div>
<div><h3>Orientations - résultats</h3></div> <div><h3>{{ $t('results_title') }}</h3></div>
</div> </div>
<!-- results which are not attached to an objective --> <!-- results which are not attached to an objective -->
@ -54,7 +59,7 @@
<div> <div>
<div v-if="showAddObjective"> <div v-if="showAddObjective">
<p>Motifs, objectifs et dispositifs disponibles pour ajout&nbsp;:</p> <p>{{ $t('available_goals_text')}}</p>
<ul class="list-objectives"> <ul class="list-objectives">
<li v-for="g in availableForCheckGoal" @click="addGoal(g)" class="badge bg-primary"> <li v-for="g in availableForCheckGoal" @click="addGoal(g)" class="badge bg-primary">
@ -65,9 +70,7 @@
</div> </div>
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
<button @click="toggleAddObjective" class="btn btn-create"> <button @click="toggleAddObjective" class="btn btn-create" :title="$t('add_an_objective')"></button>
Ajouter un objectif
</button>
</li> </li>
</ul> </ul>
</div> </div>
@ -75,9 +78,32 @@
</div> </div>
</div> </div>
<div id="evaluations">
<div class="title" aria="hidden">
<div><h3>{{ $t('Evaluations') }}</h3></div>
</div>
<!-- results which are not attached to an objective -->
<div v-if="hasEvaluationsForAction">
<add-evaluation :availableEvaluations="evaluationsForAction" destination="action"></add-evaluation>
</div>
<!-- box to add evaluation -->
<div class="add_evaluation">
<div v-if="showAddEvaluation">
bim
</div>
<ul class="record_actions">
<li>
<button @click="toggleAddEvaluation" class="btn btn-create" :title="$t('add_an_evaluation')"></button>
</li>
</ul>
<div><!-- empty for results --></div>
</div>
</div>
<div id="persons"> <div id="persons">
<h2>{{ $t('persons_involved') }}</h2> <h3>{{ $t('persons_involved') }}</h3>
<ul> <ul>
<li v-for="p in personsReachables" :key="p.id"> <li v-for="p in personsReachables" :key="p.id">
@ -87,20 +113,19 @@
</ul> </ul>
</div> </div>
<div id="handlingThirdParty"> <div id="handlingThirdParty">
<h2>Tiers traitant</h2> <h3>{{ $t('handling_thirdparty') }}</h3>
<div v-if="!hasHandlingThirdParty"> <div v-if="!hasHandlingThirdParty">
<p class="chill-no-data-statement"> <p class="chill-no-data-statement">
Aucun tiers traitant {{ $t('no_handling_thirdparty') }}
</p> </p>
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
<add-persons <add-persons
buttonTitle="Indiquer un tiers traitant" v-bind:buttonTitle="$t('precise_handling_thirdparty')"
modalTitle="Choisir un tiers" v-bind:modalTitle="$t('choose_a_thirdparty')"
v-bind:key="handlingThirdPartyPicker.key" v-bind:key="handlingThirdPartyPicker.key"
v-bind:options="handlingThirdPartyPicker.options" v-bind:options="handlingThirdPartyPicker.options"
@addNewPersons="setHandlingThirdParty" @addNewPersons="setHandlingThirdParty"
@ -116,7 +141,7 @@
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
<button class="btn btn-delete" @click="removeHandlingThirdParty"> <button class="btn btn-delete" @click="removeHandlingThirdParty">
Supprimer le tiers traitant {{ $t('remove_handling_thirdparty') }}
</button> </button>
</li> </li>
</ul> </ul>
@ -124,14 +149,13 @@
</div> </div>
<div id="thirdParties"> <div id="thirdParties">
<h2>Tiers intervenants</h2> <h3>{{ $t('thirdparty_intervener') }}</h3>
<div v-if="!hasThirdParties"> <div v-if="!hasThirdParties">
<p class="chill-no-data-statement">Aucun tiers intervenant</p> <p class="chill-no-data-statement">{{ $t('no_thirdparty_intervener') }}</p>
</div> </div>
<div v-else> <div v-else>
<ul> <ul>
<li v-for="t in thirdParties"> <li v-for="t in thirdParties">
@ -148,8 +172,8 @@
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
<add-persons <add-persons
buttonTitle="Ajouter des tiers" v-bind:buttonTitle="$t('add_thirdparties')"
modalTitle="Choisir des tiers" v-bind:modalTitle="$t('choose_thirdparties')"
v-bind:key="thirdPartyPicker.key" v-bind:key="thirdPartyPicker.key"
v-bind:options="thirdPartyPicker.options" v-bind:options="thirdPartyPicker.options"
@addNewPersons="addThirdParties" @addNewPersons="addThirdParties"
@ -160,35 +184,33 @@
</div> </div>
<div id="errors" v-if="errors.length > 0"> <div id="errors" v-if="errors.length > 0">
<p>Veuillez corriger les erreurs suivantes:</p> <p>{{ $t('fix_these_errors') }}</p>
<ul> <ul>
<li v-for="e in errors">{{ e }}</li> <li v-for="e in errors">{{ e }}</li>
</ul> </ul>
</div> </div>
</div> </div>
<ul class="record_actions sticky-form-buttons"> <ul class="record_actions sticky-form-buttons">
<li v-if="!isPosting">
<button
class="btn btn-save"
@click="submit"
>
{{ $t('action.save') }}
</button>
</li>
<li v-if="isPosting">
<button
class="btn btn-save"
disabled
>
{{ $t('action.save') }}
</button>
</li>
</ul>
<li v-if="!isPosting">
<button class="btn btn-save" @click="submit">
{{ $t('action.save') }}
</button>
</li>
<li v-if="isPosting">
<button class="btn btn-save" disabled>
{{ $t('action.save') }}
</button>
</li>
</ul>
</template> </template>
<style lang="scss"> <style lang="scss">
@import '~ChillMainAssets/module/bootstrap/shared';
@import '~ChillMainAssets/chill/scss/mixins';
#workEditor { #workEditor {
display: grid; display: grid;
@ -197,6 +219,7 @@
"startDate endDate" "startDate endDate"
"comment comment" "comment comment"
"objectives objectives" "objectives objectives"
"evaluations evaluations"
"persons persons" "persons persons"
"handling handling" "handling handling"
"tparties tparties" "tparties tparties"
@ -204,7 +227,12 @@
; ;
grid-template-columns: 50%; grid-template-columns: 50%;
column-gap: 1rem; column-gap: 0rem;
& > div {
@include border-collapse;
padding: 1em;
}
#title { #title {
grid-area: title; grid-area: title;
@ -230,22 +258,16 @@
#objectives { #objectives {
grid-area: objectives; grid-area: objectives;
> div.title { & > div {
background-color: var(--chill-light-gray);
color: white;
h3 {
text-align: center;
}
}
> div {
display: grid; display: grid;
grid-template-areas: "obj res"; grid-template-areas: "obj res";
grid-template-columns: 50%; grid-template-columns: 50%;
column-gap: 1rem; column-gap: 0rem;
& > div {
@include border-collapse;
padding: 1em;
> div {
&:nth-child(1) { &:nth-child(1) {
grid-area: obj; grid-area: obj;
} }
@ -255,13 +277,13 @@
} }
} }
> div.results_without_objective { & > div.results_without_objective {
background: repeating-linear-gradient( background: repeating-linear-gradient(
45deg, 45deg,
var(--chill-light-gray), $gray-500,
var(--chill-light-gray) 10px, $gray-500 10px,
var(--chill-llight-gray) 10px, $gray-100 10px,
var(--chill-llight-gray) 20px $gray-100 20px
); );
text-align: center; text-align: center;
@ -291,8 +313,8 @@
} }
i.fa-times { i.fa-times {
background-color: red; background-color: $red;
color: white; color: $white;
} }
} }
@ -306,11 +328,30 @@
} }
i.fa-plus { i.fa-plus {
background-color: green; background-color: $green;
} }
} }
} }
#objectives, #evaluations {
padding: 0;
& > div.title {
background-color: $gray-200;
color: $gray-700;
h3 {
text-align: center;
}
}
}
#evaluations {
grid-area: evaluations;
& > div {
@include border-collapse;
padding: 1em;
}
}
#persons { #persons {
grid-area: persons; grid-area: persons;
} }
@ -328,12 +369,12 @@
</style> </style>
<script> <script>
import { mapState, mapGetters, } from 'vuex'; import { mapState, mapGetters, } from 'vuex';
import { dateToISO, ISOToDate, ISOToDatetime } from 'ChillMainAssets/chill/js/date.js'; import { dateToISO, ISOToDate, ISOToDatetime } from 'ChillMainAssets/chill/js/date.js';
import CKEditor from '@ckeditor/ckeditor5-vue'; import CKEditor from '@ckeditor/ckeditor5-vue';
import ClassicEditor from 'ChillMainAssets/module/ckeditor5/index.js'; import ClassicEditor from 'ChillMainAssets/module/ckeditor5/index.js';
import AddResult from './components/AddResult.vue'; import AddResult from './components/AddResult.vue';
import AddEvaluation from './components/AddEvaluation.vue';
import Person from 'ChillPersonAssets/vuejs/_components/Person/Person.vue'; import Person from 'ChillPersonAssets/vuejs/_components/Person/Person.vue';
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue'; import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue';
import ShowAddress from 'ChillMainAssets/vuejs/Address/components/ShowAddress.vue'; import ShowAddress from 'ChillMainAssets/vuejs/Address/components/ShowAddress.vue';
@ -342,11 +383,28 @@ const i18n = {
messages: { messages: {
fr: { fr: {
action_title: "Action d'accompagnement", action_title: "Action d'accompagnement",
comments: "Commentaire",
startDate: "Date de début", startDate: "Date de début",
endDate: "Date de fin", endDate: "Date de fin",
goals_title: "Motifs - objectifs - dispositifs",
available_goals_text: "Motifs, objectifs et dispositifs disponibles pour ajout :",
results_title: "Orientations - résultats",
results_without_objective: "Résultats - orientations sans objectifs", results_without_objective: "Résultats - orientations sans objectifs",
add_objectif: "Ajouter un motif - objectif - dispositif", add_objectif: "Ajouter un motif - objectif - dispositif",
add_an_objective: "Ajouter un objectif",
Evaluations: "Évaluations",
add_an_evaluation: "Ajouter une évaluation",
persons_involved: "Usagers concernés", persons_involved: "Usagers concernés",
handling_thirdparty: "Tiers traitant",
no_handling_thirdparty: "Aucun tiers traitant",
precise_handling_thirdparty: "Indiquer un tiers traitant",
choose_a_thirdparty: "Choisir un tiers",
remove_handling_thirdparty: "Supprimer le tiers traitant",
thirdparty_intervener: "Tiers intervenants",
no_thirdparty_intervener: "Aucun tiers intervenant",
add_thirdparties: "Ajouter des tiers",
choose_thirdparties: "Choisir des tiers",
fix_these_errors: "Veuillez corriger les erreurs suivantes :",
} }
} }
}; };
@ -356,6 +414,7 @@ export default {
components: { components: {
ckeditor: CKEditor.component, ckeditor: CKEditor.component,
AddResult, AddResult,
AddEvaluation,
AddPersons, AddPersons,
Person, Person,
ShowAddress, ShowAddress,
@ -365,6 +424,7 @@ export default {
return { return {
editor: ClassicEditor, editor: ClassicEditor,
showAddObjective: false, showAddObjective: false,
showAddEvaluation: false,
handlingThirdPartyPicker: { handlingThirdPartyPicker: {
key: 'handling-third-party', key: 'handling-third-party',
options: { options: {
@ -387,6 +447,7 @@ export default {
...mapState([ ...mapState([
'work', 'work',
'resultsForAction', 'resultsForAction',
'evaluationsForAction',
'goalsPicked', 'goalsPicked',
'personsReachables', 'personsReachables',
'handlingThirdParty', 'handlingThirdParty',
@ -396,6 +457,7 @@ export default {
]), ]),
...mapGetters([ ...mapGetters([
'hasResultsForAction', 'hasResultsForAction',
'hasEvaluationsForAction',
'hasHandlingThirdParty', 'hasHandlingThirdParty',
'hasThirdParties', 'hasThirdParties',
]), ]),
@ -457,6 +519,9 @@ export default {
console.log('remove goal', g); console.log('remove goal', g);
this.$store.commit('removeGoal', g); this.$store.commit('removeGoal', g);
}, },
toggleAddEvaluation() {
this.showAddEvaluation = !this.showAddEvaluation;
},
setHandlingThirdParty({ selected, modal }) { setHandlingThirdParty({ selected, modal }) {
console.log('setHandlingThirdParty', selected); console.log('setHandlingThirdParty', selected);
this.$store.commit('setHandlingThirdParty', selected.shift().result); this.$store.commit('setHandlingThirdParty', selected.shift().result);

View File

@ -0,0 +1,14 @@
<template>
boum
</template>
<script>
export default {
name: "AddEvaluation",
props: ['destination', 'availableEvaluations'],
}
</script>
<style scoped>
</style>

View File

@ -86,7 +86,7 @@ const i18n = {
export default { export default {
name: "AddResult", name: "AddResult",
props: [ 'destination', 'goal' ], props: [ 'destination', 'goal', 'availableResults' ],
i18n, i18n,
data() { data() {
return { return {
@ -136,7 +136,7 @@ export default {
}, },
methods: { methods: {
toggleSelect() { toggleSelect() {
this.isExpanded = !this.isExpanded; this.isExpanded = !this.isExpanded;
}, },
addResult(r) { addResult(r) {
console.log('addResult', r); console.log('addResult', r);

View File

@ -20,6 +20,7 @@ const store = createStore({
resultsForAction: [], resultsForAction: [],
goalsForAction: [], goalsForAction: [],
resultsForGoal: [], resultsForGoal: [],
evaluationsForAction: [],
personsPicked: window.accompanyingCourseWork.persons, personsPicked: window.accompanyingCourseWork.persons,
personsReachables: window.accompanyingCourseWork.accompanyingPeriod.participations.filter(p => p.endDate == null) personsReachables: window.accompanyingCourseWork.accompanyingPeriod.participations.filter(p => p.endDate == null)
.map(p => p.person), .map(p => p.person),
@ -45,6 +46,9 @@ const store = createStore({
return found === undefined ? [] : found.results; return found === undefined ? [] : found.results;
}, },
hasEvaluationsForAction(state) {
return state.evaluationsForAction.length > 0;
},
hasHandlingThirdParty(state) { hasHandlingThirdParty(state) {
return state.handlingThirdParty !== null; return state.handlingThirdParty !== null;
}, },
@ -259,7 +263,7 @@ const store = createStore({
errors = [] errors = []
; ;
console.log('action subitting', payload, url); console.log('action submitting', payload, url);
commit('setIsPosting', true); commit('setIsPosting', true);
window.fetch(url, { window.fetch(url, {

View File

@ -6,9 +6,9 @@
{% block content %} {% block content %}
<div class="accompanying_course_work-edit"> <div class="accompanying_course_work-edit">
<h1>{{ block('title') }}</h1> <h1>{{ block('title') }}</h1>
<div id="accompanying_course_work_edit"></div> <div id="accompanying_course_work_edit"></div>
</div> </div>
{% endblock %} {% endblock %}