lavorato su calendario
This commit is contained in:
@@ -5,35 +5,21 @@
|
||||
@endsection
|
||||
@section('content')
|
||||
<div id="calendar"></div>
|
||||
<div class="modal fade " id="event" tabindex="-1" role="dialog"
|
||||
aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog draggable" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Nuovo Appuntamento</h4>
|
||||
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
Start <input type="text" id="start" name="start">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@section('js')
|
||||
<script>
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var calendarEl = document.getElementById('calendar');
|
||||
|
||||
var calendar = new FullCalendar.Calendar(calendarEl, {
|
||||
timeZone: 'UTC',
|
||||
initialView: 'dayGridMonth',
|
||||
events: '/api/demo-feeds/events.json',
|
||||
editable: true,
|
||||
selectable: true,
|
||||
// plugins: [dayGridPlugin],
|
||||
// initialView: 'dayGridWeek',
|
||||
headerToolbar: {
|
||||
left: 'prev,next',
|
||||
center: 'title',
|
||||
right: 'dayGridMonth,timeGridWeek,timeGridDay' // user can switch between the two
|
||||
},
|
||||
dateClick: function(info) {
|
||||
alert('Clicked on: ' + info.dateStr);
|
||||
}
|
||||
});
|
||||
calendar.setOption('locale', 'it');
|
||||
calendar.render();
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<script src="/js/app/calendario.js"></script>
|
||||
@endsection
|
||||
|
||||
@@ -29,21 +29,12 @@
|
||||
<script>
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
|
||||
|
||||
var SITEURL = "{{ url('/admin/') }}";
|
||||
|
||||
|
||||
|
||||
$.ajaxSetup({
|
||||
|
||||
headers: {
|
||||
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -51,167 +42,87 @@ $.ajaxSetup({
|
||||
var calendar = $('#calendar').fullCalendar({
|
||||
|
||||
editable: true,
|
||||
|
||||
events: SITEURL + "/fullcalendar",
|
||||
|
||||
displayEventTime: false,
|
||||
|
||||
editable: true,
|
||||
|
||||
eventRender: function (event, element, view) {
|
||||
|
||||
if (event.allDay === 'true') {
|
||||
|
||||
event.allDay = true;
|
||||
|
||||
} else {
|
||||
|
||||
event.allDay = false;
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
selectable: true,
|
||||
|
||||
selectHelper: true,
|
||||
|
||||
select: function (start, end, allDay) {
|
||||
|
||||
var title = prompt('Event Title:');
|
||||
|
||||
var title = prompt('Titolo evento:');
|
||||
if (title) {
|
||||
|
||||
var start = $.fullCalendar.formatDate(start, "Y-MM-DD");
|
||||
|
||||
var end = $.fullCalendar.formatDate(end, "Y-MM-DD");
|
||||
|
||||
$.ajax({
|
||||
|
||||
url: SITEURL + "/fullcalendar",
|
||||
|
||||
data: {
|
||||
|
||||
title: title,
|
||||
|
||||
start: start,
|
||||
|
||||
end: end,
|
||||
|
||||
type: 'add'
|
||||
|
||||
},
|
||||
|
||||
type: "POST",
|
||||
|
||||
success: function (data) {
|
||||
|
||||
displayMessage("Event Created Successfully");
|
||||
|
||||
|
||||
|
||||
displayMessage("Evento creato con successo");
|
||||
calendar.fullCalendar('renderEvent',
|
||||
|
||||
{
|
||||
|
||||
id: data.id,
|
||||
|
||||
title: title,
|
||||
|
||||
start: start,
|
||||
|
||||
end: end,
|
||||
|
||||
allDay: allDay
|
||||
|
||||
},true);
|
||||
|
||||
|
||||
|
||||
calendar.fullCalendar('unselect');
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
eventDrop: function (event, delta) {
|
||||
|
||||
var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD");
|
||||
|
||||
var end = $.fullCalendar.formatDate(event.end, "Y-MM-DD");
|
||||
|
||||
|
||||
|
||||
$.ajax({
|
||||
|
||||
url: SITEURL + '/fullcalendar',
|
||||
|
||||
data: {
|
||||
|
||||
title: event.title,
|
||||
|
||||
start: start,
|
||||
|
||||
end: end,
|
||||
|
||||
id: event.id,
|
||||
|
||||
type: 'update'
|
||||
|
||||
},
|
||||
|
||||
type: "POST",
|
||||
|
||||
success: function (response) {
|
||||
|
||||
displayMessage("Event Updated Successfully");
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
eventClick: function (event) {
|
||||
|
||||
var deleteMsg = confirm("Do you really want to delete?");
|
||||
|
||||
var deleteMsg = confirm("vuoi veramente cancellare?");
|
||||
if (deleteMsg) {
|
||||
|
||||
$.ajax({
|
||||
|
||||
type: "POST",
|
||||
|
||||
url: SITEURL + '/fullcalendar',
|
||||
|
||||
data: {
|
||||
|
||||
id: event.id,
|
||||
|
||||
type: 'delete'
|
||||
|
||||
},
|
||||
|
||||
success: function (response) {
|
||||
|
||||
calendar.fullCalendar('removeEvents', event.id);
|
||||
|
||||
displayMessage("Event Deleted Successfully");
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -221,9 +132,7 @@ var calendar = $('#calendar').fullCalendar({
|
||||
|
||||
|
||||
function displayMessage(message) {
|
||||
|
||||
toastr.success(message, 'Event');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user