Skip to content
Snippets Groups Projects
Commit 15d6e9b9 authored by Benjamin Hättasch's avatar Benjamin Hättasch
Browse files

WIP: Port fullcalendar of availabilities to version 4

parent 9b32e74f
No related branches found
No related tags found
No related merge requests found
...@@ -10,12 +10,15 @@ ...@@ -10,12 +10,15 @@
{% block imports %} {% block imports %}
<link rel="stylesheet" href="{% static 'common/vendor/chosen-js/chosen.css' %}"> <link rel="stylesheet" href="{% static 'common/vendor/chosen-js/chosen.css' %}">
<link rel="stylesheet" href="{% static 'common/css/bootstrap-chosen.css' %}"> <link rel="stylesheet" href="{% static 'common/css/bootstrap-chosen.css' %}">
<link href='{% static 'AKSubmission/vendor/fullcalendar3/fullcalendar.min.css' %}' rel='stylesheet'/>
<link href='{% static 'AKSubmission/css/availabilities.css' %}' rel='stylesheet'/> <link href='{% static 'AKSubmission/css/availabilities.css' %}' rel='stylesheet'/>
<script src="{% static "AKSubmission/vendor/moment/moment-with-locales.js" %}"></script> <script src="{% static "AKSubmission/vendor/moment/moment-with-locales.js" %}"></script>
<script src="{% static "AKSubmission/vendor/moment-timezone/moment-timezone-with-data-10-year-range.js" %}"></script> <script src="{% static "AKSubmission/vendor/moment-timezone/moment-timezone-with-data-10-year-range.js" %}"></script>
<script src='{% static 'AKSubmission/vendor/fullcalendar3/fullcalendar.min.js' %}'></script>
{% include "AKPlan/load_fullcalendar.html" %}
<script src="{% static "common/js/availabilities.js" %}"></script> <script src="{% static "common/js/availabilities.js" %}"></script>
{% endblock %} {% endblock %}
......
...@@ -6,14 +6,14 @@ document.addEventListener("DOMContentLoaded", function () { ...@@ -6,14 +6,14 @@ document.addEventListener("DOMContentLoaded", function () {
"use strict" "use strict"
$("input.availabilities-editor-data").each(function () { $("input.availabilities-editor-data").each(function () {
var data_field = $(this) var data_field = $(this);
var editor = $('<div class="availabilities-editor">') var editor = $('<div class="availabilities-editor">');
editor.attr("data-name", data_field.attr("name")) editor.attr("data-name", data_field.attr("name"));
data_field.after(editor) data_field.after(editor);
function save_events() { function save_events() {
data = { data = {
availabilities: editor.fullCalendar("clientEvents").map(function (e) { availabilities: availability_editor.getEvents().map(function (e) {
if (e.allDay) { if (e.allDay) {
return { return {
start: e.start.format("YYYY-MM-DD HH:mm:ss"), start: e.start.format("YYYY-MM-DD HH:mm:ss"),
...@@ -43,8 +43,8 @@ document.addEventListener("DOMContentLoaded", function () { ...@@ -43,8 +43,8 @@ document.addEventListener("DOMContentLoaded", function () {
return e return e
}) })
editor.fullCalendar({ let availability_editor = new FullCalendar.Calendar(editor, {
views: { /*views: {
agendaVariableDays: { agendaVariableDays: {
type: "agenda", type: "agenda",
duration: { duration: {
...@@ -55,25 +55,27 @@ document.addEventListener("DOMContentLoaded", function () { ...@@ -55,25 +55,27 @@ document.addEventListener("DOMContentLoaded", function () {
) + 1, ) + 1,
}, },
}, },
}, },*/
defaultView: "agendaVariableDays", initialView: 'timeGrid',
defaultDate: data.event.date_from, //defaultDate: data.event.date_from,
visibleRange: { visibleRange: {
start: data.event.date_from, start: data.event.date_from,
end: data.event.date_to, end: data.event.date_to,
}, },
events: events, events: [], //events,
nowIndicator: false, nowIndicator: false,
navLinks: false, navLinks: false,
header: false, // No header, not buttons
timeFormat: "H:mm", headerToolbar: false,
slotLabelFormat: "H:mm", //timeFormat: "H:mm",
scrollTime: "09:00:00", //slotLabelFormat: "H:mm",
scrollTime: "08:00:00",
schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
selectable: editable, selectable: editable,
selectHelper: true, //selectHelper: true,
select: function (start, end) { /*select: function (start, end) {
var wasInDeleteMode = false var wasInDeleteMode = false
editor.fullCalendar("clientEvents").forEach(function (e) { availability_editor.getEvents().forEach(function (e) {
if (e.className.indexOf("delete") >= 0) { if (e.className.indexOf("delete") >= 0) {
wasInDeleteMode = true wasInDeleteMode = true
} }
...@@ -95,12 +97,12 @@ document.addEventListener("DOMContentLoaded", function () { ...@@ -95,12 +97,12 @@ document.addEventListener("DOMContentLoaded", function () {
save_events() save_events()
}, },
eventResize: save_events, eventResize: save_events,
eventDrop: save_events, eventDrop: save_events,*/
editable: editable, editable: editable,
selectOverlap: false, selectOverlap: false,
eventOverlap: false, eventOverlap: false,
eventColor: "#00DD00", eventColor: "#00DD00",
eventClick: function (calEvent, jsEvent, view) { /*eventClick: function (calEvent, jsEvent, view) {
if (!editable) { if (!editable) {
return return
} }
...@@ -111,16 +113,17 @@ document.addEventListener("DOMContentLoaded", function () { ...@@ -111,16 +113,17 @@ document.addEventListener("DOMContentLoaded", function () {
}) })
save_events() save_events()
} else { } else {
editor.fullCalendar("clientEvents").forEach(function (e) { availability_editor.getEvents().forEach(function (e) {
if (e._id == calEvent._id) { if (e._id == calEvent._id) {
e.className = "delete" e.className = "delete"
} else { } else {
e.className = "" e.className = ""
} }
editor.fullCalendar("updateEvent", e) //editor.fullCalendar("updateEvent", e)
}) })
} }
}, },*/
}) });
availability_editor.render();
}) })
}) })
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment