Aggiornamento a Fullcalendar 6

This commit is contained in:
loviuz 2023-01-23 23:10:52 +01:00
parent 6f13d42fce
commit 875ece7e53
5 changed files with 62 additions and 59 deletions

View File

@ -53,7 +53,7 @@ const inquirer = require('inquirer');
const config = {
production: 'assets/dist', // Cartella di destinazione
development: 'assets/src', // Cartella dei file di personalizzazione
debug: false,
debug: true,
nodeDirectory: './node_modules', // Percorso per node_modules
paths: {
js: 'js',
@ -62,7 +62,7 @@ const config = {
fonts: 'fonts'
},
babelOptions: {
compact: true,
compact: false,
presets: [
['@babel/env', {
modules: false
@ -98,7 +98,9 @@ const JS = gulp.parallel(() => {
'dropzone/dist/dropzone.js',
'autonumeric/dist/autoNumeric.min.js',
'eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js',
'fullcalendar/dist/fullcalendar.js',
'fullcalendar-scheduler/index.global.js',
'@fullcalendar/moment/index.global.js',
'@fullcalendar/core/locales/it.global.js',
'geocomplete/jquery.geocomplete.js',
'inputmask/dist/min/jquery.inputmask.bundle.min.js',
'jquery-form/src/jquery.form.js',
@ -161,7 +163,6 @@ const CSS = gulp.parallel(() => {
'dropzone/dist/dropzone.css',
'eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css',
'font-awesome/css/font-awesome.min.css',
'fullcalendar/dist/fullcalendar.css',
'parsleyjs/src/parsley.css',
'select2/dist/css/select2.min.css',
'sweetalert2/dist/sweetalert2.css',
@ -208,7 +209,6 @@ function srcCSS() {
const print = gulp.src([
config.development + '/' + config.paths.css + '/print/*.{css,scss,less,styl}',
config.nodeDirectory + '/fullcalendar/fullcalendar.print.css',
], {
allowEmpty: true
})

View File

@ -105,12 +105,14 @@ switch (filter('op')) {
$results[] = [
'id' => $sessione['id'],
'idintervento' => $sessione['idintervento'],
'idtecnico' => $sessione['idtecnico'],
'title' => (($sessione['is_completato']) ? '<i class="fa fa-lock" aria-hidden="true"></i>' : '').' '.(($sessione['have_attachments']) ? '<i class="fa fa-paperclip" aria-hidden="true"></i>' : '').($sessione['is_completato'] || $sessione['have_attachments'] ? '<br>' : '').'<b>Int. '.$sessione['codice'].'</b> '.$sessione['cliente'].'<br><b>'.tr('Tecnici').':</b> '.$sessione['nome_tecnico'],
'start' => $sessione['orario_inizio'],
'end' => $sessione['orario_fine'],
'link' => base_path().'/editor.php?id_module='.$modulo_interventi->id.'&id_record='.$sessione['idintervento'],
'extendedProps' => [
'link' => base_path().'/editor.php?id_module='.$modulo_interventi->id.'&id_record='.$sessione['idintervento'],
'idintervento' => $sessione['idintervento'],
'idtecnico' => $sessione['idtecnico'],
],
'backgroundColor' => $backgroundcolor,
'textColor' => color_inverse($backgroundcolor),
'borderColor' => empty($bordercolor) ? '#FFFFFF' : $bordercolor,
@ -190,13 +192,15 @@ switch (filter('op')) {
foreach ($alldays as $evento) {
$results[] = [
'id' => $modulo_eventi->id.'_'.$evento['id'],
'idintervento' => $evento['id'],
'idtecnico' => '',
'title' => '<b>'.tr('Evento').':</b> '.$evento['nome'].'<br>
<b>'.tr('Festività').':</b> '.($evento['is_bank_holiday'] ? '<i class="fa fa-check text-success"></i>' : '<i class="fa fa-times text-danger"></i>'),
'start' => $evento['data'],
'end' => $evento['data'],
'url' => base_path().'/editor.php?id_module='.$modulo_eventi->id.'&id_record='.$evento['id'],
'extendedProps' => [
'link' => base_path().'/editor.php?id_module='.$modulo_eventi->id.'&id_record='.$evento['id'],
'idintervento' => $evento['id'],
'idtecnico' => '',
],
'backgroundColor' => '#ffebcd',
'textColor' => color_inverse('#ffebcd'),
'borderColor' => '#ffebcd',

View File

@ -329,11 +329,11 @@ WHERE (SELECT COUNT(*) FROM in_interventi_tecnici WHERE in_interventi_tecnici.id
$vista = setting('Vista dashboard');
if ($vista == 'mese') {
$def = 'month';
$def = 'dayGridMonth';
} elseif ($vista == 'giorno') {
$def = 'agendaDay';
$def = 'timeGridWeek';
} elseif ($vista == 'settimana') {
$def = 'agendaWeek';
$def = 'listWeek';
} else {
$def = 'listWeek';
}
@ -341,8 +341,8 @@ if ($vista == 'mese') {
$modulo_interventi = Modules::get('Interventi');
echo '
<script type="text/javascript">
globals.dashboard = {
<script type="text/javascript">
globals.dashboard = {
load_url: "'.$structure->fileurl('ajax.php').'?id_module='.$id_module.'",
style: "'.$def.'",
show_sunday: '.intval(setting('Visualizzare la domenica sul calendario')).',
@ -351,11 +351,6 @@ echo '
write_permission: '.intval($modulo_interventi->permission == 'rw').',
tooltip: '.intval(setting('Utilizzare i tooltip sul calendario')).',
calendar: null,
/* timeFormat: {
hour: "2-digit",
minute: "2-digit",
hour12: false
}, */
timeFormat: "H:mm",
select: {
title: "'.tr('Aggiungi intervento').'",
@ -445,7 +440,7 @@ echo '
session_set_array("dashboard,idstatiintervento", id).then(function () {
aggiorna_contatore("#dashboard_stati");
globals.dashboard.calendar.fullCalendar("refetchEvents"); //.refetchEvents()
globals.dashboard.calendar.refetchEvents();
});
});
@ -455,7 +450,7 @@ echo '
session_set_array("dashboard,idtipiintervento", id).then(function () {
aggiorna_contatore("#dashboard_tipi");
globals.dashboard.calendar.fullCalendar("refetchEvents"); //.refetchEvents()
globals.dashboard.calendar.refetchEvents();
});
});
@ -465,7 +460,7 @@ echo '
session_set_array("dashboard,idtecnici", id).then(function () {
aggiorna_contatore("#dashboard_tecnici");
globals.dashboard.calendar.fullCalendar("refetchEvents"); //.refetchEvents()
globals.dashboard.calendar.refetchEvents();
});
});
@ -475,7 +470,7 @@ echo '
session_set_array("dashboard,idzone", id).then(function () {
aggiorna_contatore("#dashboard_zone");
globals.dashboard.calendar.fullCalendar("refetchEvents"); //.refetchEvents()
globals.dashboard.calendar.refetchEvents();
});
});
@ -509,23 +504,23 @@ echo '
var calendarElement = document.getElementById("calendar");
var clickCnt = 0;
var calendar = $(calendarElement).fullCalendar({
/* plugins: [interactionPlugin, dayGridPlugin, timeGridPlugin], */
var calendar = new FullCalendar.Calendar(calendarElement, {
//plugins: [adaptivePlugin, momentPlugin, dayGridPlugin, timeGridPlugin],
/* locales: allLocales, */
locale: globals.locale,
slotEventOverlap: false,
schedulerLicenseKey: "GPL-My-Project-Is-Open-Source",
hiddenDays: globals.dashboard.show_sunday ? [] : [0],
header: {
headerToolbar: {
left: "prev,next today",
center: "title",
right: "month,agendaWeek,agendaDay,listWeek"
right: "dayGridMonth,timeGridWeek,listWeek"
},
timeFormat: globals.dashboard.timeFormat,
slotLabelFormat: globals.dashboard.timeFormat,
slotDuration: "00:15:00",
snapDuration: globals.snapDuration,
defaultView: globals.dashboard.style,
initialView: "dayGridMonth",
minTime: globals.dashboard.start_time,
maxTime: globals.dashboard.end_time,
lazyFetching: true,
@ -561,7 +556,7 @@ echo '
// Ricaricamento dei dati alla chiusura del modal
$(this).remove();
$("#modals > div").on("hidden.bs.modal", function () {
globals.dashboard.calendar.fullCalendar("refetchEvents"); //.refetchEvents()
globals.dashboard.calendar.refetchEvents();
let mese = $("#mese-promemoria").val();
carica_interventi_da_pianificare(mese);
@ -569,11 +564,11 @@ echo '
},
selectable: globals.dashboard.write_permission,
select: function (start, end, allDay) { // info
// let start = info.start;
// let end = info.end;
select: function (info) { // info
let start = info.start;
let end = info.end;
let intero_giorno = !start.hasTime() && !end.hasTime();
let intero_giorno = !start.hasTime && !end.hasTime;
if (intero_giorno !== true || globals.dashboard.informazioni_aggiuntive==0) {
let data = moment(start).format("YYYY-MM-DD");
let data_fine = moment(end).format("YYYY-MM-DD");
@ -581,7 +576,7 @@ echo '
let orario_fine = moment(end).format("HH:mm");
// Fix selezione di un giorno avanti per vista mensile
if (globals.dashboard.calendar.fullCalendar("getView").name == "month") {
if (globals.dashboard.calendar.view == "dayGridMonth") {
data_fine = moment(end).subtract(1, "days").format("YYYY-MM-DD");
}
@ -590,8 +585,8 @@ echo '
},
editable: globals.dashboard.write_permission,
eventDrop: function (event, delta, revertFunc) {// info
// let event = info.event;
eventDrop: function (info) {// info
let event = info.event;
if (event.allDay !== true) {
let start = event.start;
@ -599,7 +594,7 @@ echo '
$.post(globals.dashboard.load_url, {
op: "modifica_intervento",
id: event.id,
idintervento: event.idintervento,
idintervento: event.extendedProps.idintervento,
timeStart: moment(start).format("YYYY-MM-DD HH:mm"),
timeEnd: moment(end).format("YYYY-MM-DD HH:mm")
}, function (data, responseType) {
@ -612,22 +607,22 @@ echo '
}
if (data !== "ok") {
revertFunc(); // info.revert();
info.revert();
}
});
} else {
revertFunc();
info.revert();
}
},
eventResize: function (event, delta, revertFunc) { // info
// let event = info.event;
eventResize: function (info) {
let event = info.event;
let start = event.start;
let end = (event.end!=null ? event.end : event.start);
$.post(globals.dashboard.load_url, {
op: "modifica_intervento",
id: event.id,
idintervento: event.idintervento,
idintervento: event.extendedProps.idintervento,
timeStart: moment(start).format("YYYY-MM-DD HH:mm"),
timeEnd: moment(end).format("YYYY-MM-DD HH:mm")
}, function (data, responseType) {
@ -640,7 +635,7 @@ echo '
}
if (data !== "ok") {
revertFunc(); // info.revert();
info.revert();
}
});
@ -649,9 +644,9 @@ echo '
if(isMobile() && setting('Utilizzare i tooltip sul calendario')){
echo '
eventClick: function(info) {
let link = info.link;
let link = info.event.extendedProps.link;
let element = $(this);
clickCnt++;
clickCnt++;
if (clickCnt === 1) {
oneClickTimer = setTimeout(function() {
clickCnt = 0;
@ -666,18 +661,20 @@ if(isMobile() && setting('Utilizzare i tooltip sul calendario')){
}else{
echo '
eventClick: function(info) {
let link = info.link;
location.href = link;
info.jsEvent.preventDefault();
location.href = info.event.extendedProps.link;
},';
}
echo '
// eventPositioned: function (info) {
eventAfterRender: function (event, element) {
// let event = info.event;
// let element = $(info.el);
element.find(".fc-title, .fc-list-item-title").html(event.title);
let id_record = event.idintervento;
eventContent: function (info) {
return { html: "<div style=\"width:100%; background:" + info.event.backgroundColor + ";\">" + info.event.title + "</div>" };
},
eventDidMount: function(info){
let element = $(info.el);
let id_record = info.event.extendedProps.idintervento;
if (globals.dashboard.tooltip == 1) {
element.tooltipster({
@ -700,7 +697,7 @@ echo '
$.post(globals.dashboard.load_url, {
op: "tooltip_info",
id_record: id_record,
allDay: event.allDay,
allDay: info.event.allDay,
}, function (data, response) {
instance.content(data);
@ -711,6 +708,7 @@ echo '
});
}
},
events: {
url: globals.dashboard.load_url + "&op=interventi_periodo",
type: "GET",
@ -720,7 +718,7 @@ echo '
}
});
//calendar.render();
calendar.render();
globals.dashboard.calendar = calendar;
}

View File

@ -2,6 +2,7 @@
"private": true,
"main": "gulpfile.js",
"dependencies": {
"@fullcalendar/moment": "^6.0.3",
"admin-lte": "^2.4.18",
"autocompleter": "^6.1.1",
"autonumeric": "^4.6.0",
@ -20,7 +21,7 @@
"dropzone": "^5.7.2",
"eonasdan-bootstrap-datetimepicker": "^4.17.49",
"font-awesome": "^4.7.0",
"fullcalendar": "^3.10.5",
"fullcalendar-scheduler": "^6.0.3",
"geocomplete": "^1.7.0",
"hotkeys-js": "^3.8.5",
"html5sortable": "^0.13.2",

View File

@ -63,7 +63,7 @@ class App
'i18n/parsleyjs/|lang|.min.js',
'i18n/select2/|lang|.min.js',
'i18n/moment/|lang|.min.js',
'i18n/fullcalendar/|lang|.min.js',
'i18n/@fullcalendar/|lang|.min.js',
],
];