diff --git a/src/Bundle/ChillDocGeneratorBundle/DataFixtures/ORM/LoadDocGeneratorTemplate.php b/src/Bundle/ChillDocGeneratorBundle/DataFixtures/ORM/LoadDocGeneratorTemplate.php
index ade47e307..0d5904865 100644
--- a/src/Bundle/ChillDocGeneratorBundle/DataFixtures/ORM/LoadDocGeneratorTemplate.php
+++ b/src/Bundle/ChillDocGeneratorBundle/DataFixtures/ORM/LoadDocGeneratorTemplate.php
@@ -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],
],
];
diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/js/date.js b/src/Bundle/ChillMainBundle/Resources/public/chill/js/date.js
index 22f935744..44fab8dc2 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/chill/js/date.js
+++ b/src/Bundle/ChillMainBundle/Resources/public/chill/js/date.js
@@ -93,7 +93,6 @@ const datetimeToISO = (date) => {
};
const intervalDaysToISO = (days) => {
- console.log(days);
if (null === days) {
return 'PD0';
}
diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php
index 050be9f93..9c27aeb59 100644
--- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php
+++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php
@@ -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;
+ }
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue
index fb143789c..e89d66c1a 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue
@@ -378,7 +378,6 @@ export default {
this.$store.commit('removeGoal', g);
},
addEvaluation(e) {
- console.log('add Evaluation', e);
this.$store.commit('addEvaluation', e);
},
toggleAddEvaluation() {
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue
index 721d15450..33436f222 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue
@@ -67,19 +67,15 @@
-
+
+
-
-
@@ -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();
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js
index 87b7d03e4..22218f04f 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js
@@ -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');
},
}
});