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

Merge branch 'improve-graphical-scheduling' into 'master'

Improve graphical scheduling

See merge request !62
parents 7f8352e0 fae6fb6b
No related branches found
No related tags found
1 merge request!62Improve graphical scheduling
Pipeline #8846 passed
......@@ -245,6 +245,16 @@ class AK(models.Model):
return self.short_name
return self.name
@property
def details(self):
return f"""{self.name}{" (R)" if self.reso else ""}:
{self.owners_list}
{_("Requirements")}: {", ".join(str(r) for r in self.requirements.all())}
{_("Conflicts")}: {", ".join(str(c) for c in self.conflicts.all())}
{_("Prerequisites")}: {", ".join(str(p) for p in self.prerequisites.all())}"""
@property
def owners_list(self):
return ", ".join(str(owner) for owner in self.owners.all())
......
......@@ -42,8 +42,8 @@ class EventsView(LoginRequiredMixin, EventSlugMixin, ListView):
return JsonResponse(
[{
"slotID": slot.pk,
"title": slot.ak.short_name,
"description": slot.ak.name,
"title": f'{slot.ak.short_name}: \n{slot.ak.owners_list}',
"description": slot.ak.details,
"resourceId": slot.room.id,
"start": timezone.localtime(slot.start, self.event.timezone).strftime("%Y-%m-%d %H:%M:%S"),
"end": timezone.localtime(slot.end, self.event.timezone).strftime("%Y-%m-%d %H:%M:%S"),
......
......@@ -7,7 +7,7 @@
{% load static %}
{% load tags_AKPlan %}
{% block title %}{% trans "Scheduling for" %} {{event}}{% endblock %}
{% block title %}{% trans "Scheduling for" %} {{ event }}{% endblock %}
{% block extrahead %}
{{ block.super }}
......@@ -21,10 +21,14 @@
{% endwith %}
<style>
.unscheduled-slot {
cursor: move;
.unscheduled-slot {
cursor: move;
}
}
.fc-v-event, .tooltip {
white-space: pre-line;
}
</style>
<script>
......@@ -45,14 +49,16 @@
}
return cookieValue;
}
const csrftoken = getCookie('csrftoken');
function csrfSafeMethod(method) {
// these HTTP methods do not require CSRF protection
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
}
$.ajaxSetup({
beforeSend: function(xhr, settings) {
beforeSend: function (xhr, settings) {
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
......@@ -64,7 +70,7 @@
var containerEl = document.getElementById('unscheduled-slots');
new FullCalendar.Draggable(containerEl, {
itemSelector: '.unscheduled-slot',
});
});
// Calendar
......@@ -72,7 +78,7 @@
plan = new FullCalendar.Calendar(planEl, {
timeZone: '{{ event.timezone }}',
headerToolbar : {
headerToolbar: {
left: 'today prev,next',
center: 'title',
right: 'resourceTimelineDayVert,resourceTimelineDayHoriz,resourceTimelineEventVert,resourceTimelineEventHoriz'
......@@ -115,12 +121,12 @@
}
},
// Show full AK title as tooltip for each AK (needs to be removed and newly placed when AK is moved)
eventDidMount : function(info) {
if(info.event.extendedProps.description !== undefined) {
eventDidMount: function (info) {
if (info.event.extendedProps.description !== undefined) {
$(info.el).tooltip({title: info.event.extendedProps.description, trigger: 'hover'});
}
},
eventWillUnmount : function(info) {
eventWillUnmount: function (info) {
$(info.el).tooltip('dispose');
},
......@@ -129,7 +135,7 @@
eventReceive: updateEvent,
editable: true,
dropable: true,
drop: function(info) {
drop: function (info) {
info.draggedEl.parentNode.removeChild(info.draggedEl);
},
allDaySlot: false,
......@@ -140,9 +146,9 @@
resourceAreaHeaderContent: '{% trans "Room" %}',
resources: '{% url "model:scheduling-resources-list" event_slug=event.slug %}',
eventSources: [
'{% url "model:scheduling-events" event_slug=event.slug %}',
'{% url "model:scheduling-room-availabilities" event_slug=event.slug %}'
],
'{% url "model:scheduling-events" event_slug=event.slug %}',
'{% url "model:scheduling-room-availabilities" event_slug=event.slug %}'
],
schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
dayMinWidth: 100,
});
......@@ -160,10 +166,11 @@
end: plan.formatIso(changeInfo.event.end),
roomId: room.id,
},
success: function(response) {},
error: function(response) {
success: function (response) {
},
error: function (response) {
changeInfo.revert();
alert("ERROR. Did not update "+changeInfo.event.title)
alert("ERROR. Did not update " + changeInfo.event.title)
}
});
}
......@@ -175,11 +182,14 @@
<div class="row" style="margin-bottom: 50px;">
<div class="col-md-10 col-lg-11">
<div id="planCalendar" ></div>
<div id="planCalendar"></div>
</div>
<div class="col-md-2 col-lg-1" id="unscheduled-slots">
{% for slot in slots_unscheduled %}
<div class="unscheduled-slot badge badge-primary" data-event='{ "title": "{{ slot.ak.short_name }}", "duration": {"hours": "{{ slot.duration|unlocalize }}"}, "description": "{{ slot.ak.name }}", "slotID": "{{ slot.pk }}"}'>{{ slot.ak.short_name }} ({{ slot.duration }} h)</div>
<div class="unscheduled-slot badge badge-primary" style='background-color: {{ slot.ak.category.color }}'
data-event='{ "title": "{{ slot.ak.short_name }}", "duration": {"hours": "{{ slot.duration|unlocalize }}"}, "description": "{{ slot.ak.name }}", "slotID": "{{ slot.pk }}"}'>{{ slot.ak.short_name }}
({{ slot.duration }} h)<br>{{ slot.ak.owners_list }}
</div>
{% endfor %}
</div>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment