rdv: add content of calendar item in a modal

This commit is contained in:
nobohan 2021-09-10 17:31:19 +02:00
parent f6f24d0beb
commit 855686c0ba
4 changed files with 210 additions and 124 deletions

View File

@ -37,12 +37,14 @@ class Calendar
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue * @ORM\GeneratedValue
* @ORM\Column(type="integer") * @ORM\Column(type="integer")
* @Serializer\Groups({"calendar:read"})
*/ */
private ?int $id; private ?int $id;
/** /**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
* @Groups({"read"}) * @Groups({"read"})
* @Serializer\Groups({"calendar:read"})
*/ */
private User $user; private User $user;
@ -64,6 +66,7 @@ class Calendar
* cascade={"persist", "remove", "merge", "detach"}) * cascade={"persist", "remove", "merge", "detach"})
* @ORM\JoinTable(name="chill_calendar.calendar_to_persons") * @ORM\JoinTable(name="chill_calendar.calendar_to_persons")
* @Groups({"read"}) * @Groups({"read"})
* @Serializer\Groups({"calendar:read"})
*/ */
private Collection $persons; private Collection $persons;
@ -74,6 +77,7 @@ class Calendar
* cascade={"persist", "remove", "merge", "detach"}) * cascade={"persist", "remove", "merge", "detach"})
* @ORM\JoinTable(name="chill_calendar.calendar_to_thirdparties") * @ORM\JoinTable(name="chill_calendar.calendar_to_thirdparties")
* @Groups({"read"}) * @Groups({"read"})
* @Serializer\Groups({"calendar:read"})
*/ */
private Collection $professionals; private Collection $professionals;
@ -89,6 +93,7 @@ class Calendar
/** /**
* @ORM\Embedded(class=CommentEmbeddable::class, columnPrefix="comment_") * @ORM\Embedded(class=CommentEmbeddable::class, columnPrefix="comment_")
* @Serializer\Groups({"calendar:read"})
*/ */
private CommentEmbeddable $comment; private CommentEmbeddable $comment;

View File

@ -16,7 +16,7 @@
<span class='calendarRangeItems'> <span class='calendarRangeItems'>
<b>{{ arg.timeText }}</b> <b>{{ arg.timeText }}</b>
<i>&nbsp;{{ arg.event.title }}</i> <i>&nbsp;{{ arg.event.title }}</i>
<a class="fa fa-fw fa-times" <a v-if=!arg.event.extendedProps.myCalendar class="fa fa-fw fa-times"
@click.prevent="onClickDelete(arg.event)"> @click.prevent="onClickDelete(arg.event)">
</a> </a>
</span> </span>
@ -70,6 +70,47 @@
</div> </div>
</div> </div>
</div> </div>
<teleport to="body">
<modal v-if="modal.showModal"
:modalDialogClass="modal.modalDialogClass"
@close="modal.showModal = false">
<template v-slot:header>
<h2 class="modal-title"> {{ this.myCalendarClickedEvent.start.toLocaleString() }} - {{ this.myCalendarClickedEvent.end.toLocaleString() }}</h2>
</template>
<template v-slot:body>
<p>{{ $t('by')}} {{this.myCalendarClickedEvent.user.username }}</p>
<p>{{ $t('main_user_concerned') }} : {{ this.myCalendarClickedEvent.mainUser.username }}</p>
<p v-if="myCalendarClickedEvent.comment.length > 0" >{{ this.myCalendarClickedEvent.comment }}</p>
</template>
<template v-slot:footer>
<ul class="record_actions">
<li>
<a
class="btn btn-show"
:href=myCalendarEventShowLink() >
</a>
</li>
<li>
<a
class="btn btn-update"
:href=myCalendarEventUpdateLink() >
</a>
</li>
<li>
<a
class="btn btn-delete"
:href=myCalendarEventDeleteLink() >
</a>
</li>
</ul>
</template>
</modal>
</teleport>
</template> </template>
<script> <script>
@ -79,22 +120,29 @@ import FullCalendar from '@fullcalendar/vue3';
import dayGridPlugin from '@fullcalendar/daygrid'; import dayGridPlugin from '@fullcalendar/daygrid';
import interactionPlugin from '@fullcalendar/interaction'; import interactionPlugin from '@fullcalendar/interaction';
import timeGridPlugin from '@fullcalendar/timegrid'; import timeGridPlugin from '@fullcalendar/timegrid';
import Modal from 'ChillMainAssets/vuejs/_components/Modal';
import { deleteCalendarRange, fetchCalendar, fetchCalendarRangesByUser, patchCalendarRange, postCalendarRange } from '../_api/api'; import { deleteCalendarRange, fetchCalendar, fetchCalendarRangesByUser, patchCalendarRange, postCalendarRange } from '../_api/api';
import { mapState } from 'vuex'; import { mapState } from 'vuex';
export default { export default {
name: "App", name: "App",
components: { components: {
FullCalendar FullCalendar,
Modal
}, },
data() { data() {
return { return {
errorMsg: [], errorMsg: [],
modal: {
showModal: false,
modalDialogClass: "modal-dialog-scrollable modal-m"
},
flag: { flag: {
loading: false loading: false
}, },
userId: window.userId, userId: window.userId,
showMyCalendar: true, showMyCalendar: true,
myCalendarClickedEvent: null,
calendarEvents: { calendarEvents: {
userCalendar: null, userCalendar: null,
userCalendarRange: null, userCalendarRange: null,
@ -116,6 +164,7 @@ export default {
eventChange: this.onEventChange, eventChange: this.onEventChange,
eventDrop: this.onEventDropOrResize, eventDrop: this.onEventDropOrResize,
eventResize: this.onEventDropOrResize, eventResize: this.onEventDropOrResize,
eventClick: this.onEventClick,
selectMirror: true, selectMirror: true,
editable: true, editable: true,
weekends: false, weekends: false,
@ -149,6 +198,18 @@ export default {
init() { init() {
this.fetchData(); this.fetchData();
}, },
openModal() {
this.modal.showModal = true;
},
myCalendarEventShowLink() {
return `/fr/calendar/ ${this.myCalendarClickedEvent.id}/show?user_id=${ this.userId }`
},
myCalendarEventUpdateLink() {
return `/fr/calendar/ ${this.myCalendarClickedEvent.id}/edit?user_id=${ this.userId }`
},
myCalendarEventDeleteLink() {
return `/fr/calendar/ ${this.myCalendarClickedEvent.id}/delete?user_id=${ this.userId }`
},
resetCalendar() { resetCalendar() {
this.fetchData(); this.fetchData();
this.calendarEvents.new = { this.calendarEvents.new = {
@ -179,8 +240,15 @@ export default {
fetchCalendar(this.userId).then(calendar => new Promise((resolve, reject) => { fetchCalendar(this.userId).then(calendar => new Promise((resolve, reject) => {
let events = calendar.results.map(i => let events = calendar.results.map(i =>
({ ({
myCalendar: true,
calendarId: i.id,
start: i.startDate.datetime, start: i.startDate.datetime,
end: i.endDate.datetime, end: i.endDate.datetime,
user: i.user,
mainUser: i.mainUser,
persons: i.persons,
professionals: i.professionals,
comment: i.comment
}) })
); );
let calendarEventsCurrentUser = { let calendarEventsCurrentUser = {
@ -238,6 +306,26 @@ export default {
payload.event.setProp('textColor', '#444444'); payload.event.setProp('textColor', '#444444');
this.$store.dispatch('updateRange', payload); this.$store.dispatch('updateRange', payload);
}, },
onEventClick(payload) {
console.log(payload)
console.log(payload.event)
console.log(payload.event.extendedProps)
if (payload.event.extendedProps.myCalendar) {
this.myCalendarClickedEvent = {
id: payload.event.extendedProps.calendarId,
start: payload.event.start,
end: payload.event.end,
user: payload.event.extendedProps.user,
mainUser: payload.event.extendedProps.mainUser,
persons: payload.event.extendedProps.persons,
professionals: payload.event.extendedProps.professionals,
comment: payload.event.extendedProps.comment
};
console.log(this.myCalendarClickedEvent)
this.openModal();
}
},
onClickSave(payload) { onClickSave(payload) {
this.flag.loading = true; this.flag.loading = true;
if (this.$store.state.newCalendarRanges.length > 0){ if (this.$store.state.newCalendarRanges.length > 0){

View File

@ -10,7 +10,9 @@ const appMessages = {
copy_range_how_to: "Créez les plages de disponibilités durant une journée et copiez-les facilement au jour suivant avec ce bouton. Si les week-ends sont cachés, le jour suivant un vendredi sera le lundi.", copy_range_how_to: "Créez les plages de disponibilités durant une journée et copiez-les facilement au jour suivant avec ce bouton. Si les week-ends sont cachés, le jour suivant un vendredi sera le lundi.",
new_range_to_save: "Nouvelles plages à enregistrer", new_range_to_save: "Nouvelles plages à enregistrer",
update_range_to_save: "Plages à modifier", update_range_to_save: "Plages à modifier",
delete_range_to_save: "Plages à supprimer" delete_range_to_save: "Plages à supprimer",
by: "Par",
main_user_concerned: "Utilisateur concerné"
} }
} }

View File

@ -16,11 +16,7 @@
{% if context == 'user' %} {% if context == 'user' %}
<div id="myCalendar"></div> <div id="myCalendar"></div>
{% endif %} {% else %}
{% if context == 'user' %}
<h2 class="chill-red">{{ 'My calendar list' |trans }}</h2>
{% endif %}
{% if calendarItems|length == 0 %} {% if calendarItems|length == 0 %}
<p class="chill-no-data-statement"> <p class="chill-no-data-statement">
@ -56,16 +52,6 @@
{% endif %} {% endif %}
{% if context == 'user' and calendar.accompanyingPeriod is not empty %}
<a class="btn btn-sm btn-outline-primary"
title="{{ 'Period number %number%'|trans({'%number%': calendar.accompanyingPeriod.id}) }}"
href="{{ chill_path_add_return_path(
"chill_user_accompanying_course_index",
{ 'accompanying_period_id': calendar.accompanyingPeriod.id }
) }}"><i class="fa fa-random"></i>
</a>
{% endif %}
</div> </div>
<div class="item-col"> <div class="item-col">
@ -152,3 +138,8 @@
</li> </li>
</ul> </ul>
{% endif %} {% endif %}
{% endif %}