I'm working on a calendar base on FC6 and I was trying to add to my event title the user that created the event. This is my info.event:
and nomeUtente is the text I want to add to my event.
I tried this in my eventDidMount:
eventDidMount: function(info) {
if (info.event.title == "Normali") {
$(".fc-event-title").append(" - " + info.event.extendedProps.nomeUtente);
info.event.setProp("backgroundColor", "#FB6B4C");
} else if (info.event.title == "Straordinarie") {
$(".fc-event-title").append(" - " + info.event.extendedProps.nomeUtente);
info.event.setProp("backgroundColor", "#C8FC0C");
} else if (info.event.title == "Ferie") {
$(".fc-event-title").append(" - " + info.event.extendedProps.nomeUtente);
info.event.setProp("backgroundColor", "#EC1C28");
} else if (info.event.title == "Malattia") {
$(".fc-event-title").append(" - " + info.event.extendedProps.nomeUtente);
info.event.setProp("backgroundColor", "#FFB404");;
} else if (info.event.title == "Permesso") {
$(".fc-event-title").append(" - " + info.event.extendedProps.nomeUtente);
info.event.setProp("backgroundColor", "#A0ACDC");
} else if (info.event.title == "Smart Working") {
$(".fc-event-title").append(" - " + info.event.extendedProps.nomeUtente);
info.event.setProp("backgroundColor", "#08ACC4");
} else if (info.event.title == "Trasferta") {
$(".fc-event-title").append(" - " + info.event.extendedProps.nomeUtente);
info.event.setProp("backgroundColor", "#00897B");
} else if (info.event.title == "Assenza non retribuita") {
$(".fc-event-title").append(" - " + info.event.extendedProps.nomeUtente);
info.event.setProp("backgroundColor", "#F8D2D7");
} else if (info.event.title == "Altro") {
$(".fc-event-title").append(" - " + info.event.extendedProps.nomeUtente);
info.event.setProp("backgroundColor", "#5E35B1");
}
}
It made a distinction between the different type of events and this is the output at the moment:
I also tried to write this to set the title:
info.event.setProp("title", info.event.title + " - " + info.event.extendedProps.nomeUtente);
But this is what it shows in the calendar:
What it could be the right way to do it?
From monthView to listView and go back to monthView shows nomeUtente:
eventSources: [
{
url: '../../resource/script/apps/calendar/load.php',
method: 'POST',
display: "block ruby",
textColor: "black"
},{
url: '../../resource/script/apps/calendar/vacation.json',
rrule: {
freq: "yearly",
dtstart: "2022-01-06"
}
}
],
and this is my load.php:
<?php
require_once "../../connection.php";
$data = array();
$query= sqlsrv_query($conn,"SELECT * FROM gestioneOre ORDER BY idAssenza");
while($result = sqlsrv_fetch_array($query)){
$data[] = array(
'idAssenza' => $result['idAssenza'],
'title' => $result['ename'],
'start' => $result['starts'],
'end' => $result['ends'],
'nomeUtente'=> $result['nomeUtente'],
'pausaPranzo'=> $result['pausaPranzo']
);
}
echo json_encode($data);
?>
And the end I found out I could use EventContent
like this:
eventContent: function(info) {
const title = info.event.title;
const nomeUtente = info.event.extendedProps.nomeUtente;
if (nomeUtente){
return {
html: title + " - " + nomeUtente
}
}
}