fix loading of evaluations

This commit is contained in:
Julien Fastré 2022-01-26 21:46:07 +01:00
parent dc0fae7549
commit c70a4dc664
5 changed files with 17 additions and 7 deletions

View File

@ -17,7 +17,7 @@
<select class="form-select" v-model="template"> <select class="form-select" v-model="template">
<option disabled selected value="">{{ $t('choose_a_template') }}</option> <option disabled selected value="">{{ $t('choose_a_template') }}</option>
<template v-for="t in templates"> <template v-for="t in templates">
<option v-bind:value="t.id">{{ t.name.fr }}</option> <option v-bind:value="t.id">{{ t.name.fr || 'Aucun nom défini' }}</option>
</template> </template>
</select> </select>
<button v-if="canGenerate" class="btn btn-update btn-sm change-icon" type="button" @click="generateDocument"><i class="fa fa-fw fa-cog"></i></button> <button v-if="canGenerate" class="btn btn-update btn-sm change-icon" type="button" @click="generateDocument"><i class="fa fa-fw fa-cog"></i></button>
@ -48,6 +48,7 @@ export default {
required: true, required: true,
}, },
templates: { templates: {
type: Array,
required: true, required: true,
}, },
// beforeMove execute "something" before // beforeMove execute "something" before
@ -73,7 +74,11 @@ export default {
return true; return true;
}, },
getDescription() { getDescription() {
return this.templates.find(t => t.id === this.template).description || ''; let desc = this.templates.find(t => t.id === this.template);
if (null === desc) {
return '';
}
return desc.description || '';
}, },
}, },
methods: { methods: {

View File

@ -69,7 +69,7 @@ class AccompanyingPeriodWorkEvaluationApiController
$paginator->setItemsPerPage(count($evaluations)); $paginator->setItemsPerPage(count($evaluations));
return new JsonResponse($this->serializer->serialize( return new JsonResponse($this->serializer->serialize(
new Collection($evaluations, $paginator), new Collection(array_values($evaluations), $paginator),
'json', 'json',
[ [
AbstractNormalizer::GROUPS => ['read'], AbstractNormalizer::GROUPS => ['read'],

View File

@ -58,7 +58,11 @@ const store = createStore({
return state.thirdParties.length > 0; return state.thirdParties.length > 0;
}, },
getTemplatesAvailablesForEvaluation: (state) => (evaluation) => { getTemplatesAvailablesForEvaluation: (state) => (evaluation) => {
return state.templatesAvailablesForEvaluation.get(evaluation.id) || []; if (state.templatesAvailablesForEvaluation.has(evaluation.id)) {
return state.templatesAvailablesForEvaluation.get(evaluation.id);
}
return [];
}, },
buildPayload(state) { buildPayload(state) {
return { return {
@ -171,7 +175,6 @@ const store = createStore({
}; };
g.id = tmpIndex() -1 g.id = tmpIndex() -1
state.goalsPicked.push(g); state.goalsPicked.push(g);
//console.log('goals picked ids', state.goalsPicked.map(g => g.id))
}, },
removeGoal(state, goal) { removeGoal(state, goal) {
state.goalsPicked = state.goalsPicked.filter(g => g.id !== goal.id); state.goalsPicked = state.goalsPicked.filter(g => g.id !== goal.id);
@ -369,7 +372,6 @@ const store = createStore({
return makeFetch('PUT', url, payload) return makeFetch('PUT', url, payload)
.then(data => { .then(data => {
console.log('data received', data);
if (typeof(callback) !== 'undefined') { if (typeof(callback) !== 'undefined') {
return callback(data); return callback(data);
} else { } else {

View File

@ -98,7 +98,7 @@ class AccompanyingPeriodWorkEvaluationContext implements
return $this->translatableStringHelper->localize($e->getTitle()); return $this->translatableStringHelper->localize($e->getTitle());
}, },
'multiple' => true, 'multiple' => true,
'expanded' => true, 'attr' => ['class' => 'select2'],
]); ]);
} }

View File

@ -530,3 +530,6 @@ household_composition:
Currently no composition: Aucune composition famiale renseignée. Currently no composition: Aucune composition famiale renseignée.
Add a composition: Ajouter une composition familiale Add a composition: Ajouter une composition familiale
Update composition: Modifier la composition familiale Update composition: Modifier la composition familiale
# docgen
Linked evaluations: Évaluations associées