mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
create document from evaluation
This commit is contained in:
parent
364346d0aa
commit
a797143511
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Chill\DocGeneratorBundle\DataFixtures\ORM;
|
namespace Chill\DocGeneratorBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||||
@ -25,13 +26,13 @@ class LoadDocGeneratorTemplate extends AbstractFixture
|
|||||||
'desc' => 'stocké sur openstack comedienbe',
|
'desc' => 'stocké sur openstack comedienbe',
|
||||||
'file' => 'FORMULAIRE_AEB.docx',
|
'file' => 'FORMULAIRE_AEB.docx',
|
||||||
'context' => 'Chill\DocGeneratorBundle\Context\HouseholdMemberSelectionContext',
|
'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'],
|
'name' => ['fr' => 'AIDE ALIMENTAIRE'],
|
||||||
'desc' => 'stocké sur openstack comedienbe',
|
'desc' => 'stocké sur openstack comedienbe',
|
||||||
'file' => 'AIDE_ALIMENTAIRE.docx',
|
'file' => 'AIDE_ALIMENTAIRE.docx',
|
||||||
'context' => 'Chill\DocGeneratorBundle\Context\HouseholdMemberSelectionContext',
|
'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) => {
|
const intervalDaysToISO = (days) => {
|
||||||
console.log(days);
|
|
||||||
if (null === days) {
|
if (null === days) {
|
||||||
return 'PD0';
|
return 'PD0';
|
||||||
}
|
}
|
||||||
|
@ -126,6 +126,21 @@ class AccompanyingPeriodWorkEvaluation implements TrackUpdateInterface, TrackCre
|
|||||||
*/
|
*/
|
||||||
private Collection $documents;
|
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()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->documents = new ArrayCollection();
|
$this->documents = new ArrayCollection();
|
||||||
@ -187,7 +202,8 @@ class AccompanyingPeriodWorkEvaluation implements TrackUpdateInterface, TrackCre
|
|||||||
($this->evaluation instanceof Evaluation
|
($this->evaluation instanceof Evaluation
|
||||||
&& null === $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");
|
change or remove the linked Evaluation::class");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,5 +382,26 @@ class AccompanyingPeriodWorkEvaluation implements TrackUpdateInterface, TrackCre
|
|||||||
return $this->documents;
|
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);
|
this.$store.commit('removeGoal', g);
|
||||||
},
|
},
|
||||||
addEvaluation(e) {
|
addEvaluation(e) {
|
||||||
console.log('add Evaluation', e);
|
|
||||||
this.$store.commit('addEvaluation', e);
|
this.$store.commit('addEvaluation', e);
|
||||||
},
|
},
|
||||||
toggleAddEvaluation() {
|
toggleAddEvaluation() {
|
||||||
|
@ -67,19 +67,15 @@
|
|||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<select class="form-select form-select-sm" v-model="template">
|
<select class="form-select form-select-sm" v-model="template">
|
||||||
<option disabled value="">{{ $t('evaluation_choose_a_template') }}</option>
|
<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>
|
</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>
|
||||||
</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>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -88,6 +84,7 @@
|
|||||||
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 { mapGetters, mapState } from 'vuex';
|
||||||
|
|
||||||
const i18n = {
|
const i18n = {
|
||||||
messages: {
|
messages: {
|
||||||
@ -119,25 +116,19 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
editor: ClassicEditor,
|
editor: ClassicEditor,
|
||||||
//evaluation: {
|
template: null,
|
||||||
// status: null,
|
|
||||||
// startDate: null,
|
|
||||||
// endDate: null,
|
|
||||||
// maxDate: null,
|
|
||||||
// warningInterval: null,
|
|
||||||
// comment: null,
|
|
||||||
// template: null,
|
|
||||||
// //documents: null
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
/*
|
...mapGetters([
|
||||||
status: {
|
'getTemplatesAvailaibleForEvaluation'
|
||||||
get() { return this.evaluation.status; },
|
]),
|
||||||
set(v) { this.evaluation.status = v; }
|
...mapState([
|
||||||
|
'isPosting'
|
||||||
|
]),
|
||||||
|
canGenerate() {
|
||||||
|
return !this.$store.state.isPosting && this.template !== null;
|
||||||
},
|
},
|
||||||
*/
|
|
||||||
startDate: {
|
startDate: {
|
||||||
get() {
|
get() {
|
||||||
return dateToISO(this.evaluation.startDate);
|
return dateToISO(this.evaluation.startDate);
|
||||||
@ -171,10 +162,6 @@ export default {
|
|||||||
get() { return this.evaluation.comment; },
|
get() { return this.evaluation.comment; },
|
||||||
set(v) { this.$store.commit('setEvaluationComment', { key: this.evaluation.key, comment: v }); }
|
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: {
|
methods: {
|
||||||
listAllStatus() {
|
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() {
|
mounted() {
|
||||||
//this.listAllStatus();
|
//this.listAllStatus();
|
||||||
|
@ -4,6 +4,7 @@ import { findSocialActionsBySocialIssue } from 'ChillPersonAssets/vuejs/_api/Soc
|
|||||||
import { create } from 'ChillPersonAssets/vuejs/_api/AccompanyingCourseWork.js';
|
import { create } from 'ChillPersonAssets/vuejs/_api/AccompanyingCourseWork.js';
|
||||||
|
|
||||||
const debug = process.env.NODE_ENV !== 'production';
|
const debug = process.env.NODE_ENV !== 'production';
|
||||||
|
const evalFQDN = encodeURIComponent("Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluation");
|
||||||
|
|
||||||
const store = createStore({
|
const store = createStore({
|
||||||
strict: debug,
|
strict: debug,
|
||||||
@ -32,6 +33,7 @@ const store = createStore({
|
|||||||
return k;
|
return k;
|
||||||
}),
|
}),
|
||||||
evaluationsForAction: [],
|
evaluationsForAction: [],
|
||||||
|
templatesAvailableForEvaluation: [],
|
||||||
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),
|
||||||
@ -63,6 +65,9 @@ const store = createStore({
|
|||||||
hasThirdParties(state) {
|
hasThirdParties(state) {
|
||||||
return state.thirdParties.length > 0;
|
return state.thirdParties.length > 0;
|
||||||
},
|
},
|
||||||
|
getTemplatesAvailaibleForEvaluation(state) {
|
||||||
|
return state.templatesAvailableForEvaluation;
|
||||||
|
},
|
||||||
buildPayload(state) {
|
buildPayload(state) {
|
||||||
return {
|
return {
|
||||||
type: 'accompanying_period_work',
|
type: 'accompanying_period_work',
|
||||||
@ -99,6 +104,7 @@ const store = createStore({
|
|||||||
accompanyingPeriodWorkEvaluations: state.evaluationsPicked.map(e => {
|
accompanyingPeriodWorkEvaluations: state.evaluationsPicked.map(e => {
|
||||||
let o = {
|
let o = {
|
||||||
type: e.type,
|
type: e.type,
|
||||||
|
key: e.key,
|
||||||
evaluation: {
|
evaluation: {
|
||||||
id: e.evaluation.id,
|
id: e.evaluation.id,
|
||||||
type: e.evaluation.type
|
type: e.evaluation.type
|
||||||
@ -216,6 +222,11 @@ const store = createStore({
|
|||||||
let evaluation = state.evaluationsPicked.find(e => e.key === key);
|
let evaluation = state.evaluationsPicked.find(e => e.key === key);
|
||||||
evaluation.editEvaluation = !evaluation.editEvaluation;
|
evaluation.editEvaluation = !evaluation.editEvaluation;
|
||||||
},
|
},
|
||||||
|
setTemplatesAvailableForEvaluation(state, templates) {
|
||||||
|
for (let i in templates) {
|
||||||
|
state.templatesAvailableForEvaluation.push(templates[i]);
|
||||||
|
}
|
||||||
|
},
|
||||||
setPersonsPickedIds(state, ids) {
|
setPersonsPickedIds(state, ids) {
|
||||||
state.personsPicked = state.personsReachables
|
state.personsPicked = state.personsReachables
|
||||||
.filter(p => ids.includes(p.id))
|
.filter(p => ids.includes(p.id))
|
||||||
@ -317,7 +328,38 @@ const store = createStore({
|
|||||||
commit('setEvaluationsForAction', data.results);
|
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
|
let
|
||||||
payload = getters.buildPayload,
|
payload = getters.buildPayload,
|
||||||
url = `/api/1.0/person/accompanying-course/work/${state.work.id}.json`,
|
url = `/api/1.0/person/accompanying-course/work/${state.work.id}.json`,
|
||||||
@ -345,6 +387,8 @@ const store = createStore({
|
|||||||
}
|
}
|
||||||
commit('setErrors', errors);
|
commit('setErrors', errors);
|
||||||
commit('setIsPosting', false);
|
commit('setIsPosting', false);
|
||||||
|
} else if (typeof(callback) !== 'undefined') {
|
||||||
|
callback(data);
|
||||||
} else {
|
} else {
|
||||||
console.info('nothing to do here, bye bye');
|
console.info('nothing to do here, bye bye');
|
||||||
window.location.assign(`/fr/person/accompanying-period/${state.work.accompanyingPeriod.id}/work`);
|
window.location.assign(`/fr/person/accompanying-period/${state.work.accompanyingPeriod.id}/work`);
|
||||||
@ -360,6 +404,7 @@ const store = createStore({
|
|||||||
dispatch('getReachablesResultsForAction');
|
dispatch('getReachablesResultsForAction');
|
||||||
dispatch('getReachablesGoalsForAction');
|
dispatch('getReachablesGoalsForAction');
|
||||||
dispatch('getReachablesEvaluationsForAction');
|
dispatch('getReachablesEvaluationsForAction');
|
||||||
|
dispatch('getReachableTemplatesForEvaluation');
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user