From a9b7cf93e9943468856baf1a1fa3059ef687943f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 26 Jan 2022 13:49:50 +0100 Subject: [PATCH] adaptation for list for regulation --- .../mod/AccompanyingPeriod/setReferrer.js | 47 +++++++++++++++++++ .../AccompanyingPeriod/SetReferrer.vue | 44 +++++++++++++++++ .../AccompanyingPeriod/_list_item.html.twig | 6 +-- .../ChillPersonBundle/chill.webpack.config.js | 2 + 4 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/mod/AccompanyingPeriod/setReferrer.js create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AccompanyingPeriod/SetReferrer.vue diff --git a/src/Bundle/ChillPersonBundle/Resources/public/mod/AccompanyingPeriod/setReferrer.js b/src/Bundle/ChillPersonBundle/Resources/public/mod/AccompanyingPeriod/setReferrer.js new file mode 100644 index 000000000..b06dba5b9 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/mod/AccompanyingPeriod/setReferrer.js @@ -0,0 +1,47 @@ +import {createApp} from 'vue'; +import SetReferrer from 'ChillPersonAssets/vuejs/_components/AccompanyingPeriod/SetReferrer.vue'; +import {fetchResults} from 'ChillMainAssets/lib/api/apiMethods.js'; + +document.querySelectorAll('[data-set-referrer-app]').forEach(function (el) { + let + periodId = Number.parseInt(el.dataset.setReferrerAccompanyingPeriodId); + + const url = `/api/1.0/person/accompanying-course/${periodId}/referrers-suggested.json`; + fetchResults(url).then(suggested => { + const app = createApp({ + components: { + SetReferrer, + }, + template: + '', + data() { + return { + suggested, periodId, + } + }, + methods: { + onReferrerSet(ref) { + const bloc = document.querySelector(`[data-accompanying-period-id="${this.periodId}"]`); + if (bloc === null) { + console.error('bloc not found'); + return; + } + + const label = bloc.querySelector('[data-referrer-text]'); + + if (label === null) { + console.error('label not found'); + return; + } + + label.textContent = ref.text; + label.classList.remove('chill-no-data-statement'); + + } + } + }); + + app.mount(el); + + }) +}) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AccompanyingPeriod/SetReferrer.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AccompanyingPeriod/SetReferrer.vue new file mode 100644 index 000000000..049dabff6 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AccompanyingPeriod/SetReferrer.vue @@ -0,0 +1,44 @@ + + + + + diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list_item.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list_item.html.twig index f346c6bab..b53631e86 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list_item.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list_item.html.twig @@ -1,4 +1,4 @@ -
+
@@ -45,9 +45,9 @@ {% if chill_accompanying_periods.fields.user == 'visible' %} {% if period.user %} {{ 'Referrer'|trans }}: - {{ period.user|chill_entity_render_box }} + {{ period.user|chill_entity_render_box }} {% else %} - {{ 'No accompanying user'|trans }} + {{ 'No accompanying user'|trans }} {% endif %} {% endif %}
diff --git a/src/Bundle/ChillPersonBundle/chill.webpack.config.js b/src/Bundle/ChillPersonBundle/chill.webpack.config.js index 0b83f8e41..d57483992 100644 --- a/src/Bundle/ChillPersonBundle/chill.webpack.config.js +++ b/src/Bundle/ChillPersonBundle/chill.webpack.config.js @@ -14,6 +14,8 @@ module.exports = function(encore, entries) encore.addEntry('vue_accourse_work_edit', __dirname + '/Resources/public/vuejs/AccompanyingCourseWorkEdit/index.js'); encore.addEntry('vue_visgraph', __dirname + '/Resources/public/vuejs/VisGraph/index.js'); + encore.addEntry('mod_set_referrer', __dirname + '/Resources/public/mod/AccompanyingPeriod/setReferrer.js'); + encore.addEntry('page_household_edit_metadata', __dirname + '/Resources/public/page/household_edit_metadata/index.js'); encore.addEntry('page_person', __dirname + '/Resources/public/page/person/index.js'); encore.addEntry('page_accompanying_course_index_person_locate', __dirname + '/Resources/public/page/accompanying_course_index/person_locate.js');