mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'master' of gitlab.com:Chill-Projet/chill-bundles
This commit is contained in:
commit
f4516f8369
@ -2,25 +2,44 @@ import {createApp} from 'vue';
|
|||||||
import SetReferrer from 'ChillPersonAssets/vuejs/_components/AccompanyingPeriod/SetReferrer.vue';
|
import SetReferrer from 'ChillPersonAssets/vuejs/_components/AccompanyingPeriod/SetReferrer.vue';
|
||||||
import {fetchResults} from 'ChillMainAssets/lib/api/apiMethods.js';
|
import {fetchResults} from 'ChillMainAssets/lib/api/apiMethods.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* To start this app, add this container into recordAction passed as argument to
|
||||||
|
* `ChillPerson/AccompanyingPeriod/_list_item.html.twig`:
|
||||||
|
*
|
||||||
|
* ```html+twig
|
||||||
|
* {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE', period) %}
|
||||||
|
* <li>
|
||||||
|
* <span data-set-referrer-app="data-set-referrer-app" data-set-referrer-accompanying-period-id="{{ period.id }}"></span>
|
||||||
|
* </li>
|
||||||
|
* {% endif %}
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The app will update the referrer displayed into dedicated span
|
||||||
|
*/
|
||||||
|
|
||||||
document.querySelectorAll('[data-set-referrer-app]').forEach(function (el) {
|
document.querySelectorAll('[data-set-referrer-app]').forEach(function (el) {
|
||||||
let
|
let
|
||||||
periodId = Number.parseInt(el.dataset.setReferrerAccompanyingPeriodId);
|
periodId = Number.parseInt(el.dataset.setReferrerAccompanyingPeriodId);
|
||||||
|
|
||||||
const url = `/api/1.0/person/accompanying-course/${periodId}/referrers-suggested.json`;
|
const url = `/api/1.0/person/accompanying-course/${periodId}/referrers-suggested.json`;
|
||||||
|
|
||||||
fetchResults(url).then(suggested => {
|
fetchResults(url).then(suggested => {
|
||||||
|
|
||||||
const app = createApp({
|
const app = createApp({
|
||||||
components: {
|
components: {
|
||||||
SetReferrer,
|
SetReferrer,
|
||||||
},
|
},
|
||||||
template:
|
template:
|
||||||
'<set-referrer :suggested="this.suggested" :periodId="periodId" @referrerSet="onReferrerSet"></set-referrer>',
|
'<set-referrer :suggested="suggested" :periodId="periodId" @referrerSet="onReferrerSet"></set-referrer>',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
suggested, periodId,
|
periodId, suggested, original: suggested,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onReferrerSet(ref) {
|
onReferrerSet(ref) {
|
||||||
|
|
||||||
const bloc = document.querySelector(`[data-accompanying-period-id="${this.periodId}"]`);
|
const bloc = document.querySelector(`[data-accompanying-period-id="${this.periodId}"]`);
|
||||||
if (bloc === null) {
|
if (bloc === null) {
|
||||||
console.error('bloc not found');
|
console.error('bloc not found');
|
||||||
@ -37,6 +56,7 @@ document.querySelectorAll('[data-set-referrer-app]').forEach(function (el) {
|
|||||||
label.textContent = ref.text;
|
label.textContent = ref.text;
|
||||||
label.classList.remove('chill-no-data-statement');
|
label.classList.remove('chill-no-data-statement');
|
||||||
|
|
||||||
|
this.suggested = this.original.filter(user => user.id !== ref.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<ul class="list-suggest add-items" v-if="this.suggested.length > 0">
|
<ul class="list-suggest add-items" v-if="suggested.length > 0">
|
||||||
<li v-for="r in this.suggested" @click="setReferrer(r)"><span>{{ r.text }}</span></li>
|
<li v-for="r in suggested" @click="setReferrer(r)"><span>{{ r.text }}</span></li>
|
||||||
</ul>
|
</ul>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -14,13 +14,20 @@ export default {
|
|||||||
suggested: {
|
suggested: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: false,
|
required: false,
|
||||||
default: [],
|
//default: [],
|
||||||
},
|
},
|
||||||
periodId: {
|
periodId: {
|
||||||
type: Number,
|
type: Number,
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
/*suggested: [
|
||||||
|
{id: 5, text: 'Robert'}, {id: 8, text: 'Monique'},
|
||||||
|
]*/
|
||||||
|
}
|
||||||
|
},
|
||||||
emits: ['referrerSet'],
|
emits: ['referrerSet'],
|
||||||
methods: {
|
methods: {
|
||||||
setReferrer: function(ref) {
|
setReferrer: function(ref) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<div class="item-bloc accompanying-period-item{% if itemBlocClass is defined %} {{ itemBlocClass }}{% endif %}" {% if itemAttrs is defined %}{{ itemAttrs }}{% endif %}>
|
<div class="item-bloc accompanying-period-item{% if itemBlocClass is defined %} {{ itemBlocClass|raw }}{% endif %}" data-accompanying-period-id="{{ period.id|e('html_attr') }}">
|
||||||
<div class="item-row">
|
<div class="item-row">
|
||||||
<div class="wrap-header">
|
<div class="wrap-header">
|
||||||
<div class="wh-row">
|
<div class="wh-row">
|
||||||
@ -43,6 +43,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="wh-col">
|
<div class="wh-col">
|
||||||
{% if chill_accompanying_periods.fields.user == 'visible' %}
|
{% if chill_accompanying_periods.fields.user == 'visible' %}
|
||||||
|
{# the tags `data-referrer-text` is used by module `@ChillPerson/mod/AccompanyingPeriod/setReferrer.js` #}
|
||||||
{% if period.user %}
|
{% if period.user %}
|
||||||
<abbr class="referrer" title="{{ 'Referrer'|trans }}">{{ 'Referrer'|trans }}:</abbr>
|
<abbr class="referrer" title="{{ 'Referrer'|trans }}">{{ 'Referrer'|trans }}:</abbr>
|
||||||
<span data-referrer-text="data-referrer-text">{{ period.user|chill_entity_render_box }}</span>
|
<span data-referrer-text="data-referrer-text">{{ period.user|chill_entity_render_box }}</span>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user