mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
create document from evaluation
This commit is contained in:
parent
364346d0aa
commit
a797143511
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Chill\DocGeneratorBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
@ -25,13 +26,13 @@ class LoadDocGeneratorTemplate extends AbstractFixture
|
||||
'desc' => 'stocké sur openstack comedienbe',
|
||||
'file' => 'FORMULAIRE_AEB.docx',
|
||||
'context' => 'Chill\DocGeneratorBundle\Context\HouseholdMemberSelectionContext',
|
||||
'entities' => ['Chill\PersonBundle\Entity\AccompanyingPeriod', 'Chill\PersonBundle\Entity\SocialWork\SocialAction'],
|
||||
'entities' => ['Chill\PersonBundle\Entity\AccompanyingPeriod', 'Chill\PersonBundle\Entity\SocialWork\SocialAction', AccompanyingPeriodWorkEvaluation::class],
|
||||
], [
|
||||
'name' => ['fr' => 'AIDE ALIMENTAIRE'],
|
||||
'desc' => 'stocké sur openstack comedienbe',
|
||||
'file' => 'AIDE_ALIMENTAIRE.docx',
|
||||
'context' => 'Chill\DocGeneratorBundle\Context\HouseholdMemberSelectionContext',
|
||||
'entities' => ['Chill\PersonBundle\Entity\AccompanyingPeriod', 'Chill\PersonBundle\Entity\SocialWork\SocialAction'],
|
||||
'entities' => ['Chill\PersonBundle\Entity\AccompanyingPeriod', 'Chill\PersonBundle\Entity\SocialWork\SocialAction', AccompanyingPeriodWorkEvaluation::class],
|
||||
],
|
||||
];
|
||||
|
||||
|
@ -93,7 +93,6 @@ const datetimeToISO = (date) => {
|
||||
};
|
||||
|
||||
const intervalDaysToISO = (days) => {
|
||||
console.log(days);
|
||||
if (null === days) {
|
||||
return 'PD0';
|
||||
}
|
||||
|
@ -126,6 +126,21 @@ class AccompanyingPeriodWorkEvaluation implements TrackUpdateInterface, TrackCre
|
||||
*/
|
||||
private Collection $documents;
|
||||
|
||||
/**
|
||||
* This is a workaround for client, to allow them to assign arbitrary data
|
||||
* dedicated to their job.
|
||||
*
|
||||
* This data is not persisted into database, but will appears on the data
|
||||
* normalized during the same request (like PUT/PATCH request)
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
*
|
||||
* @var mixed
|
||||
*
|
||||
*/
|
||||
private $key = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->documents = new ArrayCollection();
|
||||
@ -187,7 +202,8 @@ class AccompanyingPeriodWorkEvaluation implements TrackUpdateInterface, TrackCre
|
||||
($this->evaluation instanceof Evaluation
|
||||
&& null === $evaluation)
|
||||
) {
|
||||
throw new \LogicException("once set, an ${self::class} cannot
|
||||
$cl = AccompanyingPeriodWorkEvaluation::class;
|
||||
throw new \LogicException("once set, an $cl cannot
|
||||
change or remove the linked Evaluation::class");
|
||||
}
|
||||
|
||||
@ -366,5 +382,26 @@ class AccompanyingPeriodWorkEvaluation implements TrackUpdateInterface, TrackCre
|
||||
return $this->documents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arbitrary data, used for client
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arbitrary data, used for client
|
||||
*
|
||||
* @param mixed $key
|
||||
* @return AccompanyingPeriodWorkEvaluation
|
||||
*/
|
||||
public function setKey($key): self
|
||||
{
|
||||
$this->key = $key;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -378,7 +378,6 @@ export default {
|
||||
this.$store.commit('removeGoal', g);
|
||||
},
|
||||
addEvaluation(e) {
|
||||
console.log('add Evaluation', e);
|
||||
this.$store.commit('addEvaluation', e);
|
||||
},
|
||||
toggleAddEvaluation() {
|
||||
|
@ -67,19 +67,15 @@
|
||||
<div class="input-group">
|
||||
<select class="form-select form-select-sm" v-model="template">
|
||||
<option disabled value="">{{ $t('evaluation_choose_a_template') }}</option>
|
||||
<option>A</option>
|
||||
<template v-for="t in getTemplatesAvailaibleForEvaluation">
|
||||
<option v-bind:value="t.id">{{ t.name.fr }}</option>
|
||||
</template>
|
||||
</select>
|
||||
<button class="btn btn-update btn-sm change-icon" type="button"><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>
|
||||
<button v-else class="btn btn-update btn-sm change-icon" type="button" disabled ><i class="fa fa-fw fa-cog"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--div class="row mb-3">
|
||||
<label class="col-sm-4 col-form-label">{{ $t('evaluation_add_a_document') }}</label>
|
||||
<div class="col-sm-8">
|
||||
<button class="btn btn-create btn-sm" @click="documents"></button>
|
||||
</div>
|
||||
</div-->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -88,6 +84,7 @@
|
||||
import {dateToISO, ISOToDate, ISOToDatetime} from 'ChillMainAssets/chill/js/date.js';
|
||||
import CKEditor from '@ckeditor/ckeditor5-vue';
|
||||
import ClassicEditor from 'ChillMainAssets/module/ckeditor5/index.js';
|
||||
import { mapGetters, mapState } from 'vuex';
|
||||
|
||||
const i18n = {
|
||||
messages: {
|
||||
@ -119,25 +116,19 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
editor: ClassicEditor,
|
||||
//evaluation: {
|
||||
// status: null,
|
||||
// startDate: null,
|
||||
// endDate: null,
|
||||
// maxDate: null,
|
||||
// warningInterval: null,
|
||||
// comment: null,
|
||||
// template: null,
|
||||
// //documents: null
|
||||
//}
|
||||
template: null,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
/*
|
||||
status: {
|
||||
get() { return this.evaluation.status; },
|
||||
set(v) { this.evaluation.status = v; }
|
||||
...mapGetters([
|
||||
'getTemplatesAvailaibleForEvaluation'
|
||||
]),
|
||||
...mapState([
|
||||
'isPosting'
|
||||
]),
|
||||
canGenerate() {
|
||||
return !this.$store.state.isPosting && this.template !== null;
|
||||
},
|
||||
*/
|
||||
startDate: {
|
||||
get() {
|
||||
return dateToISO(this.evaluation.startDate);
|
||||
@ -171,10 +162,6 @@ export default {
|
||||
get() { return this.evaluation.comment; },
|
||||
set(v) { this.$store.commit('setEvaluationComment', { key: this.evaluation.key, comment: v }); }
|
||||
},
|
||||
template: {
|
||||
get() { return this.evaluation.template; },
|
||||
set(v) { this.evaluation.template = v; }
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
listAllStatus() {
|
||||
@ -189,6 +176,10 @@ export default {
|
||||
})
|
||||
;
|
||||
},
|
||||
generateDocument() {
|
||||
console.log('template picked', this.template);
|
||||
this.$store.dispatch('generateDocument', { key: this.evaluation.key, templateId: this.template})
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
//this.listAllStatus();
|
||||
|
@ -4,6 +4,7 @@ import { findSocialActionsBySocialIssue } from 'ChillPersonAssets/vuejs/_api/Soc
|
||||
import { create } from 'ChillPersonAssets/vuejs/_api/AccompanyingCourseWork.js';
|
||||
|
||||
const debug = process.env.NODE_ENV !== 'production';
|
||||
const evalFQDN = encodeURIComponent("Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluation");
|
||||
|
||||
const store = createStore({
|
||||
strict: debug,
|
||||
@ -32,6 +33,7 @@ const store = createStore({
|
||||
return k;
|
||||
}),
|
||||
evaluationsForAction: [],
|
||||
templatesAvailableForEvaluation: [],
|
||||
personsPicked: window.accompanyingCourseWork.persons,
|
||||
personsReachables: window.accompanyingCourseWork.accompanyingPeriod.participations.filter(p => p.endDate == null)
|
||||
.map(p => p.person),
|
||||
@ -63,6 +65,9 @@ const store = createStore({
|
||||
hasThirdParties(state) {
|
||||
return state.thirdParties.length > 0;
|
||||
},
|
||||
getTemplatesAvailaibleForEvaluation(state) {
|
||||
return state.templatesAvailableForEvaluation;
|
||||
},
|
||||
buildPayload(state) {
|
||||
return {
|
||||
type: 'accompanying_period_work',
|
||||
@ -99,6 +104,7 @@ const store = createStore({
|
||||
accompanyingPeriodWorkEvaluations: state.evaluationsPicked.map(e => {
|
||||
let o = {
|
||||
type: e.type,
|
||||
key: e.key,
|
||||
evaluation: {
|
||||
id: e.evaluation.id,
|
||||
type: e.evaluation.type
|
||||
@ -216,6 +222,11 @@ const store = createStore({
|
||||
let evaluation = state.evaluationsPicked.find(e => e.key === key);
|
||||
evaluation.editEvaluation = !evaluation.editEvaluation;
|
||||
},
|
||||
setTemplatesAvailableForEvaluation(state, templates) {
|
||||
for (let i in templates) {
|
||||
state.templatesAvailableForEvaluation.push(templates[i]);
|
||||
}
|
||||
},
|
||||
setPersonsPickedIds(state, ids) {
|
||||
state.personsPicked = state.personsReachables
|
||||
.filter(p => ids.includes(p.id))
|
||||
@ -317,7 +328,38 @@ const store = createStore({
|
||||
commit('setEvaluationsForAction', data.results);
|
||||
});
|
||||
},
|
||||
submit({ getters, state, commit }) {
|
||||
getReachableTemplatesForEvaluation({commit}) {
|
||||
const
|
||||
url = `/fr/doc/gen/templates/for/${evalFQDN}`
|
||||
;
|
||||
window.fetch(url).then(r => {
|
||||
if (r.ok) {
|
||||
return r.json();
|
||||
}
|
||||
throw new Error("not possible to load templates for evaluations")
|
||||
}).then(data => {
|
||||
commit('setTemplatesAvailableForEvaluation', data.results);
|
||||
}).catch(e => {
|
||||
console.error(e);
|
||||
})
|
||||
},
|
||||
generateDocument({ dispatch }, {key, templateId}) {
|
||||
const callback = function(data) {
|
||||
// get the evaluation id from the data
|
||||
const
|
||||
evaluationId = data.accompanyingPeriodWorkEvaluations.find(e => e.key === key).id,
|
||||
returnPath = encodeURIComponent(window.location.pathname + window.location.search + window.location.hash),
|
||||
url = `/fr/doc/gen/generate/from/${templateId}/for/${evalFQDN}/${evaluationId}?returnPath=${returnPath}`
|
||||
;
|
||||
//http://localhost:8001/fr/doc/gen/generate/from/12/for/Chill%5CPersonBundle%5CEntity%5CAccompanyingPeriod%5CAccompanyingPeriodWorkEvaluation/41
|
||||
|
||||
console.log('I will generate your doc at', url);
|
||||
window.location.assign(url);
|
||||
};
|
||||
|
||||
dispatch('submit', callback);
|
||||
},
|
||||
submit({ getters, state, commit }, callback) {
|
||||
let
|
||||
payload = getters.buildPayload,
|
||||
url = `/api/1.0/person/accompanying-course/work/${state.work.id}.json`,
|
||||
@ -345,6 +387,8 @@ const store = createStore({
|
||||
}
|
||||
commit('setErrors', errors);
|
||||
commit('setIsPosting', false);
|
||||
} else if (typeof(callback) !== 'undefined') {
|
||||
callback(data);
|
||||
} else {
|
||||
console.info('nothing to do here, bye bye');
|
||||
window.location.assign(`/fr/person/accompanying-period/${state.work.accompanyingPeriod.id}/work`);
|
||||
@ -360,6 +404,7 @@ const store = createStore({
|
||||
dispatch('getReachablesResultsForAction');
|
||||
dispatch('getReachablesGoalsForAction');
|
||||
dispatch('getReachablesEvaluationsForAction');
|
||||
dispatch('getReachableTemplatesForEvaluation');
|
||||
},
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user